Use references/standards.md as the sole content source to sync the three sections of standards to the target repository's instruction file. The script handles section-level replacement or appending, preserves other content, unifies LF line endings, and verifies the result.
Choose one of two target files:AGENTS.md(default) or CLAUDE.md。
Process
-
Confirm the target directory and target file:
- Directory: defaults to the current working directory; if the target is not the repository root, pass an explicit path.
- File: if the user has specified recording to
CLAUDE.md, follow that; if unspecified, use the defaultAGENTS.md, no need to ask.
-
Run once:
# 默认:只同步 AGENTS.md node "{{SKILL_DIR}}/sync.js" # 同步 CLAUDE.md(--file 可简写为 -f) node "{{SKILL_DIR}}/sync.js" --file CLAUDE.md
node "{{SKILL_DIR}}/sync.js" "/path/to/repo" --file CLAUDE.md
`{{SKILL_DIR}}` 是 skill 所在目录的绝对路径,由 harness 替换。
3. 以退出码判断结果:退出码 `0` 表示同步并验证成功;非 `0` 时报告完整错误并停止。
4. 成功后对本次同步的文件执行 `git diff`(如 `git diff -- AGENTS.md`),向用户说明新增、替换或保留的内容。
脚本已经包揽文件读取、节切分、写入、行尾归一化和一致性验证。不要再手动编辑同一批文件,也不要用其他脚本重复实现这些步骤。
## 完成条件
- 脚本退出码为 `0`。
- 每个选中的目标文件存在,首行为对应的 `# AGENTS.md` 或 `# CLAUDE.md`。
- 选中的文件都包含 `## 交流语言`、`## 写作要求`、`## 编码准则`。
- 三节内容分别与 `references/standards.md` 逐字一致。
- 目标文件和源文件均使用 LF 行尾。
- 其他已有章节仍保留;未选中的文件未被创建或改动。
## 维护
- 只编辑 `references/standards.md` 更新规范正文;不要直接修改目标文件中的同步章节。
- 规范同步成功后,重启 Claude Code 会话,让新规范进入上下文。