Skip to content

code_context

code_context returns a combined view: the target function’s full code, every function that calls it, and every function it calls. It replaces three separate tool calls (code_get, code_callers, code_callees) with one.

code_context(name="OrderService.checkout")
code_context(name="UserService", compact=true)
ParameterTypeDefaultDescription
namestringrequiredSymbol to inspect
compactbooleanfalseShow callers and callees as signatures only (saves ~70% tokens)
depthnumber1Levels of related functions to include
--- Code ---
async checkout(order: Order): Promise<Receipt> {
const charge = await PaymentService.charge(order.total);
await InventoryService.reserve(order.items);
...
}
--- Callers (2) ---
OrderController.create (src/controllers/order.ts:31)
OrderService.retry (src/services/order.ts:201)
--- Callees (3) ---
PaymentService.charge (src/services/payment.ts:18)
InventoryService.reserve (src/services/inventory.ts:91)
NotificationService.send (src/services/notify.ts:33)
  • Understanding an unfamiliar function and its connections in one shot
  • Before refactoring — see what depends on the function and what it depends on
  • Code review — quickly understand a changed function’s blast radius

Use compact=true when you only need to know which functions are connected, not their full bodies:

code_context(name="AuthService", compact=true)

This keeps caller and callee entries to one line each, cutting token usage by roughly 70%.