Skip to content
GitHub (opens in a new tab)

Contract fit

A number from 0 to 100 for how well a screen follows the kit. It is the share of UI elements that come from the kit, minus a penalty for each review error and a smaller one for each warning, counted per 100 elements. It sits on top of review: the findings and what to fix stay the same.

Run it

Add --score to review. --min fails the run when the score is too low.

npx agentic-ds-kit review app --score
npx agentic-ds-kit review app --json --score
npx agentic-ds-kit review app --min 80

--min turns on --score and exits 1 when the score is below the number you give. Errors still exit 1 as before. Without --score or --min, review prints and exits exactly as it did. The MCP tool review_ui always includes the score.

What counts as a UI element

Each opening JSX tag counts once. CSS files add findings, not elements.

How review sorts tags.
KindTagsWhy
KitAny tag whose name (Button, or Card in Card.Header) is imported from agentic-ds-kit.This is the part the contracts cover.
Otherbutton, a, input, select, textarea, img, table, dialogThings people click, type into or clearly see, where the kit has a component to use instead.
Not counteddiv, span, main, header, nav, headings, lists, p, fragments, Lucide icons, Next.js tags, other componentsLayout and text are yours to write. Counting them would punish good markup.

The formula

Share first, then penalties per 100 elements, then kept between 0 and 100.

share = kitElements / (kitElements + otherElements)
        (or 1 when there are no countable elements)
scale = 100 / max(100, kitElements + otherElements)
value = max(0, min(100, round(100 * share - (5 * errors + 2 * warnings) * scale)))

In plain words: take the part of your elements that come from the kit, as a percent. Take off 5 for every error and 2 for every warning, for every 100 elements. Round it, and never go below 0 or above 100. Anything with up to 100 elements counts as 100, so on a single screen each error costs a full 5 points. In a folder with 400 elements it costs 1.25, so a big app is not pushed to 0 just by being big. A file with no countable elements, such as a clean CSS file, starts at 100, so errors in it still bring the score down.

Worked example

One page with 18 kit elements, 2 native ones, and one error.

The page uses 18 kit components (Buttons, Inputs, a Table and so on) and two native tags: one a and one img. Review finds one error, a hardcoded colour, and no warnings. Share is 18 / 20 = 0.9, so 90. The page has fewer than 100 elements, so the scale is 1 and the error costs 5, which gives 85. Swap the a for kit Link and fix the colour, and the score goes to 95.

"score": {
  "value": 85,
  "kitElements": 18,
  "otherElements": 2,
  "errors": 1,
  "warnings": 0,
  "formula": "share = kitElements / (kitElements + otherElements), ...; scale = ...; value = ..."
}

Post it on pull requests

A GitHub workflow template ships with the package.

mkdir -p .github/workflows
cp node_modules/agentic-ds-kit/templates/github/contract-fit.yml .github/workflows/

The workflow runs review with --json --score on each pull request and keeps one comment up to date with the score, the error and warning counts, and the top 10 findings. Change the path in the file to your UI folder. On pull requests from forks GitHub does not let the job comment, so the score is only in the job log.