Quick Explain Code
A command template for utilities workflows. Streamlines development with pre-configured patterns and best practices.
Quick Explain Code
Get a plain-language explanation of any code file, function, or block, including its purpose, inputs, outputs, side effects, and how it fits into the larger system.
When to Use This Command
Run this command when...
- You are reading unfamiliar code and need to understand what a function or module does
- You want to explain a complex piece of code to a team member or in a PR description
- You need to understand how a component interacts with the rest of the system
Avoid this command when...
- The code is trivial and self-explanatory (e.g., a simple getter function)
- You need to modify the code, not just understand it
Quick Start
# .claude/commands/quick-explain-code.md --- allowed-tools: ["Read", "Grep", "Glob"] --- Read the specified file or function. Explain its purpose, inputs, outputs, and side effects in plain language. Show how it connects to the rest of the codebase.
Example usage:
/quick-explain-code src/services/billing/invoiceGenerator.ts
/quick-explain-code "the handleWebhook function in stripe.ts"
Example output:
Explanation: invoiceGenerator.ts
================================
Purpose: Generates PDF invoices from order data and sends
them to customers via email.
Inputs:
- orderId (string): The order to generate an invoice for
- options.format: PDF or HTML output format
Outputs:
- Returns a Buffer containing the rendered invoice
Side Effects:
- Sends an email via the EmailService
- Logs invoice generation to the audit table
Called By: orderController.ts (after payment confirmation)
Calls: PdfRenderer, EmailService, AuditLogger
Core Concepts
| Concept | Description |
|---|---|
| Purpose analysis | Determines what the code is designed to accomplish |
| I/O mapping | Documents what goes in (parameters, config) and what comes out |
| Side effect detection | Identifies database writes, API calls, file system changes |
| Call graph | Shows what calls this code and what this code calls |
Target Code --> Read Source --> Analyze
|
+-----+------+------+
| | | |
Purpose I/O Side Call
Effects Graph
| | | |
+-----+------+------+
|
Plain Language Summary
Configuration
| Option | Default | Description |
|---|---|---|
depth | medium | Explanation detail level (brief, medium, thorough) |
audience | developer | Target audience (developer, junior, non-technical) |
include-graph | true | Show the call graph (callers and callees) |
include-examples | false | Add usage examples to the explanation |
format | text | Output format (text, markdown, json) |
Best Practices
- Start with the entry point -- explain the main function first, then drill into its helpers.
- Ask for the call graph -- understanding callers and callees reveals the code's role in the system.
- Use for PR descriptions -- paste the explanation into your PR to help reviewers understand context.
- Specify the audience -- a "non-technical" explanation removes jargon and focuses on business logic.
- Pair with debug-error -- when debugging, explain the error site first to understand expected behavior.
Common Issues
- Explanation too superficial -- set depth to
thoroughfor complex algorithms or business logic. - Missing broader context -- if the function depends heavily on external state, the explanation may be incomplete. Provide the full file path.
- Dynamic dispatch not resolved -- functions called via callbacks or dependency injection may not appear in the call graph. Mention the pattern explicitly.
Reviews
No reviews yet. Be the first to review this template!
Similar Templates
Git Commit Message Generator
Generates well-structured conventional commit messages by analyzing staged changes. Follows Conventional Commits spec with scope detection.
React Component Scaffolder
Scaffolds a complete React component with TypeScript types, Tailwind styles, Storybook stories, and unit tests. Follows project conventions automatically.
CI/CD Pipeline Generator
Generates GitHub Actions workflows for CI/CD including linting, testing, building, and deploying. Detects project stack automatically.