Skip to content
mentoor

Topic 2 of 5 · 4 min read

Auditing components for consistency

Goal: Use AI to find off-token values and duplicate components in a design file or codebase, and verify each finding before filing it.

An AI audit is a fast way to build a list of suspects. Each suspect still needs a person to confirm it before anyone files a ticket.

Check yourself · 1 of 3

An AI audit lists a hard-coded colour at Card.tsx line 42. What is the right next step?

Choose one answer

Over time, systems drift. Someone hard-codes #2F5BD0 because the token was hard to find. Someone else builds a third button because the first two did not fit. An audit looks for that drift: values that are not tokens, and components that do the same job under different names.

Why it matters

Every off-token value is a place where a rebrand, a dark theme or an accessibility fix will miss. Every duplicate component is a second thing to maintain. Reading hundreds of files by hand is slow, which is why people use an assistant such as Claude, Cursor or Copilot to scan them.

The weakness is that a model reading files reports what looks wrong, and sometimes reports what is not there. It can call two components duplicates because their names are close, or flag a value that is a deliberate exception.

How to do it

  1. Fix the scope. Name the folder, the file, or the exported frame. Give the model the real token list so it knows what counts as on-token.
  2. Prefer a script for exact matches. Searching code for hex values or pixel numbers outside the token file is a job for grep or a linter. Use the model for judgement: are these two components really the same thing?
  3. Ask for a table with evidence. Columns: finding, location (file and line, or frame name), the value found, the nearest token, confidence. No location means no finding.
  4. Verify each row. Open the location. Does the value exist? Is it on a token already? Is it an intentional exception, such as a brand illustration?
  5. Record the result. Confirmed, rejected with a reason, or needs a decision. Rejected rows teach you where the model over-reports.

Before and after

Weak: "Audit our design system for inconsistencies." The model returns a long, vague essay and a few invented examples.

Better: "Here are our tokens and the folder src/components. List every colour or spacing value that is not a token. Table: file, line, value, nearest token. Do not list anything you cannot point to by line."

What goes wrong

  • Invented locations. A row cites Card.tsx:42 and line 42 is a comment. Open every citation.
  • Name-based duplicates. PrimaryButton and ActionButton may differ in behaviour; compare props and states, not names.
  • Fixing everything at once. Group confirmed findings into small changes you can review.

Examples

One audit table, three outcomes

Finding Location Value Nearest token Result
Hard-coded blue Banner.tsx:18 #2F5BD0 color.brand.primary (#2E5BCF) Confirmed, one digit off
Duplicate button ActionButton and PrimaryButton n/a n/a Rejected, different loading behaviour
Odd padding Card.tsx:42 13px none Line 42 is a comment; rejected, model invented it

Only the first row becomes a ticket.

Key points

  • Use scripts for exact matches and the model for judgement calls such as whether two components duplicate each other.
  • Give the model the real token list and a fixed scope so it knows what counts as off-token.
  • Ask for a table where every finding has a location; a finding without one is dropped.
  • Open every cited location before filing, since models report lines and values that are not there.
  • Record rejected findings with a reason so you learn where the audit over-reports.

Common mistakes

  • Filing the model's table as tickets without opening each location.
  • Asking for an audit of the whole design system with no scope, token list or required evidence.
  • Calling two components duplicates because their names are similar, without comparing props and states.
  • Using the model for exact-match searches that a linter or grep does faster and without errors.

Check yourself · 2 of 3

For finding every hex colour in a codebase that is not in the token file, which approach is most reliable?

Choose one answer

Check yourself · 3 of 3

Two components, PrimaryButton and ActionButton, have similar names. What shows whether they are duplicates?

Choose one answer

Practice items, not counted towards your mastery.

Start here