首页 / 全部技能 / 基础工具与工作流 / constraint-driven-development
基础工具与工作流 · addyosmani/agent-skills

constraint-driven-development

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.

L2 本地 · 限定工作目录V1 已固定Dual-pass Audit
💬 对话试用 (预览)
Author addyosmaniGitHub addyosmani/agent-skills ↗Stars 113872License MITCommit 301b02b12b
管控等级描述 skill 的能力与建议配套的管控措施,不代表质量或安全认证,也不表示可用或不可用。是否使用由用户和管理者决定。不同 agent 宿主对权限的约束各不相同,请勿假定宿主一定会提供安全兜底。第三方 skill 版权归原作者,使用风险由使用者自行承担。

1实现原理 · 为什么它能做到

将项目的质量门槛固化为持久化的 CONSTRAINTS.md 契约文件,防止 Agent 跨会话丢失质量标准

skills/constraint-driven-development/SKILL.md
This skill produces something different: a written record of **this project's** bar, with numbers, that outlives the conversation and can be checked mechanically.
这里在做什么:将散落在自然语言中的代码规范转化为带具体阈值、可机器执行的 CONSTRAINTS.md 文本契约

遵循问询前先自动嗅探技术栈的原则(Detect before you ask),减少无效冗长交互

skills/constraint-driven-development/SKILL.md
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` |
这里在做什么:先读取项目配置文件探测语言与测试工具,再发起针对性问询

采用仅限 4 个问题且自带开箱即用默认值的访谈机制,解决用户对指标无概念的困境

skills/constraint-driven-development/SKILL.md
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.
这里在做什么:通过包含默认猜测的 4 个问题(维度、阻断策略、测量基准、超时阈值)快速定稿门禁

确立不可妥协的底线底护(Floor),死守静音注释、空桩代码与跳过测试等走捷径行为

skills/constraint-driven-development/SKILL.md
## 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
这里在做什么:禁止 Agent 通过添加 @ts-ignore、删除单测或编写假桩等方式强行凑绿

为每个维度绑定具体执行命令与执行阶段,拒绝无验证命令的空洞口号

skills/constraint-driven-development/SKILL.md
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.
这里在做什么:要求 CONSTRAINTS.md 的每一行规则都必须指明具体的命令行检查工具与运行阶段

提供配套的质量门禁脚本 quality-gate.mjs,严格拦截 Semgrep/Axe 的高危与严重漏洞

skills/constraint-driven-development/scripts/quality-gate.mjs
if (tool === 'semgrep') { if (!Array.isArray(report?.results) || !Array.isArray(report.errors) || report.errors.length || !Array.isArray(report.paths?.scanned) || !report.paths.scanned.length) { throw new Error('Incomplete scan'); } levels = report.results.map(finding => finding?.extra?.severity); allowed = ['INFO', 'WARNING', 'ERROR', 'LOW', 'MEDIUM', 'HIGH', 'CRITICAL']; blocking = ['ERROR', 'HIGH', 'CRITICAL'];
这里在做什么:在 scripts/ 中提供 Node.js 脚本解析工具报告,确保有高危问题或扫描残缺时 exit 1

提供差异级底线防护守卫脚本 floor-guard,基于 git diff 监控是否偷偷削弱质量标准

skills/constraint-driven-development/references/floor-guard.md
// floor-guard.mjs — diff-scoped enforcement of the CONSTRAINTS.md floor. // Usage: node floor-guard.mjs [--base <ref>] (default base: origin/main) import { execFileSync } from 'node:child_process';
这里在做什么:通过 git diff 分析变更内容,拦截新增的压制注释、删除的测试与被改小的阈值

2核心能力

01项目技术栈与工具链自动化探测(Detect before you ask)
02带默认基准的轻量 4 步约束访谈机制
03生成持久化机器可执行的 CONSTRAINTS.md 规范契约
04不可妥协的 Floor 底线防线(防静音、防空桩、防删测)
05多维度门禁工具链安装与脚本映射编排(check:fast/task/full)
06配套 quality-gate.mjs 扫描报告阈值解析与阻断
07基于 git diff 的 floor-guard 守卫模式检测底线破损

4管控建议与判定依据

建议配套管控措施
面向 Agent
可自动加载
面向管理者
登记来源与版本
审计说明: Skill 自带本地可执行脚本 scripts/quality-gate.mjs 并会在用户工程中运行 node 执行,且在指导过程中需要本地创建 CONSTRAINTS.md 文件及调用 git diff,符合 blue 档位标准(仅本地脚本/CLI 与本地读写)

5第二遍独立确认

  • [ok] quality-gate.mjs 本地脚本执行安全核验 — 阅读 46 行 quality-gate.mjs 脚本,仅包含本地 JSON 报告解析与 exit code 返回逻辑,无外部网络请求
  • [ok] floor-guard.md 参考脚本行为核验 — 脚本通过 execFileSync 执行本地 git diff,分析差异文本中的压制关键字,属于纯本地只读分析
  • [ok] CONSTRAINTS.md 契约格式核实 — SKILL.md 第 125-166 行完整展示了标准契约模板,含 Floor、Enforced with numbers、Measured 及 Exceptions
  • [ok] 4 步访谈法机制核实 — SKILL.md 第 85-120 行明确限定为 4 个带有开箱即用默认猜测的问题,控制访谈复杂度
  • [ok] 档位判定 blue 确认 — Skill 自身目录携带 scripts/quality-gate.mjs 可执行脚本并建议配置到本地工程执行,准确落入 blue 档位

6结论

  • 将虚无缥缈的代码规范固化为工程级可执行的 CONSTRAINTS.md 机器契约,防止跨会话质量降级
  • 坚固的 Anti-cheating 防偷懒机制,严厉打击 Agent 常用 @ts-ignore、删单测和改小阈值的逃避手法
  • 工程化务实设计,自带 quality-gate 阻断脚本与可针对 diff 极速执行的 floor-guard 守卫
  • 适合: 适用于希望彻底规范 Agent 编码行为、建立自动化质量底线,防止自主循环(Autonomous Loop)生成不可维护垃圾代码的团队与成熟项目
    不适合: 不适用于生命周期极短的抛弃型 POC/Spike 验证代码,也不适合无法进行交互访谈的非交互式 CI 初始环境
    💬 Online Trial Chat Sandbox

    Preview this skill in an interactive chat playground. Generic LLM evaluation trial.

    💬 Open Chat Trial (Preview)
    Under construction · Generic sandbox trial
    Install Agent-Ready
    ① Accelerated Distribution dl.bestaiskill.com
    Option A · Direct Zip Download⚡ Download constraint-driven-development (Zip)
    Edge-accelerated mirror via dl.bestaiskill.com
    Option B · Copy Guide for Agent
    install.json
    agent 读 JSON 指南后会自动从本站下载安装,无需更多说明。
    ② Upstream GitHub
    GitHub Repo ↗
    Pinned to commit 301b02b12b.