Part of Anthropic Claude Code in Action
A practical context engineering stack built around three MCP tools, designed so Claude can work on large codebases efficiently across sessions without reloading everything each time.
Every Claude Code session starts cold. To understand a codebase, Claude must re-read files or repack with repomix. For small tasks this is fine. For ongoing work on large codebases, it means constant reloading of context that hasn't changed.
| Layer | Tool | Purpose |
|---|---|---|
| Live Layer | repomix (via mcporter) | Pack and read current codebase content |
| Structural Layer | mcp-knowledge-graph | Persist architectural knowledge across sessions |
| Tool Access Layer | mcporter | Load MCP schemas on demand — not permanently |
┌──────────────────────────────────────────────────────────┐
│ LIVE LAYER (this session) │
│ repomix.pack_codebase() → current code, compressed │
├──────────────────────────────────────────────────────────┤
│ STRUCTURAL LAYER (persists across sessions) │
│ knowledge-graph → entities, relations, decisions │
├──────────────────────────────────────────────────────────┤
│ TOOL ACCESS LAYER (always available, zero overhead) │
│ mcporter → on-demand MCP tools, no schema cost │
└──────────────────────────────────────────────────────────┘
Session 1 — build the index:
repomix.pack_codebase(compress: true)— get full codebase (~70% token reduction via Tree-sitter)- Read and analyze output — extract components, services, modules
aim_memory_store()— persist entities to knowledge graphaim_memory_link()— record typed relations (depends_on, calls, owns)
Session 2+ — query the index:
aim_memory_search("auth")— instant lookup, no repackingaim_memory_get(["AuthService"])— exact entity retrieval
On code change:
- Repack only the changed module, update only affected graph entries
Using repomix to pack the mcp-knowledge-graph source revealed constraints the README didn't mention:
| Detail Found in Source | Impact |
|---|---|
| Full file rewrite on every write | Large graphs degrade performance |
| Substring search only (no semantic) | Naming consistency when storing is critical |
| No write locking | Concurrent sessions can corrupt the graph |
| Project detection climbs 5 directory levels | Affects which .aim/ is used |
This changed how the tool gets used. README-only integration produces brittle setups.
The method: repomix --remote user/repo → analyze source → write skill based on actual behavior.
A complete integration requires three things:
- Binary — installed under the correct Node version
- mcporter entry — wired into
~/.mcporter/mcporter.json - Skill file —
~/.claude/skills/tool-name/SKILL.mdteaching Claude when and how to use it
The skill file is the behavioral contract. Without it, Claude knows the tool exists but not when to use it, which calls to make in sequence, or how to interpret output.
Claude acts as orchestrator and reviewer, delegating execution to other CLI tools:
| Task | Tool | Why |
|---|---|---|
| Long-context retrieval | gemini-cli | 1M token context window |
| Structured planning | codex | Strong at specification reasoning |
| Code execution | claude-code subagent | Best tool use and editing |
| Review | main claude-code session | Architecture decisions |
Result handling is simple: stdout from the delegated bash call flows back to the main context automatically.
| File | Contents |
|---|---|
README.md |
This overview |
docs-context-stack.md |
Detailed architecture analysis |
docs-multi-agent.md |
Subprocess delegation pattern |
skill-repomix.md |
Claude skill file for repomix |
skill-knowledge-graph.md |
Claude skill file for mcp-knowledge-graph |
example-repomix.config.json |
repomix project config |