agentleFS
yht-4403yht-4403/jc-agent-skills/claude-md-optimizer/SKILL.md

claude-md-optimizer

Skill1 starsChanged 15 days agoMITView on GitHub

Optimize oversized CLAUDE.md files using progressive disclosure. Analyzes content tiers, detects encryption constraints, creates sub-documents, and rewrites the main file with a Sub-Documentation Table. Triggers: optimize CLAUDE.md, reduce CLAUDE.md size, CLAUDE.md too long, apply progressive disclosure to CLAUDE.md

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

Show its rules and text

We split this skill into the rules it gives an agent

14 rules. About 0 are common, 11 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈11

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Read CLAUDE.md and count total lines

    line 17
  2. Very specific:

    Check .gitattributes for filter=git-crypt diff=git-crypt patterns

    line 24
  3. Distinctive:

    Wait for user approval before proceeding.

    line 39
  4. Distinctive:

    Create sub-documents in safe directory (verbatim extraction, NO summarization)

    line 49
  5. Distinctive:

    ALWAYS: keep encryption unlock instructions in main file (chicken-and-egg problem)

    line 78
  6. Distinctive:

    ALWAYS: keep security rules, test file patterns, behavioral reminders inline

    line 79
  7. Distinctive:

    ALWAYS: keep content that CI scripts parse via regex (see CI Machine-Readable Content below)

    line 81
  8. Distinctive:

    If entire project is encrypted, warn user and recommend decrypted subdirectory

    line 86
  9. Distinctive:

    Use Sub-Documentation Table pattern at top of rewritten CLAUDE.md

    line 96
  10. Very specific:

    Use kebab-case domain names: docker-guide.md, ci-reference.md, api-docs.md

    line 111
  11. Very specific:

    Avoid generic names: reference.md, docs.md

    line 113
  12. Distinctive:

    User rejects plan: Ask for feedback, iterate on categorization.

    line 161
  13. Distinctive:

    Ambiguous categorization: Default to Essential (keep inline), ask user to review.

    line 165
  14. Distinctive:

    Always read the full CLAUDE.md before categorizing (context matters)

    line 170

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

Behavioral Classification: Guided Decision (ASK, THEN EXECUTE)

This skill analyzes CLAUDE.md files and proposes optimizations using progressive disclosure patterns. It NEVER makes destructive changes without explicit user approval. Always present the plan, get confirmation, then execute.

Quick Start

Phase 1: Analyze

  1. Read CLAUDE.md and count total lines
  2. Parse into sections and categorize each:
    • Essential - Required for every session (build commands, test patterns, security rules)
    • Reference - Needed occasionally (architecture docs, API references, troubleshooting)
    • Redundant - Duplicates existing docs or overly verbose

Phase 2: Detect Constraints

  1. Check .gitattributes for filter=git-crypt diff=git-crypt patterns
  2. Identify encrypted paths (docs/, .claude/, etc.)
  3. Find safe unencrypted directory for sub-documents (prefer project root or subdirs)
  4. Scan for CI machine-readable dependencies (see constraints.md)

Phase 3: Plan

Present categorization table to user:

| Section | Lines | Category | Target | Rationale |
|---------|-------|----------|--------|-----------|
| Docker Commands | 45 | Reference | docker-guide.md | Used <10% of sessions |
| CI Health | 120 | Reference | ci-reference.md | Detailed reference rarely needed |
| Git-Crypt Setup | 30 | Essential | Keep inline | Unlock instructions (chicken-and-egg) |

Wait for user approval before proceeding.

Phase 4: Review

User confirms:

  • Categorization is correct
  • Sub-document names make sense
  • Essential content remains inline
  • Safe directory for sub-docs identified

Phase 5: Execute

  1. Create sub-documents in safe directory (verbatim extraction, NO summarization)
  2. Rewrite CLAUDE.md with Sub-Documentation Table at top
  3. Replace extracted sections with progressive disclosure links
  4. Preserve all Essential content inline

Phase 6: Validate

  1. Count lines before/after, report reduction percentage
  2. Diff all extracted content to verify zero information loss
  3. Confirm encryption constraints respected
  4. Present validation report to user

Sub-Documentation

DocumentDescription
analysis.mdContent categorization methodology and heuristics
patterns.mdProgressive disclosure patterns and templates
constraints.mdEncryption detection and safe path selection
validation.mdBefore/after diffing and information loss verification

Essential Rules

Safety First

  • ALWAYS present the plan before making changes
  • NEVER make destructive edits without explicit user approval
  • ALWAYS validate zero information loss after optimization

Content Preservation

  • NEVER summarize or paraphrase content -- verbatim extraction only
  • ALWAYS keep encryption unlock instructions in main file (chicken-and-egg problem)
  • ALWAYS keep security rules, test file patterns, behavioral reminders inline
  • NEVER move content that is consulted in >50% of sessions
  • ALWAYS keep content that CI scripts parse via regex (see CI Machine-Readable Content below)

Encryption Safety

  • Sub-documents MUST be in unencrypted directories
  • Check .gitattributes for filter=git-crypt patterns
  • If entire project is encrypted, warn user and recommend decrypted subdirectory

CI Machine-Readable Content

  • CI audit scripts may use regex to scan CLAUDE.md for specific literal strings
  • ALWAYS scan for scripts that readFileSync('CLAUDE.md') or grep CLAUDE.md
  • Common patterns: deploy commands, function lists, config references
  • Content matched by CI regex MUST remain in CLAUDE.md -- extraction breaks CI
  • See constraints.md for detection methodology

Progressive Disclosure

  • Use Sub-Documentation Table pattern at top of rewritten CLAUDE.md
  • Link to sub-docs using relative paths (e.g., [Docker Guide](./docker-guide.md))
  • Preserve section headers with brief summary + link
  • Target: >50% line reduction with zero information loss

Quick Reference

Content Tiers

TierCriteriaAction
EssentialUsed every session, unlocks workflow, defines behaviorKeep inline
ReferenceUsed occasionally, detailed specs, troubleshootingExtract to sub-doc
RedundantDuplicates existing docs, overly verbose, historicalExtract or remove

Sub-Document Naming

  • Use kebab-case domain names: docker-guide.md, ci-reference.md, api-docs.md
  • Group related content: troubleshooting/native-modules.md
  • Avoid generic names: reference.md, docs.md

Progressive Disclosure Patterns

  1. Sub-Documentation Table - Links to extracted domains (use at top of CLAUDE.md)
  2. Quick-Reference+Link - Inline summary with "See X for details" link
  3. Compressed Table+Link - Condensed table with full version in sub-doc
  4. Summary+Link - Brief paragraph + link to comprehensive guide

Target Metrics

  • Line reduction: >50% from original
  • Information loss: 0% (verified via diff)
  • Essential content: Remains inline
  • Session impact: Minimal friction for common tasks

Example Output

Before: 850 lines After: 320 lines (62% reduction)

Extracted:

  • docker-guide.md (Docker commands and troubleshooting)
  • ci-reference.md (CI health requirements and branch protection)
  • deployment-guide.md (Deployment commands and configuration)
  • troubleshooting.md (Diagnostic procedures consolidated)

Preserved inline:

  • Encryption unlock instructions
  • Security rules (secret handling, API keys)
  • Test file patterns
  • Build commands
  • Behavioral reminders

Validation Checklist

  • All extracted content is byte-for-byte identical (verified via diff)
  • Sub-documents are in unencrypted directory
  • Essential content remains inline
  • Sub-Documentation Table is at top of rewritten CLAUDE.md
  • All relative links work
  • User approved the plan before execution
  • Line reduction >50%
  • No chicken-and-egg problems (encryption, authentication)
  • CI scripts that regex-scan CLAUDE.md still pass (see CI Machine-Readable Content)

Error Handling

Entire project is encrypted: Warn user, suggest creating docs/claude/ or similar unencrypted subdirectory.

User rejects plan: Ask for feedback, iterate on categorization.

Information loss detected: Abort optimization, present diff to user, do not commit changes.

Ambiguous categorization: Default to Essential (keep inline), ask user to review.

Notes

  • This skill is project-agnostic and works with any CLAUDE.md file
  • Always read the full CLAUDE.md before categorizing (context matters)
  • Encryption constraints are project-specific, always check .gitattributes
  • Validation is mandatory, never skip Phase 6

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.