Code Intelligence
code_intelAnalyze code structure and dependencies to assess impact of changes, find callers, and identify orphaned code using graph intelligence.
Instructions
DECISION RULE: Structure questions → this tool. Text search → Grep.
Before using Grep, ask: Is this a STRUCTURE question (definitions, callers, impact) or a TEXT question (strings, config)?
QUICK START: return await api.searchSymbols({query: "AuthService"}) — simple queries are one-liners.
Run api.listMethods() for full API reference with signatures and descriptions.
Run api.help("methodName") for inline TypeScript type definitions — no resource reads needed.
Compose: const [impact, deps] = await Promise.all([api.impactAnalysis({symbolId}), api.getDependents({filePath})]);
WHY THIS TOOL: Graph-backed intelligence finds indirect relationships, transitive dependencies, and breaking change risks that text search cannot detect.
"What uses X?" disambiguation: getDependents (file imports) vs getCallGraph (call chain) vs traceSymbolUsage (all usages).
USE IMMEDIATELY WHEN: • BEFORE using Edit on a function/class → run impactAnalysis({symbolId}) first • BEFORE exploring an unfamiliar codebase → run getArchitectureOverview() • BEFORE refactoring → trace getDependencies + getDependents for blast radius • Running 3+ Grep calls for structure? STOP → use code_intel instead
TOP 5 QUESTIONS (query is case-insensitive substring match): • "Where is X defined?" / "Find function Y" → searchSymbols({query}) • "What calls X?" / "What imports this?" → getDependents({filePath}) or getCallGraph({symbolId}) • "What does X depend on?" → getDependencies({filePath}) • "Safe to modify X?" / "Blast radius?" → impactAnalysis({symbolId}) • "Find dead code" / "Unused exports?" → findOrphanedCode() • "Complex functions?" / "Refactoring targets?" → searchSymbols results include complexity.cyclomaticComplexity + complexityRisk per function
NOT FOR: literal string search, log messages, config values, or reading source code. Use Grep/Glob/Read for those.
Supports TypeScript, JavaScript, Python, and more — run api.getCapabilities() to check your project.
File-path-scoped methods (getDependencies, getDependents, getCallGraph, traceSymbolUsage, impactAnalysis) reject calls whose filePath extension is not in the project's configured languages with UNSUPPORTED_LANGUAGE — check api.getCapabilities() first.
WRONG TOOL SIGNAL: If you've run 3+ Grep calls for structure (callers, dependencies, impact), STOP and use code_intel instead. Typical workflow: code_intel to find (results include source snippets) → Edit to modify
Sandbox limits: 50 api.* calls per execution, 128 MB memory, 100 KB max code size, limit max 100 on any method with a limit param. Pure JS only — no require/import/fs/net/process (see constellation://docs/guide for full restrictions).
IMPORTANT: The cwd parameter is required — always set it to the target project directory path.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | JavaScript code to execute. Can use top-level await. Available API methods: searchSymbols, getSymbolDetails, getDependencies, getDependents, findCircularDependencies, traceSymbolUsage, getCallGraph, impactAnalysis, findOrphanedCode, getArchitectureOverview | |
| timeout | No | Optional execution-time override in milliseconds. When omitted, the sandbox derives the timeout from the static complexity of your code (heavier api.* methods raise the budget) and clamps the result to [1000, 60000]. The breakdown is returned in the response so you can see what was applied. Explicit values still win and are clamped to the same range. | |
| cwd | Yes | Absolute path to the project directory being queried. Used to locate the correct constellation.json by finding the git repository root. Set this to the root of the repository or workspace folder you are working in. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| success | Yes | ||
| result | No | ||
| logs | No | ||
| time | No | ||
| asOfCommit | No | ||
| lastIndexedAt | No | ||
| resultContext | No | ||
| timeoutBreakdown | No | ||
| error | No |