trace_execution_path
Trace code execution paths across multiple files to understand complex call flows, identify issues, and assess technical debt with architectural insights.
Instructions
Trace execution path through multiple files starting from an entry point. Shows complete call flow with intelligent analysis and architectural insights.
WORKFLOW: Perfect for understanding complex code, identifying issues, and technical debt assessment TIP: Use Desktop Commander to read files, then pass content here for analysis SAVES: Claude context for strategic decisions
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| analysisDepth | No | Level of analysis detail | detailed |
| analysisType | No | Type of analysis to perform | comprehensive |
| code | No | The code to analyze (for single-file analysis) | |
| entryPoint | Yes | Entry point like ClassName::methodName or functionName | |
| filePath | No | Path to single file to analyze | |
| files | No | Array of specific file paths (for multi-file analysis) | |
| language | No | Programming language | javascript |
| maxDepth | No | Maximum directory depth for multi-file discovery (1-5) | |
| projectPath | No | Path to project root (for multi-file analysis) | |
| showParameters | No | Include parameter information in trace | |
| traceDepth | No | Maximum depth to trace (1-10) |
Implementation Reference
- Core handler function that implements the trace_execution_path tool logic. Handles security wrapping, parameter validation, mode detection (single/multi-file), model setup, and dispatches to specialized analysis methods.async execute(params: any, llmClient: any) { return await withSecurity(this, params, llmClient, async (secureParams) => { try { // 1. Auto-detect analysis mode based on parameters const analysisMode = this.detectAnalysisMode(secureParams); // 2. Validate parameters based on detected mode this.validateParameters(secureParams, analysisMode); // 3. Setup model const { model, contextLength } = await ModelSetup.getReadyModel(llmClient); // 4. Route to appropriate analysis method if (analysisMode === 'single-file') { return await this.executeSingleFileAnalysis(secureParams, model, contextLength); } else { return await this.executeMultiFileAnalysis(secureParams, model, contextLength); } } catch (error: any) { return ErrorHandler.createExecutionError('trace_execution_path', error); } }); }
- src/validation/schemas.ts:356-378 (schema)Output schema definition (TraceExecutionPathResponse) for the trace_execution_path tool response validation.export interface TraceExecutionPathResponse extends BaseResponse { data: { trace: Array<{ level: number; file: string; function: string; line: number; parameters?: string[]; calls: Array<{ function: string; file: string; line: number; }>; }>; summary: { totalCalls: number; uniqueFunctions: number; filesInvolved: string[]; maxDepthReached: boolean; }; visualization: string; }; }
- Input parameter schema definition for the trace_execution_path tool, supporting both single-file and multi-file analysis modes with execution tracing specifics.parameters = { // Single-file parameters code: { type: 'string' as const, description: 'The code to analyze (for single-file analysis)', required: false }, filePath: { type: 'string' as const, description: 'Path to single file to analyze', required: false }, // Multi-file parameters projectPath: { type: 'string' as const, description: 'Path to project root (for multi-file analysis)', required: false }, files: { type: 'array' as const, description: 'Array of specific file paths (for multi-file analysis)', required: false, items: { type: 'string' as const } }, maxDepth: { type: 'number' as const, description: 'Maximum directory depth for multi-file discovery (1-5)', required: false, default: 3 }, // Execution tracing specific parameters entryPoint: { type: 'string' as const, description: 'Entry point like ClassName::methodName or functionName', required: true }, traceDepth: { type: 'number' as const, description: 'Maximum depth to trace (1-10)', required: false, default: 5 }, showParameters: { type: 'boolean' as const, description: 'Include parameter information in trace', required: false, default: false }, // Universal parameters language: { type: 'string' as const, description: 'Programming language', required: false, default: 'javascript' }, analysisDepth: { type: 'string' as const, description: 'Level of analysis detail', enum: ['basic', 'detailed', 'comprehensive'], default: 'detailed', required: false }, analysisType: { type: 'string' as const, description: 'Type of analysis to perform', enum: ['execution-flow', 'call-graph', 'comprehensive'], default: 'comprehensive', required: false } };
- src/prompts/analyze/trace-execution.ts:26-30 (registration)Plugin class declaration with tool name 'trace_execution_path', category, and description - serves as the tool registration.export class ExecutionPathTracer extends BasePlugin implements IPromptPlugin { name = 'trace_execution_path'; category = 'analyze' as const; description = 'Trace execution path through multiple files starting from an entry point. Shows complete call flow with intelligent analysis and architectural insights.';