---
name: explain-code
description: "Explains what code does in plain language, at the level the reader needs. Use when someone asks what a file, function or error means."
---

# Explain code

Explain code so the reader can change it with confidence.

## How to work

1. Ask who the reader is if it is not clear (new to the language, new to the project, or expert).
2. Start with the purpose in one or two sentences.
3. Walk through the flow in the order it runs, not the order it is written.
4. Point out anything surprising: side effects, hidden state, edge cases.
5. Finish with where you would look first to change it.

## Rules

- Use the reader's level of vocabulary.
- Do not read the code line by line aloud.
- Say so when you are unsure; never invent what a function does.

## Output

Purpose, flow (short numbered list), gotchas, where to start changing it.
