explain

A code-reading command that explains a file, selected lines, or a named function or class in plain language. It describes the code's purpose, parts, execution path, dependencies, and possible problems.

In plain words
What is it for?
Use it to understand files, trace complex logic, learn what functions accept and return, and review how code connects to libraries, other modules, environment settings, databases, or APIs.
Why use it?
It helps when unfamiliar code is difficult to understand or when you need a structured explanation before changing it. It also makes hidden side effects and dependencies easier to spot.

Command

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/thedecipherist/claude-code-mastery/explain
Clone the repo
git clone --depth 1 https://github.com/TheDecipherist/claude-code-mastery
Per session 15 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 442 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00015 $0.00442
Opus 5 $0.00008 $0.00221
Sonnet 5 $0.00003 $0.00088
Haiku 4.5 $0.00002 $0.00044

Measured 2d ago against content hash 99b50c974897, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

explain scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

commands/explain.md · 87 lines

What it actually says

Explain Code

Provide a clear, thorough explanation of the specified code.

Input

The user will provide one of:

  • A file path: /explain src/auth/jwt.ts
  • A file path with line range: /explain src/auth/jwt.ts:45-80
  • A function/class name: /explain parseToken
  • Just /explain — explain the currently open or most recently discussed file

Explanation Structure

1. Overview (2-3 sentences)

What does this code do at a high level? What problem does it solve?

2. Key Components

Break down the major parts:

## Function: functionName

**Purpose:** One sentence description

**Parameters:**
- `param1` (type) — what it's for
- `param2` (type) — what it's for

**Returns:** What and when

**Side effects:** Any mutations, API calls, state changes

3. Control Flow

Explain the execution path:

  1. First, it does X
  2. Then checks Y
  3. If Y is true, Z happens
  4. Otherwise, W happens

Use a simple flowchart for complex logic:

Input → Validate → Transform → Output
              ↓
           Error → Log → Return null

4. Dependencies

What does this code depend on?

  • External libraries
  • Internal modules
  • Environment variables
  • Database/API connections

5. Gotchas & Edge Cases

Things that might surprise someone:

  • Non-obvious behavior
  • Edge cases handled (or not handled)
  • Performance considerations
  • Known limitations

6. Usage Example

Show how to use this code:

// Example usage
const result = functionName(arg1, arg2);

Tone

  • Assume the reader is a competent developer unfamiliar with this specific code
  • Avoid jargon unless defining it
  • Use "this code" not "the code" for clarity
  • Be concise but complete
Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 87 lines · 15 tokens per session scan A 99b50c974897

Subscribe to this mod's changes

explain is a command published in the GitHub repository TheDecipherist/claude-code-mastery (545 stars, last pushed 3mo ago), licensed MIT. It adds 15 tokens to every session and 442 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.