skills/developer-tools-integrations/claude-md-improver/SKILL.md
Audit and improve Claude Code CLAUDE.md guidance files, .claude/rules/ path-scoped rules, and companion code_map.md navigation maps. Use when the user asks to check, audit, update, optimize, or fix CLAUDE.md files; mentions nested CLAUDE.md, additive loading, ancestor/descendant loading, path-scoped rules, @import chains, CLAUDE.local.md, claudeMdExcludes, or code_map.md; or says "优化 CLAUDE.md", "审计 CLAUDE.md", "检查嵌套 CLAUDE.md", "Claude Code 项目指导", "生成 code_map (Claude)". Make sure to use this skill whenever the user wants to manage Claude Code memory files at any layer, even if they only mention CLAUDE.md without explicit audit wording.
npx skillsauth add bahayonghang/my-claude-code-settings claude-md-improverInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Audit and improve Claude Code CLAUDE.md guidance files, .claude/rules/ path-scoped rules, and the companion code_map.md navigation map so future Claude Code sessions receive concise, accurate, additively-layered project instructions and fast code search entry points.
Default mode is report-first. Output a quality report and proposed diff before writing. If the user explicitly asks to implement an approved plan, continue directly to targeted edits and verification.
Claude Code memory files use additive layering, not directory-scoped override. This is the most common point of confusion when migrating instructions from Codex AGENTS.md or other agents.
CLAUDE.md and CLAUDE.local.md found along the way is loaded at session start and concatenated into context, ordered from filesystem root to working directory.CLAUDE.md files in descendant directories are loaded lazily when Claude reads files in those directories during the session.CLAUDE.md files in sibling directories are never loaded for the current session.~/.claude/CLAUDE.md) → project (./CLAUDE.md then ./.claude/CLAUDE.md) → CLAUDE.local.md per layer. Repository CLAUDE.md is project guidance. User-level ~/.claude/CLAUDE.md is personal preference and is not edited unless the user explicitly asks.@path imports expand at launch (recursive, max depth 5). They do not save context; they only organize files.<!-- ... -->) are stripped before injection. Use them for human-maintainer notes that should not consume tokens..claude/rules/*.md with a paths: frontmatter glob loads only when Claude reads files matching that glob. Rules without paths: load unconditionally.CLAUDE.md carries durable behavioral constraints, commands, and project conventions. code_map.md carries navigational structure, search anchors, entry points, and generated/ignored directory notes.CLAUDE.md should name the relative code_map.md path agents must read before broad grep, for example Before broad grep, read ./code_map.md.CLAUDE.md under 200 lines; longer files reduce adherence and inflate every session's startup tokens.<!-- OMX:RUNTIME:START --> ... <!-- OMX:RUNTIME:END --> and <!-- OMX:TEAM:WORKER:START --> ... <!-- OMX:TEAM:WORKER:END -->. These are stripped at injection but are still meaningful to hook tooling and must survive edits intact.See references/claude-md-loading.md for the full loading model, including edge cases around --add-dir, claudeMdExcludes, and auto memory boundaries.
Find every memory file in scope.
# POSIX shells
find . \( -name CLAUDE.md -o -name CLAUDE.local.md -o -name code_map.md \) \
-not -path './.git/*' \
-not -path './node_modules/*' \
-not -path './target/*' \
-not -path './dist/*' \
-not -path './build/*' \
-not -path './.omx/state/*'
find . -path '*/.claude/rules/*.md' -not -path './node_modules/*'
# PowerShell
Get-ChildItem -Recurse -Force -Include CLAUDE.md,CLAUDE.local.md,code_map.md |
Where-Object { $_.FullName -notmatch '\\.git|node_modules|target|dist|build|\\.omx\\state' } |
Select-Object -ExpandProperty FullName
Get-ChildItem -Recurse -Force -Path .\.claude\rules\*.md -ErrorAction SilentlyContinue
Exclude generated, vendored, dependency, cache, and build-output directories from creation scans: .git/, node_modules/, target/, dist/, build/, .omx/state/, vendor/, coverage output, generated docs/site output, and language-specific package caches.
Also note, but do not edit by default:
~/.claude/CLAUDE.md
~/.claude/rules/
/Library/Application Support/ClaudeCode/CLAUDE.md # macOS managed policy
/etc/claude-code/CLAUDE.md # Linux/WSL managed policy
C:\Program Files\ClaudeCode\CLAUDE.md # Windows managed policy
Discover candidate subtrees for new nested CLAUDE.md (and possibly local code_map.md) before proposing writes. Score only real source subtrees that show one or more of: distinct stack or framework, independent manifest/command surface, divergent conventions, frequent agent work in that area, local safety boundary, or pressure to relieve a bloated root CLAUDE.md.
Classify each file:
| Type | Location | Purpose |
|---|---|---|
| project root guidance | ./CLAUDE.md or ./.claude/CLAUDE.md | repo-wide pointers, gotchas, conventions, top-level commands |
| nested project guidance | ./<subtree>/CLAUDE.md (or <subtree>/.claude/CLAUDE.md) | local stack, commands, safety, conventions distinct from parent |
| path-scoped rules | ./.claude/rules/*.md (optional paths: frontmatter) | conditional or always-on rules organized by topic |
| personal override | ./CLAUDE.local.md | gitignored per-developer preferences; never read content, only confirm it is gitignored |
| root code map | ./code_map.md | repo navigation, top-level routing, search anchors, ignored/generated paths |
| nested code map | ./<subtree>/code_map.md | subtree entry points, internal routing, upstream/downstream boundaries |
| user global guidance | ~/.claude/CLAUDE.md | outside repo scope; do not edit unless explicitly asked |
| managed policy guidance | OS-managed path above | IT/DevOps controlled; never edit from a repo skill |
For every in-scope file, verify claims against the repository:
package.json, justfile, Cargo.toml, pyproject.toml, Makefile, CI workflows@import targets: every @path/to/file must resolve relative to the file containing it; recursion depth ≤ 5code_map.md existence and whether each CLAUDE.md map pointer uses an explicit relative path.claude/rules/*.md frontmatter: paths: globs are valid, file globs match real source files, conditional rules are not duplicating root content.claude/settings.json — do not duplicate hard permissions.deny constraints as soft prose; if the setting already blocks an action, do not also rephrase it as a ruleclaudeMdExcludes settings (in .claude/settings.json, .claude/settings.local.json, or managed) and whether they conflict with the files you are auditingcode_map.mdOMX:...:START / END pairsCLAUDE.local.md presence — confirm it is listed in .gitignore; do not read its contentUse references/quality-criteria.md for detailed scoring, including the nested CLAUDE.md creation scorecard.
Quick checklist (100 points total):
| Criterion | Weight | Check |
|---|---:|---|
| additive layering clarity | 20 | file states which layer it occupies and what it adds, without restating parent content |
| executable commands and gates | 20 | install/build/test/lint/typecheck/dev commands are real and scoped to the file's layer |
| architecture and routing | 15 | points to ./code_map.md with an explicit relative path; does not duplicate directory indexes |
| tool permissions and safety | 15 | secrets, destructive ops, external services, generated/runtime paths are bounded; does not duplicate .claude/settings.json hard rules |
| Claude Code workflow fit | 15 | skills, hooks, MCP, sub-agents, auto memory boundaries are accurate and not overpromised |
| conciseness and currency | 15 | under 200 lines, current, dense, no template residue or stale paths |
Grades:
For each candidate nested subtree, record creation score and decision: create (≥60), candidate only (40-59), or do not create (<40). For each existing nested file, note whether it could move into a .claude/rules/*.md with a paths: glob instead.
Always provide this report before edits unless the user already approved an implementation plan.
## CLAUDE.md Quality Report
### Summary
- Files found: X (CLAUDE.md: X, CLAUDE.local.md: X, .claude/rules: X, code_map: X)
- Project root guidance: present at <path>/missing
- Root code map: present/missing/shared with agents-md-improver
- Nested project files: X (X over 200 lines)
- Average score: X/100
- Files needing update: X
- Candidate nested guidance dirs: X create / X candidate-only / X skipped
### Layering Map
| File | Loads when | Adds | Notes |
|---|---|---|---|
| `CLAUDE.md` | session start (ancestor) | repo-wide pointers + gotchas | 142 lines |
| `packages/api/CLAUDE.md` | reading files under `packages/api/` | API stack, local commands, secrets boundary | 88 lines |
| `.claude/rules/testing.md` | reading `**/*.test.ts` | TDD rules | paths-scoped |
### Code Map Coverage
| Map | Covers | Referenced by | Notes |
|---|---|---|---|
| `code_map.md` | repo root | `CLAUDE.md`, `AGENTS.md` | shared with agents-md-improver |
### Nested Guidance Candidates
| Directory | Score | Decision | Evidence |
|---|---:|---|---|
| `packages/api/` | 75 | create `packages/api/CLAUDE.md` | distinct Python stack, own pytest commands, secrets boundary |
### File-by-File Assessment
#### 1. `CLAUDE.md`
**Score: XX/100 (Grade: X)**
| Criterion | Score | Notes |
|---|---:|---|
| additive layering clarity | X/20 | ... |
| executable commands and gates | X/20 | ... |
| architecture and routing | X/15 | ... |
| tool permissions and safety | X/15 | ... |
| Claude Code workflow fit | X/15 | ... |
| conciseness and currency | X/15 | line count XXX vs 200 target |
**Issues**
- ...
**Proposed changes**
- ...
When approved or already authorized by a plan, follow references/update-guidelines.md. The nine load-bearing rules:
CLAUDE.md holds repo-wide pointers and critical gotchas only; target under 200 lines.CLAUDE.md adds local stack, commands, and safety; never restates the parent content because parent content already loaded.CLAUDE.md; navigation, anchors, and directory indexes live in code_map.md..claude/rules/*.md with paths: frontmatter — they load only when relevant and keep the root file lean../code_map.md with prose ("Before broad grep, read ./code_map.md") rather than @code_map.md. @import loads at launch and defeats the on-demand purpose of a map.CLAUDE.md, list known nested CLAUDE.md files under a "Nested Documentation" section so Claude can discover sibling subtrees by name even when their files are not yet loaded.@AGENTS.md import bridges when the repository runs both Claude Code and Codex.CLAUDE.local.md is present, only confirm it is in .gitignore; do not read its content or copy it into shared files.Run the smallest checks that prove the edits:
git diff --check
Manual checks to perform on every updated file:
.claude/rules/*.md@path/to/file import target exists on disk; recursion depth ≤ 5code_map.md pointer uses an explicit relative path.claude/rules/*.md paths: glob is valid YAML and matches at least one real file.claude/settings.json hard rulesCLAUDE.local.md is in .gitignore if it existsIf a documented full gate is expensive (browser tests, deploys), state whether it was run or why it was skipped.
references/claude-md-loading.md — Claude Code loading model, edge cases, and what each loading layer can and cannot doreferences/quality-criteria.md — scoring rubric, nested creation scorecard, and red flagsreferences/templates.md — root, monorepo package, frontend, backend, docs, .claude/rules, @AGENTS.md bridge, and code_map.md templatesreferences/update-guidelines.md — what to add, what to avoid, what to preserve, diff formatCLAUDE.md exceeds 200 lines because path-specific content was never moved to .claude/rules/*.mdCLAUDE.md missing an explicit ./code_map.md pointer when a root map exists or should existCLAUDE.md restates parent content under the false assumption that nested files override the rootCLAUDE.md only says "read the code map" without naming the relative map pathCLAUDE.md bloated with directory index content that belongs in code_map.mdCLAUDE.md@import chains exceeding 5 hops or referencing missing files<!-- ... --> comments used for instructions Claude is expected to follow (they are stripped before injection).claude/rules/*.md without paths: frontmatter that would have been a perfect path-scoped fitCLAUDE.local.md checked into git (must be gitignored)AGENTS.md pasted into CLAUDE.md instead of using the @AGENTS.md import bridge## CLAUDE.md Update Summary
### Files changed
- `CLAUDE.md` — ...
- `packages/api/CLAUDE.md` — ...
- `.claude/rules/testing.md` — ...
- `code_map.md` — ...
### What improved
- layering clarity and root-vs-nested division of labor
- command/gate accuracy
- safety boundaries aligned with `.claude/settings.json`
- map-first search flow with explicit relative `code_map.md` paths
- root file shrunk from XXX to YYY lines
### Verification
- `git diff --check` — passed
- `<targeted command>` — passed/failed/skipped with reason
### Remaining risks
- ...
development
Turn vague or complex Codex tasks into strong `/goal` commands with outcome, verification, constraints, boundaries, iteration policy, completion evidence, and pause/block conditions. Use when the user asks for Codex goal instructions, Goal 指令, 目标指令, `/goal` prompts, 中文 Goal 模板, plan-to-goal interviews, success criteria, verification commands, or bounded agent work definitions.
tools
Write, debug, and validate ast-grep structural code search rules. Use this skill when the user needs syntax-aware code search, AST pattern matching, structural refactor discovery, language-construct queries, or searches that plain text tools like rg can miss, such as finding functions with particular descendants, calls inside specific contexts, missing error handling, React hook shapes, decorators, or other Tree-sitter-backed code structures.
development
Use when the user asks to ground an ambitious proposal, avoid over-grand designs, make a bold direction executable, pressure-test feasibility, prevent "too much vision and too little landing", or turn a strategy/refactor/product idea into the smallest verifiable first move with stop rules. Trigger for requests such as 落地, 先落地, 别太飘, 收一收, 可执行, 可验证, 止损, and for follow-ups after geju-style big-picture thinking. Do not trigger for ordinary code review or implementation unless the user explicitly asks to ground or shrink the plan first.
development
Use when the user explicitly asks to think bigger, open up the design space, challenge conservative design, avoid over-indexing on backward compatibility, escape local-detail fixation, or make a bold high-level product or architecture direction call. Use for strategic reframing, not for ordinary code review, PRD writing, implementation planning, or adversarial risk review.