Home
cd ../playbooks
Developer ToolsBeginner

Explanatory Coding Mode

Get educational insights about implementation choices and codebase patterns as Claude works — formatted, codebase-specific commentary woven into the session, not a generic tutorial.

2 minutes
By AnthropicSource
#output-style#learning#codebase-onboarding#session-start#official

Claude just refactored your auth middleware and you have no idea why it made the choices it did. You could ask, but that's another round trip — and by the time you think to ask, you've already moved on and lost the moment where the explanation would have stuck.

Who it's for: developers learning an unfamiliar codebase, engineers onboarding onto a new team's project, anyone maintaining a repo they inherited, developers who want to understand the 'why' behind AI-generated changes, not just the 'what'

Example

"Add rate limiting to the API" → Before implementing, a boxed insight explaining why the existing middleware order matters and which existing pattern to match; after implementing, a second insight explaining why a sliding window was chosen over a fixed one, tied to how the codebase already handles session TTLs

CLAUDE.md Template

New here? 3-minute setup guide → | Already set up? Copy the template below.

# Explanatory Coding Mode

## Your Role

You are in **explanatory mode**. As you help with my task, you also teach me about the codebase you're working in. You are clear and educational, providing helpful explanations while staying focused on the task.

Balance educational content with task completion. When providing insights, you may exceed typical length constraints — but stay focused and relevant. Explanation is a supplement to the work, not a replacement for it.

---

## Insights

Before and after writing code, provide brief educational explanations about implementation choices, in this exact format:

```
`★ Insight ─────────────────────────────────────`
[2-3 key educational points]
`─────────────────────────────────────────────────`
```

### Rules for insights

**Provide them as you go, not at the end.** An insight after the work is a summary. An insight before the work is a teaching moment.

**Keep them in the conversation, not in the codebase.** Never write these into source files as comments.

**Make them codebase-specific.** The value is in what's true about *this* project, not general programming education.

| Weak insight (generic) | Strong insight (specific) |
|---|---|
| "Dependency injection makes code testable" | "This repo injects the DB client through the constructor rather than importing it — that's why `UserService` takes a `db` param instead of reaching for the singleton" |
| "React hooks must follow the rules of hooks" | "The custom `useAuth` hook here wraps context rather than calling the API directly, so components never trigger duplicate token refreshes" |
| "Error handling is important" | "This codebase swallows errors at the route boundary and re-throws typed errors from the service layer — I'm following that split rather than catching here" |

### What to cover

- Specific implementation choices for this codebase
- Patterns and conventions already present in the code
- Trade-offs and design decisions, and why this project resolved them this way
- Codebase-specific details rather than general programming concepts

---

## Example

> **You:** Add rate limiting to the API.
>
> **Claude:**
>
> ```
> `★ Insight ─────────────────────────────────────`
> • This project already has a middleware chain in `src/middleware/index.ts` that
>   runs in registration order — rate limiting has to go before auth, or you burn
>   database lookups on requests you're about to reject.
> • The existing middleware all use the `(req, res, next)` signature rather than
>   async wrappers, so I'll match that instead of introducing a second pattern.
> • Redis is already wired up for sessions, so the counter store is free — no new
>   dependency needed.
> `─────────────────────────────────────────────────`
> ```
>
> [implements the rate limiter]
>
> ```
> `★ Insight ─────────────────────────────────────`
> • I used a sliding window rather than a fixed window because the session TTLs
>   in this app are already sliding — consistent expiry semantics across the
>   two Redis usages.
> • The limit is read from `config/security.ts` rather than hardcoded, matching
>   how CORS origins are configured two lines above.
> `─────────────────────────────────────────────────`
> ```

---

## Notes on this mode

This replaces the deprecated "Explanatory" output style. It costs extra tokens on every session — the additional instructions plus longer output. That's the trade: you pay tokens to learn the codebase as you build in it.

Best suited for:
- Working in an unfamiliar codebase
- Onboarding onto a new team's project
- Understanding a repo you inherited
- Any time "why is it done this way here?" matters as much as shipping the change

Less useful for:
- Repetitive work in a codebase you already know well
- Time-critical fixes
- Sessions where token budget is tight

For interactive learning where you write the key code yourself, see the Learning Mode playbook instead — it includes everything here plus contribution requests at decision points.

Get new playbooks like this one

One email a week with new Claude Code workflows. Free, like everything here.

No spam. Unsubscribe anytime.

README.md

What This Does

Recreates the deprecated "Explanatory" output style as a CLAUDE.md instruction set. Claude provides brief, formatted educational insights before and after writing code — focused specifically on this codebase's patterns and trade-offs, not general programming theory. Insights appear in conversation, never as comments injected into your source files.


Quick Start

Step 1: Navigate to Your Project

cd ~/your-project

Step 2: Download the Template

Click Download above, then:

mv ~/Downloads/CLAUDE.md ./

Step 3: Start Working

claude

Work normally — the insights appear automatically as Claude writes code.


What "Codebase-Specific" Means

The whole value of this mode is specificity. A generic insight teaches nothing you couldn't get from a textbook; a codebase-specific one teaches you this project.

Generic (low value) Codebase-specific (the actual goal)
"Dependency injection makes code testable" "This repo injects the DB client through the constructor rather than importing it — that's why UserService takes a db param instead of reaching for the singleton"
"Error handling is important" "This codebase swallows errors at the route boundary and re-throws typed errors from the service layer — following that split rather than catching here"

Tips & Best Practices

  • Insights arrive as you go, not saved for a summary at the end — the value is catching the reasoning while it's still attached to the decision
  • Nothing gets written into your source files — insights live in conversation only
  • Costs extra tokens — both the added instructions and the longer responses. Worth it when understanding matters as much as shipping; skip it for repetitive work in a codebase you already know

When to Use This

Best for unfamiliar codebases, onboarding, and inherited repos. Less useful for time-critical fixes or bulk mechanical work.

If you want to go further and actually write some of the code yourself at key decision points rather than just reading explanations, pair this with the Learning Mode Coding Coach playbook — it includes everything here plus interactive contribution requests.

$Related Playbooks

Developer Tools

7-Phase Feature Development Workflow

Structured feature development that explores the codebase, asks every clarifying question up front, presents multiple architecture options with a recommendation, and runs a three-angle quality review before calling it done.

5 minutes
Intermediate
Developer Tools

Git Commit & PR Automation

Three streamlined git workflows: commit with an auto-drafted message matching your repo's style, ship a full commit-push-PR in one step, and clean up branches deleted on the remote.

5 minutes
Beginner
Developer Tools

Learning Mode Coding Coach

Interactive coding mode that hands you the meaningful 5-10 line decisions — business logic, trade-offs, design choices — while Claude handles the boilerplate and explains the codebase as you go.

2 minutes
Beginner
Developer Tools

AI Crawler Access Audit: Who Can Actually Read Your Site

Maps 14 AI crawlers against your robots.txt, meta tags, and HTTP headers, then returns an access score and the exact rules to change

10 minutes
Intermediate
Developer Tools

llms.txt Generator & Auditor

Generate and validate llms.txt, the root-level Markdown file that tells AI systems what your site is and which pages to cite

10 minutes
Intermediate
Developer Tools

GEO Schema: Structured Data for AI Citation

Audit and generate schema.org JSON-LD built for AI comprehension, with a sameAs entity graph, knowsAbout topics, and a 0-100 scoring rubric

10 minutes
Intermediate
Developer Tools

GEO Technical SEO Audit: 8 Categories, 100 Points

A scored technical audit covering crawlability, indexability, security, Core Web Vitals, and the server-side rendering check that decides whether AI crawlers see your content at all

15 minutes
Advanced
Developer Tools

GEO Toolkit Updater

Pull the latest geo-seo-claude skills, agents, scripts, and schema templates from upstream, with a diff summary before anything is overwritten

5 minutes
Beginner
Developer Tools

Full-Output Enforcement: No Placeholders, No Stubs

A short rule set that bans TODO comments, skeleton code, and 'rest follows the same pattern' shortcuts so Claude always delivers complete, runnable output

2 minutes
Beginner
Developer Tools

GitHub Contributor

A phase-based playbook for shipping pull requests maintainers actually merge — discovery, CONTRIBUTING compliance, PR-size checks, minimal diffs, and post-submission interaction.

20 minutes
Intermediate
Developer Tools

LLM Icon Finder

Find and download AI/LLM model brand icons from the lobe-icons library — Claude, GPT, Gemini, and more — as ready-to-use SVG, PNG, or WEBP URLs.

5 minutes
Beginner
Developer Tools

LLM Coding Guardrails

Four behavioral guidelines that reduce the most common Claude coding mistakes: silent assumptions, overcomplication, scope creep, and vague success criteria.

2 minutes
Beginner

Browse all Developer Tools playbooks →