explain-code
Skill0 starsChanged 3 months agoMITView on GitHub
Explains code architecture, logic, and data flow using mental models, Mermaid diagrams, edge-case analysis, and verification vectors. Trigger when asked: "cómo funciona esto", "explicame este código", "explain code", "walk me through this", "qué hace esta función", "why is this written this way", or when onboarding to unfamiliar logic.
25 other projects use a version of this.
Adopted by
Most recently taken up by
- LuisUrrutia/skillstheir own version, first seen Oct 4, 2026
- koach08/claude-code-skillstheir own version, first seen Sep 12, 2026
- Enrikkk/claude-skillstheir own version, first seen Sep 10, 2026
- renzrollon/interlocktheir own version, first seen Sep 10, 2026
- dmzoneill/skillstheir own version, first seen Sep 3, 2026
- bradywardai/claude-skillstheir own version, first seen Aug 6, 2026
Used with
Projects with it also use write-tests, teach and 8 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.
SentrySkillwrite-tests
Write tests following project conventions. Use when adding new tests or modifying existing ones.
Also in 4 projects that use this
AWSSkillteach
Teach the user a new skill or concept, within this workspace.
Also in 4 projects that use this
GitHubSkillrefactor
Surgical code refactoring to improve maintainability without changing behavior. Covers extracting functions, renaming variables, breaking down god functions, improving type safety, eliminating code smells, and applying design patterns. Less drastic than repo-rebuilder; use for gradual improvements.
Also in 3 projects that use this
NVIDIASkilldeep-research
Queue deep, multi-step research and analysis tasks to the DeepAgents worker. Supports execution depth presets, request-specific rubrics, SubAgent delegation, and RubricMiddleware cross-validation.
Also in 3 projects that use this
AnthropicSkilldebug
Structured debugging session — reproduce, isolate, diagnose, and fix. Trigger with an error message or stack trace, "this works in staging but not prod", "something broke after the deploy", or when behavior diverges from expected and the cause isn't obvious.
Also in 3 projects that use this
SentrySkillcommit
Create commit messages following Sentry conventions. Use when committing code changes, writing commit messages, or formatting git history. Follows conventional commits with Sentry-specific issue references.
Also in 4 projects that use this
Other versions25 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 25
- AgnosticUI/agnosticui★ 826same name
- renzrollon/interlock★ 17same name
- zbruhnke/claude-code-starter★ 17same name
- helderberto/agent-skills★ 16same name
- sidkh/skills★ 8same name
- viknesh20-20/claude-code-tool-kit★ 7same name
- zeon-kun/claude-skills★ 6same name
- Akindu23/my-agent-skills★ 4same name
- Arcadi4/skills★ 4same name
- koach08/claude-code-skills★ 4same name
15 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.
The file
We split this skill into the rules it gives an agent
6 rules. 0 are common, 5 are distinctive, and 1 is very specific to this project.
0
Common
Most of the 23 edited versions we read keep these.
5
Distinctive
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 21
When explaining any function, module, architectural pattern, or code snippet, structure the explanation following this 5-part cognitive …
- Distinctive: line 28
If a dependency cannot be read (vendored binary, remote service, missing file), say so explicitly in that section and mark the claim as …
- Very specific: line 29
Every line reference (file.ts:L12-L24) must point at a line you actually opened.
- Distinctive: line 62
Never ask the user to "trust" the explanation.
- Distinctive: line 68
Adaptive depth: If the concept is complex, break it into composable layers (High-Level Contract -> Mechanical Implementation).
- Distinctive: line 69
Zero AI fluff: No conversational filler ("Sure, I can explain that!").
“Common” is measured: kept by at least 6 in 10 of the 23 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 (Pedagogical Standard 2026)
When explaining any function, module, architectural pattern, or code snippet, structure the explanation following this 5-part cognitive contract. Never output generic summaries or restate obvious syntax.
A complete worked example — the five parts applied to real code, next to the generic output this skill exists to prevent — lives in examples.md. Read it when the shape of a section is unclear.
0. Read Before Explaining (Hard Precondition)
- Never explain code you have not read. Open the file. If the symbol comes from elsewhere, follow it (
Grep) before describing what it does. - If a dependency cannot be read (vendored binary, remote service, missing file), say so explicitly in that section and mark the claim as unverified. An unmarked guess is worse than an admitted gap.
- Every line reference (
file.ts:L12-L24) must point at a line you actually opened. A fabricated citation destroys the value of every other citation.
1. Mental Anchor (The Physical Analogy)
- Ground the concept in a physical, everyday system (e.g., civil architecture, logistics routing, restaurant kitchens, electrical circuits).
- Explain why this pattern exists before discussing syntax.
- The analogy must break somewhere. Name where it breaks — an analogy carried too far teaches a false model.
2. Visual Architecture (Executable Mermaid Diagram)
- Provide a clear, valid
mermaiddiagram (flowchart, sequence, or state diagram). - Highlight state transitions, async boundaries, and error branches.
- The diagram must show the mechanism, not the file list. A box per module connected by arrows is a table of contents, not a diagram. If the code has no interesting flow, skip this section and say why — a decorative diagram costs the reader attention and returns nothing.
3. Data Flow & Contract Lifecycle
- Input shape: What enters the boundary (types, invariants, validation).
- Transformation pipeline: Step-by-step state changes with exact line references (
file.ts:L12-L24). - Output shape & Side effects: What exits, what gets mutated, and what I/O occurs (database, network, disk).
4. Failure Modes & Gotchas (The Traps)
- Hunt for non-obvious failure modes: race conditions, silent exceptions, memory/token leaks, boundary edge cases, N+1 queries.
- Explain the technical root cause and how to prevent it.
- A failure mode is a scenario, not a category. "Could have a race condition" is a label. "Two requests arriving within the TTL window both miss the cache and both hit the database" is a finding. Give concrete inputs and the wrong result they produce.
- Default to nothing, and do not build a container for it. If the code is sound, this section is ONE LINE naming what you checked and found clean — no table, no list, no scenario grid. A table with zero rows looks broken, so a table gets rows; that is how invented defects get written. Build the table only after you have a real finding to put in it.
- These are not failure modes, and listing them is the failure this section guards against: a caller who violates the declared type signature; a degenerate-but-correct input (
min === max); a hardening suggestion ("you could validate this"); a design tradeoff; anything you have to introduce with "the caller might not expect". If your entry ends in "no error" or "acceptable", delete it. - A fabricated failure mode is worse than an absent one: the reader acts on it, and every real finding you make loses credibility.
5. Verification Vector (Empirical Test Scenario)
- Provide a minimal test scenario (TDD style, input vs. expected output) that proves the code works or reproduces the edge case.
- The vector must target the failure mode named in section 4 — a happy-path test that would pass on broken code verifies nothing. If section 4 found nothing, target the invariant the code exists to guarantee, at its boundary.
- Never ask the user to "trust" the explanation; give them the exact assertion to verify it.
- Hand-execute every expected value before writing it. Walk the code with the literal inputs you chose and read off the result; do not infer it from what the function is supposed to do. A wrong assertion is the most expensive thing in this document — the reader runs it, it fails, and they go hunting for a defect that is not there. If you cannot compute an expected value with certainty, choose simpler inputs.
Tone & Constraints
- Direct and evidence-based: Facts, line numbers, and data shapes over subjective prose.
- Adaptive depth: If the concept is complex, break it into composable layers (High-Level Contract -> Mechanical Implementation).
- Zero AI fluff: No conversational filler ("Sure, I can explain that!"). Start immediately with the Mental Anchor.
- Sections earn their place. For a genuinely trivial snippet, collapse to sections 1, 3 and 5 and state that 2 and 4 were skipped for lack of substance. Padding an empty section is the same failure as a generic summary.
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.

