--- name: claude-md-maintainer description: Validate/update/create CLAUDE.md memory files with progressive disclosure and context-optimized structure user-invocable: false allowed-tools: Read, Write, Edit, Glob, Grep, Bash(find:*), Bash(git:*), Bash(ls:*), Bash(wc:*), Bash(head:*), Bash(tail:*) --- # CLAUDE.md Maintainer Audit and maintain `CLAUDE.md` files across any repository. Ensures they function as Claude Code memory (not user documentation). ## Core Principle `CLAUDE.md` is **Claude's memory**, not a README. Every line loads into context, so keep it lean and actionable. ## Algorithm ### Phase 1: Plan (read-only) 1. **Discover** existing memory files: - `./CLAUDE.md` or `./.claude/CLAUDE.md` - `./CLAUDE.local.md` - Nested `**/CLAUDE.md` - `.claude/rules/**/*.md` 2. **Validate** each against invariants (see `docs/invariants.md`) 3. **Audit verbosity**: - Count total lines (warn if > 300, suggest if > 60) - Detect verbose patterns (see `docs/verbose-patterns.md`) - Flag linter-duplicating instructions - Identify content that should move to agent_docs/ - Report actionable findings with line numbers 4. **Identify** module roots (see `docs/directory-heuristics.md`) 5. **Output** proposed changes: - Files to update (with change summary) - Files to create - Ambiguous cases requiring human decision ### Phase 2: Apply (with confirmation) Only after user confirms: 1. Update existing files 2. Create missing files from templates 3. Report final state --- ## Init Algorithm For `/bluera-base:claude-md init` - creates new CLAUDE.md from scratch. ### Detection Priority Check files in order (stop at first match): ```text package.json → JavaScript/TypeScript Cargo.toml → Rust pyproject.toml → Python go.mod → Go ``` ### Lockfile → Package Manager | Lockfile | Manager | |----------|---------| | bun.lock / bun.lockb | bun | | yarn.lock | yarn | | pnpm-lock.yaml | pnpm | | package-lock.json | npm | | poetry.lock | poetry | | uv.lock | uv | | (none) | ask user | ### Script Extraction **JavaScript/TypeScript:** ```bash jq -r '.scripts | keys[]' package.json 2>/dev/null | head -10 ``` **Python (pyproject.toml):** ```bash grep -A 20 '^\[project.scripts\]' pyproject.toml | grep '=' | cut -d'=' -f1 | tr -d ' "' ``` **Rust/Go:** Use standard commands (cargo build/test, go build/test). ### Generated Structure ```markdown @bluera-base/includes/CLAUDE-BASE.md --- ## Package Manager **Use `{PM}`** - All scripts: `{PM} run