claude-md-init
Installation
SKILL.md
[IMPORTANT] Use
TaskCreateto break ALL work into small tasks BEFORE starting — including tasks for each file read. This prevents context loss from long files. For simple tasks, AI MUST ask user whether to skip.
Quick Summary
Goal: Automate CLAUDE.md lifecycle — generate from project-config.json + template, incrementally update marked sections, or refactor for token efficiency.
Workflow:
- Detect Mode — init (no CLAUDE.md or
--mode init), update (--mode update), refactor (--mode refactor) - Run Generator —
node .claude/skills/claude-md-init/scripts/generate-claude-md.cjs --mode <mode> - AI Fill — Review output, fill creative sections (project description, golden rules inference)
- Verify — Confirm output is valid, no project-specific leaks from template
Key Rules:
- Generic — works in any project by reading
docs/project-config.json - Section markers (
<!-- SECTION:key -->) enable incremental updates without overwriting user content - Conditional sections — generated ONLY when config has matching data; empty config = section omitted
- Static framework sections (8 total) are portable across all projects
Modes
| Mode | When | Behavior |
|---|---|---|
init |
No CLAUDE.md exists, or first-time setup | Generate fresh CLAUDE.md from template + config. Populates all markers. |
update |
CLAUDE.md exists with markers | Replace only content between markers. Preserve everything else. |
refactor |
CLAUDE.md exists, needs optimization | AI reads entire CLAUDE.md, optimizes for token efficiency, removes redundancy, improves structure. No script — pure AI. |
Prerequisites
docs/project-config.json— primary data source (run/project-configfirst if missing)- Node.js available (for generator script)
Phase 1: Detect Mode
# Check CLAUDE.md state
node .claude/skills/claude-md-init/scripts/generate-claude-md.cjs --detect
Decision logic:
- No CLAUDE.md →
init - CLAUDE.md with markers →
update - CLAUDE.md without markers →
smart-merge(see below) - User explicit
--modeflag → override detection
Phase 2: Run Generator Script
# Init mode: generate fresh CLAUDE.md
node .claude/skills/claude-md-init/scripts/generate-claude-md.cjs --mode init
# Update mode: sync marked sections only
node .claude/skills/claude-md-init/scripts/generate-claude-md.cjs --mode update
Script behavior:
- Reads
docs/project-config.json - Reads template (
references/claude-md-template.md) for init, or existing CLAUDE.md for update - Calls section builders to generate content for each marker key
- Writes output to
CLAUDE.md(creates backup.claude-md.backupfirst) - Outputs report: which sections were generated, which skipped (no data), which preserved
Smart-Merge (Update on CLAUDE.md Without Markers)
When running update on an existing CLAUDE.md that has NO section markers:
- Read existing CLAUDE.md
- Match sections by
##heading text against known section keys (seereferences/section-registry.md) - For each matched section: wrap with markers, replace content with generated content
- For unmatched user sections: preserve as-is (no markers added)
- Write output with backup
Phase 3: AI Fill (Post-Script)
After the script generates the mechanical parts, AI reviews and fills:
- Project description in TL;DR — write a concise 2-3 sentence description based on config + codebase
- Golden rules — infer from
contextGroups[].rulesin config, but rewrite as human-readable rules - Decision quick-ref — build from
modules[]+frameworkconfig, add project-specific patterns - Naming conventions — detect from codebase patterns if not in config
Phase 4: Verify
- CLAUDE.md is valid markdown
- All section markers are properly paired (open + close)
- No template placeholder text remains (e.g.,
{project-name},TODO) - No
.claude/skills/claude-md-init/references leak into output (self-reference) - Conditional sections with no data are omitted (not empty stubs)
Refactor Mode (AI-Only)
When --mode refactor or user asks to optimize CLAUDE.md:
- Read entire CLAUDE.md
- Identify: redundant sections, verbose explanations, duplicate info available in referenced docs
- Apply token efficiency: remove duplication, consolidate tables, shorten where possible
- Preserve all section markers
- Report: lines before/after, sections changed, estimated token savings
Section Marker Protocol
<!-- SECTION:tldr -->
Auto-generated content here...
<!-- /SECTION:tldr -->
Rules:
- Only content between markers is replaced on update
- Content outside markers is never touched
- Missing markers in update mode → section skipped (not inserted)
- Init mode uses template which includes all markers
- Markers use lowercase kebab-case keys matching section-registry.md
Section Keys (Quick Reference)
See references/section-registry.md for full mapping. Summary:
| Key | Source | Conditional? |
|---|---|---|
tldr |
project.*, modules[], framework.* |
No — always generated |
golden-rules |
contextGroups[].rules |
Yes — skip if no rules |
decision-quick-ref |
modules[], framework.* |
Yes — skip if no modules |
key-locations |
modules[].pathRegex |
Yes — skip if no modules |
dev-commands |
testing.commands, infrastructure.* |
Yes — skip if no commands |
infra-ports |
modules[].meta.port (infra) |
Yes — skip if no ports |
api-ports |
modules[].meta.port (services) |
Yes — skip if no ports |
integration-testing |
framework.integrationTestDoc |
Yes — skip if no doc |
e2e-testing |
framework.e2eTestDoc or scan |
Yes — skip if no tests |
doc-index |
Scan docs/ directory |
Yes — skip if no docs/ |
doc-lookup |
modules[] + business features |
Yes — skip if no modules |
Running Tests
node .claude/skills/claude-md-init/scripts/test-generate-claude-md.cjs
Weekly Installs
2
Repository
duc01226/easyplatformGitHub Stars
6
First Seen
12 days ago
Security Audits
Installed on
amp2
cline2
opencode2
cursor2
kimi-cli2
warp2