explain_code
Understand code functionality quickly by providing a detailed explanation of the target code, with optional context for clarity.
Instructions
Provides detailed explanation of the given code.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | Target code | |
| context | No | Additional context |
Implementation Reference
- claude-code-server/src/index.ts:514-531 (handler)Handler for executing the 'explain_code' tool: destructures args, truncates and base64-encodes code if needed, builds prompt, calls Claude CLI via runClaudeCommand, returns text response.case 'explain_code': { const { code, context } = args; try { logger.debug(`Processing explain_code request, code length: ${code.length}`); const encodedCode = encodeText(truncateIfNeeded(code)); logger.debug(`Code encoded to base64, length: ${encodedCode.length}`); // ファイルを使用して大きな入力を渡す場合の代替方法 const prompt = `You are super professional engineer. Please kindly provide a detailed explanation of the following Base64 encoded code:\n\n${encodedCode}\n\nAdditional context (if provided):\n${context || 'No additional context provided.'}`; logger.debug('Calling Claude CLI with prompt'); const output = await runClaudeCommand(['--print'], prompt); logger.debug(`Received response from Claude, length: ${output.length}`); return { content: [{ type: 'text', text: output }] }; } catch (err) { logger.error("Error in explain_code:", err); logger.debug(`explain_code error details: ${err instanceof Error ? err.stack : String(err)}`); throw err; } }
- Input schema definition for the 'explain_code' tool, specifying required 'code' string and optional 'context'.inputSchema: { type: 'object', properties: { code: { type: 'string', description: 'Target code' }, context: { type: 'string', description: 'Additional context', default: '' } }, required: ['code'] }
- claude-code-server/src/index.ts:323-334 (registration)Registration of the 'explain_code' tool in the ListTools response, including name, description, and schema.{ name: 'explain_code', description: 'Provides detailed explanation of the given code.', inputSchema: { type: 'object', properties: { code: { type: 'string', description: 'Target code' }, context: { type: 'string', description: 'Additional context', default: '' } }, required: ['code'] } },