Explain a piece of code
Explains a piece of code step by step at the reader's level, starting with what it is for, then walking through how it works with a worked example and the parts that are easy to misread.
A useful explanation starts from purpose, not syntax: what problem the code solves and where it sits, then how it works, then the details that trip people up. The right level depends on the reader. A newcomer needs the concepts named and defined; an expert needs the non-obvious parts and nothing else. Only if [READER] is given: Reader:
Explain this code:
Only if [QUESTION] is given: The reader's question:
- If the reader is not described, assume an engineer who knows programming but not this code, say that assumption in one line, and offer to adjust.
- Say in two or three sentences what the code does and why someone would write it. If it is part of a larger codebase you can read, say where it is called from.
- Walk through how it works in order, grouping lines into meaningful steps rather than narrating every line. Name and briefly define each language feature, library call or pattern the reader may not know.
- Trace one small, concrete input through the code and show the intermediate values.
- Point out what is easy to misread: side effects, mutation, ordering, async behaviour, edge cases, hidden assumptions and anything that looks like a bug. Label a suspected bug as suspected and say how to check it.
- If a question was asked, answer it directly first, then give the rest of the explanation only as far as it helps.
- Explain the code that is there. Do not rewrite or refactor it unless asked.
- Do not invent behaviour of functions you cannot see; say what you are assuming about them.
- Match the depth to the reader: skip basics for experts, define terms for newcomers.
- Keep it as short as understanding allows.
What it does
Two or three sentences.
How it works
Numbered steps, with the relevant lines quoted.
Worked example
One input traced through to the output.
Watch out for
Short bullets; suspected bugs labelled as such.
1 required value still a placeholder; the assistant will ask for it.
details
- kind
- Prompt: a task you run by name to get one finished thing back
- domain
- Software engineering
- category
- Learning to code
- level
- Beginner
- depth
- Start here
- made for
- Software engineer, Student
- risk
- read-only
- version
- v1.0.0 · incubating
- reviewed
- 2026-10-04
- aliases
- explain
- works in
- Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Antigravity, OpenCode, Windsurf, Zed, Continue, AGENTS.md, ChatGPT, claude.ai
use in
npx @hermes-hq/hodios install explain-code --target claude-codeThis entry is in the full catalog, not the curated set the skills installer and plugins carry, so install it with the Hodios CLI.
pairs well with
All of Learning to codeExplain a codebase
Explains an unfamiliar codebase. Maps its structure, traces one real request end to end and names the concepts and gotchas a newcomer needs. Use when joining a project or reading an unknown repo.
explain-codebaseExplain a concept with code
Explains a programming concept through the problem it solves, a minimal runnable example, a common mistake and a quick self-check, pitched at the learner's level. Use to learn or teach a concept.
explain-concept-with-codeExplain a stack trace
Explains an error and its stack trace in plain words, finds the frame that matters, and ranks the likely causes with the next checks to run. Use when an exception or crash is hard to read.
explain-stack-traceCoding mentor
Acts as a senior developer mentoring a junior, asking what they tried, explaining the why behind fixes and reviewing code to teach. Use for early-career developers who want to grow.
coding-mentorExplain a SQL query
Explains a complex SQL query clause by clause in logical execution order, shows intermediate results on a tiny example, and points out bugs and performance traps. Use when inheriting a query.
explain-sql-queryBeginner coding buddy
Acts as a patient coding helper for non-programmers, such as office workers, researchers and teachers, by explaining in plain words, keeping programs small and warning before anything risky.
beginner-coding-buddy