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)Parameters
Section titled “Parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
name | string | required | Symbol to inspect |
compact | boolean | false | Show callers and callees as signatures only (saves ~70% tokens) |
depth | number | 1 | Levels of related functions to include |
Output
Section titled “Output”--- 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)When to use
Section titled “When to use”- 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
compact mode
Section titled “compact mode”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%.