PluginBench
Skill
Pass
Audit score 90

agent-md-refactor

softaworks/agent-toolkit

Refactor bloated agent instruction files into organized, linked documentation following progressive disclosure principles.

What is agent-md-refactor?

This skill refactors monolithic agent instruction files (AGENTS.md, CLAUDE.md, etc.) by identifying contradictions, extracting essentials, categorizing remaining content, and splitting into a minimal root file with organized linked documentation. Use it when your agent config files have grown too large or disorganized.

  • Identifies and resolves contradictions in instruction files
  • Extracts essential content for the root file (project description, commands, critical overrides)
  • Groups remaining instructions into logical categories (TypeScript, testing, code style, git workflow, architecture, etc.)
  • Creates a file hierarchy with minimal root and linked topic-specific files
  • Flags redundant, vague, or outdated instructions for deletion
  • Verifies structure with actionable content and working links

How to install agent-md-refactor

npx skills add https://github.com/softaworks/agent-toolkit --skill agent-md-refactor
Claude Code
Cursor
Windsurf
Cline

How to use agent-md-refactor

  1. 1.Run the skill and provide your current agent instruction file (AGENTS.md, CLAUDE.md, etc.)
  2. 2.Phase 1: Review and resolve any contradictions the skill identifies
  3. 3.Phase 2: Confirm which content is essential for the root file
  4. 4.Phase 3: Review proposed categories and adjust groupings if needed
  5. 5.Phase 4: Accept the generated file structure and linked files
  6. 6.Phase 5: Review flagged instructions for deletion and confirm removals
  7. 7.Verify the root file is under 50 lines and all links work correctly

Use cases

Good for
  • Refactor a 500+ line CLAUDE.md into a minimal root with 5-6 linked topic files
  • Resolve contradictory style guidelines in an AGENTS.md file before splitting
  • Organize scattered instructions in COPILOT.md into a progressive disclosure structure
  • Clean up outdated or vague instructions that waste token context
  • Create a maintainable agent instruction hierarchy for a team project
Who it's for
  • Developers managing agent instruction files for Claude, Cursor, or similar coding agents
  • Teams with bloated or contradictory agent configuration files
  • Projects needing organized, linked documentation for agent behavior
  • Anyone using progressive disclosure to keep essential info at root level

agent-md-refactor FAQ

What counts as 'essential' content for the root file?

Only information that applies to every single task: one-sentence project description, non-standard package manager or commands, critical overrides, and universal rules. Language-specific conventions, testing guidelines, code style details, and framework patterns belong in linked files.

How many linked files should I create?

Aim for 3-8 files. Common categories include typescript.md, testing.md, code-style.md, git-workflow.md, and architecture.md. Consolidate related topics rather than creating too many granular files.

What should I delete?

Remove instructions that are redundant (agent already knows), too vague to be actionable, overly obvious, default behavior, or outdated. Examples: 'Write clean code', 'Use TypeScript' (in a TS project), 'Don't introduce bugs'.

Can I customize the file structure?

Yes. The skill provides a standard structure, but you can adjust category names, folder location (.claude/ vs docs/agent-instructions/), and groupings based on your project needs.

How do I know if the refactoring is successful?

Verify: root file is under 50 lines with only universal info, all links work, no contradictions remain, every instruction is specific and actionable, and each linked file is self-contained.

Full instructions (SKILL.md)

Source of truth, from softaworks/agent-toolkit.


name: agent-md-refactor description: Refactor bloated AGENTS.md, CLAUDE.md, or similar agent instruction files to follow progressive disclosure principles. Splits monolithic files into organized, linked documentation. license: MIT

Agent MD Refactor

Refactor bloated agent instruction files (AGENTS.md, CLAUDE.md, COPILOT.md, etc.) to follow progressive disclosure principles - keeping essentials at root and organizing the rest into linked, categorized files.


Triggers

Use this skill when:

  • "refactor my AGENTS.md" / "refactor my CLAUDE.md"
  • "split my agent instructions"
  • "organize my CLAUDE.md file"
  • "my AGENTS.md is too long"
  • "progressive disclosure for my instructions"
  • "clean up my agent config"

Quick Reference

PhaseActionOutput
1. AnalyzeFind contradictionsList of conflicts to resolve
2. ExtractIdentify essentialsCore instructions for root file
3. CategorizeGroup remaining instructionsLogical categories
4. StructureCreate file hierarchyRoot + linked files
5. PruneFlag for deletionRedundant/vague instructions

Process

Phase 1: Find Contradictions

Identify any instructions that conflict with each other.

Look for:

  • Contradictory style guidelines (e.g., "use semicolons" vs "no semicolons")
  • Conflicting workflow instructions
  • Incompatible tool preferences
  • Mutually exclusive patterns

For each contradiction found:

## Contradiction Found

**Instruction A:** [quote]
**Instruction B:** [quote]

**Question:** Which should take precedence, or should both be conditional?

Ask the user to resolve before proceeding.


Phase 2: Identify the Essentials

Extract ONLY what belongs in the root agent file. The root should be minimal - information that applies to every single task.

Essential content (keep in root):

CategoryExample
Project descriptionOne sentence: "A React dashboard for analytics"
Package managerOnly if not npm (e.g., "Uses pnpm")
Non-standard commandsCustom build/test/typecheck commands
Critical overridesThings that MUST override defaults
Universal rulesApplies to 100% of tasks

NOT essential (move to linked files):

  • Language-specific conventions
  • Testing guidelines
  • Code style details
  • Framework patterns
  • Documentation standards
  • Git workflow details

Phase 3: Group the Rest

Organize remaining instructions into logical categories.

Common categories:

CategoryContents
typescript.mdTS conventions, type patterns, strict mode rules
testing.mdTest frameworks, coverage, mocking patterns
code-style.mdFormatting, naming, comments, structure
git-workflow.mdCommits, branches, PRs, reviews
architecture.mdPatterns, folder structure, dependencies
api-design.mdREST/GraphQL conventions, error handling
security.mdAuth patterns, input validation, secrets
performance.mdOptimization rules, caching, lazy loading

Grouping rules:

  1. Each file should be self-contained for its topic
  2. Aim for 3-8 files (not too granular, not too broad)
  3. Name files clearly: {topic}.md
  4. Include only actionable instructions

Phase 4: Create the File Structure

Output structure:

project-root/
├── CLAUDE.md (or AGENTS.md)     # Minimal root with links
└── .claude/                      # Or docs/agent-instructions/
    ├── typescript.md
    ├── testing.md
    ├── code-style.md
    ├── git-workflow.md
    └── architecture.md

Root file template:

# Project Name

One-sentence description of the project.

## Quick Reference

- **Package Manager:** pnpm
- **Build:** `pnpm build`
- **Test:** `pnpm test`
- **Typecheck:** `pnpm typecheck`

## Detailed Instructions

For specific guidelines, see:
- [TypeScript Conventions](.claude/typescript.md)
- [Testing Guidelines](.claude/testing.md)
- [Code Style](.claude/code-style.md)
- [Git Workflow](.claude/git-workflow.md)
- [Architecture Patterns](.claude/architecture.md)

Each linked file template:

# {Topic} Guidelines

## Overview
Brief context for when these guidelines apply.

## Rules

### Rule Category 1
- Specific, actionable instruction
- Another specific instruction

### Rule Category 2
- Specific, actionable instruction

## Examples

### Good
\`\`\`typescript
// Example of correct pattern
\`\`\`

### Avoid
\`\`\`typescript
// Example of what not to do
\`\`\`

Phase 5: Flag for Deletion

Identify instructions that should be removed entirely.

Delete if:

CriterionExampleWhy Delete
Redundant"Use TypeScript" (in a .ts project)Agent already knows
Too vague"Write clean code"Not actionable
Overly obvious"Don't introduce bugs"Wastes context
Default behavior"Use descriptive variable names"Standard practice
OutdatedReferences deprecated APIsNo longer applies

Output format:

## Flagged for Deletion

| Instruction | Reason |
|-------------|--------|
| "Write clean, maintainable code" | Too vague to be actionable |
| "Use TypeScript" | Redundant - project is already TS |
| "Don't commit secrets" | Agent already knows this |
| "Follow best practices" | Meaningless without specifics |

Execution Checklist

[ ] Phase 1: All contradictions identified and resolved
[ ] Phase 2: Root file contains ONLY essentials
[ ] Phase 3: All remaining instructions categorized
[ ] Phase 4: File structure created with proper links
[ ] Phase 5: Redundant/vague instructions removed
[ ] Verify: Each linked file is self-contained
[ ] Verify: Root file is under 50 lines
[ ] Verify: All links work correctly

Anti-Patterns

AvoidWhyInstead
Keeping everything in rootBloated, hard to maintainSplit into linked files
Too many categoriesFragmentationConsolidate related topics
Vague instructionsWastes tokens, no valueBe specific or delete
Duplicating defaultsAgent already knowsOnly override when needed
Deep nestingHard to navigateFlat structure with links

Examples

Before (Bloated Root)

# CLAUDE.md

This is a React project.

## Code Style
- Use 2 spaces
- Use semicolons
- Prefer const over let
- Use arrow functions
... (200 more lines)

## Testing
- Use Jest
- Coverage > 80%
... (100 more lines)

## TypeScript
- Enable strict mode
... (150 more lines)

After (Progressive Disclosure)

# CLAUDE.md

React dashboard for real-time analytics visualization.

## Commands
- `pnpm dev` - Start development server
- `pnpm test` - Run tests with coverage
- `pnpm build` - Production build

## Guidelines
- [Code Style](.claude/code-style.md)
- [Testing](.claude/testing.md)
- [TypeScript](.claude/typescript.md)

Verification

After refactoring, verify:

  1. Root file is minimal - Under 50 lines, only universal info
  2. Links work - All referenced files exist
  3. No contradictions - Instructions are consistent
  4. Actionable content - Every instruction is specific
  5. Complete coverage - No instructions were lost (unless flagged for deletion)
  6. Self-contained files - Each linked file stands alone