12. Context Packing Tools
When working with LLMs on large codebases, context packing refers to techniques for extracting and feeding relevant code context to the model efficiently.
Why Context Matters
Claude Code automatically reads files as needed, but external tools exist for:
- Pre-session preparation: Dump relevant code before starting
- Cross-tool workflows: Feed context to models outside Claude Code
- Offline analysis: Prepare context for later use
Available Tools
| Tool | Purpose | How It Works |
|---|---|---|
| gitingest | Repo → text dump | Extracts relevant files into a single text file for LLM consumption |
| repo2txt | Repo → formatted context | Similar to gitingest, with formatting options |
| Context7 MCP | Docs lookup | Fetches library documentation on-demand (see MCP section) |
When to Use (and When Not)
| Scenario | Best Approach |
|---|---|
| Working in Claude Code | Let Claude read files naturally (no pre-dumping needed) |
| Feeding context to ChatGPT/Gemini | gitingest/repo2txt useful |
| Preparing spec for team review | Export relevant files to share |
| Very large monorepo (>1M LOC) | May help with selective extraction |
Note: Claude Code's native file access is usually sufficient. These tools are most useful for cross-tool workflows or when working with models that don't have file system access.
Source
- Addy Osmani: My AI Coding Workflow in 2026, discussing context packing as part of a broader AI development workflow
Architecture Diagrams as Context (Advanced Pattern)
For large OOP codebases, research confirms LLMs struggle with polymorphism and dependency reasoning when processing files in chunks (ACM 2024: "LLMs Still Can't Avoid Instanceof").
Problem: File chunking loses structural relationships (class hierarchies, interface implementations, cross-module dependencies).
Solution: Include architecture diagrams in project context to provide explicit relationships.
Approaches
| Approach | Maintenance | Token Cost | Best For |
|---|---|---|---|
| Archy MCP | Zero (auto-gen) | On-demand | GitHub repos with class hierarchies |
| Inline Mermaid | Manual | 200-500 tokens | Custom architectural views |
| PlantUML ref | Manual | Minimal | Enterprise/IDE integration |
MCP Tools for Architecture Visualization
Archy MCP (phxdev1, April 2025):
- Auto-generates Mermaid from GitHub repos or text descriptions
- Supports: flowcharts, class diagrams, sequence diagrams
- URL: pulsemcp.com/servers/phxdev1-archy
Mermaid MCP (hustcc, 61.4K users):
- Custom themes, background colors
- Real-time rendering
Blueprint MCP (ArcadeAI):
- Text descriptions → technical diagrams
- Async job management
Inline Example (CLAUDE.md)
## Architecture Overview
\`\`\`mermaid
classDiagram
class UserService {
+authenticate()
+getProfile()
}
class AuthProvider {
<<interface>>
+validate()
}
UserService --> AuthProvider
\`\`\`When to Use
- OOP codebases >20 modules with complex inheritance
- Java/Spring projects with deep polymorphism
- When Serena symbol overview is insufficient
Recommended Workflow
- Try Serena first:
get_symbols_overview+find_symbol(zero maintenance) - If insufficient: Use Archy MCP to auto-generate class diagrams
- Last resort: Manual inline Mermaid for custom views
Key Insight
"Context structure matters more than context size." Explicit relationships improve LLM reasoning on OOP architectures.
Source: LinkedIn discussion (Jan 2026)
Note: Pattern reported on Java/Spring project. Not validated at scale. Alternative Serena + grepai achieves similar results with zero maintenance.