A Claude Code slash command for generating deep-dive code explanations with diagrams.
# Clone to your preferred location
git clone git@github.com:claude-commands/command-explain.git <clone-path>/command-explain
# Symlink (use full path to cloned repo)
ln -s <clone-path>/command-explain/explain.md ~/.claude/commands/explain.md/explain src/auth/login.ts # Explain a file
/explain handleAuthentication # Explain a function
/explain src/services/ # Explain a module/directory
- Analyzes the specified code target
- Extracts key concepts, dependencies, and relationships
- Generates documentation-style explanation
- Creates Mermaid diagrams for complex flows
- Identifies potential improvements and edge cases
# handleAuthentication
## Overview
Validates user credentials and creates a session token...
## Key Concepts
- **JWT Tokens**: Used for stateless authentication
- **Bcrypt**: Password hashing algorithm
## How It Works
1. Receives username and password
2. Looks up user in database
3. Validates password hash
4. Generates JWT with user claims
5. Returns token and refresh token
## Diagram
```mermaid
sequenceDiagram
Client->>Server: POST /login
Server->>Database: Find user
Database-->>Server: User record
Server->>Server: Validate password
Server-->>Client: JWT token- Multi-target: Explain files, functions, or directories
- Mermaid diagrams: Flowcharts, sequence diagrams, class diagrams
- Layered depth: Adjusts detail based on complexity
- Context-aware: Links to related code and tests
- Onboarding-friendly: Written for unfamiliar readers
| Type | Best For |
|---|---|
| Flowchart | Control flow, algorithms, decisions |
| Sequence | API calls, service interactions |
| Class | OOP structures, relationships |
| State | State machines, lifecycle |
- Git repository with source code
- Claude Code with Opus 4.5 model access
cd <clone-path>/command-explain && git pull