From explain
Use when user invokes /explain with a file path, directory path, function/class name, or natural language concept. Also triggers on "explain this", "how does X work", "walk me through". Produces a structured, layered explanation of what the code does, how it connects, and where to start if you need to change it. Do NOT use when the user wants to trace data flow through a pipeline — use /lineage instead.
How this skill is triggered — by the user, by Claude, or both
Slash command
/explain:explainThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Produce layered explanations of code — files, directories, functions, classes, or cross-cutting concepts. Designed for developers working in unfamiliar parts of a codebase.
Produce layered explanations of code — files, directories, functions, classes, or cross-cutting concepts. Designed for developers working in unfamiliar parts of a codebase.
Core principles:
User types /explain followed by:
/explain src/auth/middleware.ts
/explain the payment processing flow
/explain src/services/
/explain OrderProcessor.process
/explain how webhooks get dispatched
You MUST follow this order. No skipping steps.
Classify the argument:
| Type | Detection | Example |
|---|---|---|
| File path | Has file extension or resolves to a file | src/auth/middleware.ts |
| Directory path | Resolves to a directory (or ends with /) | src/services/ |
| Symbol name | Looks like a function, class, or method (CamelCase, dot notation, ::) | OrderProcessor.process |
| Concept | Natural language, doesn't resolve to a file or directory | the payment processing flow |
If ambiguous (e.g., auth could be a directory or a concept), check the filesystem first. If it resolves to a file or directory, treat it as that. Otherwise, treat it as a concept.
For a file path:
*.ts, *.py, *.go, etc. to avoid noise from docs, tests, and build output)For a directory path:
For a symbol name:
function symbolName, class SymbolName, def symbol_name, func symbolName (adjust for the project's language). Filter to source file types.For a concept:
Look for project-level CLAUDE.md in the repository root:
CLAUDE.md in the working directory or its parent directoriesIf no CLAUDE.md exists, proceed without it — this step is additive, not blocking.
Before producing the explanation, determine what scope is appropriate:
Use this structure. Every section is required for narrow/medium scope. For wide scope, produce the map version (see Step 4).
1. Summary (2-3 sentences)
What this code does and why it exists. Lead with purpose, not implementation details.
2. Key Components
The important pieces — functions, classes, modules, config — with one-line descriptions. Use a table or bullet list:
- `authenticate()` — validates JWT token from Authorization header, attaches user to request context
- `requireRole(role)` — middleware factory that checks user.role against the required role
- `rateLimiter` — token bucket rate limiter, configured per-route in config.yml
3. How It Connects
What calls this code, what this code calls, and how data flows in and out. Be specific about entry points and dependencies:
Called by:
- Express router (src/routes/api.ts:14) — applied to all /api/* routes
Calls:
- UserService.findById() — to hydrate user from token claims
- config.get('auth.jwtSecret') — for token verification
Data flow:
- IN: Authorization header (Bearer token)
- OUT: req.user object attached to request, or 401 response
4. Patterns & Conventions
Design patterns used, naming conventions, framework idioms. Only include patterns that are actually present — don't list patterns that aren't used.
Examples: middleware chain pattern, repository pattern, dependency injection, event-driven, pub-sub, factory pattern, decorator pattern.
5. Gotchas
Non-obvious behavior, edge cases, known issues, things that will bite you. If there are no gotchas, say "None identified" rather than inventing them.
Examples:
6. Entry Points for Change
If you need to modify this code, where to start and what to watch out for. Be practical:
- To add a new auth provider: implement the AuthProvider interface in src/auth/providers/,
register it in src/auth/registry.ts
- To change token expiry: update config.yml (auth.tokenExpiry), but note that existing
tokens will still use their original expiry
- To add rate limit exemptions: add the route pattern to rateLimiter.exemptions in config.yml
End with: "Want me to go deeper on any section, or explain a related part of the codebase?"
For wide-scope explanations (directories/concepts), be more specific: list the components you can deep-dive into.
| Mistake | Fix |
|---|---|
| Reading every file in a directory | Read the map (ls), identify key files, read those. Offer to go deeper. |
| Inventing gotchas that aren't real | Only list gotchas you actually observed in the code. "None identified" is fine. |
| Generic patterns section | Only list patterns that are concretely present in the code. Skip if nothing notable. |
| Ignoring CLAUDE.md | If it exists, use its Architecture section to contextualize the explanation. |
| Wall of text with no structure | Always use the 6-section structure. Use code blocks, tables, and bullet lists. |
| Explaining language basics | Assume the reader knows the programming language. Explain the code's purpose and design, not syntax. |
| Not searching for callers | "How It Connects" requires knowing what calls this code. Always search for callers. |
| Dumping raw search output | Synthesize search results into a coherent explanation. The user wants understanding, not search results. |
npx claudepluginhub harnessprotocol/harness-kit --plugin explainExplains complex code, files, or concepts using structural search and mermaid diagrams. Useful for architecture, data flow, and design analysis.
Explains code for project newcomers with structured coverage of purpose, rationale, connections, design decisions, and non-obvious details. Use for 'explain this', 'what does this do', or onboarding.
Read-only codebase investigation via Explore agent; handles broad code search and upward-zoom for unfamiliar code regions.