writing-rules

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Writing rules

写作规则

One list, one copy, synced from the hub — rules update here, never in a consumer. Enforcement varies per repo; the rules do not.
The rules live in sidecar files, one per style, so only what applies gets injected:
  • rules/all.md — every file: audience, words and links, the never list, where a statement lives
  • rules/plain.md — a person reads it: README, docs, code comments
  • rules/dense.md — only an agent reads it: CLAUDE.md, AGENTS.md, skill files, agent docs; where both could apply, dense wins
  • rules/git.md — commits, PRs, issues; the format is enforced by setup-repo's commit gate
Reviewing or writing prose by hand? Read the sidecars above — this file holds no rule.
一份统一的规则列表,从中心仓库同步更新——规则仅在此处更新,不会在使用方仓库中更新。不同仓库的执行力度可能不同,但规则本身保持一致。
规则存储在附属文件中,每种风格对应一个文件,因此只会注入适用的规则:
  • rules/all.md — 所有文件通用:受众、用词与链接、禁用列表、内容放置位置
  • rules/plain.md — 面向人类阅读:README、文档、代码注释
  • rules/dense.md — 仅面向Agent阅读:CLAUDE.md、AGENTS.md、skill文件、Agent文档;若同时适用多种规则,优先遵循dense规则
  • rules/git.md — 提交记录、PR、Issue;格式由setup-repo的提交网关强制执行
手动审阅或撰写文本内容?请阅读上述附属文件——本文件不包含具体规则。

Injection on write actions

写入操作时的规则注入

scripts/inject-writing-rules.mjs is a PreToolUse hook: on every file-writing tool call it prints the matching rules (all + plain|dense by path) as additional context, so the writer sees them without loading this skill.
/setup-repo
wires it into
.claude/settings.json
. Markdown files only;
node_modules
,
.temp/
and the synced
.claude/skills
/
.claude/rules
trees are skipped.
scripts/inject-writing-rules.mjs 是一个PreToolUse钩子:在每次文件写入工具调用时,它会打印匹配的规则(all规则 + 按路径匹配的plain|dense规则)作为额外上下文,因此撰写者无需加载此skill即可看到规则。
/setup-repo
将其关联到
.claude/settings.json
。仅适用于Markdown文件;会跳过
node_modules
、
.temp/
以及同步的
.claude/skills
/
.claude/rules
目录树。