agentleFS
Data-WiseData-Wise/craft/skills/docs/claude-md/SKILL.md

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.

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
  1. Distinctive:

    Create a new CLAUDE.md from a project-type template (lean, < 150 lines, pointer architecture).

    line 32
  2. Very specific:

    Refusal: if file exists and --force not set, redirect to sync.

    line 44
  3. Very specific:

    All three phases accept --global / -g:

    line 114
  4. Distinctive:

    Use global for cross-project rules (workflow, git, safety).

    line 123

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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

SituationUse Instead
Applying suggestions from /insights report to global CLAUDE.mdinsights-apply skill
Classifying which doc types a feature needsdoc-classifier skill
Generating release notes / CHANGELOGchangelog-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).

StepAction
1Detect project type: plugin (.claude-plugin/plugin.json), teaching (_quarto.yml + course.yml), r-package (DESCRIPTION)
2Scan metadata: version, counts (commands/skills/agents), test count, repo URL, git branch
3Populate lean template with discovered values
4Show preview with line count vs budget
5Create 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.

PhaseWhatTrigger
DetectProject type, version sourcealways
Update MetricsVersion, counts, tests, docs%always
Audit5 checks + anti-pattern + budgetalways
FixAuto-fix fixable issues--fix
OptimizeEnforce budget, move bloat to detail files--optimize

Anti-patterns blocked (refuse to add to CLAUDE.md):

PatternRedirect 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.

StepAction
1Parse sections (H2 headers + horizontal rules)
2Display section table with line ranges
3User picks section (or all)
4Insert <!-- TODO: ... --> hints (unless --no-hints)
5Open in editor (default ia, also code / sublime / cursor)
6Wait for user to say "done"
7Re-read, strip TODO comments
8Run post-edit audit (unless --no-validate)
9Show 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

UtilityRole
utils/claude_md_detector.pyProject type detection
utils/claude_md_template_populator.pyLean template variable substitution
utils/claude_md_sync.py4-phase sync pipeline (also called by insights-apply)
utils/claude_md_optimizer.pyBudget enforcement + bloat detection
templates/claude-md/*.mdLean 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` skill

Error Recovery

ErrorRecovery
CLAUDE.md not found (sync/edit)Suggest Init
Project type unknown (init)Offer generic template or --type <name>
Over budget after edit/syncOffer --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 submittedBlock, redirect to detail file

See Also

  • insights-apply — apply /insights report suggestions to global CLAUDE.md (specific source)
  • doc-classifier — decide what doc types a feature needs (sibling in skills/docs/)
  • changelog-automation — release notes / CHANGELOG generation (sibling)
  • /craft:check — invokes sync internally as part of pre-commit validation

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.