Skip to content
Skillpedia
Prompts & LLMs33k Β· #8721

agent-md-refactor

What it does

This skill helps your AI agent tidy up long instruction files for coding agents. It is for people whose CLAUDE.md or AGENTS.md file has grown too big to be useful.

When to use it

  • βœ“When your CLAUDE.md or AGENTS.md file has become too long to read.
  • βœ“When your agent instructions contain conflicting rules you want to resolve.
  • βœ“When you want to organize agent instructions into linked topic files.

Skill link

https://github.com/davila7/claude-code-templates/blob/main/cli-tool/components/skills/development/agent-md-refactor/SKILL.md

Copy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.

How to use

The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.

Ready-to-paste message

Use this skill to help me: https://github.com/davila7/claude-code-templates/blob/main/cli-tool/components/skills/development/agent-md-refactor/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
Want your AI to find skills like this on its own?Install the free Skillpedia MCP: one line, and it searches 15,000+ skills before each task.Install in 1 minute β†’

Example of what to ask your AI

β€œMy CLAUDE.md is huge and messy. Split it into a short main file and organized pages.”

5 new skills a week. 1 minute to read.

How it works

The agent first finds contradictions, then pulls out the essentials for the main file. It groups the rest into categories, creates linked files, and flags vague or redundant instructions.

Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

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

Phase Action Output
1. Analyze Find contradictions List of conflicts to resolve
2. Extract Identify essentials Core instructions for root file
3. Categorize Group remaining instructions Logical categories
4. Structure Create file hierarchy Root + linked files
5. Prune Flag for deletion Redundant/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):

Category Example
Project description One sentence: "A React dashboard for analytics"
Package manager Only if not npm (e.g., "Uses pnpm")
Non-standard commands Custom build/test/typecheck commands
Critical overrides Things that MUST override defaults
Universal rules Applies 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:

Category Contents
typescript.md TS conventions, type patterns, strict mode rules
testing.md Test frameworks, coverage, mocking patterns
code-style.md Formatting, naming, comments, structure
git-workflow.md Commits, branches, PRs, reviews
architecture.md Patterns, folder structure, dependencies
api-design.md REST/GraphQL conventions, error handling
security.md Auth patterns, input validation, secrets
performance.md Optimization 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:

| Criterion | Example | Why Delete | |--------

FAQ

Will it delete my instructions?

It flags redundant or vague instructions for removal, so you can review them before anything is dropped.

What goes in the main file?

The essentials every session needs, with links to more detailed files for everything else.

Does it find conflicting rules?

Yes, its first step looks for instructions that contradict each other and asks which should take precedence.

Details

Original description by the author

Refactor bloated AGENTS.md, CLAUDE.md, or similar agent instruction files to follow progressive disclosure principles. Splits monolithic files into organized, linked documentation.

repo: davila7/claude-code-templates

Popularity

GitHub stars
33k
Ranking position
#8721
License
MIT
Updated
11/2/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills