agentleFS
thettwethettwe/nyann/skills/optimize-claudemd/SKILL.md

optimize-claudemd

Skill6 starsChanged 3 months agoMITView on GitHub

Optimize CLAUDE.md based on actual usage patterns. TRIGGER ON: 'optimize CLAUDE.md', 'improve CLAUDE.md', 'make CLAUDE.md better', 'trim CLAUDE.md', 'what is unused in CLAUDE.md', 'CLAUDE.md is too big', 'shrink CLAUDE.md', 'which docs are never read', 'CLAUDE.md usage', 'optimize context'. Analyzes which sections, docs, and commands Claude actually uses and recommends removals, compressions, and additions.

The file

We split this skill into the rules it gives an agent

9 rules. About 0 are common, 4 are distinctive, and 5 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    After significant project evolution (new features, removed docs)

    line 15
  2. Very specific:

    If tracking is not enabled, offer to enable it: create memory/claudemd-usage.json with the empty template, then explain that data will …

    line 26
  3. Very specific:

    Run bin/analyze-claudemd-usage.sh --target .

    line 32
  4. Very specific:

    Check sufficient_data — if false, explain how many more sessions are needed and offer --force.

    line 33
  5. Distinctive:

    Ask which recommendations to apply (all, specific ones, or none).

    line 51
  6. Very specific:

    Run bin/optimize-claudemd.sh --target .

    line 52
  7. Distinctive:

    If tracking was just enabled, explain that optimization will improve with more usage data.

    line 60
  8. Very specific:

    Only modifies content within <!-- nyann:start --> / <!-- nyann:end --> markers

    line 64
  9. Distinctive:

    Never removes sections without showing the user what will be removed

    line 67

≈ “Common” is an estimate: at least 1 in 5 of the 213,895 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

optimize-claudemd — Optimize CLAUDE.md Based on Usage

You are the optimize-claudemd skill. You analyze how Claude actually uses the CLAUDE.md file — which sections are referenced, which docs are read, which commands are run — and recommend optimizations to maximize the value of every byte.

When to trigger

  • User asks to optimize, improve, trim, or shrink CLAUDE.md
  • User asks what's unused or which docs are never read
  • User says CLAUDE.md is too big or wants to improve context quality
  • After significant project evolution (new features, removed docs)
  • Health score shows CLAUDE.md-related deductions

DO NOT trigger on: general CLAUDE.md questions (use explain-state), initial CLAUDE.md generation (use bootstrap), or manual CLAUDE.md editing.

Prerequisites

  • Usage tracking must be enabled (memory/claudemd-usage.json must exist)
  • At least 10 sessions of tracked data (override with --force)
  • CLAUDE.md must have nyann markers (<!-- nyann:start --> / <!-- nyann:end -->)

If tracking is not enabled, offer to enable it: create memory/claudemd-usage.json with the empty template, then explain that data will accumulate over future sessions.

Execution flow

Phase 1: Analyze usage

  1. Run bin/analyze-claudemd-usage.sh --target . to get the usage analysis.
  2. Check sufficient_data — if false, explain how many more sessions are needed and offer --force.

Phase 2: Present findings

  1. Show the analysis summary:
    • Total sessions tracked
    • Section-by-section density table (section, bytes, references, density, verdict)
    • Unused docs (referenced in CLAUDE.md but never read by Claude)
    • Missing commands (frequently run but not documented)
    • Budget usage (bytes used / remaining)
  2. For each recommendation, explain:
    • What to change (remove, compress, or add)
    • Why (density score, usage count)
    • Estimated byte savings

Phase 3: Apply optimizations

  1. Ask which recommendations to apply (all, specific ones, or none).
  2. Run bin/optimize-claudemd.sh --target . --profile <path> --dry-run to preview.
  3. Show the before/after diff.
  4. On confirmation, run without --dry-run.
  5. Report total bytes saved and new budget status.

Phase 4: Next steps

  1. Suggest running /nyann:doctor to see the health score impact.
  2. If tracking was just enabled, explain that optimization will improve with more usage data.

Key constraints

  • Only modifies content within <!-- nyann:start --> / <!-- nyann:end --> markers
  • Preserves all user content outside markers
  • Respects 3KB soft budget and 8KB hard cap
  • Never removes sections without showing the user what will be removed
  • Compression is advisory — the skill shows what could be shortened but the actual rewrite is done by the LLM, not the bash script

When to hand off

  • "Regenerate CLAUDE.md from scratch" → gen-claudemd skill (full regeneration from profile + stack, not usage-driven pruning).
  • "Check repo health" → doctor skill.
  • "What does nyann see here?" → explain-state skill.

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.