A

Agent Md Refactor Engine

All-in-one skill covering refactor, bloated, agents, claude. Includes structured workflows, validation checks, and reusable patterns for development.

SkillClipticsdevelopmentv1.0.0MIT
0 views0 copies

Agent MD Refactor Engine

A Claude Code skill for refactoring bloated agent instruction files (AGENTS.md, CLAUDE.md, COPILOT.md, etc.) using progressive disclosure principles. Transforms monolithic instruction files into a well-organized hierarchy that keeps essentials at root level and pushes details into topic-specific files.

When to Use This Skill

Choose Agent MD Refactor when:

  • Your CLAUDE.md or AGENTS.md has grown beyond 500 lines
  • Agent performance has degraded due to excessive instruction context
  • You want to organize instructions into a maintainable hierarchy
  • You need to split monolithic instructions into topic-specific files
  • You want to follow progressive disclosure for agent instructions

Consider alternatives when:

  • You're creating a new CLAUDE.md from scratch (use project setup best practices)
  • You need prompt engineering for API calls (use a prompt engineering skill)
  • You want to build a multi-agent system (use an agent platform skill)

Quick Start

# Install the skill claude install agent-md-refactor-engine # Analyze current instruction file claude "Analyze my CLAUDE.md for bloat. How many lines? What can be extracted?" # Refactor into hierarchy claude "Refactor my CLAUDE.md into a progressive disclosure structure: root essentials + topic-specific reference files" # Optimize for context window claude "My AGENTS.md is 2,000 lines. Reduce it to under 200 lines while preserving all instructions in linked files"

Core Concepts

Progressive Disclosure Hierarchy

LevelContentsMax Length
Root (CLAUDE.md)Critical rules, project context, navigation100-200 lines
Topic FilesDetailed guidelines per domain200-400 lines each
Reference FilesExhaustive documentation, examplesUnlimited

File Organization

project/
ā”œā”€ā”€ CLAUDE.md (root — essentials only)
│   → Project overview
│   → Critical rules (5-10 most important)
│   → File navigation guide
│   → @import references to topic files
│
ā”œā”€ā”€ .claude/
│   ā”œā”€ā”€ code-style.md → Coding conventions, formatting
│   ā”œā”€ā”€ architecture.md → System design, patterns
│   ā”œā”€ā”€ testing.md → Test conventions, coverage rules
│   ā”œā”€ā”€ git.md → Commit format, branch strategy
│   ā”œā”€ā”€ deployment.md → Deploy process, environments
│   └── api.md → API conventions, error handling
│
└── docs/ (reference only, not in context)
    ā”œā”€ā”€ onboarding.md → New developer guide
    └── decisions/ → ADRs and decision logs

Refactoring Rules

RuleBeforeAfter
Extract by topicAll rules in one fileTopic-specific files
Keep root lean2,000-line CLAUDE.md150-line CLAUDE.md
Link, don't duplicateSame rule in 3 placesOne source of truth
Prioritize essentialsEverything is equal priorityTop 10 rules at root
Use cross-referencesFlat list of rules"See .claude/testing.md for details"

Configuration

ParameterTypeDefaultDescription
source_filestring"CLAUDE.md"File to refactor
max_root_linesnumber200Maximum lines in root file
output_dirstring".claude"Directory for extracted topic files
formatstring"markdown"Output format: markdown, yaml
preserve_originalsbooleantrueKeep backup of original files

Best Practices

  1. The root file should answer "what matters most?" — Read your CLAUDE.md and ask: if the agent could only see 20 lines, which 20 would matter most? Those go at root level. Everything else is extracted.

  2. Group instructions by when they're needed — Testing guidelines are only relevant when writing tests. API conventions matter only when touching APIs. Put these in topic files that the agent references on demand.

  3. Remove duplicates ruthlessly — Bloated instruction files often repeat the same rule in different phrasings. Pick the clearest version, put it in one place, and link to it from other contexts.

  4. Use imperative language — "Use TypeScript strict mode" is clearer than "We prefer to use TypeScript strict mode when possible." Instructions should be direct commands, not suggestions.

  5. Review quarterly — Instructions accumulate over time. Schedule quarterly reviews to remove outdated rules, consolidate similar instructions, and ensure the hierarchy still makes sense as the project evolves.

Common Issues

Agent ignores extracted files — The root file must clearly reference topic files with specific triggers: "When writing tests, follow .claude/testing.md." Without clear triggers, the agent won't know when to consult topic files.

Too many topic files — Don't extract every paragraph into its own file. Aim for 4-8 topic files that cover broad domains. Too many small files make navigation harder, not easier.

Refactoring loses important context — Before refactoring, catalog every instruction and ensure it appears in the new structure. Use a checklist to verify nothing was dropped during extraction.

Community

Reviews

Write a review

No reviews yet. Be the first to review this template!

Similar Templates