agentleFS
secondorderaisecondorderai/ouroboros/.claude/skills/refactor-agents-md/SKILL.md

refactor-agents-md

Skill3 starsChanged 6 months agoMITView on GitHub

Refactor an AGENTS.md or CLAUDE.md file using the Progressive Disclosure Principle so that only essential, universal instructions stay at root level while domain-specific guidance moves to subsidiary files loaded just-in-time. Use this skill whenever the user wants to restructure, slim down, optimize, or declutter their AGENTS.md or CLAUDE.md file, mentions "progressive disclosure" for agent instructions, says their instruction file is "too long" or "bloated," asks how to reduce token overhead in their agent config, or wants Claude to "only load what it needs." Also trigger when the user says things like "refactor my CLAUDE.md," "split up my AGENTS.md," "organize my agent instructions," or "my AGENTS.md has gotten out of hand."

3 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

8 rules. 0 are common, 8 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 3 edited versions we read keep these.

  • 8

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Read the current AGENTS.md (or CLAUDE.md — treat them identically).

    line 31
  2. Distinctive:

    If the file is under 40 lines and cleanly organized, tell the user it's already lean and progressive disclosure may not add much value.

    line 36
  3. Distinctive:

    When in doubt, ask: "Would an agent doing a completely unrelated task in this repo still need this information?" If no, it's …

    line 59
  4. Distinctive:

    Before touching any files, show the user a clear summary:

    line 64
  5. Distinctive:

    Not a bulleted link dump — a sentence that tells the agent when and why to look there.

    line 105
  6. Distinctive:

    Check for cross-references: If the original file had internal references between sections (e.g., "as described in Architecture above"), …

    line 107
  7. Distinctive:

    If any check fails, fix it before reporting completion.

    line 124
  8. Distinctive:

    Don't duplicate — if the root file covers a topic, the package file should reference it rather than repeat it.

    line 134

“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “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

Refactor AGENTS.md with Progressive Disclosure

Frontier LLMs can follow roughly 150-200 instructions with reasonable consistency. Every token in AGENTS.md loads on every single request — whether or not it's relevant to the current task. A bloated instruction file wastes context window on guidance the agent doesn't need right now, leaving less room for the actual work.

Progressive disclosure fixes this: keep the root file minimal (universal essentials only) and move domain-specific guidance into subsidiary files that the agent reads only when relevant. No content is lost — it's redistributed so the agent finds what it needs exactly when it needs it.

Workflow

Step 1: Read and Measure

Read the current AGENTS.md (or CLAUDE.md — treat them identically). Note:

  • Total line count
  • Each ## section heading and its approximate size
  • Whether the project is a monorepo (multiple packages with their own instruction needs)

If the file is under 40 lines and cleanly organized, tell the user it's already lean and progressive disclosure may not add much value. Offer to review it for other improvements instead.

Step 2: Classify Every Section

Go through each section and classify it as either root-essential or domain-specific.

Root-essential (stays in the root file):

  • One-sentence project description (what this project is)
  • Runtime / package manager (if non-standard)
  • Build and test commands (the commands an agent needs for any task)
  • Universal workflow rules (e.g., "always run lint before committing")
  • Any rule that applies to literally every task regardless of domain

Domain-specific (moves to a subsidiary file):

  • Language or framework conventions (TypeScript style, React patterns)
  • Architecture details (system design, module boundaries, data flow)
  • Testing patterns and strategies (test organization, fixture conventions)
  • Tool or API-specific guidance (tool registry patterns, SDK usage)
  • Deployment and CI/CD instructions
  • Safety or permission models (unless they're brief enough for root)

When in doubt, ask: "Would an agent doing a completely unrelated task in this repo still need this information?" If no, it's domain-specific.

Step 3: Present the Refactoring Plan

Before touching any files, show the user a clear summary:

Sections staying at root:
  - Project Overview (3 lines)
  - Commands (8 lines)
  - Workflow (6 lines)

Sections moving to subsidiary files:
  - Architecture → doc/ARCHITECTURE.md
  - Conventions → doc/CONVENTIONS.md
  - Testing Patterns → doc/TESTING.md

Explain the rationale briefly. Ask the user to confirm or adjust — they may want to keep certain sections at root, merge some subsidiary files, or use a different directory than doc/.

Step 4: Execute the Refactoring

Once approved:

  1. Create subsidiary files in the agreed directory (default: doc/). Each file should:
    • Have a clear # Title matching its domain
    • Contain the full content extracted from the root file, unmodified
    • Be self-contained — someone reading just that file should understand the domain
  2. Rewrite the root AGENTS.md with:

    • The root-essential sections, unchanged
    • Conversational breadcrumbs pointing to each subsidiary file

    Breadcrumbs should feel natural, not like a table of contents. Place them where the content used to be, so the flow still reads logically. For example:

    ## Architecture
    
    For architecture details including the core loop pattern, tool registry,
    and memory system, see doc/ARCHITECTURE.md.

    Not a bulleted link dump — a sentence that tells the agent when and why to look there.

  3. Check for cross-references. If the original file had internal references between sections (e.g., "as described in Architecture above"), update them to point to the correct subsidiary file.

For detailed guidance on what makes good breadcrumbs, monorepo layering, and common anti-patterns, see references/progressive-disclosure-guide.md.

Step 5: Verify

After refactoring, confirm:

  • Root file is lean (ideally under 50 lines for most projects)
  • Every breadcrumb path actually resolves to an existing file
  • No content was lost — diff the total content before and after
  • Subsidiary files are self-contained and clearly titled
  • The root file still reads naturally top-to-bottom

If any check fails, fix it before reporting completion.

Monorepo Handling

For monorepos, apply a two-level strategy:

  • Root AGENTS.md: Monorepo purpose, shared tooling (package manager, workspace commands), cross-package conventions
  • Package-level AGENTS.md: Package-specific tech stack, conventions, and commands

Don't duplicate — if the root file covers a topic, the package file should reference it rather than repeat it. Package-level files merge with the root at runtime, so they can assume root context is available.

When to Stop Splitting

Progressive disclosure has diminishing returns. Don't create a subsidiary file for a section that's only 3-5 lines — the breadcrumb itself would be nearly as long. A good rule of thumb: if a section is under 10 lines and isn't part of a clear domain grouping, leave it at root.

The goal is a root file that an agent can absorb in seconds, with clear paths to deeper knowledge. Not a fractal of tiny files.

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.