explain-code
Explain a code element, file, or line range with diagrams and architectural context
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Explain a code element, file, or line range with diagrams and architectural context
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Analyze repos in a workspace — generate compressed codebase indexes (AGENTS.md), per-repo docs, cross-repo dependency map, and master TOC for AI agent consumption
Analyze an MCP server's GitHub repository for security risks, malicious intent, and code quality. Produces a trust rating and recommends whether to use it or suggests safer alternatives.
Conduct systematic multi-phase research on a topic and produce a documented findings report
Show a comprehensive project status report with git state, active specs, and suggested next actions
Find and apply one small, safe code cleanup improvement with user approval (Boy Scout Rule)
| name | explain-code |
| mode | agent |
| description | Explain a code element, file, or line range with diagrams and architectural context |
| argument-hint | [function-name|class-name|file-path|line-range] |
Provides comprehensive explanations of code segments, functions, classes, or entire files. Combines natural language explanations with visual diagrams to help developers understand complex code quickly and thoroughly.
[function-name] - Specific function to explain[class-name] - Entire class explanation[file-path] - Explain entire file[line-range] - Explain specific lines (e.g., src/utils/helpers.js:45-78)current-selection - Explain currently selected or pasted codeThe skill automatically:
.code-captain/explanations/ for future reference/explain-code calculateUserDiscount
/explain-code PaymentProcessor
/explain-code src/auth/AuthService.js
/explain-code "src/utils/helpers.js:45-78"
/explain-code current-selection
Grep to find its definition in the codebaseRead to load the fileRead with offset/limit to load just those linescurrent-selection, ask the user to paste the code if not already visibleRead to load the file containing the target (if not already loaded)Grep to find callers, dependencies, and related componentsGlob to identify related files (tests, types, interfaces)Produce a comprehensive explanation covering:
📋 Function/Class Overview
🔄 Execution Flow
🏗️ Architecture Context
⚡ Technical Details
date +%Y-%m-%d
.code-captain/explanations/[DATE]-[target-name].mdSaved Format:
# Code Explanation: [Target Name]
_Generated on [DATE]_
## Overview
[Natural language summary]
## Execution Flow
```mermaid
[Generated diagram]
[Step-by-step explanation]
[How it fits in the system]
[Code examples]
[Links to other explanations or files]
Generated by Code Captain on [timestamp]
### Step 5: Present Output
Display the full explanation in chat, then confirm where the file was saved.
## Output Characteristics
All explanations use a consistent intermediate technical level:
- **Technical but accessible**: Explains how the code works with some optimization details
- **Full context**: Always includes related functions, dependencies, and architectural context
- **Visual diagrams**: Every explanation includes appropriate Mermaid flowcharts, sequence diagrams, or class diagrams
- **Comprehensive coverage**: Shows how the code fits in the entire system
## File Organization
.code-captain/ └── explanations/ ├── 2024-01-15-AuthenticationFlow.md ├── 2024-01-16-PaymentProcessor.md └── 2024-01-17-SearchAlgorithm.md
Files are named using the format: `[YYYY-MM-DD]-[target-name].md`
## Diagram Types Generated
### Flowcharts
- Control flow through functions
- Decision trees for complex logic
- Error handling paths
### Sequence Diagrams
- Function call sequences
- API interaction flows
- Database transaction flows
### Class Diagrams
- Object relationships
- Inheritance hierarchies
- Dependency structures
## Error Handling
- **Code not found**: Report "Could not locate [target]. Please check the path/name."
- **Too complex**: Suggest breaking into smaller explanations
- **Limited context**: Note that some context may be missing and explain what was found
- **Diagram fails**: Provide text-based flow description as fallback