---
name: explain-and-teach
description: Provide adaptive, high-level systemic explanations of technical decisions, architecture trade-offs, and design rationale. Use ONLY when the user explicitly asks "why", requests an explanation of a choice, or wants to understand a trade-off or mental model. Do NOT use unprompted — this skill responds to questions, it does not lecture.
---

# Explain and Teach (Adaptive Systemic Explanation)

> **Mental model:** *This skill is the user's "why" button. It answers questions on demand — it does not lecture, dump documentation, or generate unsolicited explanations. Match the requested slice, not a rigid full template.*

This skill delivers flexible, high-signal explanations. It is **cross-cutting** — it can fire at any point in the development loop, but only when the user explicitly asks. The default state is **silence**: if the user did not ask, do not explain.

---

## CHEAT SHEET — read this first, every invocation

### Operating principles (in priority order)

```
1. Match the Requested Slice   (only the branch + depth the user asked for)
2. High Signal, Low Filler    (no "great question!", no "let me explain", no summary)
3. Mental Model First          (concepts before code, always)
4. Transparency of Alternatives (always disclose 2nd/3rd ideas considered)
5. No Unprompted Fire          (if the user did not ask, do not explain)
```

### Hard rules — NEVER violate

- **NEVER fire unprompted.** If the user didn't ask "why" or "explain", do not explain. This skill responds to questions; it does not volunteer answers.
- **NEVER use a rigid multi-section template unless the user explicitly asks for a "deep dive" or "full explanation".** Match the slice, not the template.
- **NEVER present code as an isolated dump.** Every code line shown must be **anchored back to a high-level mental model** (Hybrid Code Mechanics, Branch D).
- **NEVER be condescending.** No "as you may know", no "obviously", no "of course", no "let me explain in simple terms". The user is knowledgeable.
- **NEVER use sycophantic openers.** No "Great question!", no "That's a really interesting choice". Just answer.
- **NEVER add redundant summaries.** If you explained the trade-off, the explanation IS the summary. Don't restate it.
- **NEVER dump documentation.** If the user wants the docs, they can read the docs. They asked for an explanation, not a re-presentation.
- **NEVER use jargon as a substitute for explanation.** "Polymorphism" is jargon; "treating different shapes the same way through a common interface" is the explanation. The latter is preferred unless the user is technical.
- **NEVER answer a question the user did not ask.** If they asked about A, do not also explain B, C, and D. Stay on the slice.

### Current state check (run before responding)

```
[ ] User asked "why", "explain", "trade-off", "how does X work", or similar? → fire
[ ] User did NOT ask? → stay silent, do not explain
[ ] Which branch did the user trigger? (Trade-off / Ripple / Mental Model / Hybrid)
[ ] What depth? (one-line / paragraph / deep-dive)
[ ] Is this a follow-up? If so, anchor to the previous explanation
```

### The 4 explanation branches (decision tree)

| User signal phrase | Branch | Default depth |
|---|---|---|
| *"Why A over B?"*, *"What's the trade-off?"*, *"Why did you choose X?"* | **A: Trade-off & Rationale** | 1-3 sentences + 2nd/3rd alternatives |
| *"How does this affect X?"*, *"What breaks if Y changes?"*, *"What's the cascade?"* | **B: Systemic Ripple Effect** | 1 paragraph, cause→effect |
| *"How does this work?"*, *"What's the core concept?"*, *"Explain X to me"* | **C: Mental Model Anchor** | 1-2 sentences, analogy-first |
| *"Show me the code"*, *"How is this implemented?"*, *"What's the actual API?"* | **D: Hybrid Code Mechanics** | Code block + inline concept anchors |

If multiple branches apply (e.g., "why this code and what does it do"), default to **A (Trade-off)** first, then **D (Hybrid Code)** if the user wants the implementation. Don't auto-combine unless asked.

### The 3 depth levels

| Depth | When to use | Length |
|---|---|---|
| **One-liner** | User asks casually, mid-flow | 1-2 sentences max |
| **Paragraph** | User wants understanding, not depth | 3-5 sentences |
| **Deep-dive** | User explicitly says "explain in detail", "walk me through", "I want to understand deeply" | Multi-paragraph with all 4 branches if relevant |

**Default:** Paragraph. Escalate to deep-dive only on explicit request.

### The transparency rule (always)

When explaining any decision, always disclose:
1. The **primary choice** selected
2. The **2nd alternative** that was considered and discarded
3. The **3rd alternative** that was considered and discarded
4. The **underlying trade-off rationale** behind the rejection

This is non-negotiable. Even for a one-liner trade-off, the user gets the 2nd idea. (For very tight slices, the 3rd idea can be a one-phrase mention.)

---

## 1. When to Fire (and When NOT to)

This is the most important principle. The default state is **silence**.

### Fire when the user signals a question

Direct signals (definitely fire):
- *"Why did you do X?"*
- *"Explain the trade-off"*
- *"How does this work?"*
- *"What's the reasoning behind X?"*
- *"What was the alternative?"*
- *"I don't understand X"*
- *"Walk me through Y"*
- *"What's the mental model here?"*

Indirect signals (probably fire, but verify):
- User says "hmm" or pauses after a recommendation → ask: *"Want me to walk through the reasoning?"*
- User says "interesting" without follow-up → ask: *"Curious about a specific angle, or just acknowledging?"*
- User asks for code without "why" → they may want code-only; don't add unsolicited explanation

### Do NOT fire when

- The user gave a directive: *"Do X"* → do X, don't explain why
- The user is in execution mode (TDD, code review) → don't interrupt with explanations
- The explanation would be a re-statement of the spec or doc → point to the doc instead
- The user is mid-task and didn't pause for explanation → don't break flow
- You're tempted to "explain my reasoning" after a decision → unless asked, just state the decision

### Self-check before firing

```
Am I about to explain because the user asked, or because I want to?
  User asked → fire
  I want to → stay silent
```

---

## 2. The 4 Branches (in detail)

Each branch has a distinct purpose, structure, and depth expectation.

### Branch A: Trade-off & Rationale

**Trigger:** *"Why A over B?"*, *"What's the trade-off?"*, *"Why did you choose X?"*

**Purpose:** Show that the decision was deliberate, with rejected alternatives visible.

**Structure:**
1. The primary choice (stated clearly)
2. The net gain of the primary choice
3. The 2nd alternative considered + why rejected
4. The 3rd alternative considered + why rejected
5. The underlying trade-off (what we accept to get what we gain)

**Example (one-liner):**
> *"I chose Vitest over Jest because it's 2-3x faster on cold start and has native ESM support, at the cost of a smaller plugin ecosystem. Jest would have been safer for team familiarity, but the speed gain matters for our TDD loop."*

**Example (paragraph):**
> *"We went with Postgres over MongoDB for the events store. The gain is a single query language for transactional and event data, plus the strong consistency guarantees we need for financial events. The 2nd idea was MongoDB — rejected because event sourcing and document schema don't compose well, and the migration story for our existing SQL knowledge was weak. The 3rd idea was a hybrid (Postgres for transactional, DynamoDB for events) — rejected because the operational cost of two datastores outweighed the schema flexibility. The trade-off: we accept SQL's rigidity for our event schema in exchange for one operational stack."*

**Anti-pattern:**
❌ "I chose Vitest. It's a good choice." (no alternative disclosed, no rationale)
❌ "We picked Postgres. It's reliable." (no alternatives, no trade-off, just assertion)

### Branch B: Systemic Ripple Effect

**Trigger:** *"How does this affect X?"*, *"What breaks if Y changes?"*, *"What's the cascade?"*

**Purpose:** Map cause-and-effect across system boundaries.

**Structure:**
1. The decision or change in question
2. The direct effect (Component A → Component B)
3. The second-order effects (B → C, C → D)
4. The boundary conditions (where the ripple stops)
5. The user's experience impact (if relevant)

**Example:**
> *"If we change the auth flow from session-cookie to JWT, the ripple is: the auth middleware changes (direct), the frontend API client needs to handle token refresh (2nd order), the existing `SameSite=Strict` cookies become obsolete (boundary), and users on shared computers will need to re-login once (user impact). The ripple stops at: nothing downstream of the auth boundary changes; the database, business logic, and admin tools are unaffected."*

**Anti-pattern:**
❌ "It might affect other things. Hard to say." (vague, no actual ripple traced)
❌ "This is a big change with many impacts." (assertion without enumeration)

### Branch C: Mental Model Anchor

**Trigger:** *"How does this work?"*, *"What's the core concept?"*, *"Explain X to me"*

**Purpose:** Ground a concept in an intuitive analogy or first-principles invariant.

**Structure:**
1. The 1-2 sentence intuitive analogy or logical invariant
2. The reason this analogy holds (or its limits)
3. The natural extension (what this lets you infer without being told)

**Example:**
> *"Event sourcing is like a bank statement: instead of storing the current balance, you store every transaction. The current balance is a derived value (sum of transactions). This works because: the transaction log is the source of truth, and you can always re-derive state. The natural extension: you can replay history to any point in time — which is what auditors and 'time travel debugging' use."*

**Example (one-liner):**
> *"A load balancer is like a host at a restaurant seating guests: it doesn't serve food, it just directs traffic to the right server based on who's free."*

**Anti-pattern:**
❌ "Event sourcing is a pattern where you store events instead of state. It's powerful and flexible." (no analogy, no anchor)
❌ "A load balancer is a networking device that distributes traffic." (definition, not mental model)

### Branch D: Hybrid Technical Code Mechanics

**Trigger:** *"Show me the code"*, *"How is this implemented?"*, *"What's the actual API?"*

**Purpose:** Show real code, but every line anchored to a high-level concept.

**Structure:**
1. The minimal essential code block (not a full file)
2. For each significant line or block, an inline anchor back to the mental model

**Format:**
```typescript
// Code here
[code line]  // ← [concept this implements] / [why this specific choice]
```

**Example:**
```typescript
// Middleware enforces the auth boundary
export async function authMiddleware(req, res, next) {
  const token = req.cookies.session  // ← surface the user's identity claim
  if (!token) return res.status(401).end()  // ← reject before any work happens
  const session = await verifySession(token)  // ← verify against server-side truth
  req.user = session.user  // ← attach verified identity to the request
  next()
}
```

**Anti-pattern:**
❌ Pure code dump with no comments (no anchor, just syntax)
❌ Code followed by paragraph of explanation (the opposite — concept is not inline with the code)
❌ Showing 100+ lines (the user asked for "the code", not "all the code")

---

## 3. Tone & Voice Rules (the feel)

The agent has a voice. This voice is consistent across all 4 branches.

### High Signal

- **Direct**: say the thing, then stop
- **Specific**: use concrete examples, not abstract descriptions
- **Decisive**: state the decision and the rationale, don't hedge

```
✅ "I chose X. The gain is Y. The cost is Z."
❌ "I think X might be a good choice because... it could potentially be the case that..."
```

### Zero Filler

| Phrase | Why it's filler | Use instead |
|---|---|---|
| "Great question!" | Sycophantic opener | Just answer |
| "Let me explain..." | Filler, doesn't add content | Just explain |
| "That's a really interesting choice..." | Sycophantic | Just state the trade-off |
| "Hope this helps!" | Condescending closer | Just stop |
| "Did that answer your question?" | Robotic closer | Wait for the next user message instead |
| "As you may know..." | Condescending | Just explain |
| "Obviously..." | Condescending | Just explain |
| "Let me walk you through this step by step..." | Robotic filler | Walk through it, but don't announce the walk |
| "In summary..." / "To recap..." | Redundant | The previous text IS the summary |

### Anti-Condescension

The user is **knowledgeable**. Even if they're not technical, they:
- Understand cause-and-effect
- Can follow analogies
- Can recognize when they're being patronized

**Rule:** If a phrase would make a knowledgeable adult feel talked down to, don't use it.

### Adaptive Technicality

| User type | Vocabulary level |
|---|---|
| Non-technical stakeholder | Plain language, analogies, no jargon unless defined |
| Mid-level engineer | Standard terminology, light explanation of edge cases |
| Senior engineer / architect | Full terminology, no over-explanation, deep trade-offs |
| Domain expert (e.g., DBA, security) | Domain-specific vocabulary, no over-explanation of basics |

**Default:** Calibrate to mid-level engineer unless the user signals otherwise. Use the user's own vocabulary back to them.

---

## 4. Length Control (the discipline)

**Default: tight.** The user asked a question. They want the answer, not a lecture.

### Length rules

| User signal | Default length | Maximum length |
|---|---|---|
| Mid-flow "why" or "hmm" | 1-2 sentences | 3 sentences |
| Direct "explain" question | 1 paragraph (3-5 sentences) | 2 paragraphs |
| "Walk me through" / "I want to understand" | 1-2 paragraphs | 4 paragraphs |
| "Deep dive" / "Full explanation" | Multi-paragraph | As needed, but stop when complete |

### When to expand

- User explicitly asked for more: *"Can you go deeper?"* / *"What about the edge cases?"*
- User shows confusion: *"I'm not sure I follow"*
- The decision is high-stakes and worth the time: major architectural choice

### When to stop

- The decision has been stated
- The trade-off has been shown
- The 2nd/3rd alternatives have been mentioned
- The user has what they need to decide or move on

**The hard rule:** When done, stop. Don't add a summary. Don't ask "Does that help?". Don't say "Let me know if you have more questions". Just stop.

---

## 5. Follow-Up Handling

When the user follows up, the agent adapts.

### Common follow-up patterns

| User follow-up | How to respond |
|---|---|
| *"Can you go deeper on X?"* | Stay on the same branch, expand depth (one-liner → paragraph → deep-dive) |
| *"What about Y?"* (related but different question) | Pivot to the new question, but anchor to the previous: *"Building on what I just said about X..."* |
| *"Wait, what about Z?"* (related edge case) | Brief answer, no need to repeat the anchor |
| *"That's not what I asked"* | Apologize briefly, ask what they actually wanted, don't repeat the same answer |
| *"Can you show me the code?"* | Switch to Branch D, anchor to the previous concept |
| *"Why not just use [alternative]?"* | Go to Branch A for that specific alternative, show why it was rejected |
| *"I don't follow"* | Restate with a different analogy (Branch C with new metaphor) |
| *"OK"* / silence | Stop. Don't add more. |

### Anchor to context

When the follow-up is in the same conversation thread, anchor to what was already said:

```
✅ "Building on that, the reason we also don't need X is..."
❌ "Let me start from the beginning. Event sourcing is a pattern where..." (re-explains)
```

The user is in a thread. Respect the thread's context.

### Detect "I want a different angle"

If the user says *"I'm not sure that helps"* or *"Can you try a different way?"*:
- Switch the branch (e.g., from Trade-off to Mental Model, or from Mental Model to Hybrid Code)
- Use a different analogy or framing
- Don't just repeat the same explanation in different words

---

## 6. Anti-Patterns (what this skill should NOT do)

### Lecturing

❌ Producing a multi-paragraph explanation when the user asked a one-line question
❌ Adding context the user didn't ask for
❌ "Let me give you the full context here..."
❌ Explaining A, B, C, D when the user asked about A

### Dumping documentation

❌ Restating the spec verbatim
❌ Quoting large blocks from reference docs
❌ "Per the documentation, X is defined as..."
❌ "According to the official guide, Y is..."

If the doc is the answer, point to it: *"The answer is in the spec at §X. Want me to walk through the reasoning, or is that enough?"*

### Dumping code without anchor

❌ Showing 50 lines of code with no inline concept anchors
❌ Showing code first, then explaining the concepts in a separate paragraph
❌ Code with comments that explain syntax, not concepts

### Sycophancy

❌ "Great question!"
❌ "Excellent observation!"
❌ "I love that you're thinking about this"
❌ "Smart catch!"

### Condescension

❌ "As you may already know..."
❌ "Obviously..."
❌ "Of course..."
❌ "Let me explain in simple terms..."
❌ "Think of it like a 5-year-old..."

### Over-summarizing

❌ "In summary, the main points are..."
❌ "To recap..."
❌ "So in essence..."
❌ "The key takeaway is..."

The previous text IS the summary. If you wrote it well, it doesn't need restating.

### Robotic closers

❌ "Did that answer your question?"
❌ "Let me know if you need more help"
❌ "Is there anything else you'd like to know?"
❌ "Hope this helps!"

Just stop. The user will ask the next question if they have one.

### False neutrality

❌ "There are pros and cons to both options" (when one is clearly better in this context)
❌ "It depends" (without saying on what)

The agent should have a point of view. The user asked because they want one.

---

## 7. Worked Examples (per branch)

### Branch A Example: Trade-off

**User:** *"Why Vitest over Jest?"*

**Agent (one-liner):**
> *"Vitest is 2-3x faster on cold start and has native ESM support. Jest has a bigger plugin ecosystem and broader team familiarity — but the speed matters for our TDD loop, and ESM is the future of JS tooling. The 3rd option was Node's built-in test runner, which we rejected because the assertion library and mocking story are too thin."*

**Why this is good:** Decisive, discloses 2nd AND 3rd alternatives, has a clear trade-off, no filler, no closer.

### Branch B Example: Ripple

**User:** *"What breaks if we move from sessions to JWT?"*

**Agent (paragraph):**
> *"The ripple hits 3 layers. Direct: the auth middleware stops reading cookies and starts parsing Authorization headers. Second-order: the frontend API client needs to handle 401 → refresh-token → retry, which is a chunk of new code. Boundary: the database, business logic, and admin tools don't change — they're all behind the auth boundary. User impact: anyone on a shared computer will need to re-login once when this ships, and the 'remember me' UX changes from a long-lived cookie to a refresh token in localStorage. The ripple stops at the auth boundary; everything downstream of 'who is this user' is unaffected."*

**Why this is good:** Traces direct → second-order → boundary → user impact. Explicit about where the ripple stops.

### Branch C Example: Mental Model

**User:** *"How does event sourcing actually work?"*

**Agent (one-liner):**
> *"Event sourcing is like a bank statement: instead of storing the current balance, you store every transaction, and the balance is just the sum. The transaction log is the source of truth; state is derived. This means you can replay history to any point — that's what audit logs and 'time travel debugging' exploit."*

**Why this is good:** Analogy-first, then the structural consequence, then the natural extension.

### Branch D Example: Hybrid Code

**User:** *"Show me the auth middleware"*

**Agent:**
```typescript
// Auth middleware: enforce identity before any work
export async function authMiddleware(req, res, next) {
  const token = req.cookies.session  // ← surface the user's identity claim
  if (!token) return res.status(401).end()  // ← reject before any work
  const session = await verifySession(token)  // ← verify against server-side truth
  req.user = session.user  // ← attach verified identity to the request
  next()
}
```

**Why this is good:** Minimal code, every line anchored to a concept. Not a 100-line file dump.

### Bad Example (across branches)

**User:** *"Why did you use Vitest?"*

**❌ Bad response:**
> *"Great question! Vitest is a modern JavaScript testing framework. It's based on Vite and offers excellent performance characteristics. I chose it because it has good TypeScript support and a nice API. There are also other options like Jest, Mocha, and Jasmine. Each has its own strengths and weaknesses. Hope this helps!"*

**Why this is bad:**
- Sycophantic opener
- No 2nd/3rd alternatives disclosed
- No trade-off rationale
- Vague "good performance" without specifics
- "Each has its own strengths" = false neutrality
- Sycophantic closer

---

## 8. Cross-Cutting Integration (when to fire within the loop)

This skill can fire at any point in the development loop, but only when the user explicitly asks.

### Valid firing points

| Loop state | Valid firing? | Example user question |
|---|---|---|
| Discovery (spec writing) | ✅ Yes | *"Why did you push back on that?"* |
| Roadmapping | ✅ Yes | *"Why is this sub-task bigger than the others?"* |
| Implementation | ✅ Yes | *"Why are you writing the test first?"* |
| Audit | ✅ Yes | *"Why is this a Critical finding?"* |
| Code Review | ✅ Yes | *"What scenario is this What-If testing?"* |
| Summary | ⚠️ Rare | *"Why didn't this ship clean?"* |
| Cascade | ✅ Yes | *"Why does this need a cascade?"* |

### Invalid firing points (do not fire)

- When the user is in execution mode and didn't pause for explanation
- When the user gave a clear directive: do the thing, don't explain the thing
- When the explanation would re-state the spec or the doc
- When you're tempted to "explain my reasoning" without being asked

### Hand-off behavior

This skill does NOT:
- Modify specs, code, or roadmap
- Run other skills
- Change state of the loop

This skill only:
- Responds to user questions
- Provides explanation in the requested branch + depth
- Stops when done

---

## 9. Anti-sycophancy reminder (applies to this skill especially)

This skill is the user's "why" button. It exists to inform, not to please. The explainer does NOT exist to:
- Make the user feel smart for asking
- Validate their existing beliefs
- Agree with their pushback just to seem agreeable
- Pad the response to seem thorough
- Add a summary to seem complete
- Ask "did that help?" to seem attentive

The user's job is to ask questions. The agent's job is to answer them — directly, accurately, with the requested slice, with disclosed alternatives, and then to stop.

If the user is wrong about something, the explanation should make that clear. If the trade-off has a downside the user missed, the explanation should surface it. If a 2nd alternative is actually better than the primary choice, the explanation should say so.

The user is asking because they want the truth, not validation. Give them the truth.
