config-audit
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chineseconfig-audit
config-audit
Audits the repo's Claude configuration against. Read-only. Producesdocs/config-guidelines.mdconsumed byaudit-report.md.config-refactor
Triggers: /config-audit, audit config, audit claude config, review configuration, configuration health check
针对审核仓库的Claude配置。只读模式。 生成供docs/config-guidelines.md使用的config-refactor。audit-report.md
触发词:/config-audit、audit config、audit claude config、review configuration、configuration health check
Process
流程
Step 0 — Detect execution context
步骤0 — 检测执行上下文
Determine which mode to run in (per Principle 13):
- Global mode — CWD is the repo. Detected when ALL of:
claude-config- exists at CWD root.
install.sh - exists at CWD root.
skills/_shared/ - OR basename of CWD matches or
claude-config.agent-config
- Project mode — CWD is any other directory containing a at root.
CLAUDE.md - No-config mode — CWD has no . Stop and print:
CLAUDE.mdNo CLAUDE.md found in this directory. Run /project-setup --interactive or create one manually before auditing.
Record the detected mode and proceed. The mode controls Step 1 (guidelines source)
and Step 2 (target file enumeration).
确定运行模式(遵循原则13):
- 全局模式 — CWD为仓库。满足以下全部条件时触发:
claude-config- CWD根目录存在。
install.sh - CWD根目录存在。
skills/_shared/ - 或CWD的基名称为或
claude-config。agent-config
- CWD根目录存在
- 项目模式 — CWD为其他任何在根目录包含的目录。
CLAUDE.md - 无配置模式 — CWD中无。停止运行并打印:
CLAUDE.md未在此目录中找到CLAUDE.md。请先运行/project-setup --interactive或手动创建后再进行审核。
记录检测到的模式并继续执行。模式将控制步骤1(指南来源)和步骤2(目标文件枚举)。
Step 1 — Locate guidelines
步骤1 — 定位指南
Global mode — read from CWD. This file is the spec.
docs/config-guidelines.mdProject mode — read (the deployed global
spec) as the read-only baseline. The project's own is the audit
target, not a spec source.
~/.claude/docs/config-guidelines.mdCLAUDE.mdIf the guidelines file does not exist in either mode:
- Emit CRITICAL "Guidelines file missing — cannot audit. In global mode, create
. In project mode, run
docs/config-guidelines.mdfrom theinstall.shrepo on this machine."claude-config - Stop. Do not produce a partial report.
全局模式 — 读取CWD下的,该文件为规范文件。
docs/config-guidelines.md项目模式 — 读取(已部署的全局规范)作为只读基准。项目自身的是审核目标,而非规范来源。
~/.claude/docs/config-guidelines.mdCLAUDE.md若任意模式下指南文件不存在:
- 输出严重错误提示:"指南文件缺失——无法执行审核。全局模式下请创建。项目模式下请在本机运行
docs/config-guidelines.md仓库中的claude-config。"install.sh - 停止运行,不生成部分报告。
Step 2 — Enumerate target files
步骤2 — 枚举目标文件
Global mode — audit only these targets, in this order. This repo follows the
+ → assembly model (Principle 14): root
, , are build products — audit them at their
source, never as hand-edited files.
core/adapters/<tool>/install.shCLAUDE.mdAGENTS.mdGEMINI.md- (root) — build product; audit its sources:
CLAUDE.md,core/instructions/*,core/methodology/*.adapters/claude-code/claude.sections-*.md - and
core/output-styles/*.body.md(output styles).adapters/claude-code/output-styles/* - — see shape note below.
skills/*/SKILL.md - and
hooks/*(read for cross-checks againstcore/hooks/*, do NOT audit hook internals).CLAUDE.md - and
adapters/claude-code/settings.json(cross-checks only — duplicated rules, hook declarations matching files insettings.local.json).hooks/ - (existence only).
adapters/<tool>/mcp/*.json - (existence only).
adapters/claude-code/keybindings.json - orphan scan (Principle 12 whitelists).
~/.claude/
Skill shape (Principle 14) — a containing an marker is
spliced: its source of truth is , and the spliced region in
is a build product — audit findings inside it map to the source. A
with no marker is direct-source: audit it in place. Both shapes coexist by
design (27/39 spliced — live count enforced by Check 7; the other 12 are
direct-source by nature — governance/setup skills
whose logic references Claude-specific paths), so audit tooling MUST handle both.
SKILL.mdASSEMBLY:BEGINcore/skills/<x>/logic.mdSKILL.mdcore/SKILL.mdvalidate.shDo not audit anything else. Out of scope: (except guidelines), , ,
test fixtures, README.
docs/memory/agents/Project mode — audit only these targets:
- at CWD root (the project's own).
CLAUDE.md - if present (project-local skills).
.claude/skills/*/SKILL.md - and
.claude/settings.jsonif present..claude/settings.local.json
Out of scope in project mode: runtime directories, the global
, anything outside the project root. The global layer is read-only
reference for duplication checks (Principle 13 anti-duplication rule).
~/.claude/CLAUDE.md全局模式 — 仅按以下顺序审核这些目标。本仓库遵循 + → 组装模型(原则14):根目录下的、、为构建产物——需审核其源文件,切勿将其视为手动编辑文件。
core/adapters/<tool>/install.shCLAUDE.mdAGENTS.mdGEMINI.md- (根目录)——构建产物;审核其源文件:
CLAUDE.md、core/instructions/*、core/methodology/*。adapters/claude-code/claude.sections-*.md - 和
core/output-styles/*.body.md(输出样式)。adapters/claude-code/output-styles/* - ——参见下方格式说明。
skills/*/SKILL.md - 和
hooks/*(仅用于与core/hooks/*交叉核对,不审核钩子内部逻辑)。CLAUDE.md - 和
adapters/claude-code/settings.json(仅用于交叉核对——重复规则、钩子声明与settings.local.json中的文件匹配情况)。hooks/ - (仅检查是否存在)。
adapters/<tool>/mcp/*.json - (仅检查是否存在)。
adapters/claude-code/keybindings.json - 孤立文件扫描(原则12白名单)。
~/.claude/
Skill格式(原则14) — 包含标记的为拼接式:其可信源为,中的拼接区域为构建产物——审核发现需映射至源文件。无该标记的为直接源式:直接审核该文件。两种格式共存为设计要求(39个中有27个为拼接式——由检查7强制验证当前数量;其余12个为直接源式——治理/设置类Skill,其逻辑引用Claude特定路径),因此审核工具必须兼容两种格式。
ASSEMBLY:BEGINSKILL.mdcore/skills/<x>/logic.mdSKILL.mdcore/SKILL.mdvalidate.sh请勿审核其他内容。范围外内容:(指南文件除外)、、、测试 fixtures、README。
docs/memory/agents/项目模式 — 仅审核以下目标:
- CWD根目录下的(项目自身的配置文件)。
CLAUDE.md - 若存在(项目本地Skill)。
.claude/skills/*/SKILL.md - 若存在和
.claude/settings.json。.claude/settings.local.json
项目模式下范围外内容:运行时目录、全局、项目根目录外的任何内容。全局层仅作为重复检查的只读参考(原则13反重复规则)。
~/.claude/CLAUDE.mdStep 3 — Run check matrix
步骤3 — 运行检查矩阵
Apply every check below. For each finding, record:
- : CRITICAL | WARNING | SUGGESTION
severity - : absolute path
file - (if applicable)
line - : the principle name from guidelines (e.g. "Principle 4 — Token budget")
rule - : one-sentence description
finding - : one-sentence suggested action
fix_hint
应用以下所有检查项。针对每个发现,记录:
- : CRITICAL | WARNING | SUGGESTION(严重错误 | 警告 | 建议)
severity - : 绝对路径
file - (若适用)
line - : 指南中的原则名称(例如:"原则4 — Token预算")
rule - : 一句话描述
finding - : 一句话建议操作
fix_hint
Token-budget checks (Principle 4)
Token预算检查(原则4)
For each target file:
- Count lines.
- Compare against the file's soft and hard limit from the guidelines table.
- Over hard limit → CRITICAL.
- Over soft limit → WARNING.
针对每个目标文件:
- 统计行数。
- 与指南表格中该文件的软限制和硬限制对比。
- 超过硬限制 → 严重错误。
- 超过软限制 → 警告。
Separation-of-concerns checks (Principle 2)
关注点分离检查(原则2)
Scan for:
CLAUDE.md- Sections that match orchestrator/agent-specific scope (e.g. "Bind this to … agent or
rule only", explicit sub-agent contracts, SDD model assignments). If found and no
exists, raise WARNING "Move scoped section to
agents/<name>.md".agents/ - A manual skill catalog (table listing 5+ skills with descriptions). If found, raise WARNING "Remove manual skill catalog — harness auto-discovers skills (Principle 2)".
Scan each output-style source ( and ) for:
core/output-styles/*.body.mdadapters/claude-code/output-styles/*- Bullets that begin with verbs like "Verify", "Never agree", "Propose alternatives",
"Explain why with evidence". These restate behavior rules → WARNING.
CLAUDE.md - Prescriptive technical opinions ("X over Y", "always use X", "concepts > code"). Raise WARNING with rule "Principle 7 — Output styles are tone, not behavior".
扫描以查找:
CLAUDE.md- 符合编排器/Agent特定范围的章节(例如:"仅绑定至…Agent或规则"、明确的子Agent契约、SDD模型分配)。若存在且无文件,触发警告:"将特定范围章节移至
agents/<name>.md目录"。agents/ - 手动Skill目录(列出5个以上Skill及描述的表格)。若存在,触发警告:"移除手动Skill目录——工具将自动发现Skill(原则2)"。
扫描每个输出样式源文件(和)以查找:
core/output-styles/*.body.mdadapters/claude-code/output-styles/*- 以"Verify"、"Never agree"、"Propose alternatives"、"Explain why with evidence"等动词开头的项目符号。这些内容重复了中的行为规则 → 警告。
CLAUDE.md - 规定性技术观点("X优于Y"、"始终使用X"、"概念>代码")。触发警告,规则为"原则7 — 输出样式为语气风格,而非行为规则"。
Anti-duplication checks (Principle 3)
反重复检查(原则3)
Build a normalized fingerprint of each rule line in and each rule line in
output styles and skills. A "rule line" is a top-level bullet inside a -like
section.
CLAUDE.md## RulesFor each pair that exceeds 70% token overlap:
- If one of the two files is a hook and the other is → CRITICAL "Rule duplicated between hook and CLAUDE.md (Principle 3.1)".
CLAUDE.md - If and an output-style → WARNING "Rule duplicated (Principle 3.2)".
CLAUDE.md - If two skills → SUGGESTION "Extract shared rule into ".
skills/_shared/
为中的每条规则行、输出样式及Skill中的每条规则行生成标准化指纹。"规则行"指类章节下的顶级项目符号。
CLAUDE.md## Rules针对每对令牌重叠度超过70%的内容:
- 若其中一个文件为钩子,另一个为→ 严重错误:"规则在钩子与CLAUDE.md之间重复(原则3.1)"。
CLAUDE.md - 若为与输出样式 → 警告:"规则重复(原则3.2)"。
CLAUDE.md - 若为两个Skill → 建议:"将共享规则提取至目录"。
skills/_shared/
OS-correctness checks (Principle 5)
系统正确性检查(原则5)
Scan for these substrings (case-insensitive): , , ,
, , (as Bash command, not the Grep tool), .
CLAUDE.mdbrewapt-getcat find sed grep ls For each hit:
- If the line is not prefixed by an OS-specific marker ("On Linux/macOS only:", "WSL:", etc.) → WARNING "OS-specific tooling assumed without declaration (Principle 5)".
扫描以查找以下子字符串(不区分大小写):、、、、、(作为Bash命令,而非Grep工具)、。
CLAUDE.mdbrewapt-getcat find sed grep ls 针对每个匹配项:
- 若该行未以系统特定标记前缀("仅在Linux/macOS下:"、"WSL:"等)开头 → 警告:"假设使用特定系统工具但未声明(原则5)"。
Engram-ownership checks (Principle 9)
Engram归属检查(原则9)
Scan for headings or bullets that look like the engram protocol payload:
CLAUDE.md- "PROACTIVE SAVE TRIGGERS"
- "SESSION START PROTOCOL"
- "SESSION CLOSE PROTOCOL"
- "AFTER COMPACTION"
- format template (a multi-bullet block describing
mem_save,title,type)content
If found AND the same content is also injected by a hook → CRITICAL
"Engram protocol duplicated between hook and CLAUDE.md (Principle 9)".
SessionStartIf found AND no hook injects it → WARNING "Engram protocol in CLAUDE.md but no hook
injects it; verify ownership".
扫描以查找类似Engram协议负载的标题或项目符号:
CLAUDE.md- "PROACTIVE SAVE TRIGGERS"
- "SESSION START PROTOCOL"
- "SESSION CLOSE PROTOCOL"
- "AFTER COMPACTION"
- 格式模板(描述
mem_save、title、type的多项目符号块)content
若存在且相同内容也由钩子注入 → 严重错误:"Engram协议在钩子与CLAUDE.md之间重复(原则9)"。
SessionStart若存在且无钩子注入该内容 → 警告:"Engram协议存在于CLAUDE.md中但无钩子注入;请验证归属"。
Force-read-inline table checks (Principle 10)
强制内联读取表格检查(原则10)
Find the "Skills — Force-read inline" table (or any table at root of listing
skills with paths). Check:
CLAUDE.md- More than 4 entries → WARNING "Force-read table exceeds 4 entries".
- Title is "Skills catalog", "Auto-load skills", or any wording that implies full catalog → WARNING "Rename to 'Skills — Force-read inline'".
- Any path that does not exist on disk → CRITICAL "Force-read entry points to missing file".
查找"Skills — Force-read inline"表格(或根目录下任何列出Skill及路径的表格)。检查:
CLAUDE.md- 条目超过4个 → 警告:"强制读取表格条目超过4个"。
- 标题为"Skills catalog"、"Auto-load skills"或任何暗示完整目录的表述 → 警告:"重命名为'Skills — Force-read inline'"。
- 任何指向磁盘上不存在路径的条目 → 严重错误:"强制读取条目指向不存在的文件"。
Skill format checks (Principle 8)
Skill格式检查(原则8)
For each :
skills/*/SKILL.md- Missing YAML frontmatter → CRITICAL.
- Missing ,
name, ordescriptionin frontmatter → CRITICAL.format - value not in {procedural, reference, anti-pattern} → CRITICAL.
format - Missing line in body → WARNING.
**Triggers**: - Section contract for declared format not met (see ) → WARNING.
core/format-types.md
针对每个:
skills/*/SKILL.md- 缺少YAML前置元数据 → 严重错误。
- 前置元数据中缺少、
name或description→ 严重错误。format - 值不在{procedural, reference, anti-pattern}中 → 严重错误。
format - 正文中缺少行 → 警告。
**Triggers**: - 未满足声明格式的章节契约(参见)→ 警告。
core/format-types.md
Two-layer duplication checks (Principle 13, project mode only)
双层重复检查(原则13,仅项目模式)
For each rule line in the project :
CLAUDE.md- Normalize and fingerprint as in the anti-duplication check.
- Compare against rules in the global .
~/.claude/CLAUDE.md - Token overlap > 70% AND no block declares the rule → CRITICAL "Project CLAUDE.md restates global rule without override declaration (Principle 13)".
## Overrides global - If a project rule contradicts a global rule (semantic opposite) and no override block is declared → CRITICAL "Project CLAUDE.md contradicts global without override (Principle 13)".
In global mode this check is skipped (only one layer present).
针对项目中的每条规则行:
CLAUDE.md- 按反重复检查中的方式生成标准化指纹。
- 与全局中的规则对比。
~/.claude/CLAUDE.md - 令牌重叠度>70%且无块声明该规则 → 严重错误:"项目CLAUDE.md重复全局规则但未声明覆盖(原则13)"。
## Overrides global - 若项目规则与全局规则矛盾(语义相反)且未声明覆盖块 → 严重错误:"项目CLAUDE.md与全局规则矛盾但未声明覆盖(原则13)"。
全局模式下跳过此检查(仅存在一层)。
Orphan checks in ~/.claude/
(Principle 12, global mode only)
~/.claude/~/.claude/
孤立文件检查(原则12,仅全局模式)
~/.claude/List the entries directly under . For each entry:
~/.claude/- If the name is in the known-runtime whitelist (Principle 12) → ignore.
- If the name is in the known-deployed whitelist → ignore.
- Otherwise → WARNING "Orphan in ~/.claude/: <name>. Investigate origin or remove."
Do not recurse into runtime directories. The check is one level deep.
列出下的直接条目。针对每个条目:
~/.claude/- 若名称在已知运行时白名单(原则12)中 → 忽略。
- 若名称在已知部署白名单中 → 忽略。
- 否则 → 警告:中存在孤立文件:<name>。请调查来源或删除。
~/.claude/
请勿递归进入运行时目录。检查仅针对一级目录。
Cross-reference checks (general)
交叉引用检查(通用)
- For every absolute path mentioned in (e.g.
CLAUDE.md), verify the corresponding repo path exists. If not → SUGGESTION "Dead reference".~/.claude/skills/foo/SKILL.md - For every skill name referenced inside another body, verify it exists in
SKILL.md. If not → SUGGESTION "Reference to missing skill".skills/
- 针对中提及的每个绝对路径(例如:
CLAUDE.md),验证对应的仓库路径是否存在。若不存在 → 建议:"无效引用"。~/.claude/skills/foo/SKILL.md - 针对另一个正文中引用的每个Skill名称,验证其是否存在于
SKILL.md目录中。若不存在 → 建议:"引用了不存在的Skill"。skills/
Step 4 — Write the report
步骤4 — 生成报告
Write the result to at the repo root with this exact structure:
audit-report.mdmarkdown
undefined将结果写入仓库根目录下的,需严格遵循以下结构:
audit-report.mdmarkdown
undefinedConfiguration Audit Report
Configuration Audit Report
Generated: YYYY-MM-DD HH:MM
Guidelines version: <git short hash of docs/config-guidelines.md if available, else "untracked">
Generated: YYYY-MM-DD HH:MM
Guidelines version: <git short hash of docs/config-guidelines.md if available, else "untracked">
Summary
Summary
- CRITICAL: <count>
- WARNING: <count>
- SUGGESTION: <count>
- CRITICAL: <count>
- WARNING: <count>
- SUGGESTION: <count>
Findings
Findings
CRITICAL
CRITICAL
[CRIT-1] <one-line title>
[CRIT-1] <one-line title>
- File: (line <n> if applicable)
<path> - Rule: <principle name>
- Finding: <one sentence>
- Fix hint: <one sentence>
(repeat for each CRITICAL)
- File: (line <n> if applicable)
<path> - Rule: <principle name>
- Finding: <one sentence>
- Fix hint: <one sentence>
(repeat for each CRITICAL)
WARNING
WARNING
(same shape)
(same shape)
SUGGESTION
SUGGESTION
(same shape)
(same shape)
No-issues sections
No-issues sections
List target files that produced zero findings. One per line.
List target files that produced zero findings. One per line.
Next step
Next step
Run to apply fixes. The refactor skill reads this file as its spec.
/config-refactor
Use stable IDs (`CRIT-1`, `WARN-1`, `SUGG-1` …) so `config-refactor` can reference them
exactly.Run to apply fixes. The refactor skill reads this file as its spec.
/config-refactor
使用稳定ID(`CRIT-1`、`WARN-1`、`SUGG-1`……)以便`config-refactor`能准确引用。Step 5 — Print summary to chat
步骤5 — 向聊天窗口打印摘要
After writing the report, print a compact summary to the user:
- The three counts.
- The top 3 CRITICAL findings (title + file only).
- The path to the full report.
- One closing line: "Run to apply, or open the report to triage first."
/config-refactor
Do NOT propose fixes inline. The refactor skill owns that.
生成报告后,向用户打印简洁摘要:
- 三类问题的数量。
- 前3个严重错误发现(仅标题和文件)。
- 完整报告的路径。
- 结束语:"运行应用修复,或先打开报告进行分类处理。"
/config-refactor
请勿在聊天窗口中直接提出修复方案。修复工作由refactor skill负责。
Rules
规则
- Read-only. This skill never edits any file other than .
audit-report.md - Never invent rules. Every finding cites a principle from .
docs/config-guidelines.md - If a check would produce more than 20 findings of the same severity for the same file, collapse them into one finding ("File has 23 lines exceeding token budget by …") to keep the report readable.
- Deterministic ordering: CRITICAL before WARNING before SUGGESTION; inside each, ordered by file path then line number.
- The report MUST be self-contained — reads only
config-refactorandaudit-report.md, never the original conversation.docs/config-guidelines.md - Audit only the files listed in Step 2. Do not expand scope mid-run.
- 只读模式。本Skill仅编辑,绝不修改其他任何文件。
audit-report.md - 不得自行制定规则。每个发现必须引用中的原则。
docs/config-guidelines.md - 若同一文件同一严重级别的检查发现超过20个,需合并为一个发现(例如:"文件有23行超出Token预算……")以保证报告可读性。
- 确定性排序:严重错误优先于警告,警告优先于建议;同一级别内按文件路径和行号排序。
- 报告必须自包含——仅读取
config-refactor和audit-report.md,绝不读取原始对话内容。docs/config-guidelines.md - 仅审核步骤2中列出的文件。运行过程中不得扩大范围。