by softaworks
Claude Code 经常在 AGENTS.md 或 CLAUDE.md 文件中积累数百行混合指令,浪费上下文令牌并造成维护麻烦。此技能使用渐进式披露原则将单体代理指令重构为整洁的链接文档。
1. 打开 Claude 聊天界面
2. 点击下方 "📋 复制" 按钮
3. 粘贴到 Claude 聊天框中并发送
4. 输入 "使用 agent-md-refactor 技能" 开始使用
=== agent-md-refactor 技能 === 作者: softaworks 描述: Claude Code 经常在 AGENTS.md 或 CLAUDE.md 文件中积累数百行混合指令,浪费上下文令牌并造成维护麻烦。此技能使用渐进式披露原则将单体代理指令重构为整洁的链接文档。 使用方法: 1. 调用技能: "使用 agent-md-refactor 技能" 2. 提供相关信息: 根据技能要求提供必要参数 3. 查看结果: 技能会返回处理结果 示例: "使用 agent-md-refactor 技能,帮我分析一下这段代码"
这种方法适用于所有 Claude 用户,不需要安装额外工具。
productivity
safe
A Claude Code skill that transforms bloated agent instruction files into clean, organized documentation using progressive disclosure principles.
Based on https://x.com/mattpocockuk/status/2012906065856270504 (Matt Pocock's Prompt Idea)
Over time, agent instruction files like CLAUDE.md, AGENTS.md, or COPILOT.md tend to grow into unwieldy documents containing hundreds of lines of mixed instructions. This creates several problems:
This skill solves these problems by applying progressive disclosure - keeping only essential, universal instructions in the root file while organizing everything else into focused, linked documentation files.
Use this skill when you need to clean up agent instruction files. Common trigger phrases include:
Good candidates for refactoring:
The skill follows a systematic 5-phase process:
Before restructuring, the skill identifies conflicting instructions that need resolution. Examples include contradictory style guidelines ("use semicolons" vs "no semicolons") or incompatible workflow instructions. Each contradiction is surfaced with a question for the user to resolve.
Extracts only what truly belongs in the root file - information that applies to every single task:
| Keep in Root | Move Out |
|---|---|
| One-sentence project description | Language-specific conventions |
| Non-standard package manager | Testing guidelines |
| Custom build/test commands | Code style details |
| Critical overrides | Framework patterns |
| Universal rules (100% of tasks) | Documentation standards |
Organizes remaining instructions into logical categories like:
typescript.md - Type patterns, strict mode rulestesting.md - Test frameworks, coverage, mockingcode-style.md - Formatting, naming, structuregit-workflow.md - Commits, branches, PRsarchitecture.md - Patterns, folder structureGenerates the new file hierarchy with properly linked documentation:
project-root/
├── CLAUDE.md # Minimal root with links
└── .claude/ # Categorized instructions
├── typescript.md
├── testing.md
├── code-style.md
└── architecture.md
Identifies instructions that should be removed entirely:
User: refactor my CLAUDE.md
Claude: I'll analyze your CLAUDE.md file and refactor it using progressive
disclosure principles...
User: my AGENTS.md is too long, can you split it up?
Claude: I'll review your AGENTS.md and organize it into focused, linked files...
User: organize my agent config - it's gotten out of control
Claude: I'll apply the 5-phase refactoring process to clean up your
agent instructions...
After running the skill, you get:
Minimal root file (~50 lines or less):
# Project Name
One-sentence description of the project.
## Quick Reference
- **Package Manager:** pnpm
- **Build:** `pnpm build`
- **Test:** `pnpm test`
## Detailed Instructions
- [TypeScript Conventions](.claude/typescript.md)
- [Testing Guidelines](.claude/testing.md)
- [Code Style](.claude/code-style.md)
Organized linked files with consistent structure:
# Testing Guidelines
## Overview
Brief context for when these guidelines apply.
## Rules
### Unit Tests
- Specific, actionable instruction
- Another specific instruction
## Examples
### Good
[code example]
### Avoid
[code example]
Deletion report:
## Flagged for Deletion
| Instruction | Reason |
|-------------|--------|
| "Write clean, maintainable code" | Too vague to be actionable |
| "Use TypeScript" | Redundant - project is already TS |
| Avoid | Why | Instead |
|---|---|---|
| Keeping everything in root | Bloated, hard to maintain | Split into linked files |
| Too many categories | Fragmentation, navigation overhead | 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 |
After refactoring, verify:
MIT
View Count
0
Download Count
0
Favorite Count
0
Quality Score
70