constraint-driven-development
它能做什么
这个工具会为你的编程项目制定一份质量“约定”。它会明确规定什么样的代码是可以接受的,比如测试覆盖率要达到多少,或者不能有报错,并确保这些规则被自动执行,防止代码质量在不知不觉中下降。
适用场景
- ✓开始一个新项目或一个重要功能的时候。
- ✓你希望 AI 始终遵守既定质量标准的时候。
- ✓AI 生成的代码太多,靠人工审查已经忙不过来的时候。
技能链接
https://github.com/addyosmani/agent-skills/blob/main/skills/constraint-driven-development/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请为这个项目制定质量标准,包括测试覆盖率和安全规则。”
每周 5 个新技能,1 分钟读完。
工作原理
工具会先检查项目里已有的内容(比如测试和代码检查工具)。然后它会问你几个简单的问题,来确定质量规则,比如哪些检查最重要,以及检查不通过时是直接阻止工作,还是只发出警告。最后,它会把这些规则保存到名为 CONSTRAINTS.md 的文件中,并持续监控代码,确保规则不被破坏。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Constraint-Driven Development
Overview
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.
When to Use
Apply this skill when:
- Starting a project or a significant feature and no quality bar is written down
- The user asks to "set up constraints", "add quality gates", "define our standards", or "stop the agent shipping junk"
- An agent is producing volume nobody is reading line by line
- CI has checks but nobody can say which ones block a merge and which ones are decoration
- Coverage, performance, or accessibility numbers get argued about per-PR instead of decided once
- You're about to run
/build autoor any autonomous loop, and the only thing standing between it and main is a test suite the agent also wrote
When NOT to use:
- The project already has a
CONSTRAINTS.mdand the user isn't changing it — read it and follow it instead - One-off scripts, spikes, throwaway prototypes
- The user wants a code review right now (
code-review-and-quality) or a CI pipeline built (ci-cd-and-automation) - Pre-product-market-fit code with a two-week expected lifetime — the floor below is still worth it, the rest isn't
Loading Constraints
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.
The Process
Step 1: Detect before you ask
Never ask what you can read. Before the first question, gather:
| What | Where to look |
|---|---|
| Language and stack | package.json, pyproject.toml, go.mod, Cargo.toml |
| Test runner | dev dependencies, test script, existing test files |
| Existing linters | eslint.config.*, biome.json, .ruff.toml |
| Coverage today | coverage/ output, or run the suite once |
| CI | .github/workflows/, .gitlab-ci.yml |
| Agent harness | .claude/, .codex/, AGENTS.md |
Report what you found in two lines, then ask only what's left.
Step 2: Four questions, each with a default
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.
…
常见问题
什么是“底线”?
“底线”指的是无论你是否额外设定其他规则,都会始终执行的最低质量要求。例如,不允许用注释忽略错误,也不允许留下未完成的代码。
为什么要用数字,而不是只写笼统的规则?
“80% 测试覆盖率”这类数字让规则变得客观,也便于自动检查。这样就不会引发争论,大家也都清楚具体的要求是什么。
如果违反了规则会怎样?
根据规则的配置方式,工具可能会发出警告,也可能会阻止后续工作,直到问题被修复。这样就能保证既定的质量得到维持。
详情
作者的原始描述
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, unimplement
repo: addyosmani/agent-skills
热度
- GitHub 星标
- 107k
- 排名
- #766
- 许可证
- MIT
- 更新时间
- 2026/10/13
评论
- …
同一仓库的更多技能
api-and-interface-design
107k帮助设计定义清晰的 API 和接口。适用于规划软件不同部分之间的通信方式。
browser-testing-with-devtools
107k帮助你的智能体直接在真实浏览器中测试代码。适用于检查功能在实际使用环境中的表现,并发现错误和性能问题。
ci-cd-and-automation
107k教你的 AI 智能体自动化重复性任务、发布项目并管理基础设施。
code-review-and-quality
107k从多个角度对代码进行详细审查。适用于合并新改动之前,确保质量并避免日后出现问题。