Skip to main content

Claude audit CLAUDE.md for bloat

Code
By TenaciousTenrec69 | 94 views 2 copies |

Prompt

Audit CLAUDE.md files for bloat, duplication, and context efficiency with INTERACTIVE approval for each change. ## Instructions ### Phase 1: READ & ANALYZE 1. READ both files: - `~/.claude/CLAUDE.md` (global) - `CLAUDE.md` (project, if exists) 2. IDENTIFY issues: - **Exact duplicates**: Same instruction in both files - **Semantic duplicates**: Same meaning, different wording - **Default behaviors**: Things Claude does anyway (waste of tokens) - **Verbose phrasing**: Could be compressed to fewer words - **Misplaced scope**: Global items in project or vice versa - **Stale/outdated**: Instructions that no longer apply 3. BE AGGRESSIVE - every line costs context tokens. If it's not essential, flag it. 4. CATEGORIZE findings: - **Project removals**: Content to delete from project CLAUDE.md - **Global optimizations**: Content to compress/rewrite in global CLAUDE.md - **Moves**: Content to move from project global 5. **CREATE BACKUP of global CLAUDE.md** BEFORE any modifications: - Get current date/time: `powershell -Command "Get-Date -Format 'MM-dd-yyyy_hh-mm-tt'"` - PowerShell returns uppercase (e.g., `01-14-2026_09-14-PM`), convert to lowercase: `01-14-2026_09-14-pm` - Final format: `claude-MM-DD-YYYY_HH-MM-am/pm.bak` (NOT military time) - Example: `claude-01-14-2026_09-14-pm.bak` - Use Bash to copy with lowercase conversion - Confirm backup created with full path and show timestamp used ### Phase 2: INTERACTIVE APPROVAL & EXECUTION **CRITICAL: DO NOT make ANY edits without explicit user approval for EACH change.** For each finding, present ONE AT A TIME in this order: #### A. PROJECT CLAUDE.md REMOVALS For each piece of content to remove from project CLAUDE.md: 1. **Show the content**: ``` Lines X-Y: [exact content to be removed] ``` 2. **Explain justification**: - Why is this wasteful? (e.g., "Duplicate of global line Z", "User-facing docs, not AI instructions", "Claude default behavior") - Token impact (if significant) 3. **Ask for approval** using AskUserQuestion: - Question: "Remove this content from project CLAUDE.md?" - Options: - "Yes, remove it" (Recommended) - "No, keep it" 4. **If approved**: Use Edit tool to remove, then show confirmation: ``` Removed lines X-Y from project CLAUDE.md ``` 5. **If rejected**: Move to next item, note the rejection for final summary. #### B. GLOBAL CLAUDE.md OPTIMIZATIONS For each optimization to global CLAUDE.md: 1. **Show current content**: ``` Lines X-Y (CURRENT): [exact current content] ``` 2. **Show proposed change**: ``` Lines X-Y (PROPOSED): [optimized rewrite] ``` 3. **Explain justification**: - Why compress/modify? (e.g., "Same meaning in 50 percent fewer tokens", "Redundant explanation removed", "Combined duplicate rules") - Token savings estimate 4. **Ask for approval** using AskUserQuestion: - Question: "Apply this optimization to global CLAUDE.md?" - Options: - "Yes, apply it" (Recommended) - "No, keep current" 5. **If approved**: Use Edit tool to apply, then show confirmation: ``` Optimized lines X-Y in global CLAUDE.md (saved ~N tokens) ``` 6. **If rejected**: Move to next item, note the rejection for final summary. #### C. CONTENT MOVES (Project Global) For each piece to move from project to global: 1. **Show the content**: ``` Lines X-Y in project CLAUDE.md: [content to move] ``` 2. **Explain justification**: - Why does this belong in global? (e.g., "Applies to all projects", "Not project-specific") 3. **Ask for approval** using AskUserQuestion: - Question: "Move this content from project CLAUDE.md to global CLAUDE.md?" - Options: - "Yes, move it" (Recommended) - "No, keep in project" 4. **If approved**: - Add to global CLAUDE.md (show where it was added) - Remove from project CLAUDE.md - Show confirmation: ``` Moved content from project global CLAUDE.md ``` 5. **If rejected**: Move to next item, note the rejection for final summary. ### Phase 3: FINAL SUMMARY After all changes are processed (approved or rejected), provide: ```markdown ## Audit Complete ### Changes Applied **Project CLAUDE.md:** - Removed lines X-Y: [brief description] - Removed lines A-B: [brief description] - Kept lines C-D: [reason user rejected] **Global CLAUDE.md:** - Optimized lines X-Y: [brief description] (saved ~N tokens) - Optimized lines A-B: [brief description] (saved ~N tokens) - Kept lines C-D unchanged: [reason user rejected] **Moves:** - Moved lines X-Y from project global ### Token Savings Estimate | File | Before | After | Saved | |------|--------|-------|-------| | Global | ~X tokens | ~Y tokens | ~Z percent | | Project | ~A tokens | ~B tokens | ~C percent | | **Total** | ~X+A tokens | ~Y+B tokens | **~D percent** | ### Rejected Changes (User Kept) - [List any changes user chose not to apply] ``` ## Important Guidelines 1. **One change at a time**: Do NOT batch multiple changes into a single approval question 2. **Show actual content**: Always display the exact lines being modified/removed, not summaries 3. **Clear justification**: Explain the "why" for every recommendation 4. **Respect rejections**: If user says no, move on without argument 5. **Track progress**: Keep running count of changes (e.g., "Processing item 3 of 12...") 6. **Use Edit tool**: Apply approved changes immediately after approval 7. **Confirm each edit**: After using Edit tool, show what was changed

Rate this prompt

Click to rate

0.0 avg rating (0)

Notes

Tip: Save this in your .claude/commands folder as "audit-claude-context.md" Then call it /audit-claude-context when needed.
Subcategory: Claude