claude-md-lifecycle
Skill4 starsChanged 12 days agoMITView on GitHub
This skill should be used when the user asks to "create CLAUDE.md", "scaffold CLAUDE.md", "sync CLAUDE.md", "update CLAUDE.md", "audit CLAUDE.md", "fix CLAUDE.md", "optimize CLAUDE.md", "edit CLAUDE.md sections", or otherwise wants to manage the CLAUDE.md lifecycle (init, sync, edit). Covers project-local and global (`~/.claude/CLAUDE.md`) files. For applying suggestions from the /insights report specifically, use the `insights-apply` skill instead.
In this repository42 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- system-architectSkill
- project-detectorSkill
- audit-routerSkill
- command-skill-token-efficiencySkill
- plugin-auditSkill
- sync-featuresSkill
- backend-designerSkill
- devops-helperSkill
- frontend-designerSkill
- git-workflowSkill
- dist-extrasSkill
- distribution-strategistSkill
- homebrew-formula-expertSkill
- homebrew-multi-formulaSkill
- homebrew-setup-wizardSkill
- homebrew-workflow-expertSkill
- architecture-decision-recordsSkill
- changelog-automationSkill
- guard-auditSkill
- hooksSkill
- insights-applySkill
- mode-controllerSkill
- drive-engineSkill
- plan-orchestratorSkill
- repo-triageSkill
- session-stateSkill
- task-analyzerSkill
- workflow-engineSkill
- orchestrator-resilienceSkill
- project-plannerSkill
- preflight-checkSkill
- releaseSkill
- test-generatorSkill
- test-strategistSkill
- adhd-workflowSkill
- brainstorm-insightsSkill
- brainstormSkill
- grillSkill
- prompt-refinerSkill
- background-task-managerSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 2 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 32
Create a new CLAUDE.md from a project-type template (lean, < 150 lines, pointer architecture).
- Very specific: line 44
Refusal: if file exists and --force not set, redirect to sync.
- Very specific: line 114
All three phases accept --global / -g:
- Distinctive: line 123
Use global for cross-project rules (workflow, git, safety).
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md Lifecycle
End-to-end management of CLAUDE.md files: scaffold from project-type templates, sync with project state (audit + fix + optimize), and edit sections interactively. Targets both project-local CLAUDE.md and global ~/.claude/CLAUDE.md.
When to Use
- User asks to create a CLAUDE.md from scratch (new project, missing file)
- User asks to sync / update / audit / fix / optimize an existing CLAUDE.md
- User asks to edit a specific section with preview and validation
- File is over the 150-line budget and needs trimming via pointer architecture
- Version/count drift detected between CLAUDE.md and project sources (
plugin.json,DESCRIPTION, etc.)
When NOT to Use
| Situation | Use Instead |
Applying suggestions from /insights report to global CLAUDE.md | insights-apply skill |
| Classifying which doc types a feature needs | doc-classifier skill |
| Generating release notes / CHANGELOG | changelog-automation skill |
The boundary with insights-apply: that skill is the rule-applier for one specific source (the /insights report → global CLAUDE.md). This skill is the editor for the full lifecycle (init/sync/edit) of any CLAUDE.md. They share the underlying sync pipeline (utils/claude_md_sync.py) but enter it from different intents.
Three Phases
Phase 1: Init (scaffold)
Create a new CLAUDE.md from a project-type template (lean, < 150 lines, pointer architecture).
| Step | Action |
| 1 | Detect project type: plugin (.claude-plugin/plugin.json), teaching (_quarto.yml + course.yml), r-package (DESCRIPTION) |
| 2 | Scan metadata: version, counts (commands/skills/agents), test count, repo URL, git branch |
| 3 | Populate lean template with discovered values |
| 4 | Show preview with line count vs budget |
| 5 | Create file after confirmation; run post-creation audit |
Flags: --type, --force (overwrite), --dry-run, --global (target ~/.claude/CLAUDE.md)
Refusal: if file exists and --force not set, redirect to sync.
Phase 2: Sync (update + audit + fix + optimize)
Four-phase pipeline against an existing CLAUDE.md.
| Phase | What | Trigger |
| Detect | Project type, version source | always |
| Update Metrics | Version, counts, tests, docs% | always |
| Audit | 5 checks + anti-pattern + budget | always |
| Fix | Auto-fix fixable issues | --fix |
| Optimize | Enforce budget, move bloat to detail files | --optimize |
Anti-patterns blocked (refuse to add to CLAUDE.md):
| Pattern | Redirect To |
Release notes (### v\d+) | docs/VERSION-HISTORY.md |
Diffstats (Files Changed) | delete |
| "What Shipped" / "Merged PR" | docs/VERSION-HISTORY.md |
"Status: Complete" / Released ✅ | docs/VERSION-HISTORY.md |
Phase details (### Phase N) | detail file |
Budget resolution order: .claude-plugin/config.json → package.json claudeMd.budget → default 150. Never store in plugin.json (strict schema rejects it).
Sections: --section status|commands|testing|all (default all).
Phase 3: Edit (interactive section editing)
Open one or more sections in an external editor with TODO hints, validate after.
| Step | Action |
| 1 | Parse sections (H2 headers + horizontal rules) |
| 2 | Display section table with line ranges |
| 3 | User picks section (or all) |
| 4 | Insert <!-- TODO: ... --> hints (unless --no-hints) |
| 5 | Open in editor (default ia, also code / sublime / cursor) |
| 6 | Wait for user to say "done" |
| 7 | Re-read, strip TODO comments |
| 8 | Run post-edit audit (unless --no-validate) |
| 9 | Show diff preview before applying |
iA Writer integration (default): open via AppleScript
osascript -e 'tell application "iA Writer"
activate
open POSIX file "/path/to/CLAUDE.md"
end tell'Pointer Architecture
The 150-line budget is enforced by pointing out of CLAUDE.md rather than inlining detail:
## References
-> Release history: [VERSION-HISTORY.md](docs/VERSION-HISTORY.md)
-> Architecture: [ARCHITECTURE.md](docs/ARCHITECTURE.md)
-> Contributing: [CONTRIBUTING.md](CONTRIBUTING.md)
-> Command reference: [COMMANDS.md](docs/COMMANDS.md)Claude Code follows markdown links naturally — keep CLAUDE.md as an index, not an encyclopedia.
Global vs Project Targeting
All three phases accept --global / -g:
if "--global" in args or "-g" in args:
target = Path.home() / ".claude" / "CLAUDE.md"
else:
target = Path.cwd() / "CLAUDE.md"Use global for cross-project rules (workflow, git, safety); use project-local for project-specific commands and structure.
Underlying Utilities
| Utility | Role |
utils/claude_md_detector.py | Project type detection |
utils/claude_md_template_populator.py | Lean template variable substitution |
utils/claude_md_sync.py | 4-phase sync pipeline (also called by insights-apply) |
utils/claude_md_optimizer.py | Budget enforcement + bloat detection |
templates/claude-md/*.md | Lean templates per project type |
Decision Flow
User intent ─┐
├─► file missing? → Init (Phase 1)
├─► drift / audit needed?→ Sync (Phase 2)
├─► specific section? → Edit (Phase 3)
└─► /insights source? → use `insights-apply` skillError Recovery
| Error | Recovery |
| CLAUDE.md not found (sync/edit) | Suggest Init |
| Project type unknown (init) | Offer generic template or --type <name> |
| Over budget after edit/sync | Offer --optimize or manual edit |
| Section not found (edit) | Show available sections + fuzzy suggestion |
| Editor not installed (edit) | List available editors, prompt to pick |
| Anti-pattern submitted | Block, redirect to detail file |
See Also
insights-apply— apply/insightsreport suggestions to global CLAUDE.md (specific source)doc-classifier— decide what doc types a feature needs (sibling inskills/docs/)changelog-automation— release notes / CHANGELOG generation (sibling)/craft:check— invokes sync internally as part of pre-commit validation
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

