Back to Documentation & Writing

agent-md-refactor

agent instructionsmarkdownrefactoringdocumentationprogressive disclosureAI agentscode organizationsoftaworks
⭐ 2.0kπŸ“„ MITπŸ•’ 2026-03-05Source β†—

Install this skill

npx skills add softaworks/agent-toolkit

Works across Claude Code, Cursor, Codex, Copilot & Antigravity

The agent-md-refactor skill transforms monolithic, bloated instruction files like CLAUDE.md or AGENTS.md into a clean, modular documentation system. It applies progressive disclosure by isolating mission-critical, global project context at the root level while offloading domain-specific rulesβ€”such as testing protocols, architecture patterns, and styling conventionsβ€”into dedicated, linked files. This process improves model performance by reducing context window clutter and ensuring that instructions remain highly discoverable and maintainable. The skill identifies conflicting directives, eliminates redundant or obvious advice, and structures the remaining documentation into a predictable, logical hierarchy. By standardizing the configuration, teams prevent instruction drift, making it easier for AI agents to retrieve precise, relevant guidelines without wading through irrelevant noise or outdated boilerplate.

When to Use This Skill

  • β€’Standardizing instructions across a large team repository
  • β€’Cleaning up an agent config that has grown too long to parse accurately
  • β€’Separating language-specific rules from general project behavior
  • β€’Preparing a codebase for new LLM-based development workflows

How to Invoke This Skill

Example prompts that trigger this skill in Claude Code, Cursor, or Antigravity:

  • β€œrefactor my CLAUDE.md file
  • β€œorganize my agent instructions
  • β€œsplit my AGENTS.md into smaller files
  • β€œapply progressive disclosure to my system prompts
  • β€œclean up my bloated agent config

Pro Tips

  • πŸ’‘Before initiating the refactor, back up your original instruction file to easily revert if needed.
  • πŸ’‘Review the proposed categories and file structure carefully, customizing them to best fit your agent's specific needs and workflow.
  • πŸ’‘After refactoring, test your AI agent's behavior thoroughly to ensure all instructions are still correctly interpreted and followed in the new structure.

What this skill does

  • β€’Identifies and prompts resolution for conflicting instructions
  • β€’Separates core project metadata from technical domain rules
  • β€’Establishes a standardized file hierarchy for AI instruction sets
  • β€’Filters out vague, redundant, or deprecated prompt content
  • β€’Generates clean documentation templates for segmented topics

When not to use it

  • βœ•Small projects with only a few simple system instructions
  • βœ•Highly proprietary agent frameworks that do not support external file links

Example workflow

  1. Analyze the existing root file to map all active instructions
  2. Flag conflicting or redundant rules for user review
  3. Extract project essentials to maintain in the primary root file
  4. Organize remaining rules into thematic categories like testing or style
  5. Move categories into a dedicated folder and update the root file with relative links

Prerequisites

  • –An existing AGENTS.md or CLAUDE.md file
  • –Write access to the repository directory structure

Pitfalls & limitations

  • !Over-segmentation leading to too many tiny, hard-to-manage files
  • !Removing instructions that are redundant to humans but necessary as anchor points for specific AI models
  • !Breaking file references if the project directory structure changes later

FAQ

Will this tool delete instructions permanently?
It identifies redundant or vague content for deletion, but you retain final approval on all items flagged for removal before any files are modified.
Does this work with both AGENTS.md and CLAUDE.md?
Yes, the skill is agnostic to the file name and applies the same refactoring logic to whichever instruction file you provide.
How many files should I split my instructions into?
Aim for 3 to 8 files based on logical domains like testing, security, and architecture to maintain a balance between clarity and file management.

How it compares

Unlike manual editing which often leads to inconsistent formatting, this skill applies a standardized heuristic to ensure all agents receive a uniform, predictable documentation structure.

Source & trust

⭐ 2.0k starsπŸ“„ MITπŸ•’ Updated 2026-03-05
πŸ“„ Full skill instructions β€” original source: softaworks/agent-toolkit
# 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 |
|-----------|---------|------------|
| 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 |
| Outdated | References deprecated APIs | No 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

| Avoid | Why | Instead |
|-------|-----|---------|
| Keeping everything in root | Bloated, hard to maintain | Split into linked files |
| Too many categories | Fragmentation | Consolidate related topics |
| Vague instructions | Wastes tokens, no value | Be specific or delete |
| Duplicating defaults | Agent already knows | Only override when needed |
| Deep nesting | Hard to navigate | Flat 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

---

How to Use This Skill Unit

Option A: Project-Specific (Recommended)

  1. Click "Download" above
  2. In your project, create the directory: .agent/skills/agent-md-refactor/
  3. Save the file as SKILL.md
  4. The agent will automatically discover the skill based on its description.

Option B: Global Installation (All Agents)

Save the file to these locations to make it available across all projects:

  • Claude Code: ~/.claude/skills/softaworks/agent-toolkit/agent-md-refactor/SKILL.md
  • Cursor: ~/.cursor/skills/softaworks/agent-toolkit/agent-md-refactor/SKILL.md
  • Antigravity: ~/.gemini/antigravity/skills/softaworks/agent-toolkit/agent-md-refactor/SKILL.md

πŸš€ Install with CLI:
npx skills add softaworks/agent-toolkit

Read the Master Guide: Mastering Agent Skills β†’

Recommended Rules

View more rules β†’

Recommended Workflows

View more workflows β†’

Recommended MCP Servers

View more MCP servers β†’

Take It Further

Maximize your productivity with these powerful resources

πŸ“‹

Define Your Standards

Set up coding standards to ensure this workflow produces consistent, high-quality results.

Browse Rules Library
πŸ“–

Master Workflows

Learn how to create custom workflows, use Turbo Mode, and build your automation library.

Complete Guide

How to use this Skill in Claude Code & Cursor

For Claude Code (CLI)

To use this skill in Claude Code, copy the rule content into your project's custom instructions or follow our Add-Skill CLI guide. This ensures Claude follows your standards during every code generation.

For Cursor & Windsurf

For Cursor or Windsurf, individual skills are best used in the "Rules for AI" section. This specific unit helps the agent avoid documentation & writing issues, leading to cleaner, more efficient code.

Why the skill format matters: the standardized Agent Skills format lets your AI agent load detailed instructions only when they are relevant, keeping your prompt clean while improving results.

Source & attribution

This skill is categorized under Documentation & Writing and is published by Softaworks, maintained in softaworks/agent-toolkit.

← Browse All Agent Skills