Claude-skill-registry claude-code-md-maintainer
Validate/update/create CLAUDE.md memory files with progressive disclosure and context-optimized structure
git clone https://github.com/majiayu000/claude-skill-registry
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/claude-code-md-maintainer" ~/.claude/skills/majiayu000-claude-skill-registry-claude-code-md-maintainer && rm -rf "$T"
skills/data/claude-code-md-maintainer/SKILL.mdCLAUDE.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)
-
Discover existing memory files:
or./CLAUDE.md./.claude/CLAUDE.md./CLAUDE.local.md- Nested
**/CLAUDE.md .claude/rules/**/*.md
-
Validate each against invariants (see
)docs/invariants.md -
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
-
Identify module roots (see
)docs/directory-heuristics.md -
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:
- Update existing files
- Create missing files from templates
- Report final state
Init Algorithm
For
/bluera-base:claude-code-md init - creates new CLAUDE.md from scratch.
Detection Priority
Check files in order (stop at first match):
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:
jq -r '.scripts | keys[]' package.json 2>/dev/null | head -10
Python (pyproject.toml):
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
includes/CLAUDE-BASE.md --- ## Package Manager **Use `{PM}`** - All scripts: `{PM} run <script>` --- ## Scripts {SCRIPTS - grouped by category if many} --- ## CI/CD {Only if .github/workflows/ or .gitlab-ci.yml exists} ---
Design Principles
- Auto-detect over ask - Only interview when ambiguous
- < 60 lines target - Start lean, user expands later
- Never overwrite - Check for existing CLAUDE.md first
- @include always - Start with CLAUDE-BASE.md reference
Learn Algorithm
For
/bluera-base:claude-code-md learn - adds learnings to marker-delimited regions.
Marker Format
## Auto-Learned (bluera-base) <!-- AUTO:bluera-base:learned --> - Learning 1 - Learning 2 <!-- END:bluera-base:learned -->
Algorithm Steps
-
Determine target file:
- Default:
(personal, gitignored)CLAUDE.local.md - With
:--shared
(team-shared)CLAUDE.md
- Default:
-
Read target file (or create if missing)
-
Find markers:
- Start:
<!-- AUTO:bluera-base:learned --> - End:
<!-- END:bluera-base:learned -->
- Start:
-
If markers missing: Insert at end of file:
--- ## Auto-Learned (bluera-base) <!-- AUTO:bluera-base:learned --> <!-- END:bluera-base:learned --> -
Parse existing learnings between markers into list
-
Dedupe check:
- Normalize: trim whitespace, lowercase
- If learning already exists (fuzzy match), skip with message
-
Secrets check (CRITICAL):
- Regex:
api[_-]?key|token|password|secret|-----BEGIN|AWS_|GITHUB_TOKEN|ANTHROPIC_API - If match: REJECT with warning, do NOT write
- Regex:
-
Hard cap check:
- Max 50 lines in auto-managed section
- If exceeded: warn user, suggest pruning old learnings
-
Insert learning as new bullet point
-
Write file using Edit tool (replace marker region only)
Secrets Denylist
api[_-]?key token password secret -----BEGIN AWS_ GITHUB_TOKEN ANTHROPIC_API_KEY OPENAI_API_KEY private[_-]?key credential
Example Implementation
# Pseudo-code for the Edit operation OLD_CONTENT="<!-- AUTO:bluera-base:learned --> - Old learning 1 <!-- END:bluera-base:learned -->" NEW_CONTENT="<!-- AUTO:bluera-base:learned --> - Old learning 1 - New learning here <!-- END:bluera-base:learned -->"
User Control Modes
Control auto-learning behavior via
/bluera-base:config command:
/bluera-base:config enable auto-learn # Opt-in to learning observation /bluera-base:config set .autoLearn.mode auto # Change mode
Configuration stored in
.bluera/bluera-base/config.json:
{ "autoLearn": { "enabled": false, // opt-in by default "mode": "suggest", // suggest | auto "threshold": 3, // occurrences before suggesting "target": "local" // local | shared } }
| Mode | Behavior |
|---|---|
| Show learning suggestions at session end |
| Automatically add learnings to marker regions |
Session signals are tracked in
.bluera/bluera-base/state/session-signals.json (ephemeral, gitignored).
Commands with ≥threshold occurrences trigger learning suggestions.
References
-
Audit Templates:
${CLAUDE_PLUGIN_ROOT}/skills/claude-code-md-maintainer/templates/
- Root project memoryroot_CLAUDE.md
- Directory-scoped memorymodule_CLAUDE.md
- Personal noteslocal_CLAUDE.local.md
-
Init Templates:
${CLAUDE_PLUGIN_ROOT}/skills/claude-code-md-maintainer/templates/init/
- JavaScript/TypeScript projectsjs-ts.md
- Python projectspython.md
- Rust projectsrust.md
- Go projectsgo.md
- GitHub Actions CI sectionci-github.md
- GitLab CI sectionci-gitlab.md
-
Validation rules:
${CLAUDE_PLUGIN_ROOT}/skills/claude-code-md-maintainer/docs/invariants.md -
Directory detection:
${CLAUDE_PLUGIN_ROOT}/skills/claude-code-md-maintainer/docs/directory-heuristics.md -
Reliability guidance:
${CLAUDE_PLUGIN_ROOT}/skills/claude-code-md-maintainer/docs/reliability.md -
Scope decision guide:
${CLAUDE_PLUGIN_ROOT}/skills/claude-code-md-maintainer/docs/scope-guide.md
Key Rules
- Never duplicate - Module CLAUDE.md should not repeat root rules
- Prefer rules files - Move topic-specific rules to
.claude/rules/<topic>.md - Use paths: scoping - Rules files can use
frontmatterpaths: - Hard cap - If > 25 modules, summarize at bucket level, defer individuals
Output Format
Report these sections:
- Memory files found
- Files to create
- Files to update (with diff summary)
- Rules files to create/update
- Verbosity report (if issues detected)
- Follow-ups (ambiguous items)
Verbosity Report
When line count exceeds targets or verbose patterns detected, include:
Line Count:
- CLAUDE.md: 142 lines (target: < 60, hard limit: < 300)
Verbose Patterns Detected:
| Lines | Issue | Suggestion |
|---|---|---|
| 45-60 | Tool explanation (npm) | Remove - Claude knows npm |
| 80-95 | Command output example | Remove or move to agent_docs/ |
| 110-125 | File enumeration | Summarize as "src/ - application code" |