Generate comprehensive map of current context knowledge with token costs
Analyze your current context to identify token waste and optimization opportunities. Use this when context feels bloated or you're approaching token limits to get actionable pruning recommendations.
/plugin marketplace add vzwjustin/Claudecontext/plugin install vzwjustin-context-window-manager@vzwjustin/ClaudecontextCreate a detailed knowledge map of everything currently in context, showing what Claude knows and what it costs.
Use an agent to analyze and map all context components:
For each file in context:
📄 src/main.py (8,500 tokens)
├─ Last accessed: 5 minutes ago
├─ Access count: 12 times
├─ Contains:
│ ├─ function main() - entry point
│ ├─ function process_data() - data processing
│ ├─ class DataHandler - data management
│ └─ 15 imports from external libraries
├─ Referenced by: src/utils.py, tests/test_main.py
├─ Depends on: config.json, utils.py
├─ Usage: ACTIVE (currently discussing)
└─ Prune recommendation: ❌ KEEP (active use)
Analyze conversation context:
💬 Message History (45,000 tokens)
├─ Total messages: 87
├─ Time span: 2h 15m
├─ Topics covered:
│ ├─ Database schema design (20 messages, ~10K tokens)
│ ├─ Bug fixing in auth module (15 messages, ~8K tokens)
│ ├─ Code review discussions (12 messages, ~6K tokens)
│ ├─ General questions (40 messages, ~21K tokens)
├─ Compressible: ~15K tokens (33%)
│ └─ Old messages (>1h ago) could be summarized
└─ Prune recommendation: ⚠️ SUMMARIZE old messages
Track tool output in context:
🔧 Tool Results (28,000 tokens)
├─ Read operations: 15 results (~12K tokens)
├─ Grep results: 8 results (~5K tokens)
├─ Bash outputs: 6 results (~8K tokens)
├─ Write confirmations: 10 results (~3K tokens)
├─ Oldest result: 45 minutes ago
├─ Still relevant: 8 results (~10K tokens)
└─ Prune recommendation: ✓ CLEAR 18K tokens of old results
System knowledge being tracked:
🧠 System Context (12,000 tokens)
├─ Session initialization
├─ Custom instructions
├─ Plugin configurations
├─ MCP server data
├─ Working directory info
└─ Prune recommendation: ❌ KEEP (required)
Visualize relationships:
┌─────────────────────────────────────────────────┐
│ CONTEXT KNOWLEDGE GRAPH │
├─────────────────────────────────────────────────┤
│ │
│ config.json ──────┬──────> main.py │
│ ↓ │ ↓ │
│ schema.sql └──────> utils.py │
│ ↓ ↓ │
│ test-output.log tests/test_*.py │
│ [12K tokens] [15K tokens] │
│ ⚠️ PRUNE ✓ KEEP │
│ │
│ Message Flow: │
│ [Initial Q] → [Exploration] → [Implementation] │
│ [40K tokens] [25K tokens] [15K tokens] │
│ ⚠️ SUMMARIZE ✓ KEEP ✓ KEEP │
└─────────────────────────────────────────────────┘
Detailed token accounting:
╔═══════════════════════════════════════════════╗
║ TOKEN ALLOCATION MAP ║
╠═══════════════════════════════════════════════╣
║ ║
║ Category Tokens % Action ║
║ ──────────────── ──────── ───── ──────── ║
║ Active Files 35,000 24% KEEP ║
║ Inactive Files 18,000 12% PRUNE ║
║ Recent Messages 30,000 21% KEEP ║
║ Old Messages 15,000 10% COMPRESS ║
║ Fresh Tools 10,000 7% KEEP ║
║ Stale Tools 18,000 12% CLEAR ║
║ System Context 12,000 8% KEEP ║
║ Other 8,000 6% REVIEW ║
║ ──────────────── ──────── ───── ──────── ║
║ TOTAL 146,000 100% ║
║ ║
║ Prunable: 51,000 35% ║
║ After Pruning: 95,000 65% → 47% of 200K║
║ Status Change: 🟡 Warning → 🟢 Healthy ║
╚═══════════════════════════════════════════════╝
Rate how useful current context is:
Knowledge Quality Metrics:
├─ Relevance Score: 78/100
│ └─ 22% of context not used in last 30min
├─ Efficiency Score: 65/100
│ └─ 35% prunable without information loss
├─ Coherence Score: 85/100
│ └─ Most context relates to current task
└─ Recommendation: PRUNE to increase efficiency
Based on knowledge map:
📊 SMART RECOMMENDATIONS:
Immediate (High Value):
1. Remove test-output.log (12K tokens)
- Last accessed: 45 mins ago
- Content: Already reviewed
- Risk: None (reproducible)
2. Clear stale Bash outputs (8K tokens)
- Results from completed operations
- No longer referenced
- Risk: None
3. Prune schema.sql (18K tokens)
- Last accessed: 60 mins ago
- Original task completed
- Risk: Low (can reload)
Medium Priority:
4. Summarize early messages (15K tokens → 5K)
- Compress first 30 messages
- Preserve key decisions
- Risk: Low (detail loss acceptable)
Low Priority:
5. Remove backup-config.json (8K tokens)
- Duplicate of main config
- Never referenced
- Risk: None
TOTAL SAVINGS: 51K tokens (35% reduction)
TIME TO EXECUTE: ~30 seconds
This command uses the Explore agent to:
Speed: ~10x faster than manual analysis Accuracy: Uses actual /context output + heuristics Coverage: Analyzes 100% of context automatically
Choose your preferred format:
Let me generate your context knowledge map now using an agent for speed.