debt-ops-init
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesedebt-ops-init
debt-ops-init
Write or update a section in the project's agent charter.
Idempotent — only the managed section changes.
## Tech debt operationsRun only on explicit user request ("set up debt-ops", "init debt-ops",
"write the disciplines"). Do not invoke this as part of normal work. (Tools with a
debt-ops hook adapter inject these disciplines per-session automatically; this skill
is the persistence step for everyone else.)
在项目的Agent章程中撰写或更新章节。
具有幂等性——仅修改受管理的章节。
## Tech debt operations仅在用户明确请求时运行(例如“set up debt-ops”、“init debt-ops”、“write the disciplines”)。请勿在常规工作中调用此工具。(带有debt-ops钩子适配器的工具会在每个会话中自动注入这些规范;本技能是为其他用户提供的持久化步骤。)
Why this matters more on skills-only tools
为什么这在仅支持技能的工具上更为重要
Without a hook adapter there is no per-edit enforcement and no automatic capture.
The charter is the only place the disciplines live, so the agent self-applies them.
That's "vibes," not a tripwire — be honest with the user that the persistent charter
is the substitute for, not the equal of, the hook-driven write-time loop.
如果没有钩子适配器,就无法在每次编辑时进行强制检查和自动捕获。
章程是这些规范的唯一存放位置,因此Agent会自行应用这些规范。
这是一种“共识约束”,而非强制触发机制——请如实告知用户,持久化章程是钩子驱动的写入时循环的替代方案,而非等同方案。
1. Pick the charter file
1. 选择章程文件
Use at the repo root — the cross-tool charter most agents read. If the
project clearly standardizes on a different file your agent auto-loads
(, , ), use that instead and
tell the user which you picked.
AGENTS.mdGEMINI.md.github/copilot-instructions.mdCLAUDE.md使用仓库根目录下的——这是大多数Agent都会读取的跨工具章程。如果项目明确标准化使用其他你的Agent会自动加载的文件(如、、),则改用该文件并告知用户你的选择。
AGENTS.mdGEMINI.md.github/copilot-instructions.mdCLAUDE.md2. Read any cached quality commands (optional)
2. 读取缓存的质量检查命令(可选)
If a hook adapter previously ran in this repo, it cached the project's quality
commands. Include them if present; otherwise leave the placeholder.
bash
REPO_HASH=$(python3 -c "import hashlib,subprocess;t=subprocess.run(['git','rev-parse','--show-toplevel'],capture_output=True,text=True).stdout.strip();print(hashlib.sha1(t.encode()).hexdigest()[:12] if t else '')")
CACHE_DIR="${DEBT_OPS_CACHE:-$HOME/.cache/debt-ops}/cache/$REPO_HASH"
[ -f "$CACHE_DIR/feedback.list" ] && cat "$CACHE_DIR/feedback.list"
ADR_DIR=$( [ -s "$CACHE_DIR/adr-dir" ] && cat "$CACHE_DIR/adr-dir" || echo "docs/adr" )
REGISTRY_DIR=$( [ -s "$CACHE_DIR/registry-dir" ] && cat "$CACHE_DIR/registry-dir" || echo "docs/debt" )
echo "adr-dir: $ADR_DIR"
echo "registry-dir: $REGISTRY_DIR"If no commands are cached, detect the project's lint/type/test commands by scanning
its manifests (, , , , ,
…). Prefer commands that take a changed-file argument and run in a few seconds.
package.jsonpyproject.tomlCargo.tomlgo.modMakefile如果钩子适配器此前已在本仓库中运行过,它会缓存项目的质量检查命令。如果存在则包含这些命令;否则保留占位符。
bash
REPO_HASH=$(python3 -c "import hashlib,subprocess;t=subprocess.run(['git','rev-parse','--show-toplevel'],capture_output=True,text=True).stdout.strip();print(hashlib.sha1(t.encode()).hexdigest()[:12] if t else '')")
CACHE_DIR="${DEBT_OPS_CACHE:-$HOME/.cache/debt-ops}/cache/$REPO_HASH"
[ -f "$CACHE_DIR/feedback.list" ] && cat "$CACHE_DIR/feedback.list"
ADR_DIR=$( [ -s "$CACHE_DIR/adr-dir" ] && cat "$CACHE_DIR/adr-dir" || echo "docs/adr" )
REGISTRY_DIR=$( [ -s "$CACHE_DIR/registry-dir" ] && cat "$CACHE_DIR/registry-dir" || echo "docs/debt" )
echo "adr-dir: $ADR_DIR"
echo "registry-dir: $REGISTRY_DIR"如果没有缓存的命令,则通过扫描项目的清单文件(、、、、等)检测项目的lint/类型检查/测试命令。优先选择接受变更文件参数且能在数秒内运行的命令。
package.jsonpyproject.tomlCargo.tomlgo.modMakefile3. Compose the section (template)
3. 撰写章节内容(模板)
Substitute , , and (the cached or
detected commands, one per line; leave a
placeholder if none found).
{{ADR_DIR}}{{REGISTRY_DIR}}{{COMMANDS}}# add your lint/type/test commands heremarkdown
undefined替换、和(缓存或检测到的命令,每行一个;如果未找到则保留占位符)。
{{ADR_DIR}}{{REGISTRY_DIR}}{{COMMANDS}}# add your lint/type/test commands heremarkdown
undefinedTech debt operations
Tech debt operations
<!-- this section is auto-managed by the debt-ops agent skill; safe to edit, run debt-ops-init to regenerate -->
<!-- this section is auto-managed by the debt-ops agent skill; safe to edit, run debt-ops-init to regenerate -->
Disciplines
Disciplines
-
The test for debt: would a future reader ask "why this way?" If yes, register via theskill immediately — no prompt. This is judgment, not a marker scan: a
debt-ops-add/TODO/FIXME/HACKis the obvious case, but an unmade decision, a stub, a loosened type, or a default picked "for now" all count even with no marker in the diff. UseXXXif unsure. Announce:payoff_trigger: unknown. Over-register freely; the developer drops with "drop it".+1 entry: <slug> (drop?) -
When making an architecturally significant change — a data model, public interface, security boundary, release pipeline, or a dep-manifest change that is a major-version bump or a new top-level dependency — draft an ADR underin Nygard format: a
{{ADR_DIR}}/heading,# NNNN — Titleand**Date:**lines, then Context, Decision, Consequences, Alternatives, Payoff trigger. Create the directory if needed. Only draft an ADR when there are two credible alternatives; if you cannot list two, it is a comment, not an ADR. An ADR with a payoff trigger is deliberate debt — when you write one, also use**Status:**so the registry entry mirrors the ADR.debt-ops-add -
Read entries underbefore changing files they reference.
{{REGISTRY_DIR}}/
-
债务的判断标准:未来的读者是否会问“为什么要这样做?”如果是,立即通过技能登记——无需提示。这是基于判断的,而非标记扫描:
debt-ops-add/TODO/FIXME/HACK是明显的情况,但未做出的决策、存根代码、放宽的类型限制或“暂时”选择的默认值,即使差异中没有标记,也都属于技术债务。如果不确定,使用XXX。发布通知:payoff_trigger: unknown。可以过度登记;开发者可通过“drop it”来移除条目。+1 entry: <slug> (drop?) -
当进行具有架构重要性的变更时——例如数据模型、公共接口、安全边界、发布流水线,或是涉及主版本升级或新增顶级依赖的依赖清单变更——在下按照Nygard格式撰写ADR:包含
{{ADR_DIR}}/标题、# NNNN — Title和**Date:**行,然后是Context(背景)、Decision(决策)、Consequences(影响)、Alternatives(替代方案)、Payoff trigger(偿还触发条件)。如果目录不存在则创建。仅当存在两种可信的替代方案时才撰写ADR;如果无法列出两种方案,则只需添加注释,无需撰写ADR。带有偿还触发条件的ADR属于刻意的技术债务——撰写此类ADR时,同时使用**Status:**技能,以便登记条目与ADR保持一致。debt-ops-add -
在修改下条目所引用的文件之前,请先阅读这些条目。
{{REGISTRY_DIR}}/
Quality checks
Quality checks
If a debt-ops hook adapter is installed (e.g. the Copilot adapter), it reads the marker block below and runs these after every edit under a 3 s budget. Without an adapter (skills-only tool), they are not enforced automatically — you, the agent, run them after editing and fix failures before moving on. Lines starting with are estimates/comments and are skipped at run time.
<!-- debt-ops:feedback v1 -->
#{{COMMANDS}}
<!-- /debt-ops:feedback -->
undefined如果已安装debt-ops钩子适配器(例如Copilot适配器),它会读取下方的标记块,并在每次编辑后在3秒预算内运行这些命令。如果没有适配器(仅支持技能的工具),则不会自动强制执行这些检查——你(Agent)需要在编辑后运行这些检查,并在继续操作前修复失败项。以开头的行是估算/注释,运行时会被跳过。
<!-- debt-ops:feedback v1 -->
#{{COMMANDS}}
<!-- /debt-ops:feedback -->
undefined4. Apply
4. 应用修改
- If the charter file doesn't exist: create it with the section above as the entire file.
- If it has a section: replace exactly that section — from the heading through (but not including) the next
## Tech debt operationsheading, or EOF if none. Leave every other byte unchanged.## - If it exists without the section: append the section after the last line, with one blank line between.
- 如果章程文件不存在: 创建该文件,并将上述章节作为整个文件的内容。
- 如果文件已有章节: 精确替换该章节——从标题开始,到下一个
## Tech debt operations标题之前(不包含该标题),如果没有下一个##标题则到文件末尾。其他内容保持不变。## - 如果文件存在但没有该章节: 在文件最后一行之后添加该章节,两者之间保留一个空行。
5. Announce
5. 发布通知
charter updated: <file> — disciplines + N quality commandscharter updated: <file> — disciplines + N quality commandsMarker contract — do not deviate
Marker contract — do not deviate
- is the open marker the hook adapters key on. Exact string; the
<!-- debt-ops:feedback v1 -->is part of the marker.v1 - is the close marker.
<!-- /debt-ops:feedback --> - This must stay identical across every adapter's and
feedback.pyskill — see CLAUDE.md "Adapter parity." A drift here silently breaks the Copilot write-time loop (it reads the block by this exact marker).init
- 是钩子适配器识别的起始标记。 字符串必须完全一致;
<!-- debt-ops:feedback v1 -->是标记的一部分。v1 - 是结束标记。
<!-- /debt-ops:feedback --> - 所有适配器的和
feedback.py技能中的此标记必须保持完全一致——请参阅CLAUDE.md中的“Adapter parity”(适配器一致性)。此处的差异会静默破坏Copilot的写入时循环(它通过此精确标记读取块内容)。init
Don't
Don't
- Don't auto-invoke. Only on explicit user request.
- Don't touch any byte outside the section.
## Tech debt operations - Don't claim the charter gives deterministic enforcement — it doesn't without a hook adapter. Say so.
- 请勿自动调用。仅在用户明确请求时运行。
- 请勿修改章节之外的任何内容。
## Tech debt operations - 请勿声称章程能提供确定性的强制约束——没有钩子适配器的话是做不到的。请如实说明。