/spwf:claudemd-curatorfrom spwf
Audits, refactors, and keeps CLAUDE.md and AGENTS.md healthy and in sync. Use whenever the user mentions reviewing, refactoring, optimising, slimming, or auditing CLAUDE.md or AGENTS.md, asks "what should be in my CLAUDE.md", wants to migrate to AGENTS.md, suspects rule drift, complains that Claude is ignoring instructions, or has just initialised a repo with /init and wants the output cleaned up. Also trigger when the user mentions context-token bloat, rule violations across sessions, dead rules, or symlink/shim setup between AGENTS.md and CLAUDE.md. Apply this skill before any other CLAUDE.md edit so the curation pass runs first.
Ships in spwf. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description, though model invocation is off: only you can start it.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Keep CLAUDE.md and AGENTS.md lean, layered, in sync, and grounded in what actually happens during sessions.
This skill does four things in order: inventory, behavioural audit, layer classification, sync verification, then proposes a diff. It does not edit files until the user approves.
jq — required by scripts/mine-conversations.sh for JSONL parsing. Install with brew install jq or apt-get install jq.scripts/mine-conversations.sh and scripts/sync-agents-md.sh must be executable. If not: chmod +x scripts/mine-conversations.sh scripts/sync-agents-md.sh.~/.claude/projects/ to be populated. On a fresh install, Phase 2 produces an empty findings section (graceful, not a failure)./init and wanting the auto-generated file cleaned up (it always includes obvious things Claude can infer from the codebase).Do not trigger this skill for one-off rule additions ("please remember we use pnpm") — those are direct edits.
Three published references inform this skill, each addressing a different layer:
| Source | Addresses | What it adds to CLAUDE.md |
|---|---|---|
Karpathy's CLAUDE.md (forrestchang/andrej-karpathy-skills) | Coding discipline | Think before coding · Simplicity first · Surgical changes · Goal-driven execution |
sohaibt/product-mode | Decision posture | User/JTBD anchor · One-way vs two-way doors · Written tradeoffs · "Merged ≠ done" |
ykdojo review-claudemd (skills.sh/ykdojo/claude-code-tips) | Feedback loop | Mine ~/.claude/projects/*.jsonl for violations, candidate additions, dead rules |
Karpathy is for the engineer; product-mode is for the team; ykdojo closes the loop. Use all three.
Every line in CLAUDE.md should be classifiable into exactly one layer. If it isn't, it's bloat or it belongs in a pointer.
@imports, .claude/rules/*.md with paths: frontmatter, skill names, agent guides. Pointers, not content.Total target: under 200 lines for the project-level CLAUDE.md, under 100 lines for ~/.claude/CLAUDE.md.
Full layer definitions including templates and examples are in references/layer-model.md.
As of late April 2026, Claude Code does not officially read AGENTS.md natively (issue anthropics/claude-code#34235 open, dup of #6235). Operative pattern:
ln -s AGENTS.md CLAUDE.md) when there is nothing Claude-specific.See @AGENTS.md and then adds only Claude-specific content (skills loaded, hook references, compact instructions, model/effort hints)..github/copilot-instructions.md, .cursor/rules/main.mdc, etc. One source of truth, many filenames.The script scripts/sync-agents-md.sh handles symlink setup and verification.
Run the four phases in order. Do not skip phases.
Read every relevant file. Do not assume contents from filenames.
# At the project root
ls -la CLAUDE.md AGENTS.md CLAUDE.local.md 2>/dev/null
ls -la .claude/rules/ .claude/skills/ .claude/agents/ .claude/hooks/ 2>/dev/null
ls -la docs/agent-guides/ 2>/dev/null # if the user follows the Groff convention
# Global
ls -la ~/.claude/CLAUDE.md ~/.claude/agents/ ~/.claude/skills/ 2>/dev/null
For each markdown file found, count lines and characters. CLAUDE.md over 300 lines is a code smell; over 500 is a problem. Note any files that are git-tracked vs gitignored.
Check for the AGENTS.md sync pattern:
# Is CLAUDE.md a symlink, a shim, or a fully separate file?
[ -L CLAUDE.md ] && echo "symlink → $(readlink CLAUDE.md)"
[ -f CLAUDE.md ] && [ ! -L CLAUDE.md ] && head -3 CLAUDE.md
If the project has a .claude/agents/ or .claude/skills/ directory, run agentlint to surface structural issues with agent and skill definitions:
# Only run if .claude/agents or .claude/skills exists
if [ -d .claude/agents ] || [ -d .claude/skills ]; then
npx --yes @agent-lint/cli scan --json 2>/dev/null \
|| echo "agentlint unavailable or timed out — skip"
fi
agentlint scans only the .claude/ tree — it will not discover agents or skills in plugins/ or other custom directories. Record the finding count and severity breakdown, and include any HIGH-severity findings in the inventory.
Interpreting findings before including them in Phase 5: Cross-check every finding against the Gotchas section below. Two categories are reliably false positives:
<name>, <capability>, openspec/changes/<name>/proposal.md inside skill files are intentional syntax placeholders, not broken file references.goal, preconditions, and step frontmatter. Our SKILL.md format uses name, description, disable-model-invocation, allowed-tools. These produce schema warnings that are not real errors.Genuine HIGH-severity signals to surface: missing description fields in agent frontmatter, agents with no model set, skill files with no allowed-tools constraint.
Skip this step if: .claude/agents/ and .claude/skills/ do not exist, or if npx is not available in the shell environment.
Mine the project's actual session history to find what's broken in practice.
First, locate the mine-conversations.sh script:
CURATOR_SCRIPTS="$(find ~/.claude -name 'mine-conversations.sh' \
-path '*/claudemd-curator/scripts/*' 2>/dev/null | head -1 | xargs dirname 2>/dev/null || echo '')"
If $CURATOR_SCRIPTS is non-empty, run:
TRANSCRIPT_DIR="$("$CURATOR_SCRIPTS/mine-conversations.sh" -n 15)"
The script handles the path conversion (slashes → dashes) and the JSONL parsing. It writes transcripts to a temp directory and prints the path on stdout.
If $CURATOR_SCRIPTS is empty (scripts not installed on the Claude Code path), do the transcript extraction inline:
~/.claude/projects/ directory corresponding to the current project path.jq directly to parse the .jsonl files into USER: / ASSISTANT: text.For each batch of transcripts, spawn a Sonnet subagent with this exact prompt template:
Read three things, in order:
1. Global CLAUDE.md: ~/.claude/CLAUDE.md (if it exists)
2. Project CLAUDE.md and AGENTS.md (if they exist)
3. Conversation transcripts: <list of files>
Then, against BOTH instruction files, identify:
1. INSTRUCTIONS VIOLATED — existing rules the agent broke. Quote the rule and the violation.
2. CANDIDATE ADDITIONS — LOCAL — patterns the project repeatedly needed that aren't in the project file.
3. CANDIDATE ADDITIONS — GLOBAL — patterns that recurred and apply across all the user's projects.
4. POTENTIALLY OUTDATED — rules that don't seem to apply anymore, were never followed, or contradict newer patterns.
For each finding, cite at least one transcript and one quote. Bullet points only. No preamble.
Batch by file size: large transcripts (>100KB) one or two per agent, medium (10–100KB) three to five, small (<10KB) up to ten. If the user has fewer than five transcripts in ~/.claude/projects/, do the analysis inline without subagents.
For every line currently in CLAUDE.md, assign a layer (L0–L4) or mark for removal. Apply these tests in order — first failure wins:
grep or ls calls? ("This is a TypeScript project", "We use Vite") → Remove..claude/rules/<scope>.md with paths: frontmatter for lazy loading, or docs/agent-guides/<topic>.md referenced from L3.references/karpathy-block.md.@docs/agent-guides/migrations.md or Read .claude/rules/api-conventions.md when touching src/api/? → Convert to pointer.Anything that fails all eight tests is bloat.
Full layer definitions, templates, and a worked 280→65 line refactor example are in references/layer-model.md. Anti-patterns with rationale are in references/anti-patterns.md.
After the layer classification pass, score each CLAUDE.md file against six quality dimensions. This is the official Anthropic quality rubric from the claude-md-management plugin (Isabella He, Anthropic). Full scoring detail is in references/quality-criteria.md.
| Criterion | Points | What to check |
|---|---|---|
| Commands/workflows | /20 | Are build, test, lint, deploy commands present and correct? |
| Architecture clarity | /20 | Key directories explained? Entry points identified? Module relationships clear? |
| Non-obvious patterns | /15 | Gotchas, quirks, workarounds, "why we do it this way" for unusual patterns |
| Conciseness | /15 | No filler, no restating obvious code, no redundancy with code comments |
| Currency | /15 | Commands work as documented? File references exist? Tech stack current? |
| Actionability | /15 | Instructions executable and copy-paste ready? Paths are real? |
Grade thresholds: A (90–100) · B (70–89) · C (50–69) · D (30–49) · F (0–29)
Red flags to check explicitly:
TODO items that were never completedInclude the score and grade in the Phase 5 proposal header for each file audited. For files scoring C or below, the proposal must include concrete additions drawn from references/templates.md.
Locate the sync-agents-md.sh script:
CURATOR_SCRIPTS="$(find ~/.claude -name 'sync-agents-md.sh' \
-path '*/claudemd-curator/scripts/*' 2>/dev/null | head -1 | xargs dirname 2>/dev/null || echo '')"
If found, run:
"$CURATOR_SCRIPTS/sync-agents-md.sh" check
If not found, perform equivalent checks inline using ls -la, readlink, and head.
The script reports four states:
OK_SYMLINK — CLAUDE.md → AGENTS.md, no drift possible.OK_SHIM — CLAUDE.md is a small file beginning with See @AGENTS.md. Inspect for drift in the Claude-specific section.DUAL — both files exist as full content. Drift risk. Diff them and propose one of: convert CLAUDE.md to symlink, convert to shim, or merge.CLAUDE_ONLY / AGENTS_ONLY — only one exists. Propose creating the other (or the symlink) per the chosen pattern.Before assembling the proposal, validate every proposed addition against this checklist (from references/update-guidelines.md). Any addition that fails a check should be dropped or reworded:
Produce a single artefact: a side-by-side proposal showing current → proposed CLAUDE.md and current → proposed AGENTS.md, plus a numbered list of behavioural-audit findings with the user's accept/reject decision required for each. Wait for explicit approval before editing files.
Format the proposal as:
## Proposed changes
### Quality scores
- CLAUDE.md: XX/100 (Grade: X) — <one-line summary of main weakness>
- AGENTS.md: XX/100 (Grade: X) — <one-line summary>
### Removals (N)
- [path:line] <content> — reason: <linter | inferable | not universal | bloat>
### Layer reassignments (N)
- L? → L? — <content>
### Behavioural-audit findings (N from M sessions)
- [VIOLATED] <rule> — observed N times — proposed rewording: <new rule>
- [ADD-LOCAL] <pattern> — observed N times — proposed text: <new rule>
- [ADD-GLOBAL] <pattern> — observed N times across <N> projects — proposed text: <new rule>
- [DEAD] <rule> — never followed; observed bypassed N times — propose remove
### Sync action
- <one of: NO_CHANGE | CONVERT_TO_SYMLINK | CONVERT_TO_SHIM | MERGE | CREATE_AGENTS_MD>
### Final files
- AGENTS.md: <line-count>, layers L0–L3 represented
- CLAUDE.md: <line-count>, layers L1, L2, L4 + pointer to AGENTS.md
/init-generated CLAUDE.mdUser runs /init in a Next.js + Postgres repo. Output is 280 lines. Phase 3 classification finds: 90 lines of style rules (linter test fails), 40 lines describing the package.json (inferability test fails), 60 lines of generic "best practices" (universality test fails — they apply only to specific kinds of work and belong in .claude/rules/). Final CLAUDE.md is 65 lines. Behavioural audit on three weeks of sessions finds two repeatedly-violated rules — one rewording proposed, one removed because it was never going to be followed and pretending it was a rule was the actual problem.
Repo has a 250-line CLAUDE.md and a 180-line AGENTS.md. Phase 4 reports DUAL with substantial drift. Phase 5 proposal: AGENTS.md absorbs the 90% of CLAUDE.md content that is tool-agnostic (commands, architecture, conventions); CLAUDE.md becomes a 25-line shim covering Claude-specific items only (skills loaded, compact instructions, effort hint). Sister files (copilot-instructions.md, Cursor rules) symlinked to AGENTS.md.
User asks for a behavioural audit but doesn't want a full refactor. Run Phase 1 (minimal — just the two files) + Phase 2 (full transcript mining), skip Phase 3 and Phase 4, deliver only the four bullet-point sections (violated, add-local, add-global, outdated). User picks which to apply manually.
/init output as a starting point instead of a draft to delete. Most of what /init writes is inferable. Be ruthless.grep calls outperform a wall of style instructions and don't burn context every turn..claude/rules/. Path-scoped rules with paths: YAML frontmatter are lazy-loaded — they don't count against the always-on context budget. Many things that look like CLAUDE.md candidates belong here instead.~/.claude/CLAUDE.md. Global CLAUDE.md applies to every project. It's the most leveraged file the user has, and it's almost always neglected. Audit it on the same cadence as project files.docs/SCORM.md and that file moved to docs/features/scorm/overview.md, the skill will surface it as a stale path — which is correct. But path-like strings inside code fences or example blocks (e.g. openspec/changes/<name>/proposal.md) are intentional template syntax, not broken links. Read the context before flagging.todo/CLAUDE.md or .epic/CLAUDE.md from an older process now superseded by OpenSpec or a similar tool. The inventory phase will surface them; always ask before removing whether the old workflow is still in use anywhere.<name>, <capability>) treated as broken file references, and SKILL.md frontmatter (name, description, disable-model-invocation) flagged as schema violations because agentlint expects a different format (goal, preconditions, step). Filter these before surfacing findings in Phase 5. agentlint also only scans .claude/ — findings will be incomplete if agents or skills live elsewhere (e.g. in a plugins/ directory).Deeper material is in references/ — load on demand:
references/layer-model.md — Full L0–L4 definitions, templates, worked examples.references/karpathy-block.md — Canonical wording for the L1 discipline block, ready to paste.references/product-mode-block.md — Canonical wording for the L2 decision-posture block.references/anti-patterns.md — Specific things to remove, with rationale.references/quality-criteria.md — Full 100-point scoring rubric for the six quality dimensions (Anthropic/Isabella He). Load when scoring a file in Phase 3.references/templates.md — Four CLAUDE.md templates: minimal, comprehensive, package/module, monorepo root. Load when Phase 5 proposal includes structural additions for a C-or-below file.references/update-guidelines.md — What to add vs not add, diff format, and validation checklist. Load to verify proposed additions in Phase 5.Scripts in scripts/ — execute when needed:
scripts/mine-conversations.sh — Extract recent transcripts from ~/.claude/projects/. Requires jq.scripts/sync-agents-md.sh — Verify, create, or repair AGENTS.md ↔ CLAUDE.md sync.External references the skill is grounded in:
https://github.com/forrestchang/andrej-karpathy-skills/blob/main/CLAUDE.mdhttps://github.com/sohaibt/product-mode and the announcement post at https://www.masteringproducthq.com/p/what-karpathys-claudemd-misses-andhttps://skills.sh/ykdojo/claude-code-tips/review-claudemdhttps://www.humanlayer.dev/blog/writing-a-good-claude-mdhttps://www.groff.dev/blog/implementing-claude-md-agent-skillshttps://github.com/anthropics/claude-code/issues/34235references/anti-patterns.md (opens in a new tab)references/karpathy-block.md (opens in a new tab)references/layer-model.md (opens in a new tab)references/product-mode-block.md (opens in a new tab)references/quality-criteria.md (opens in a new tab)references/templates.md (opens in a new tab)references/update-guidelines.md (opens in a new tab)scripts/mine-conversations.sh (opens in a new tab)scripts/sync-agents-md.sh (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub simon-potter/spwf --plugin spwf38 skills in this plugin
/address-reviewPhase 6.5 — Address Review. Turn review feedback into action. Sources feedback from either a local report file (e.g. {branch}-review.md from /spwf:pr-review or {branch}-self-review.md from /spwf:simplify) or fetched human comments on an open PR/MR. For each item runs READ → VERIFY → EVALUATE → implement-or-push-back, in priority order (blocking → important → nit). Forbids performative agreement ("you're absolutely right"). Use after pr-review, or whenever a reviewer leaves comments./agent-optimiseCross-cutting — Audit both the project .claude/ and personal ~/.claude/ for quality issues. Covers CLAUDE.md scope and length, agent descriptions, skill frontmatter, and settings.json conflicts. Always audits both scopes. Produces a prioritised P1/P2/P3 fix list./approve-planPhase 2 — Approve plan. Reviews the task list from spec for quality (atomicity, testability, clarity), then applies four adversarial lenses (Skeptic, Architect, Minimalist, Security) as advisory input for the human reviewer. Quality issues are blocking; adversarial findings are advisory. Security lens identifies tasks touching auth, billing, user input, or secrets so the builder has explicit awareness before writing those tasks. Presents everything for explicit human go/no-go before building starts./branch-rescueRecovery skill — moves commits that landed on the base branch onto a proper feature branch and resets local base, without touching origin. Resolves the active OpenSpec change, detects the pre-spec base commit (subject-line grep with manual-confirm fallback), performs three local-only safe git operations, and surfaces the force-push command for the user to run manually. Run standalone; pr-create's rescue offer runs the same procedure inline (_shared/branch-management.md §4), because this skill is user-only./briefPhase 1.5 — Explain a planned change before it is built. Runs between spec and approve-plan, so a mismatch costs a conversation rather than a change. Five sections, expanding then summarising — what will be built, why this way, the choices you didn't make, what it touches, and a short summary. Never blocks: it prints, offers one skippable prompt, and returns. Calibrated via .spwf/learner.md. Companion to recap and understand, which teach after the fact; this teaches before. Runs on changes, not bug fixes./buildPhase 3 orchestrator — Full Red-Green-Refactor cycle. For each pending task: invokes write-tests (Red: write failing tests), then opsx:apply (Green: implement via OpenSpec), then run-tests (Verify: confirm green before moving on). Loops until all tasks complete. After all tasks complete, runs opsx:verify (spec sign-off), then recommends simplify (Refactor).