Mikk
Guides

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, getSessionExpiry

Walk — 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
               →  writeSession

Score — rank every function

Each reachable function receives a composite score:

FactorWeight
Graph proximity to seedHigh
Keyword match with taskMedium
Entry point bonusLow
Module boundary matchLow

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:

FormatUse case
xmlClaude (default) — structured <function> tags
textGeneric — plain text with headers
compactTight 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 1000

Prop

Type

Impact Analysis

Before touching any file, see what you'd break:

mikk context impact src/auth/login.ts
Impact 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:

SectionContent
Tier 1: OverviewProject name, language, framework, entry points
Tier 2: ModulesEach module's intent, file count, public API
Tier 3: Key functionsHighest-importance functions with signatures
Tier 4: ConstraintsAll architectural rules in plain English
Tier 5: DecisionsADRs summarized for AI context

Was this page helpful?

On this page