explain-code
Skill1 starsChanged 2 months agoMITView on GitHub
Explain how code works by teaching the mental model first, then the mechanism, then one specific gotcha. Use this skill whenever the user says "how does this work", "explain this", "walk me through", "teach me", "what is this doing", "I don't get it", "I'm new to this codebase", or when they paste code and ask about it in any form. Also use when onboarding to an unfamiliar library, function, or system, even if they don't explicitly ask for an explanation. The goal is a reader who could reproduce the code's behavior from memory and predict where it breaks, not just read its signature back.
60 other projects use a version of this.
Adopted by
Most recently taken up by
- Blaeste/claude-skillstheir own version, first seen Nov 29, 2026
- YauhenBichel/engineering-skillstheir own version, first seen Nov 29, 2026
- BetoFrega/skillstheir own version, first seen Nov 29, 2026
- afine907/skillstheir own version, first seen Nov 29, 2026
- dan1elw/dotclaudetheir own version, first seen Nov 22, 2026
- lmuntaner-bah/Claude-Skillstheir own version, first seen Nov 22, 2026
Used with
Projects with it also use explore-codebase, write-tests and 10 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
srclightSkillexplore-codebase
This skill should be used when the user asks to "explore this codebase", "understand this project", "give me an overview", "how does this work", "onboard me", "walk me through the architecture", "map the codebase", or any request to understand a codebase's structure, architecture, or design.
Also in 3 projects that use this
SentrySkillwrite-tests
Write tests following project conventions. Use when adding new tests or modifying existing ones.
Also in 7 projects that use this
Google CloudSkillopen-pr
Commits local changes to a new Git branch and opens a GitHub pull request through the configured GitHub MCP server. Use when proposing code changes in a new pull request. Don't use for local-only commits without a remote GitHub repository.
Also in 4 projects that use this
silvainfmSkillcopy-editing
When the user wants to edit, review, or improve existing marketing copy. Also use when the user mentions 'edit this copy,' 'review my copy,' 'copy feedback,' 'proofread,' 'polish this,' 'make this better,' or 'copy sweep.' This skill provides a systematic approach to editing marketing copy through multiple focused passes.
Also in 3 projects that use this
silvainfmSkillpricing-strategy
When the user wants help with pricing decisions, packaging, or monetization strategy. Also use when the user mentions 'pricing,' 'pricing tiers,' 'freemium,' 'free trial,' 'packaging,' 'price increase,' 'value metric,' 'Van Westendorp,' 'willingness to pay,' or 'monetization.' This skill covers pricing research, tier structure, and packaging strategy.
Also in 3 projects that use this
SentrySkillmarketing-psychology
When the user wants to apply psychological principles, mental models, or behavioral science to marketing. Also use when the user mentions 'psychology,' 'mental models,' 'cognitive bias,' 'persuasion,' 'behavioral science,' 'why people buy,' 'decision-making,' or 'consumer behavior.' This skill provides 70+ mental models organized for marketing application.
Also in 3 projects that use this
- +1 more from getsentry
Other versions60 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 60
- AgnosticUI/agnosticui★ 832same name
- renzrollon/interlock★ 68same name
- Integralist/agent-skills★ 30same name
- zbruhnke/claude-code-starter★ 16same name
- rommelporras/kiro-config★ 13same name
- holt-os/holt★ 8same name
- sidkh/skills★ 8same name
- Arcadi4/skills★ 7same name
- bsene/skills★ 7same name
- viknesh20-20/claude-code-tool-kit★ 7same name
50 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository38 other files it gives its agents.
- AGENTS.mdAGENTS.md
- airtable-backup-and-migrateSkill
- applicant-csv-to-airtable-syncSkill
- autoSkill
- binti-airtable-date-reconciliationSkill
- build-sprint-summarySkill
- client-doc-changelogSkill
- client-doc-decisionsSkill
- client-doc-interface-promptsSkill
- client-doc-pushSkill
- client-docsSkill
- client-doc-user-storiesSkill
- client-doc-vision-and-scopeSkill
- course-completion-certificateSkill
- dissonance-radarSkill
- educationSkill
- eval-creationSkill
- execute-and-reconcile-pain-pointsSkill
- file-naming-conventionSkill
- five-signals-prdSkill
- friday-sprint-summarySkill
- gem-minerSkill
- gmail-triageSkill
- how-it-works-docSkill
- kpi-reportSkill
- meeting-prepSkill
- micro-case-studySkill
- mistakesSkill
- normalize-csvs-for-airtableSkill
- omni-promptSkill
- plain-english-project-communicationSkill
- postmortemSkill
- post-to-huddleSkill
- rubricSkill
- slack-power-mapSkill
- voice-alignSkill
- work-voiceSkill
- write-artifactSkill
The file
We split this skill into the rules it gives an agent
8 rules. 0 are common, 8 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 51 edited versions we read keep these.
8
Distinctive
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 19
Start with the question the reader actually has, not the top of the file.
- Distinctive: line 49
If a diagram would be busier than the code, skip it.
- Distinctive: line 65
Specific to this code: Not a generic programming warning.
- Distinctive: line 68
If you can't come up with a gotcha, the code either has none worth mentioning (unusual) or you don't understand it well enough yet (more …
- Distinctive: line 93
Fabien Sanglard: start from the constraints (hardware, performance budget, time period).
- Distinctive: line 97
"Build your own X" tutorials: start from empty, add one piece at a time.
- Distinctive: line 123
If you can't be confident the reader could do those three things after reading your explanation, it isn't finished.
- Distinctive: line 129
No em dashes. Use commas, semicolons, parentheses, or two sentences instead.
“Common” is measured: kept by at least 6 in 10 of the 51 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Explain Code
What this skill is for
A good code explanation changes what the reader can do next. Before: they can run it. After: they can modify it, debug it, and predict its edge cases.
This skill fights the explanation that reads code out loud as English. "This function takes a list and returns the sum" is not an explanation. It's a signature with extra words.
The move at the center of every good explanation
Start with the question the reader actually has, not the top of the file.
Readers come in with specific confusion: "why does this not do what I expected?", "what is this one line doing?", "why is there a try/except around nothing?". A great explanation names that confusion in the first sentence and then resolves it. Only after the confusion is resolved do you widen out to the full picture.
Julia Evans does this constantly. Her zines open with a question ("why is my disk full?", "what are tcp states?") and build the answer; she never starts with "here is a definition of X." Dan Abramov's "Just JavaScript" opens each chapter with a "guess the output" quiz because the surprise IS the hook into the mental model.
The four parts, and what each one is actually doing
1. Mental model (what the runtime sees)
Teach the reader how to think about the thing, not what it looks like on the page. A mental model is a small set of rules that lets the reader predict behavior without re-reading the code.
Good mental models are:
- Concrete. "Every variable is a wire pointing at a value. Values live in a soup on the side." (Dan Abramov, "Just JavaScript")
- Falsifiable. The reader can test them. "If this model is right, then X should happen; if X doesn't happen, the model is wrong."
- Minimal. Three rules the reader can hold in their head, not thirty.
Pick an analogy from physical life (mail sorting, a restaurant kitchen, a thermostat, a conveyor belt, a queue at a counter). Never use another piece of code as the analogy; "it's like a stream" is jargon, not a model.
Push one analogy hard rather than sprinkling five shallow ones. If the analogy breaks at some point, say so out loud: "the elevator analogy stops working here because elevators don't have a timeout; what actually happens is...".
2. Diagram (what the shape is)
ASCII or a short drawing that shows flow, structure, or timing. The diagram earns its place by making something visible that prose hides: timing between events, which pieces call which, where data moves.
Rules:
- Readable in two seconds. If it isn't, cut it.
- Label the pieces with the names from the code so the reader can map back.
- Show the interesting state, not every state. One timeline, not seven.
If a diagram would be busier than the code, skip it; prose is fine.
3. Walkthrough (what happens when it runs)
Trace one concrete call from start to finish with real values. Not foo(bar), use debounce(fn, 300) and show the actual millisecond timings. Real values beat variable names every time.
The walkthrough ties each step back to a specific line or function. "At line 7, we clear the existing timer. At line 8, we set a new one. The old callback is now unreachable; garbage collector will clean it up next cycle."
Include the state transitions. What was true before this line? What's true after?
4. Gotcha (what trips people up)
One specific mistake, not a general warning. "Watch out for async behavior" is useless. "The first call fires after a 300ms delay, not immediately; if you want fire-immediately-then-wait, that's throttle, not debounce" is a gotcha.
A good gotcha has three properties:
- Observable. The reader can see the wrong behavior if they hit it.
- Specific to this code. Not a generic programming warning.
- Named cause. The gotcha points at the line or design decision that causes the surprise.
If you can't come up with a gotcha, the code either has none worth mentioning (unusual) or you don't understand it well enough yet (more common). Read it again.
The closer: "now you can read the rest"
End the explanation by pointing at what the reader can now do on their own. "Now you can read the rest of the file; the other three functions are variations on this pattern" or "with this model, you can predict what happens if you call it twice in the same tick: the first call's timer gets dropped on the floor."
This is the Fabien Sanglard move: his "Game Engine Black Books" always end a chapter by saying what the next chapter will build on. The reader leaves equipped, not just informed.
When to use what
Different asks need different shapes. Pick the shape before writing:
| User says | What they need |
| "How does this work?" (pastes a function) | All four parts, short |
| "I don't get line 12" | Mental model + walkthrough of that line only |
| "Teach me this codebase" | Map first (file-level diagram), then four-parts on the central function |
| "Why does this do X?" | Historical/design context + gotcha; skip the walkthrough |
| "What's the difference between X and Y?" | Side-by-side mental models, one gotcha each |
| "Walk me through this bug" | Walkthrough with real failing values, then the fix |
Techniques pulled from writers who do this well
- Julia Evans: open with the reader's question; use one concrete scenario throughout; show the surprising thing up front.
- Dan Abramov: teach a mental model with rules the reader can test; use "guess what this prints" to surface wrong models; show what the runtime sees, not what the syntax looks like.
- Fabien Sanglard: start from the constraints (hardware, performance budget, time period); annotate the actual source; name why the author made each choice.
- Jessica Kerr: name the human who wrote it and why; explain the connections between parts, not just the parts; respect that "obvious" refactors often break things for reasons the current code encodes.
- Hillel Wayne: name the invariants the code maintains; be careful with "always" and "never"; a counterexample beats a definition.
- LWN kernel walkthroughs: patch-level ("this line was added because..."); name data structures as characters with roles; timeline of how the subsystem evolved.
- "Build your own X" tutorials: start from empty, add one piece at a time; every intermediate state runs; call out what's missing at each step so the reader isn't surprised later.
Worked examples
See references/worked-examples.md for three full-length explanations following the pattern: a debounce function, a React useEffect cleanup, and an Airtable formula. Read it when you want to see the shape at full size.
Anti-patterns (what makes an explanation bad)
See references/anti-patterns.md for the long list. Short version:
- Reading the signature out loud as prose.
- Analogies to other code ("it's like a stream", "like a Promise").
- Walkthroughs that restate each line in English without adding meaning.
- Generic gotchas ("be careful with mutation!").
- Starting at line 1 when line 1 isn't the interesting part.
- Explaining easy parts in detail and waving at the hard parts.
- "This is called a monad" (naming a pattern instead of explaining what it does).
- Seven analogies, each half a sentence long.
How to know you're done
The reader should be able to:
- Predict the output of a call you didn't show them.
- Point to the line that would cause a specific bug you describe.
- Modify the code to change one behavior without breaking another.
If you can't be confident the reader could do those three things after reading your explanation, it isn't finished. Add the piece that would let them.
Voice
Conversational. Short sentences for the hard parts; longer ones when the reader can coast. Say "you" to the reader; say "the code" or name the function, not "we." Skip hedging like "basically" and "essentially"; if a thing is approximate, say what's missing.
No em dashes. Use commas, semicolons, parentheses, or two sentences instead.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

