AI Context Guide
How Mikk builds token-budgeted, graph-traced context payloads — and how to tune them for your AI workflow.
The core problem with AI + codebases
Dumping your entire codebase into an LLM context window is wasteful and ineffective. Mikk solves this by tracing only the functions your task actually touches — giving AI assistants the exact context they need, nothing more.
How Context Building Works
The 5-Step Algorithm
Seed — find the entry points
Mikk matches your task description against function names, descriptions, and module intents stored in mikk.lock.json.
mikk context build "Fix the session expiry bug"
# Seeds: validateToken, refreshSession, getSessionExpiryWalk — BFS graph traversal
From each seed function, Mikk traces the call graph outward using BFS. Configurable with --hops (default: 2).
validateToken → parseJWT → getKeystore
→ checkExpiry
refreshSession → validateToken
→ writeSessionScore — rank every function
Each reachable function receives a composite score:
| Factor | Weight |
|---|---|
| Graph proximity to seed | High |
| Keyword match with task | Medium |
| Entry point bonus | Low |
| Module boundary match | Low |
Budget — greedy knapsack
Functions are packed into the context payload in score order until the token budget is exhausted.
Each function's token cost is pre-computed from its source body in mikk.lock.json.
Format — provider-specific output
The payload is formatted for your target AI:
| Format | Use case |
|---|---|
xml | Claude (default) — structured <function> tags |
text | Generic — plain text with headers |
compact | Tight budgets — minimal whitespace, no source bodies |
CLI Usage
# Basic context build
mikk context build "How does authentication work?"
# With custom token budget
mikk context build "Refactor the payments module" --tokens 8000
# XML format for Claude, 3 hops deep
mikk context build "Debug the login flow" --format xml --hops 3
# Compact format for tight context windows
mikk context build "What does parseToken do?" --format compact --tokens 1000Prop
Type
Impact Analysis
Before touching any file, see what you'd break:
mikk context impact src/auth/login.tsImpact analysis for: src/auth/login.ts
Direct dependents (3):
src/api/routes.ts (imports: login)
src/auth/session.ts (imports: login, validateToken)
tests/auth/login.test.ts (imports: login)
Transitive blast radius (8 files):
src/api/middleware.ts
src/api/user.ts
...
Estimated impact: HIGH (8 files, 2 public API consumers)MCP Usage
When connected via MCP, your AI assistant can call context tools directly:
mikk_build_context({ task: "Add rate limiting to the auth module", tokens: 6000 })
mikk_get_impact({ file: "src/auth/login.ts" })
mikk_get_call_graph({ function: "validateToken", depth: 3 })Tuning Tips
claude.md Structure
The generated claude.md contains tiered architecture information:
| Section | Content |
|---|---|
| Tier 1: Overview | Project name, language, framework, entry points |
| Tier 2: Modules | Each module's intent, file count, public API |
| Tier 3: Key functions | Highest-importance functions with signatures |
| Tier 4: Constraints | All architectural rules in plain English |
| Tier 5: Decisions | ADRs summarized for AI context |
Was this page helpful?
Core Concepts
The Mesh, Merkle-tree hashing, Module Clusters, AI Context Builder, and Intent Pre-flight — the foundational primitives of Mikk.
VS Code Extension
The Mikk VS Code extension brings codebase intelligence directly into your editor — module tree, impact analysis, AI context, and MCP integration.