agent-md-refactor by softaworks/agent-toolkit
npx skills add https://github.com/softaworks/agent-toolkit --skill agent-md-refactor重构臃肿的智能体指令文件(AGENTS.md、CLAUDE.md、COPILOT.md 等),使其遵循渐进式披露原则——将核心内容保留在根文件,其余内容组织到链接的、分类的文件中。
在以下情况使用此技能:
| 阶段 | 操作 | 输出 |
|---|
识别任何相互冲突的指令。
寻找:
对于发现的每个矛盾:
## 发现矛盾
**指令 A:** [引用]
**指令 B:** [引用]
**问题:** 哪个应该优先,或者两者都应该是条件性的?
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
在继续之前,请用户解决。
仅提取属于根智能体文件的内容。根文件应该是最简化的——适用于每一项任务的信息。
核心内容(保留在根文件中):
| 类别 | 示例 |
|---|---|
| 项目描述 | 一句话:“用于分析的可视化 React 仪表板” |
| 包管理器 | 仅当不是 npm 时(例如,“使用 pnpm”) |
| 非标准命令 | 自定义构建/测试/类型检查命令 |
| 关键覆盖项 | 必须覆盖默认设置的事项 |
| 通用规则 | 适用于 100% 任务的规则 |
非核心内容(移至链接文件):
将剩余的指令组织到逻辑类别中。
常见类别:
| 类别 | 内容 |
|---|---|
typescript.md | TypeScript 约定、类型模式、严格模式规则 |
testing.md | 测试框架、覆盖率、模拟模式 |
code-style.md | 格式化、命名、注释、结构 |
git-workflow.md | 提交、分支、PR、审查 |
architecture.md | 模式、文件夹结构、依赖关系 |
api-design.md | REST/GraphQL 约定、错误处理 |
security.md | 认证模式、输入验证、密钥 |
performance.md | 优化规则、缓存、懒加载 |
分组规则:
{主题}.md输出结构:
project-root/
├── CLAUDE.md (或 AGENTS.md) # 包含链接的最小化根文件
└── .claude/ # 或 docs/agent-instructions/
├── typescript.md
├── testing.md
├── code-style.md
├── git-workflow.md
└── architecture.md
根文件模板:
# 项目名称
项目的一句话描述。
## 快速参考
- **包管理器:** pnpm
- **构建:** `pnpm build`
- **测试:** `pnpm test`
- **类型检查:** `pnpm typecheck`
## 详细说明
有关具体指南,请参阅:
- [TypeScript 约定](.claude/typescript.md)
- [测试指南](.claude/testing.md)
- [代码风格](.claude/code-style.md)
- [Git 工作流](.claude/git-workflow.md)
- [架构模式](.claude/architecture.md)
每个链接文件模板:
# {主题} 指南
## 概述
简要说明这些指南适用的场景。
## 规则
### 规则类别 1
- 具体、可操作的指令
- 另一个具体指令
### 规则类别 2
- 具体、可操作的指令
## 示例
### 良好示例
\`\`\`typescript
// 正确模式的示例
\`\`\`
### 避免示例
\`\`\`typescript
// 不应做法的示例
\`\`\`
识别应完全删除的指令。
如果符合以下条件则删除:
| 标准 | 示例 | 删除原因 |
|---|---|---|
| 冗余 | “使用 TypeScript”(在 .ts 项目中) | 智能体已经知道 |
| 过于模糊 | “编写干净的代码” | 不可操作 |
| 过于明显 | “不要引入错误” | 浪费上下文 |
| 默认行为 | “使用描述性变量名” | 标准实践 |
| 过时 | 引用已弃用的 API | 不再适用 |
输出格式:
## 标记为待删除
| 指令 | 原因 |
|-------------|--------|
| “编写干净、可维护的代码” | 过于模糊,不可操作 |
| “使用 TypeScript” | 冗余 - 项目已经是 TS |
| “不要提交密钥” | 智能体已经知道这一点 |
| “遵循最佳实践” | 没有具体说明则无意义 |
[ ] 阶段 1:所有矛盾已识别并解决
[ ] 阶段 2:根文件仅包含核心内容
[ ] 阶段 3:所有剩余指令已分类
[ ] 阶段 4:已创建具有正确链接的文件结构
[ ] 阶段 5:冗余/模糊指令已移除
[ ] 验证:每个链接文件自成一体
[ ] 验证:根文件少于 50 行
[ ] 验证:所有链接正常工作
| 避免 | 原因 | 替代方案 |
|---|---|---|
| 将所有内容保留在根文件 | 臃肿,难以维护 | 拆分为链接文件 |
| 类别过多 | 碎片化 | 合并相关主题 |
| 模糊指令 | 浪费 token,无价值 | 具体说明或删除 |
| 重复默认设置 | 智能体已经知道 | 仅在需要覆盖时说明 |
| 深层嵌套 | 难以导航 | 扁平结构配合链接 |
# CLAUDE.md
这是一个 React 项目。
## 代码风格
- 使用 2 个空格缩进
- 使用分号
- 优先使用 const 而非 let
- 使用箭头函数
... (还有 200 多行)
## 测试
- 使用 Jest
- 覆盖率 > 80%
... (还有 100 多行)
## TypeScript
- 启用严格模式
... (还有 150 多行)
# CLAUDE.md
用于实时分析可视化的 React 仪表板。
## 命令
- `pnpm dev` - 启动开发服务器
- `pnpm test` - 运行测试并生成覆盖率报告
- `pnpm build` - 生产环境构建
## 指南
- [代码风格](.claude/code-style.md)
- [测试](.claude/testing.md)
- [TypeScript](.claude/typescript.md)
重构后,验证:
每周安装量
573
代码仓库
GitHub 星标数
1.2K
首次出现
2026年1月20日
安全审计
安装于
codex418
gemini-cli418
claude-code417
cursor417
opencode401
cline398
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.
Use this skill when:
| 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 |
Identify any instructions that conflict with each other.
Look for:
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.
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):
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 |
Grouping rules:
{topic}.mdOutput 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
\`\`\`
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 |
[ ] 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
| 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 |
# 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)
# 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)
After refactoring, verify:
Weekly Installs
573
Repository
GitHub Stars
1.2K
First Seen
Jan 20, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
codex418
gemini-cli418
claude-code417
cursor417
opencode401
cline398
AI 代码实施计划编写技能 | 自动化开发任务分解与 TDD 流程规划工具
41,400 周安装
OpenAPI 转 TypeScript 工具 - 自动生成 API 接口与类型守卫
563 周安装
数据库模式设计器 - 内置最佳实践,自动生成生产级SQL/NoSQL数据库架构
564 周安装
Rust Unsafe代码检查器 - 安全使用Unsafe Rust的完整指南与最佳实践
564 周安装
.NET并发编程模式指南:async/await、Channels、Akka.NET选择决策树
565 周安装
韩语语法检查器 - 基于国立国语院标准的拼写、空格、语法、标点错误检测与纠正
565 周安装
技能安全扫描器 - 检测Claude技能安全漏洞,防范提示注入与恶意代码
565 周安装
| REST/GraphQL conventions, error handling |
security.md | Auth patterns, input validation, secrets |
performance.md | Optimization rules, caching, lazy loading |