Optimize CLAUDE.md / AGENTS.md for AI Consumption
Purpose: Optimize CLAUDE.md or AGENTS.md files for AI agent/machine consumption. Focus on quality improvements: inconsistencies, duplicates, unnecessary content, and content that should be moved elsewhere. Preserve all essential actionable guidance.
Target: Any CLAUDE.md or AGENTS.md file in doc workspaces or code repositories. Size reduction is a byproduct, not the primary goal.
Optimization Process
Step 1: Analyze Current State
- Count total lines in
AGENTS.md (for context only, not a target)
- Identify verbose sections (paragraphs, long explanations, multiple examples)
- Find duplicate content across sections
- Identify specific examples that could be genericized
- Check for content that duplicates instruction files
- Identify content that should be moved to instruction files or other locations
- Find content that isn't needed for AI agents (human-only notes, historical context, etc.)
Step 1.5: Identify Inconsistencies
Format Inconsistencies:
- Inconsistent heading levels (H2 vs H3 for similar content)
- Mixed list formats (bullets vs numbered vs dashes)
- Inconsistent code block formatting (language tags, indentation)
- Inconsistent link formats (markdown vs wiki-style vs plain text)
- Inconsistent checkbox syntax (
- [ ] vs - [x] vs * [ ])
- Inconsistent spacing (blank lines, indentation)
- Inconsistent emphasis (bold vs italic vs code formatting)
Content Inconsistencies:
- Same concept described differently in multiple sections
- Conflicting file naming conventions (different formats for same file type)
- Conflicting directory structure guidance
- Different workflow descriptions for same process
- Inconsistent terminology (same concept with different names)
- Conflicting formatting rules (e.g., "use bullets" vs "use paragraphs")
Contradictory Instructions:
- One section says "do X" while another says "don't do X"
- Conflicting rules about when to use certain formats
- Contradictory guidance on file organization
- One workflow contradicts another workflow
- Different sections give opposite advice for same scenario
- Conflicting examples showing different approaches
Resolution Strategy:
- Identify all instances of each inconsistency pattern
- Determine authoritative source (most specific, most recent, or most referenced)
- Resolve contradictions by:
- Keeping the more specific/complete guidance
- Removing the less accurate version
- Merging complementary guidance when both are valid
- Adding clarifying notes if context-dependent
- Standardize format across all sections
- Update all references to use consistent terminology
- Document resolution in comments if needed (remove after verification)
Common Contradiction Patterns:
- File naming: Multiple formats for same file type → Standardize to one format
- Workflow steps: Different step counts/orders → Consolidate to authoritative version
- Formatting rules: "Use X" vs "Use Y" → Choose one, document exception if needed
- Organization: Different folder structures → Standardize to one structure
- Terminology: Same concept, different names → Use consistent term throughout
Step 2: Remove Redundancy
Consolidate:
- Duplicate guidance appearing in multiple sections → Single consolidated section
- Similar checklists → Merge into one
- Repeated principles → Single location with cross-reference
- Same content in DO/DON'T, Principles, and Common Issues → One section only
Use cross-references instead of repeating content:
- If instruction file exists: Replace detailed steps with 1-3 line summary + reference
- If content appears elsewhere: Reference it, don't duplicate
Step 3: Condense Content
Convert:
- Paragraphs → Bullet points
- Explanations → Actionable steps
- Multiple examples → Single generic template
- Detailed descriptions → Concise requirements
- Verbose workflows → Step-by-step lists
- Multi-line bullet lists → Single-line comma-separated formats
- Numbered lists with explanations → Concise bullet points
- Verbose section headers → Condensed inline descriptions
Specific patterns:
- Content Filters: Multi-line bullets → Single-line comma-separated
- Workflow descriptions: Numbered lists with explanations → Concise bullets
- Workspace structure: Nested descriptions → Single-line comma-separated lists
- Instruction file lists: Shorten descriptions, remove redundant phrases
Step 4: Remove Unnecessary Content
Remove (AI-agent-irrelevant only):
- Content that isn't needed for AI agents (human-only notes, historical context, evolution notes)
- Redundant descriptions repeating earlier content (after consolidation)
- Multiple examples of the same concept (keep one generic template)
- Generic productivity advice (not workspace-specific)
- Notes sections repeating earlier guidance (after consolidation)
- Integration workflow details (keep references only)
Do NOT remove:
- Essential actionable guidance
- Critical checklists
- Structure templates
- Core principles
- Workflow references
- File naming conventions
Keep:
- Essential structure templates
- Actionable workflow steps
- Core principles (DO/DON'T lists)
- Critical checklists
- Common issues and fixes
- File naming conventions
- Related instruction references
Step 5: Move Content to Appropriate Locations
Move to instruction files:
- Detailed step-by-step workflows → Instruction files (keep only reference in AGENTS.md)
- Verbose examples → Instruction files (keep generic template in AGENTS.md)
- Detailed templates → Instruction files (keep structure reference in AGENTS.md)
Move to other locations:
- Project-specific details → Project documentation
- Historical context → Archive or historical notes
- Human-only notes → Separate documentation
Genericize examples (if keeping in AGENTS.md):
- Specific examples → Generic placeholders (
[Team], [Component], [Process], [Repository], [Workspace])
- Specific tool names → Generic terms (platform-agnostic where possible)
- Implementation-specific details → Generic patterns
- Person/team names → Placeholders or generic references
- Real-world scenarios → Generic templates
Keep examples only if they illustrate unique concepts (make them generic templates with placeholders)
Step 6: Verify Preservation
Ensure:
- All essential actionable guidance remains
- Critical checklists are complete
- Structure templates are intact
- Core principles are actionable
- No critical content lost
Step 7: Verify Quality Improvements
- Verify all inconsistencies resolved (format + content)
- Confirm duplicates removed or consolidated
- Check content moved to appropriate locations
- Verify unnecessary content removed (only AI-agent-irrelevant content)
- Confirm all essential actionable guidance preserved
- Count lines after optimization (for reference only, not a target)
Common Patterns to Optimize
- Verbose Workflow Sections: Multi-paragraph → Condensed step-by-step lists
- Multiple Similar Examples: 3-4 detailed → Single generic template
- Repeated Principles: Same guidance in multiple sections → Single consolidated section
- Explanatory Notes: "Notes" section repeating earlier guidance → Remove
- Integration Details: Detailed workflow → Brief reference only
- Specific Examples: Real-world with names → Generic templates with placeholders
- Duplicate Guidance: Same content in DO/DON'T, Principles, and Common Issues → Consolidate
- Platform-Specific Details: Tool-specific → Generic platform-agnostic patterns
- Implementation-Specific Examples: Specific details → Generic patterns with placeholders
- Format Inconsistencies: Mixed formatting styles → Standardized format throughout
- Content Contradictions: Conflicting instructions → Resolved to single authoritative guidance
- Terminology Inconsistencies: Same concept, different names → Consistent terminology
AGENTS.md Structure Rules
Navigation Layer Only:
- Workflows with instruction files: 1-3 lines + reference (max 3 lines total)
- Workflows without files: Core principles only (<10 bullets)
- Never duplicate step-by-step instructions from instruction files
- Navigation, not detail (tells WHERE to find info, not WHAT the info is)
Critical Rules:
- If instruction file exists: Only summary + reference (3 lines max)
- If no instruction file: Core principles only (<10 bullets)
- Never duplicate step-by-step instructions
- Focus on repeatable patterns, not one-offs
Quality Checklist
After Optimization:
Usage
Run this command when:
- Format inconsistencies detected (mixed styles, inconsistent structure)
- Content contradictions found (conflicting instructions, contradictory rules)
- Terminology inconsistencies identified (same concept with different names)
- Duplicate content found across sections
- Content that should be moved to instruction files or other locations
- AI-agent-irrelevant content present (human-only notes, historical context)
- AGENTS.md entries duplicate instruction file content
- Multiple sections repeat same guidance
- Examples are verbose or specific (should be genericized or moved)
Don't optimize:
- Files already optimized and consistent
- Files with essential detailed templates/examples that must remain specific
- Files where all content is needed for AI agents
Output
Optimized AGENTS.md file with:
- All essential guidance preserved
- All inconsistencies resolved (format + content)
- Duplicate content consolidated or removed
- Content moved to appropriate locations (instruction files, project docs, etc.)
- AI-agent-irrelevant content removed
- Generic placeholders instead of specific examples (where appropriate)
- Concise, AI-consumable format
- Navigation layer maintained (references to instruction files)
- Consistent formatting throughout (standardized headings, lists, links, code blocks)
- All contradictions resolved (single authoritative guidance)
- Consistent terminology and naming conventions
Note: Size reduction is a byproduct of quality improvements, not the primary goal. Focus on consistency, removing duplicates, and optimizing for AI agent consumption.
1---2name: optimize-workspace-context3description: Optimize CLAUDE.md or AGENTS.md files for AI consumption. Focus on quality improvements — inconsistencies, duplicates, unnecessary content, content that should be moved elsewhere. Use when asked to optimize, review, or clean up an AI config file.4---56# Optimize CLAUDE.md / AGENTS.md for AI Consumption78**Purpose**: Optimize `CLAUDE.md` or `AGENTS.md` files for AI agent/machine consumption. Focus on quality improvements: inconsistencies, duplicates, unnecessary content, and content that should be moved elsewhere. Preserve all essential actionable guidance.910**Target**: Any `CLAUDE.md` or `AGENTS.md` file in doc workspaces or code repositories. Size reduction is a byproduct, not the primary goal.1112---1314## Optimization Process1516### Step 1: Analyze Current State17181. Count total lines in `AGENTS.md` (for context only, not a target)192. Identify verbose sections (paragraphs, long explanations, multiple examples)203. Find duplicate content across sections214. Identify specific examples that could be genericized225. Check for content that duplicates instruction files236. Identify content that should be moved to instruction files or other locations247. Find content that isn't needed for AI agents (human-only notes, historical context, etc.)2526### Step 1.5: Identify Inconsistencies2728**Format Inconsistencies:**29- Inconsistent heading levels (H2 vs H3 for similar content)30- Mixed list formats (bullets vs numbered vs dashes)31- Inconsistent code block formatting (language tags, indentation)32- Inconsistent link formats (markdown vs wiki-style vs plain text)33- Inconsistent checkbox syntax (`- [ ]` vs `- [x]` vs `* [ ]`)34- Inconsistent spacing (blank lines, indentation)35- Inconsistent emphasis (bold vs italic vs code formatting)3637**Content Inconsistencies:**38- Same concept described differently in multiple sections39- Conflicting file naming conventions (different formats for same file type)40- Conflicting directory structure guidance41- Different workflow descriptions for same process42- Inconsistent terminology (same concept with different names)43- Conflicting formatting rules (e.g., "use bullets" vs "use paragraphs")4445**Contradictory Instructions:**46- One section says "do X" while another says "don't do X"47- Conflicting rules about when to use certain formats48- Contradictory guidance on file organization49- One workflow contradicts another workflow50- Different sections give opposite advice for same scenario51- Conflicting examples showing different approaches5253**Resolution Strategy:**541. **Identify all instances** of each inconsistency pattern552. **Determine authoritative source** (most specific, most recent, or most referenced)563. **Resolve contradictions** by:57 - Keeping the more specific/complete guidance58 - Removing the less accurate version59 - Merging complementary guidance when both are valid60 - Adding clarifying notes if context-dependent614. **Standardize format** across all sections625. **Update all references** to use consistent terminology636. **Document resolution** in comments if needed (remove after verification)6465**Common Contradiction Patterns:**66- File naming: Multiple formats for same file type → Standardize to one format67- Workflow steps: Different step counts/orders → Consolidate to authoritative version68- Formatting rules: "Use X" vs "Use Y" → Choose one, document exception if needed69- Organization: Different folder structures → Standardize to one structure70- Terminology: Same concept, different names → Use consistent term throughout7172### Step 2: Remove Redundancy7374**Consolidate:**75- Duplicate guidance appearing in multiple sections → Single consolidated section76- Similar checklists → Merge into one77- Repeated principles → Single location with cross-reference78- Same content in DO/DON'T, Principles, and Common Issues → One section only7980**Use cross-references instead of repeating content:**81- If instruction file exists: Replace detailed steps with 1-3 line summary + reference82- If content appears elsewhere: Reference it, don't duplicate8384### Step 3: Condense Content8586**Convert:**87- Paragraphs → Bullet points88- Explanations → Actionable steps89- Multiple examples → Single generic template90- Detailed descriptions → Concise requirements91- Verbose workflows → Step-by-step lists92- Multi-line bullet lists → Single-line comma-separated formats93- Numbered lists with explanations → Concise bullet points94- Verbose section headers → Condensed inline descriptions9596**Specific patterns:**97- Content Filters: Multi-line bullets → Single-line comma-separated98- Workflow descriptions: Numbered lists with explanations → Concise bullets99- Workspace structure: Nested descriptions → Single-line comma-separated lists100- Instruction file lists: Shorten descriptions, remove redundant phrases101102### Step 4: Remove Unnecessary Content103104**Remove (AI-agent-irrelevant only):**105- Content that isn't needed for AI agents (human-only notes, historical context, evolution notes)106- Redundant descriptions repeating earlier content (after consolidation)107- Multiple examples of the same concept (keep one generic template)108- Generic productivity advice (not workspace-specific)109- Notes sections repeating earlier guidance (after consolidation)110- Integration workflow details (keep references only)111112**Do NOT remove:**113- Essential actionable guidance114- Critical checklists115- Structure templates116- Core principles117- Workflow references118- File naming conventions119120**Keep:**121- Essential structure templates122- Actionable workflow steps123- Core principles (DO/DON'T lists)124- Critical checklists125- Common issues and fixes126- File naming conventions127- Related instruction references128129### Step 5: Move Content to Appropriate Locations130131**Move to instruction files:**132- Detailed step-by-step workflows → Instruction files (keep only reference in AGENTS.md)133- Verbose examples → Instruction files (keep generic template in AGENTS.md)134- Detailed templates → Instruction files (keep structure reference in AGENTS.md)135136**Move to other locations:**137- Project-specific details → Project documentation138- Historical context → Archive or historical notes139- Human-only notes → Separate documentation140141**Genericize examples (if keeping in AGENTS.md):**142- Specific examples → Generic placeholders (`[Team]`, `[Component]`, `[Process]`, `[Repository]`, `[Workspace]`)143- Specific tool names → Generic terms (platform-agnostic where possible)144- Implementation-specific details → Generic patterns145- Person/team names → Placeholders or generic references146- Real-world scenarios → Generic templates147148**Keep examples only if they illustrate unique concepts** (make them generic templates with placeholders)149150### Step 6: Verify Preservation151152**Ensure:**153- All essential actionable guidance remains154- Critical checklists are complete155- Structure templates are intact156- Core principles are actionable157- No critical content lost158159### Step 7: Verify Quality Improvements1601611. Verify all inconsistencies resolved (format + content)1622. Confirm duplicates removed or consolidated1633. Check content moved to appropriate locations1644. Verify unnecessary content removed (only AI-agent-irrelevant content)1655. Confirm all essential actionable guidance preserved1666. Count lines after optimization (for reference only, not a target)167168---169170## Common Patterns to Optimize171172- **Verbose Workflow Sections**: Multi-paragraph → Condensed step-by-step lists173- **Multiple Similar Examples**: 3-4 detailed → Single generic template174- **Repeated Principles**: Same guidance in multiple sections → Single consolidated section175- **Explanatory Notes**: "Notes" section repeating earlier guidance → Remove176- **Integration Details**: Detailed workflow → Brief reference only177- **Specific Examples**: Real-world with names → Generic templates with placeholders178- **Duplicate Guidance**: Same content in DO/DON'T, Principles, and Common Issues → Consolidate179- **Platform-Specific Details**: Tool-specific → Generic platform-agnostic patterns180- **Implementation-Specific Examples**: Specific details → Generic patterns with placeholders181- **Format Inconsistencies**: Mixed formatting styles → Standardized format throughout182- **Content Contradictions**: Conflicting instructions → Resolved to single authoritative guidance183- **Terminology Inconsistencies**: Same concept, different names → Consistent terminology184185---186187## AGENTS.md Structure Rules188189**Navigation Layer Only:**190- Workflows with instruction files: 1-3 lines + reference (max 3 lines total)191- Workflows without files: Core principles only (<10 bullets)192- Never duplicate step-by-step instructions from instruction files193- Navigation, not detail (tells WHERE to find info, not WHAT the info is)194195**Critical Rules:**196- If instruction file exists: Only summary + reference (3 lines max)197- If no instruction file: Core principles only (<10 bullets)198- Never duplicate step-by-step instructions199- Focus on repeatable patterns, not one-offs200201---202203## Quality Checklist204205**After Optimization:**206- [ ] All essential actionable guidance preserved207- [ ] No critical checklists removed208- [ ] Structure templates intact209- [ ] Core principles actionable210- [ ] No duplicate content across sections211- [ ] All inconsistencies resolved (format + content)212- [ ] Examples genericized (placeholders, not specifics)213- [ ] Content is concise and AI-consumable214- [ ] Steps are actionable, not theoretical215- [ ] Formatting consistent throughout (headings, lists, code blocks, links)216- [ ] Navigation layer maintained (references, not details)217- [ ] No contradictory instructions (all conflicts resolved)218- [ ] Consistent terminology used throughout219- [ ] File naming conventions standardized220- [ ] Workflow descriptions consistent (no conflicting steps)221- [ ] Formatting rules consistent (no "do X" vs "do Y" conflicts)222- [ ] Content moved to appropriate locations (instruction files, project docs, etc.)223- [ ] AI-agent-irrelevant content removed (only unnecessary content)224225---226227## Usage228229Run this command when:230- Format inconsistencies detected (mixed styles, inconsistent structure)231- Content contradictions found (conflicting instructions, contradictory rules)232- Terminology inconsistencies identified (same concept with different names)233- Duplicate content found across sections234- Content that should be moved to instruction files or other locations235- AI-agent-irrelevant content present (human-only notes, historical context)236- AGENTS.md entries duplicate instruction file content237- Multiple sections repeat same guidance238- Examples are verbose or specific (should be genericized or moved)239240**Don't optimize:**241- Files already optimized and consistent242- Files with essential detailed templates/examples that must remain specific243- Files where all content is needed for AI agents244245---246247## Output248249Optimized `AGENTS.md` file with:250- All essential guidance preserved251- All inconsistencies resolved (format + content)252- Duplicate content consolidated or removed253- Content moved to appropriate locations (instruction files, project docs, etc.)254- AI-agent-irrelevant content removed255- Generic placeholders instead of specific examples (where appropriate)256- Concise, AI-consumable format257- Navigation layer maintained (references to instruction files)258- Consistent formatting throughout (standardized headings, lists, links, code blocks)259- All contradictions resolved (single authoritative guidance)260- Consistent terminology and naming conventions261262**Note**: Size reduction is a byproduct of quality improvements, not the primary goal. Focus on consistency, removing duplicates, and optimizing for AI agent consumption.