- name
SKILL.md
技能檔案保留在發布者的儲存庫中。
在終端機中貼上複製的指令。它會將這個 SKILL.md 安裝到對應的代理中。
npx skills add addyosmani/agent-skills --skill constraint-driven-development -a cursor -y在終端機中貼上複製的指令。它會將這個 SKILL.md 安裝到對應的代理中。
npx skills add addyosmani/agent-skills --skill constraint-driven-development -a claude-code -y在終端機中貼上複製的指令。它會將這個 SKILL.md 安裝到對應的代理中。
npx skills add addyosmani/agent-skills --skill constraint-driven-development -a codex -y在終端機中貼上複製的指令。它會將這個 SKILL.md 安裝到對應的代理中。
npx skills add addyosmani/agent-skills --skill constraint-driven-development -a grok -y在 Grok Bot 聊天中傳送複製的訊息。Bot 會從 GitHub 取得這個 SKILL.md,並加入你所有 Bot 共用的技能中。
Install this skill: https://github.com/addyosmani/agent-skills/tree/HEAD/skills/constraint-driven-development來自發布者
Other skills in this pack describe what good looks like. code-review-and-quality gives you five axes. test-driven-development gives you a cycle. security-and-hardening gives you a threat list. All of that lives in prose the agent reads and may or may not follow, and none of it survives the end of the session.
This skill produces something different: a written record of this project's bar, with numbers, that outlives the conversation and can be checked mechanically.
The reason matters. When you wrote the code, reading it told you whether it was any good. An agent writes more in an afternoon than you will read that week, so the judgement moves out of your head and into checks that run around the loop. Those checks need to exist, they need numbers you actually chose, and they need to fire close enough to the work that the agent fixes its own output.
Spec-driven development says what to build. Test-driven development proves it works. Constraint-driven development defines what "good enough to ship" means, before anyone argues about it in a pull request.
Apply this skill when:
/build auto or any autonomous loop, and the only thing standing between it and main is a test suite the agent also wroteWhen NOT to use:
CONSTRAINTS.md and the user isn't changing it — read it and follow it insteadcode-review-and-quality) or a CI pipeline built (ci-cd-and-automation)The interview needs a live user. Don't run it in non-interactive contexts (CI, /loop, autonomous runs). If constraints are missing and you're in one of those, apply the Floor below, note that you did, and flag the rest for a human.
Never ask what you can read. Before the first question, gather:
Report what you found in two lines, then ask only what's left.
Follow the one-question-at-a-time discipline from interview-me, with one change: every question here has a default, so "I don't know" is a complete answer that still produces a working config.
Q1: Beyond the floor, which of these do you want enforced?
(a) Test coverage on new code
(b) Security scanning
(c) Performance budgets
(d) Accessibility
(e) Architecture boundaries
GUESS: (a) and (b) — you have a test runner already and you're handling user input.
DEFAULT if unsure: (a) and (b).
Say what each pick costs: (c) and (d) need a running URL, (e) needs a rules file written.
Q2: When a check fails while the agent is mid-task, should it block or warn?
GUESS: Block. You're running agents unattended and a warning nobody reads is a warning.
DEFAULT if unsure: Block on the floor, warn on everything else for the first two weeks.
Q3: Do you have target numbers in mind, or should I measure where you are today and hold that line?
GUESS: Measure. Most teams don't have a number, and an invented one gets ignored.
DEFAULT if unsure: Measure and hold. See "Ratchets" below.
Q4: What's the slowest check you'll tolerate before the agent hands work back?
GUESS: About 90 seconds. Longer and you'll stop running it.
DEFAULT if unsure: 90 seconds at task end, unlimited in CI.
Stop at four. A twelve-question intake produces a config nobody understands and a user who regrets starting.
One file at the repo root. Any agent on any harness can read it, and a change to it shows up in review where it belongs.
# Constraints
Last reviewed: 2026-08-08 by @addy
## Floor (always enforced, no setup required)
- No new suppression comments: `@ts-ignore`, `eslint-disable`, `# noqa`, `# type: ignore`
- No unimplemented stubs: `throw new Error("Not implemented")`, empty `catch {}`
- No skipped or deleted tests without a reason in the commit message
- No secrets in source
- This file does not get weakened to make a change pass
## Enforced with numbers
| Dimension | Rule | Checked by | Runs at |
|-----------|------|-----------|---------|
| Types | Zero type errors | `tsc --noEmit` | every edit |
| Lint | Zero errors from our config | `biome check` | every edit |
| Secrets | No secrets in source | `gitleaks dir . --redact` | every edit |
| Coverage | Changed lines ≥ 80% covered | `vitest run --coverage` + git diff | task end, CI |
| Security: code | Nothing at high or above | `npm run check:security` | CI |
| Security: deps | Nothing at high or above | `osv-scanner scan source -r .` | CI |
| Accessibility | Zero critical or serious | `npm run check:a11y` | preview deploy |
| Performance | LCP ≤ 2500ms, CLS ≤ 0.1 | `lighthouse $PREVIEW_URL --output=json` | preview deploy |
Every row names the command that produces the verdict. A dimension with a
number and no command in this column is an aspiration, not a constraint.
## Measured, not yet enforced
| Metric | Today | Direction |
|--------|-------|-----------|
| Project coverage | 62.4% | must not fall |
| Bundle size (main) | 184 kB | must not grow |
## Exceptions
| ID | Rule | Path | Reason | Owner | Expires |
|----|------|------|--------|-------|---------|
| W1 | `no-explicit-any` | `src/legacy/**` | Rewrite tracked in ENG-441 | @addy | 2026-11-01 |
Then add one line to AGENTS.md and CLAUDE.md: Read CONSTRAINTS.md before writing code. Do not weaken it to make a change pass.
Picking a dimension means installing something. Don't leave the user with a number and no mechanism, and don't invent your own checker when a de facto one exists — these tools are listed because their rule formats and thresholds are what everything else in the ecosystem targets, so the team's existing config keeps working.
Five things that will bite you if you skip them:
--redact on gitleaks is not optional. Without it the matched secret lands in the agent's transcript, which is how a leaked key ends up in a log, a summary, or a commit message. Report the rule and the location, never the value.stryker run --mutate on the whole repo takes hours and gets turned off; on the files a change touched it takes under a minute. Same for Semgrep, which takes a path list.git diff. Running the suite twice to get a number is the fastest way to make people hate this.opengrep is a drop-in fork with the same rule format and JSON output if that matters to your legal team.semgrep scan and axe can exit 0 on findings; copy scripts/quality-gate.mjs into the project's scripts/ directory to enforce these thresholds.
Keep the scanner before && so a failed scan stops the command.
Add each one to the project's own script so it's reproducible without an agent:
{
"scripts": {
"check:fast": "tsc --noEmit && eslint . && gitleaks dir . --redact --no-banner",
"check:task": "npm run check:fast && vitest run --coverage",
"check:security": "semgrep scan --config p/default --strict --json > semgrep-results.json && node scripts/quality-gate.mjs semgrep semgrep-results.json",
"check:a11y": "axe \"$PREVIEW_URL\" --tags wcag2a,wcag2aa,wcag21aa --stdout > axe-results.json && node scripts/quality-gate.mjs axe axe-results.json",
"check:full": "npm run check:task && npm run check:security && osv-scanner scan source -r ."
}
}
That mapping matters more than the tools. check:fast is what runs after an edit, check:task when the agent thinks it's done, check:full in CI. Run check:a11y after the preview is reachable, with PREVIEW_URL set (the example uses POSIX shell syntax).
Before calling any row enforced, run its actual CI command against a known violation and a clean control. Confirm that the violation fails, the control passes, and scanner errors fail too. For a severity threshold, also confirm a below-threshold finding passes. Apply this to every dimension, including coverage and Lighthouse: generating a report alone does not enforce the number in CONSTRAINTS.md.
The commands now live in two places — the Checked by column in CONSTRAINTS.md and these scripts. CONSTRAINTS.md is the canonical source: it carries the reason alongside each command and it shows up in review. The scripts are convenience wrappers that must mirror it, not a second source of truth; if they drift, the file wins.
The single biggest mistake is running everything everywhere. A check that stalls the agent gets switched off, and a gate people switched off is worse than no gate, because the bar still looks like it exists.
Two rules that keep this tolerable:
Someone will point out that if the agent writes the code and the checks, the checks prove nothing. Half right, and worth engineering around.
Agents don't craft clever loopholes. They hit a red check and take the cheapest road to green. Watch for these five moves in the diff, at review time:
CONSTRAINTS.md against its state at the branch point..skip added, a test file deleted, assertions pulled out of tests that stayed.@ts-ignore or eslint-disable. Four suppressions deserve special attention because they switch off a check you're relying on: istanbul ignore drops code from coverage instead of testing it, Stryker disable hides a surviving mutant, nosemgrep and gitleaks:allow do it for security findings.catch turning a failure into silence, a TODO standing where the implementation should be.None of this needs tooling beyond git diff. Tightening the bar should be silent; loosening it should be loud.
Unlike the numbered dimensions, the floor has no de facto tool of its own, so an agent asked to enforce it tends to write a checker from scratch, and two agents write two different ones. A reference implementation of these five checks ships with this skill in references/floor-guard.md (diff-scoped, exit 0/1/2, patterns adaptable per ecosystem). Adapt that rather than reinventing it, for the same reason every dimension names a de facto tool: so the mechanism is the same across runs and stacks.
Not all checks are equally circular. Rank them by one question: can the agent make this pass by writing code that doesn't work?
osv-scanner reads a vulnerability database, Lighthouse measures a real browser. The agent can't argue with these.A bar made entirely of the third kind is worth less than one with an outside opinion in it. Check that at least one external constraint is present.
Set 80% coverage on a codebase at 62% and you get a red build forever, then a team that learns to ignore red builds.
The alternative asks for no decision: record where you are, then refuse to get worse. Put it in the "Measured, not yet enforced" table with today's number and a direction. Every check compares against the recorded value, not an aspiration. When a number improves, update it; when it drops, that's the finding.
This also answers a fair objection to training. Models are rewarded for passing tests, which you can evaluate in seconds. Architectural rot shows up over months and never reaches the weights. A ratchet is the missing penalty, written down where the build can see it.
When the user has no opinion, use these. They're chosen to be met by most codebases on day one.
State the number and the reason together. A threshold without a rationale gets deleted by the next person who hits it.
Constraints work at three levels of teeth. Start at the first.
CONSTRAINTS.md exists and agents read it. Costs nothing, catches the honest mistakes, relies on the agent complying.npm run check (or make check) that runs the fast checks, wired into your agent's post-edit hook and your CI. Deterministic, no new dependency.Most projects should stop at 2. Move to 3 when you're maintaining more than about thirty lines of check-running shell.
A first run can be floor-only. The floor guard is diff-only and needs no installs, so you can enforce the floor on day one and add numbered dimensions as you install each tool, rather than standing up every checker before the first commit is protected. Security tools that install machine-wide (gitleaks, osv-scanner) can also run CI-only if you'd rather keep laptops clean; declare where each dimension runs in the Runs at column.
Stop and reconsider if you notice:
CONSTRAINTS.md changed in the same commit as the feature that was failing--no-verifyCONSTRAINTS.md since it was writtenThe skill was applied correctly when:
CONSTRAINTS.md exists, and every number in it has a stated reasonAGENTS.md or CLAUDE.md points at the fileinterview-me — the one-question-at-a-time discipline this skill's intake borrowscode-review-and-quality — how to review; this skill decides what the review enforcesci-cd-and-automation — building the pipeline these constraints run intest-driven-development — the suite that coverage and mutation constraints measuresecurity-and-hardening — what the security dimension should containperformance-optimization — where the performance numbers come fromEstablishes a project's quality bar as a written contract and stops agents quietly lowering it. Interviews the user on which dimensions matter, supplies sane default thresholds when they have no numbe
---name: constraint-driven-developmentdescription: Establishes a project's quality bar as a written contract and stops agents quietly lowering it. Interviews the…---# skills/constraint-driven-development/SKILL.md總覽
Establishes a project's quality bar as a written contract and stops agents quietly lowering it. Interviews the user on which dimensions matter, supplies sane default thresholds when they have no number in mind, records everything in CONSTRAINTS.md, and watches the diff for a weakened bar — new @ts-ignore or eslint-disable suppressions, skipped or deleted tests, assertions stripped out, unimplemented stubs, thresholds edited down. Use when no quality bar is written down, when the user says "set up constraints" or "define our standards", when the user wants dimensions they care about — accessibility, web performance, coverage — set up as enforced constraints, when an agent keeps silencing checks or skipping tests to get to green, when you need a coverage or performance threshold and don't know what number to pick, or when an agent writes more code than anyone will read.
常見問題
從發布者下載 skills/constraint-driven-development/SKILL.md,或複製路徑後開啟儲存庫。PlugMCP 只收錄這項技能,不代管檔案。
發布者將它存放在 https://github.com/addyosmani/agent-skills。
Claude、Cursor、Codex 和 Grok Build 可以讀取你從發布者儲存庫加入的 SKILL.md。在聊天中傳送技能的 GitHub 資料夾連結,Grok Bot 就會安裝它。
| dependency-cruiser |
npm i -D dependency-cruiser |
depcruise src |
| any violation |
| Assertion quality | Stryker | npm i -D @stryker-mutator/core | stryker run --mutate <changed files> | mutation score |