---
name: code-explanation
description: Explains complex code through clear narratives, visual diagrams, and step-by-step breakdowns. Use when user asks to explain code, understand algorithms, analyze design patterns, wants code walkthroughs, or mentions "explain this code", "how does this work", "code breakdown", or "understand this function".
---

# Code Explanation

Expert skill for explaining complex code to developers at all levels through visual aids, step-by-step breakdowns, and progressive complexity.

## Quick Start

### 1. Analyze Complexity First

Before explaining, assess the code:
- **Lines of code** and structural complexity
- **Concepts used** (async, decorators, generators, etc.)
- **Design patterns** present
- **Difficulty level** (beginner/intermediate/advanced)

### 2. Choose Explanation Depth

| Audience | Approach |
|----------|----------|
| Beginner | Start with analogies, avoid jargon, explain fundamentals |
| Intermediate | Focus on patterns and design decisions |
| Advanced | Deep dive into implementation details and trade-offs |

### 3. Use Visual Aids

Generate Mermaid diagrams for:
- **Flow diagrams** - Control flow and decision trees
- **Class diagrams** - Object relationships and inheritance
- **Sequence diagrams** - Method calls and interactions

### 4. Progressive Disclosure

Structure explanations from simple to complex:
1. **Overview** - What does this code do? (1-2 sentences)
2. **Key Concepts** - What programming concepts are used?
3. **Step-by-Step** - Walk through the logic
4. **Deep Dive** - Advanced details for those who want more

## Output Format

### Standard Explanation Structure

```markdown
## What This Code Does
[1-2 sentence summary]

## Key Concepts
- Concept 1: Brief explanation
- Concept 2: Brief explanation

## Visual Overview
[Mermaid diagram if complexity warrants]

## Step-by-Step Breakdown
1. [First step with code reference]
2. [Second step with code reference]
...

## Common Questions
- Why is X done this way?
- What happens if Y?

## Related Patterns
[Links to similar patterns or alternatives]
```

## Core Techniques

### Explaining Algorithms
1. State the problem being solved
2. Show input → output transformation
3. Visualize with step-by-step execution
4. Analyze time/space complexity

### Explaining Design Patterns
1. Name the pattern
2. Explain the problem it solves
3. Show UML-style diagram
4. List benefits and trade-offs

### Explaining Complex Functions
1. Signature and purpose
2. Parameter meanings
3. Return value
4. Side effects (if any)
5. Edge cases

## Best Practices

- **Use analogies** - Compare to real-world concepts
- **Show, don't just tell** - Include code snippets
- **Reference line numbers** - Use `file_path:line_number` format
- **Highlight gotchas** - Point out non-obvious behavior
- **Suggest improvements** - When appropriate

## Resources

- [WORKFLOW.md](WORKFLOW.md) - Detailed step-by-step methodology
- [EXAMPLES.md](EXAMPLES.md) - Comprehensive explanation examples
- [TROUBLESHOOTING.md](TROUBLESHOOTING.md) - Common issues and fixes

## Integration

This skill auto-invokes when triggered by explanation-related keywords. For explicit control, use the `/code-explain` command.


---
Source attribution: joaquimscosta
Original project: https://github.com/joaquimscosta/arkhe-claude-plugins/blob/8e1be1b8604f3f6adf3ac6469a4271bfa5285ac1/plugins/doc/skills/code-explanation/SKILL.md
License: MIT
License information: https://opensource.org/license/mit
Original upstream instructions; downloaded from Dave AI.

## Upstream license notice

MIT License

Copyright (c) 2025 Joaquim Costa

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.



# Dave AI resource metadata

Creator / publisher: joaquimscosta
Original project: https://github.com/joaquimscosta/arkhe-claude-plugins/blob/8e1be1b8604f3f6adf3ac6469a4271bfa5285ac1/plugins/doc/skills/code-explanation/SKILL.md
Attribution basis: Recovered original package and original project license at a pinned revision

Fields of work: Content & Media, Data & Analytics, Design, Development & Engineering
Roles: Backend Developer, Data Scientist, Frontend Developer, Technical Writer, UX Writer
Specialties: Cross Platform
Tools: Tool not specified
Country applicability: Country not specified
Classification basis: Source catalog labels
Instruction SHA-256: 5dfc3a27b97f27fec0c440c37af3bccac187f922352bcf5c0007122200fcc72b
Metadata reviewed: 2026-10-27
This metadata supersedes earlier Dave AI catalog attribution. Original instruction and supporting files are preserved.
