···11+---
22+name: diagnose
33+description: Disciplined diagnosis loop for hard bugs and performance regressions. Reproduce → minimise → hypothesise → instrument → fix → regression-test. Use when user says "diagnose this" / "debug this", reports a bug, says something is broken/throwing/failing, or describes a performance regression.
44+---
55+66+# Diagnose
77+88+A discipline for hard bugs. Skip phases only when explicitly justified.
99+1010+When exploring the codebase, use the project's domain glossary to get a clear mental model of the relevant modules, and check ADRs in the area you're touching.
1111+1212+## Phase 1 — Build a feedback loop
1313+1414+**This is the skill.** Everything else is mechanical. If you have a fast, deterministic, agent-runnable pass/fail signal for the bug, you will find the cause — bisection, hypothesis-testing, and instrumentation all just consume that signal. If you don't have one, no amount of staring at code will save you.
1515+1616+Spend disproportionate effort here. **Be aggressive. Be creative. Refuse to give up.**
1717+1818+### Ways to construct one — try them in roughly this order
1919+2020+1. **Failing test** at whatever seam reaches the bug — unit, integration, e2e.
2121+2. **Curl / HTTP script** against a running dev server.
2222+3. **CLI invocation** with a fixture input, diffing stdout against a known-good snapshot.
2323+4. **Headless browser script** (Playwright / Puppeteer) — drives the UI, asserts on DOM/console/network.
2424+5. **Replay a captured trace.** Save a real network request / payload / event log to disk; replay it through the code path in isolation.
2525+6. **Throwaway harness.** Spin up a minimal subset of the system (one service, mocked deps) that exercises the bug code path with a single function call.
2626+7. **Property / fuzz loop.** If the bug is "sometimes wrong output", run 1000 random inputs and look for the failure mode.
2727+8. **Bisection harness.** If the bug appeared between two known states (commit, dataset, version), automate "boot at state X, check, repeat" so you can `git bisect run` it.
2828+9. **Differential loop.** Run the same input through old-version vs new-version (or two configs) and diff outputs.
2929+10. **HITL bash script.** Last resort. If a human must click, drive _them_ with `scripts/hitl-loop.template.sh` so the loop is still structured. Captured output feeds back to you.
3030+3131+Build the right feedback loop, and the bug is 90% fixed.
3232+3333+### Iterate on the loop itself
3434+3535+Treat the loop as a product. Once you have _a_ loop, ask:
3636+3737+- Can I make it faster? (Cache setup, skip unrelated init, narrow the test scope.)
3838+- Can I make the signal sharper? (Assert on the specific symptom, not "didn't crash".)
3939+- Can I make it more deterministic? (Pin time, seed RNG, isolate filesystem, freeze network.)
4040+4141+A 30-second flaky loop is barely better than no loop. A 2-second deterministic loop is a debugging superpower.
4242+4343+### Non-deterministic bugs
4444+4545+The goal is not a clean repro but a **higher reproduction rate**. Loop the trigger 100×, parallelise, add stress, narrow timing windows, inject sleeps. A 50%-flake bug is debuggable; 1% is not — keep raising the rate until it's debuggable.
4646+4747+### When you genuinely cannot build a loop
4848+4949+Stop and say so explicitly. List what you tried. Ask the user for: (a) access to whatever environment reproduces it, (b) a captured artifact (HAR file, log dump, core dump, screen recording with timestamps), or (c) permission to add temporary production instrumentation. Do **not** proceed to hypothesise without a loop.
5050+5151+Do not proceed to Phase 2 until you have a loop you believe in.
5252+5353+## Phase 2 — Reproduce
5454+5555+Run the loop. Watch the bug appear.
5656+5757+Confirm:
5858+5959+- [ ] The loop produces the failure mode the **user** described — not a different failure that happens to be nearby. Wrong bug = wrong fix.
6060+- [ ] The failure is reproducible across multiple runs (or, for non-deterministic bugs, reproducible at a high enough rate to debug against).
6161+- [ ] You have captured the exact symptom (error message, wrong output, slow timing) so later phases can verify the fix actually addresses it.
6262+6363+Do not proceed until you reproduce the bug.
6464+6565+## Phase 3 — Hypothesise
6666+6767+Generate **3–5 ranked hypotheses** before testing any of them. Single-hypothesis generation anchors on the first plausible idea.
6868+6969+Each hypothesis must be **falsifiable**: state the prediction it makes.
7070+7171+> Format: "If <X> is the cause, then <changing Y> will make the bug disappear / <changing Z> will make it worse."
7272+7373+If you cannot state the prediction, the hypothesis is a vibe — discard or sharpen it.
7474+7575+**Show the ranked list to the user before testing.** They often have domain knowledge that re-ranks instantly ("we just deployed a change to #3"), or know hypotheses they've already ruled out. Cheap checkpoint, big time saver. Don't block on it — proceed with your ranking if the user is AFK.
7676+7777+## Phase 4 — Instrument
7878+7979+Each probe must map to a specific prediction from Phase 3. **Change one variable at a time.**
8080+8181+Tool preference:
8282+8383+1. **Debugger / REPL inspection** if the env supports it. One breakpoint beats ten logs.
8484+2. **Targeted logs** at the boundaries that distinguish hypotheses.
8585+3. Never "log everything and grep".
8686+8787+**Tag every debug log** with a unique prefix, e.g. `[DEBUG-a4f2]`. Cleanup at the end becomes a single grep. Untagged logs survive; tagged logs die.
8888+8989+**Perf branch.** For performance regressions, logs are usually wrong. Instead: establish a baseline measurement (timing harness, `performance.now()`, profiler, query plan), then bisect. Measure first, fix second.
9090+9191+## Phase 5 — Fix + regression test
9292+9393+Write the regression test **before the fix** — but only if there is a **correct seam** for it.
9494+9595+A correct seam is one where the test exercises the **real bug pattern** as it occurs at the call site. If the only available seam is too shallow (single-caller test when the bug needs multiple callers, unit test that can't replicate the chain that triggered the bug), a regression test there gives false confidence.
9696+9797+**If no correct seam exists, that itself is the finding.** Note it. The codebase architecture is preventing the bug from being locked down. Flag this for the next phase.
9898+9999+If a correct seam exists:
100100+101101+1. Turn the minimised repro into a failing test at that seam.
102102+2. Watch it fail.
103103+3. Apply the fix.
104104+4. Watch it pass.
105105+5. Re-run the Phase 1 feedback loop against the original (un-minimised) scenario.
106106+107107+## Phase 6 — Cleanup + post-mortem
108108+109109+Required before declaring done:
110110+111111+- [ ] Original repro no longer reproduces (re-run the Phase 1 loop)
112112+- [ ] Regression test passes (or absence of seam is documented)
113113+- [ ] All `[DEBUG-...]` instrumentation removed (`grep` the prefix)
114114+- [ ] Throwaway prototypes deleted (or moved to a clearly-marked debug location)
115115+- [ ] The hypothesis that turned out correct is stated in the commit / PR message — so the next debugger learns
116116+117117+**Then ask: what would have prevented this bug?** If the answer involves architectural change (no good test seam, tangled callers, hidden coupling) hand off to the `/improve-codebase-architecture` skill with the specifics. Make the recommendation **after** the fix is in, not before — you have more information now than when you started.
···11+#!/usr/bin/env bash
22+# Human-in-the-loop reproduction loop.
33+# Copy this file, edit the steps below, and run it.
44+# The agent runs the script; the user follows prompts in their terminal.
55+#
66+# Usage:
77+# bash hitl-loop.template.sh
88+#
99+# Two helpers:
1010+# step "<instruction>" → show instruction, wait for Enter
1111+# capture VAR "<question>" → show question, read response into VAR
1212+#
1313+# At the end, captured values are printed as KEY=VALUE for the agent to parse.
1414+1515+set -euo pipefail
1616+1717+step() {
1818+ printf '\n>>> %s\n' "$1"
1919+ read -r -p " [Enter when done] " _
2020+}
2121+2222+capture() {
2323+ local var="$1" question="$2" answer
2424+ printf '\n>>> %s\n' "$question"
2525+ read -r -p " > " answer
2626+ printf -v "$var" '%s' "$answer"
2727+}
2828+2929+# --- edit below ---------------------------------------------------------
3030+3131+step "Open the app at http://localhost:3000 and sign in."
3232+3333+capture ERRORED "Click the 'Export' button. Did it throw an error? (y/n)"
3434+3535+capture ERROR_MSG "Paste the error message (or 'none'):"
3636+3737+# --- edit above ---------------------------------------------------------
3838+3939+printf '\n--- Captured ---\n'
4040+printf 'ERRORED=%s\n' "$ERRORED"
4141+printf 'ERROR_MSG=%s\n' "$ERROR_MSG"
+10
.agents/skills/grill-me/SKILL.md
···11+---
22+name: grill-me
33+description: Interview the user relentlessly about a plan or design until reaching shared understanding, resolving each branch of the decision tree. Use when user wants to stress-test a plan, get grilled on their design, or mentions "grill me".
44+---
55+66+Interview me relentlessly about every aspect of this plan until we reach a shared understanding. Walk down each branch of the design tree, resolving dependencies between decisions one-by-one. For each question, provide your recommended answer.
77+88+Ask the questions one at a time.
99+1010+If a question can be answered by exploring the codebase, explore the codebase instead.
+47
.agents/skills/grill-with-docs/ADR-FORMAT.md
···11+# ADR Format
22+33+ADRs live in `docs/adr/` and use sequential numbering: `0001-slug.md`, `0002-slug.md`, etc.
44+55+Create the `docs/adr/` directory lazily — only when the first ADR is needed.
66+77+## Template
88+99+```md
1010+# {Short title of the decision}
1111+1212+{1-3 sentences: what's the context, what did we decide, and why.}
1313+```
1414+1515+That's it. An ADR can be a single paragraph. The value is in recording *that* a decision was made and *why* — not in filling out sections.
1616+1717+## Optional sections
1818+1919+Only include these when they add genuine value. Most ADRs won't need them.
2020+2121+- **Status** frontmatter (`proposed | accepted | deprecated | superseded by ADR-NNNN`) — useful when decisions are revisited
2222+- **Considered Options** — only when the rejected alternatives are worth remembering
2323+- **Consequences** — only when non-obvious downstream effects need to be called out
2424+2525+## Numbering
2626+2727+Scan `docs/adr/` for the highest existing number and increment by one.
2828+2929+## When to offer an ADR
3030+3131+All three of these must be true:
3232+3333+1. **Hard to reverse** — the cost of changing your mind later is meaningful
3434+2. **Surprising without context** — a future reader will look at the code and wonder "why on earth did they do it this way?"
3535+3. **The result of a real trade-off** — there were genuine alternatives and you picked one for specific reasons
3636+3737+If a decision is easy to reverse, skip it — you'll just reverse it. If it's not surprising, nobody will wonder why. If there was no real alternative, there's nothing to record beyond "we did the obvious thing."
3838+3939+### What qualifies
4040+4141+- **Architectural shape.** "We're using a monorepo." "The write model is event-sourced, the read model is projected into Postgres."
4242+- **Integration patterns between contexts.** "Ordering and Billing communicate via domain events, not synchronous HTTP."
4343+- **Technology choices that carry lock-in.** Database, message bus, auth provider, deployment target. Not every library — just the ones that would take a quarter to swap out.
4444+- **Boundary and scope decisions.** "Customer data is owned by the Customer context; other contexts reference it by ID only." The explicit no-s are as valuable as the yes-s.
4545+- **Deliberate deviations from the obvious path.** "We're using manual SQL instead of an ORM because X." Anything where a reasonable reader would assume the opposite. These stop the next engineer from "fixing" something that was deliberate.
4646+- **Constraints not visible in the code.** "We can't use AWS because of compliance requirements." "Response times must be under 200ms because of the partner API contract."
4747+- **Rejected alternatives when the rejection is non-obvious.** If you considered GraphQL and picked REST for subtle reasons, record it — otherwise someone will suggest GraphQL again in six months.
+77
.agents/skills/grill-with-docs/CONTEXT-FORMAT.md
···11+# CONTEXT.md Format
22+33+## Structure
44+55+```md
66+# {Context Name}
77+88+{One or two sentence description of what this context is and why it exists.}
99+1010+## Language
1111+1212+**Order**:
1313+{A concise description of the term}
1414+_Avoid_: Purchase, transaction
1515+1616+**Invoice**:
1717+A request for payment sent to a customer after delivery.
1818+_Avoid_: Bill, payment request
1919+2020+**Customer**:
2121+A person or organization that places orders.
2222+_Avoid_: Client, buyer, account
2323+2424+## Relationships
2525+2626+- An **Order** produces one or more **Invoices**
2727+- An **Invoice** belongs to exactly one **Customer**
2828+2929+## Example dialogue
3030+3131+> **Dev:** "When a **Customer** places an **Order**, do we create the **Invoice** immediately?"
3232+> **Domain expert:** "No — an **Invoice** is only generated once a **Fulfillment** is confirmed."
3333+3434+## Flagged ambiguities
3535+3636+- "account" was used to mean both **Customer** and **User** — resolved: these are distinct concepts.
3737+```
3838+3939+## Rules
4040+4141+- **Be opinionated.** When multiple words exist for the same concept, pick the best one and list the others as aliases to avoid.
4242+- **Flag conflicts explicitly.** If a term is used ambiguously, call it out in "Flagged ambiguities" with a clear resolution.
4343+- **Keep definitions tight.** One sentence max. Define what it IS, not what it does.
4444+- **Show relationships.** Use bold term names and express cardinality where obvious.
4545+- **Only include terms specific to this project's context.** General programming concepts (timeouts, error types, utility patterns) don't belong even if the project uses them extensively. Before adding a term, ask: is this a concept unique to this context, or a general programming concept? Only the former belongs.
4646+- **Group terms under subheadings** when natural clusters emerge. If all terms belong to a single cohesive area, a flat list is fine.
4747+- **Write an example dialogue.** A conversation between a dev and a domain expert that demonstrates how the terms interact naturally and clarifies boundaries between related concepts.
4848+4949+## Single vs multi-context repos
5050+5151+**Single context (most repos):** One `CONTEXT.md` at the repo root.
5252+5353+**Multiple contexts:** A `CONTEXT-MAP.md` at the repo root lists the contexts, where they live, and how they relate to each other:
5454+5555+```md
5656+# Context Map
5757+5858+## Contexts
5959+6060+- [Ordering](./src/ordering/CONTEXT.md) — receives and tracks customer orders
6161+- [Billing](./src/billing/CONTEXT.md) — generates invoices and processes payments
6262+- [Fulfillment](./src/fulfillment/CONTEXT.md) — manages warehouse picking and shipping
6363+6464+## Relationships
6565+6666+- **Ordering → Fulfillment**: Ordering emits `OrderPlaced` events; Fulfillment consumes them to start picking
6767+- **Fulfillment → Billing**: Fulfillment emits `ShipmentDispatched` events; Billing consumes them to generate invoices
6868+- **Ordering ↔ Billing**: Shared types for `CustomerId` and `Money`
6969+```
7070+7171+The skill infers which structure applies:
7272+7373+- If `CONTEXT-MAP.md` exists, read it to find contexts
7474+- If only a root `CONTEXT.md` exists, single context
7575+- If neither exists, create a root `CONTEXT.md` lazily when the first term is resolved
7676+7777+When multiple contexts exist, infer which one the current topic relates to. If unclear, ask.
+81
.agents/skills/grill-with-docs/SKILL.md
···11+---
22+name: grill-with-docs
33+description: Grilling session that challenges your plan against the existing domain model, sharpens terminology, and updates documentation (CONTEXT.md, ADRs) inline as decisions crystallise. Use when user wants to stress-test a plan against their project's language and documented decisions.
44+disable-model-invocation: true
55+---
66+77+Interview me relentlessly about every aspect of this plan until we reach a shared understanding. Walk down each branch of the design tree, resolving dependencies between decisions one-by-one. For each question, provide your recommended answer.
88+99+Ask the questions one at a time, waiting for feedback on each question before continuing.
1010+1111+If a question can be answered by exploring the codebase, explore the codebase instead.
1212+1313+## Domain awareness
1414+1515+During codebase exploration, also look for existing documentation:
1616+1717+### File structure
1818+1919+Most repos have a single context:
2020+2121+```
2222+/
2323+├── CONTEXT.md
2424+├── docs/
2525+│ └── adr/
2626+│ ├── 0001-event-sourced-orders.md
2727+│ └── 0002-postgres-for-write-model.md
2828+└── src/
2929+```
3030+3131+If a `CONTEXT-MAP.md` exists at the root, the repo has multiple contexts. The map points to where each one lives:
3232+3333+```
3434+/
3535+├── CONTEXT-MAP.md
3636+├── docs/
3737+│ └── adr/ ← system-wide decisions
3838+├── src/
3939+│ ├── ordering/
4040+│ │ ├── CONTEXT.md
4141+│ │ └── docs/adr/ ← context-specific decisions
4242+│ └── billing/
4343+│ ├── CONTEXT.md
4444+│ └── docs/adr/
4545+```
4646+4747+Create files lazily — only when you have something to write. If no `CONTEXT.md` exists, create one when the first term is resolved. If no `docs/adr/` exists, create it when the first ADR is needed.
4848+4949+## During the session
5050+5151+### Challenge against the glossary
5252+5353+When the user uses a term that conflicts with the existing language in `CONTEXT.md`, call it out immediately. "Your glossary defines 'cancellation' as X, but you seem to mean Y — which is it?"
5454+5555+### Sharpen fuzzy language
5656+5757+When the user uses vague or overloaded terms, propose a precise canonical term. "You're saying 'account' — do you mean the Customer or the User? Those are different things."
5858+5959+### Discuss concrete scenarios
6060+6161+When domain relationships are being discussed, stress-test them with specific scenarios. Invent scenarios that probe edge cases and force the user to be precise about the boundaries between concepts.
6262+6363+### Cross-reference with code
6464+6565+When the user states how something works, check whether the code agrees. If you find a contradiction, surface it: "Your code cancels entire Orders, but you just said partial cancellation is possible — which is right?"
6666+6767+### Update CONTEXT.md inline
6868+6969+When a term is resolved, update `CONTEXT.md` right there. Don't batch these up — capture them as they happen. Use the format in [CONTEXT-FORMAT.md](./CONTEXT-FORMAT.md).
7070+7171+Don't couple `CONTEXT.md` to implementation details. Only include terms that are meaningful to domain experts.
7272+7373+### Offer ADRs sparingly
7474+7575+Only offer to create an ADR when all three are true:
7676+7777+1. **Hard to reverse** — the cost of changing your mind later is meaningful
7878+2. **Surprising without context** — a future reader will wonder "why did they do it this way?"
7979+3. **The result of a real trade-off** — there were genuine alternatives and you picked one for specific reasons
8080+8181+If any of the three is missing, skip the ADR. Use the format in [ADR-FORMAT.md](./ADR-FORMAT.md).
···11+# Deepening
22+33+How to deepen a cluster of shallow modules safely, given its dependencies. Assumes the vocabulary in [LANGUAGE.md](LANGUAGE.md) — **module**, **interface**, **seam**, **adapter**.
44+55+## Dependency categories
66+77+When assessing a candidate for deepening, classify its dependencies. The category determines how the deepened module is tested across its seam.
88+99+### 1. In-process
1010+1111+Pure computation, in-memory state, no I/O. Always deepenable — merge the modules and test through the new interface directly. No adapter needed.
1212+1313+### 2. Local-substitutable
1414+1515+Dependencies that have local test stand-ins (PGLite for Postgres, in-memory filesystem). Deepenable if the stand-in exists. The deepened module is tested with the stand-in running in the test suite. The seam is internal; no port at the module's external interface.
1616+1717+### 3. Remote but owned (Ports & Adapters)
1818+1919+Your own services across a network boundary (microservices, internal APIs). Define a **port** (interface) at the seam. The deep module owns the logic; the transport is injected as an **adapter**. Tests use an in-memory adapter. Production uses an HTTP/gRPC/queue adapter.
2020+2121+Recommendation shape: *"Define a port at the seam, implement an HTTP adapter for production and an in-memory adapter for testing, so the logic sits in one deep module even though it's deployed across a network."*
2222+2323+### 4. True external (Mock)
2424+2525+Third-party services (Stripe, Twilio, etc.) you don't control. The deepened module takes the external dependency as an injected port; tests provide a mock adapter.
2626+2727+## Seam discipline
2828+2929+- **One adapter means a hypothetical seam. Two adapters means a real one.** Don't introduce a port unless at least two adapters are justified (typically production + test). A single-adapter seam is just indirection.
3030+- **Internal seams vs external seams.** A deep module can have internal seams (private to its implementation, used by its own tests) as well as the external seam at its interface. Don't expose internal seams through the interface just because tests use them.
3131+3232+## Testing strategy: replace, don't layer
3333+3434+- Old unit tests on shallow modules become waste once tests at the deepened module's interface exist — delete them.
3535+- Write new tests at the deepened module's interface. The **interface is the test surface**.
3636+- Tests assert on observable outcomes through the interface, not internal state.
3737+- Tests should survive internal refactors — they describe behaviour, not implementation. If a test has to change when the implementation changes, it's testing past the interface.
···11+# Interface Design
22+33+When the user wants to explore alternative interfaces for a chosen deepening candidate, use this parallel sub-agent pattern. Based on "Design It Twice" (Ousterhout) — your first idea is unlikely to be the best.
44+55+Uses the vocabulary in [LANGUAGE.md](LANGUAGE.md) — **module**, **interface**, **seam**, **adapter**, **leverage**.
66+77+## Process
88+99+### 1. Frame the problem space
1010+1111+Before spawning sub-agents, write a user-facing explanation of the problem space for the chosen candidate:
1212+1313+- The constraints any new interface would need to satisfy
1414+- The dependencies it would rely on, and which category they fall into (see [DEEPENING.md](DEEPENING.md))
1515+- A rough illustrative code sketch to ground the constraints — not a proposal, just a way to make the constraints concrete
1616+1717+Show this to the user, then immediately proceed to Step 2. The user reads and thinks while the sub-agents work in parallel.
1818+1919+### 2. Spawn sub-agents
2020+2121+Spawn 3+ sub-agents in parallel using the Agent tool. Each must produce a **radically different** interface for the deepened module.
2222+2323+Prompt each sub-agent with a separate technical brief (file paths, coupling details, dependency category from [DEEPENING.md](DEEPENING.md), what sits behind the seam). The brief is independent of the user-facing problem-space explanation in Step 1. Give each agent a different design constraint:
2424+2525+- Agent 1: "Minimize the interface — aim for 1–3 entry points max. Maximise leverage per entry point."
2626+- Agent 2: "Maximise flexibility — support many use cases and extension."
2727+- Agent 3: "Optimise for the most common caller — make the default case trivial."
2828+- Agent 4 (if applicable): "Design around ports & adapters for cross-seam dependencies."
2929+3030+Include both [LANGUAGE.md](LANGUAGE.md) vocabulary and CONTEXT.md vocabulary in the brief so each sub-agent names things consistently with the architecture language and the project's domain language.
3131+3232+Each sub-agent outputs:
3333+3434+1. Interface (types, methods, params — plus invariants, ordering, error modes)
3535+2. Usage example showing how callers use it
3636+3. What the implementation hides behind the seam
3737+4. Dependency strategy and adapters (see [DEEPENING.md](DEEPENING.md))
3838+5. Trade-offs — where leverage is high, where it's thin
3939+4040+### 3. Present and compare
4141+4242+Present designs sequentially so the user can absorb each one, then compare them in prose. Contrast by **depth** (leverage at the interface), **locality** (where change concentrates), and **seam placement**.
4343+4444+After comparing, give your own recommendation: which design you think is strongest and why. If elements from different designs would combine well, propose a hybrid. Be opinionated — the user wants a strong read, not a menu.
···11+# Language
22+33+Shared vocabulary for every suggestion this skill makes. Use these terms exactly — don't substitute "component," "service," "API," or "boundary." Consistent language is the whole point.
44+55+## Terms
66+77+**Module**
88+Anything with an interface and an implementation. Deliberately scale-agnostic — applies equally to a function, class, package, or tier-spanning slice.
99+_Avoid_: unit, component, service.
1010+1111+**Interface**
1212+Everything a caller must know to use the module correctly. Includes the type signature, but also invariants, ordering constraints, error modes, required configuration, and performance characteristics.
1313+_Avoid_: API, signature (too narrow — those refer only to the type-level surface).
1414+1515+**Implementation**
1616+What's inside a module — its body of code. Distinct from **Adapter**: a thing can be a small adapter with a large implementation (a Postgres repo) or a large adapter with a small implementation (an in-memory fake). Reach for "adapter" when the seam is the topic; "implementation" otherwise.
1717+1818+**Depth**
1919+Leverage at the interface — the amount of behaviour a caller (or test) can exercise per unit of interface they have to learn. A module is **deep** when a large amount of behaviour sits behind a small interface. A module is **shallow** when the interface is nearly as complex as the implementation.
2020+2121+**Seam** _(from Michael Feathers)_
2222+A place where you can alter behaviour without editing in that place. The *location* at which a module's interface lives. Choosing where to put the seam is its own design decision, distinct from what goes behind it.
2323+_Avoid_: boundary (overloaded with DDD's bounded context).
2424+2525+**Adapter**
2626+A concrete thing that satisfies an interface at a seam. Describes *role* (what slot it fills), not substance (what's inside).
2727+2828+**Leverage**
2929+What callers get from depth. More capability per unit of interface they have to learn. One implementation pays back across N call sites and M tests.
3030+3131+**Locality**
3232+What maintainers get from depth. Change, bugs, knowledge, and verification concentrate at one place rather than spreading across callers. Fix once, fixed everywhere.
3333+3434+## Principles
3535+3636+- **Depth is a property of the interface, not the implementation.** A deep module can be internally composed of small, mockable, swappable parts — they just aren't part of the interface. A module can have **internal seams** (private to its implementation, used by its own tests) as well as the **external seam** at its interface.
3737+- **The deletion test.** Imagine deleting the module. If complexity vanishes, the module wasn't hiding anything (it was a pass-through). If complexity reappears across N callers, the module was earning its keep.
3838+- **The interface is the test surface.** Callers and tests cross the same seam. If you want to test *past* the interface, the module is probably the wrong shape.
3939+- **One adapter means a hypothetical seam. Two adapters means a real one.** Don't introduce a seam unless something actually varies across it.
4040+4141+## Relationships
4242+4343+- A **Module** has exactly one **Interface** (the surface it presents to callers and tests).
4444+- **Depth** is a property of a **Module**, measured against its **Interface**.
4545+- A **Seam** is where a **Module**'s **Interface** lives.
4646+- An **Adapter** sits at a **Seam** and satisfies the **Interface**.
4747+- **Depth** produces **Leverage** for callers and **Locality** for maintainers.
4848+4949+## Rejected framings
5050+5151+- **Depth as ratio of implementation-lines to interface-lines** (Ousterhout): rewards padding the implementation. We use depth-as-leverage instead.
5252+- **"Interface" as the TypeScript `interface` keyword or a class's public methods**: too narrow — interface here includes every fact a caller must know.
5353+- **"Boundary"**: overloaded with DDD's bounded context. Say **seam** or **interface**.
···11+---
22+name: improve-codebase-architecture
33+description: Find deepening opportunities in a codebase, informed by the domain language in CONTEXT.md and the decisions in docs/adr/. Use when the user wants to improve architecture, find refactoring opportunities, consolidate tightly-coupled modules, or make a codebase more testable and AI-navigable.
44+---
55+66+# Improve Codebase Architecture
77+88+Surface architectural friction and propose **deepening opportunities** — refactors that turn shallow modules into deep ones. The aim is testability and AI-navigability.
99+1010+## Glossary
1111+1212+Use these terms exactly in every suggestion. Consistent language is the point — don't drift into "component," "service," "API," or "boundary." Full definitions in [LANGUAGE.md](LANGUAGE.md).
1313+1414+- **Module** — anything with an interface and an implementation (function, class, package, slice).
1515+- **Interface** — everything a caller must know to use the module: types, invariants, error modes, ordering, config. Not just the type signature.
1616+- **Implementation** — the code inside.
1717+- **Depth** — leverage at the interface: a lot of behaviour behind a small interface. **Deep** = high leverage. **Shallow** = interface nearly as complex as the implementation.
1818+- **Seam** — where an interface lives; a place behaviour can be altered without editing in place. (Use this, not "boundary.")
1919+- **Adapter** — a concrete thing satisfying an interface at a seam.
2020+- **Leverage** — what callers get from depth.
2121+- **Locality** — what maintainers get from depth: change, bugs, knowledge concentrated in one place.
2222+2323+Key principles (see [LANGUAGE.md](LANGUAGE.md) for the full list):
2424+2525+- **Deletion test**: imagine deleting the module. If complexity vanishes, it was a pass-through. If complexity reappears across N callers, it was earning its keep.
2626+- **The interface is the test surface.**
2727+- **One adapter = hypothetical seam. Two adapters = real seam.**
2828+2929+This skill is _informed_ by the project's domain model. The domain language gives names to good seams; ADRs record decisions the skill should not re-litigate.
3030+3131+## Process
3232+3333+### 1. Explore
3434+3535+Read the project's domain glossary and any ADRs in the area you're touching first.
3636+3737+Then use the Agent tool with `subagent_type=Explore` to walk the codebase. Don't follow rigid heuristics — explore organically and note where you experience friction:
3838+3939+- Where does understanding one concept require bouncing between many small modules?
4040+- Where are modules **shallow** — interface nearly as complex as the implementation?
4141+- Where have pure functions been extracted just for testability, but the real bugs hide in how they're called (no **locality**)?
4242+- Where do tightly-coupled modules leak across their seams?
4343+- Which parts of the codebase are untested, or hard to test through their current interface?
4444+4545+Apply the **deletion test** to anything you suspect is shallow: would deleting it concentrate complexity, or just move it? A "yes, concentrates" is the signal you want.
4646+4747+### 2. Present candidates
4848+4949+Present a numbered list of deepening opportunities. For each candidate:
5050+5151+- **Files** — which files/modules are involved
5252+- **Problem** — why the current architecture is causing friction
5353+- **Solution** — plain English description of what would change
5454+- **Benefits** — explained in terms of locality and leverage, and also in how tests would improve
5555+5656+**Use CONTEXT.md vocabulary for the domain, and [LANGUAGE.md](LANGUAGE.md) vocabulary for the architecture.** If `CONTEXT.md` defines "Order," talk about "the Order intake module" — not "the FooBarHandler," and not "the Order service."
5757+5858+**ADR conflicts**: if a candidate contradicts an existing ADR, only surface it when the friction is real enough to warrant revisiting the ADR. Mark it clearly (e.g. _"contradicts ADR-0007 — but worth reopening because…"_). Don't list every theoretical refactor an ADR forbids.
5959+6060+Do NOT propose interfaces yet. Ask the user: "Which of these would you like to explore?"
6161+6262+### 3. Grilling loop
6363+6464+Once the user picks a candidate, drop into a grilling conversation. Walk the design tree with them — constraints, dependencies, the shape of the deepened module, what sits behind the seam, what tests survive.
6565+6666+Side effects happen inline as decisions crystallize:
6767+6868+- **Naming a deepened module after a concept not in `CONTEXT.md`?** Add the term to `CONTEXT.md` — same discipline as `/grill-with-docs` (see [CONTEXT-FORMAT.md](../grill-with-docs/CONTEXT-FORMAT.md)). Create the file lazily if it doesn't exist.
6969+- **Sharpening a fuzzy term during the conversation?** Update `CONTEXT.md` right there.
7070+- **User rejects the candidate with a load-bearing reason?** Offer an ADR, framed as: _"Want me to record this as an ADR so future architecture reviews don't re-suggest it?"_ Only offer when the reason would actually be needed by a future explorer to avoid re-suggesting the same thing — skip ephemeral reasons ("not worth it right now") and self-evident ones. See [ADR-FORMAT.md](../grill-with-docs/ADR-FORMAT.md).
7171+- **Want to explore alternative interfaces for the deepened module?** See [INTERFACE-DESIGN.md](INTERFACE-DESIGN.md).
+121
.agents/skills/setup-matt-pocock-skills/SKILL.md
···11+---
22+name: setup-matt-pocock-skills
33+description: Sets up an `## Agent skills` block in AGENTS.md/CLAUDE.md and `docs/agents/` so the engineering skills know this repo's issue tracker (GitHub or local markdown), triage label vocabulary, and domain doc layout. Run before first use of `to-issues`, `to-prd`, `triage`, `diagnose`, `tdd`, `improve-codebase-architecture`, or `zoom-out` — or if those skills appear to be missing context about the issue tracker, triage labels, or domain docs.
44+disable-model-invocation: true
55+---
66+77+# Setup Matt Pocock's Skills
88+99+Scaffold the per-repo configuration that the engineering skills assume:
1010+1111+- **Issue tracker** — where issues live (GitHub by default; local markdown is also supported out of the box)
1212+- **Triage labels** — the strings used for the five canonical triage roles
1313+- **Domain docs** — where `CONTEXT.md` and ADRs live, and the consumer rules for reading them
1414+1515+This is a prompt-driven skill, not a deterministic script. Explore, present what you found, confirm with the user, then write.
1616+1717+## Process
1818+1919+### 1. Explore
2020+2121+Look at the current repo to understand its starting state. Read whatever exists; don't assume:
2222+2323+- `git remote -v` and `.git/config` — is this a GitHub repo? Which one?
2424+- `AGENTS.md` and `CLAUDE.md` at the repo root — does either exist? Is there already an `## Agent skills` section in either?
2525+- `CONTEXT.md` and `CONTEXT-MAP.md` at the repo root
2626+- `docs/adr/` and any `src/*/docs/adr/` directories
2727+- `docs/agents/` — does this skill's prior output already exist?
2828+- `.scratch/` — sign that a local-markdown issue tracker convention is already in use
2929+3030+### 2. Present findings and ask
3131+3232+Summarise what's present and what's missing. Then walk the user through the three decisions **one at a time** — present a section, get the user's answer, then move to the next. Don't dump all three at once.
3333+3434+Assume the user does not know what these terms mean. Each section starts with a short explainer (what it is, why these skills need it, what changes if they pick differently). Then show the choices and the default.
3535+3636+**Section A — Issue tracker.**
3737+3838+> Explainer: The "issue tracker" is where issues live for this repo. Skills like `to-issues`, `triage`, `to-prd`, and `qa` read from and write to it — they need to know whether to call `gh issue create`, write a markdown file under `.scratch/`, or follow some other workflow you describe. Pick the place you actually track work for this repo.
3939+4040+Default posture: these skills were designed for GitHub. If a `git remote` points at GitHub, propose that. If a `git remote` points at GitLab (`gitlab.com` or a self-hosted host), propose GitLab. Otherwise (or if the user prefers), offer:
4141+4242+- **GitHub** — issues live in the repo's GitHub Issues (uses the `gh` CLI)
4343+- **GitLab** — issues live in the repo's GitLab Issues (uses the [`glab`](https://gitlab.com/gitlab-org/cli) CLI)
4444+- **Local markdown** — issues live as files under `.scratch/<feature>/` in this repo (good for solo projects or repos without a remote)
4545+- **Other** (Jira, Linear, etc.) — ask the user to describe the workflow in one paragraph; the skill will record it as freeform prose
4646+4747+**Section B — Triage label vocabulary.**
4848+4949+> Explainer: When the `triage` skill processes an incoming issue, it moves it through a state machine — needs evaluation, waiting on reporter, ready for an AFK agent to pick up, ready for a human, or won't fix. To do that, it needs to apply labels (or the equivalent in your issue tracker) that match strings *you've actually configured*. If your repo already uses different label names (e.g. `bug:triage` instead of `needs-triage`), map them here so the skill applies the right ones instead of creating duplicates.
5050+5151+The five canonical roles:
5252+5353+- `needs-triage` — maintainer needs to evaluate
5454+- `needs-info` — waiting on reporter
5555+- `ready-for-agent` — fully specified, AFK-ready (an agent can pick it up with no human context)
5656+- `ready-for-human` — needs human implementation
5757+- `wontfix` — will not be actioned
5858+5959+Default: each role's string equals its name. Ask the user if they want to override any. If their issue tracker has no existing labels, the defaults are fine.
6060+6161+**Section C — Domain docs.**
6262+6363+> Explainer: Some skills (`improve-codebase-architecture`, `diagnose`, `tdd`) read a `CONTEXT.md` file to learn the project's domain language, and `docs/adr/` for past architectural decisions. They need to know whether the repo has one global context or multiple (e.g. a monorepo with separate frontend/backend contexts) so they look in the right place.
6464+6565+Confirm the layout:
6666+6767+- **Single-context** — one `CONTEXT.md` + `docs/adr/` at the repo root. Most repos are this.
6868+- **Multi-context** — `CONTEXT-MAP.md` at the root pointing to per-context `CONTEXT.md` files (typically a monorepo).
6969+7070+### 3. Confirm and edit
7171+7272+Show the user a draft of:
7373+7474+- The `## Agent skills` block to add to whichever of `CLAUDE.md` / `AGENTS.md` is being edited (see step 4 for selection rules)
7575+- The contents of `docs/agents/issue-tracker.md`, `docs/agents/triage-labels.md`, `docs/agents/domain.md`
7676+7777+Let them edit before writing.
7878+7979+### 4. Write
8080+8181+**Pick the file to edit:**
8282+8383+- If `CLAUDE.md` exists, edit it.
8484+- Else if `AGENTS.md` exists, edit it.
8585+- If neither exists, ask the user which one to create — don't pick for them.
8686+8787+Never create `AGENTS.md` when `CLAUDE.md` already exists (or vice versa) — always edit the one that's already there.
8888+8989+If an `## Agent skills` block already exists in the chosen file, update its contents in-place rather than appending a duplicate. Don't overwrite user edits to the surrounding sections.
9090+9191+The block:
9292+9393+```markdown
9494+## Agent skills
9595+9696+### Issue tracker
9797+9898+[one-line summary of where issues are tracked]. See `docs/agents/issue-tracker.md`.
9999+100100+### Triage labels
101101+102102+[one-line summary of the label vocabulary]. See `docs/agents/triage-labels.md`.
103103+104104+### Domain docs
105105+106106+[one-line summary of layout — "single-context" or "multi-context"]. See `docs/agents/domain.md`.
107107+```
108108+109109+Then write the three docs files using the seed templates in this skill folder as a starting point:
110110+111111+- [issue-tracker-github.md](./issue-tracker-github.md) — GitHub issue tracker
112112+- [issue-tracker-gitlab.md](./issue-tracker-gitlab.md) — GitLab issue tracker
113113+- [issue-tracker-local.md](./issue-tracker-local.md) — local-markdown issue tracker
114114+- [triage-labels.md](./triage-labels.md) — label mapping
115115+- [domain.md](./domain.md) — domain doc consumer rules + layout
116116+117117+For "other" issue trackers, write `docs/agents/issue-tracker.md` from scratch using the user's description.
118118+119119+### 5. Done
120120+121121+Tell the user the setup is complete and which engineering skills will now read from these files. Mention they can edit `docs/agents/*.md` directly later — re-running this skill is only necessary if they want to switch issue trackers or restart from scratch.
+51
.agents/skills/setup-matt-pocock-skills/domain.md
···11+# Domain Docs
22+33+How the engineering skills should consume this repo's domain documentation when exploring the codebase.
44+55+## Before exploring, read these
66+77+- **`CONTEXT.md`** at the repo root, or
88+- **`CONTEXT-MAP.md`** at the repo root if it exists — it points at one `CONTEXT.md` per context. Read each one relevant to the topic.
99+- **`docs/adr/`** — read ADRs that touch the area you're about to work in. In multi-context repos, also check `src/<context>/docs/adr/` for context-scoped decisions.
1010+1111+If any of these files don't exist, **proceed silently**. Don't flag their absence; don't suggest creating them upfront. The producer skill (`/grill-with-docs`) creates them lazily when terms or decisions actually get resolved.
1212+1313+## File structure
1414+1515+Single-context repo (most repos):
1616+1717+```
1818+/
1919+├── CONTEXT.md
2020+├── docs/adr/
2121+│ ├── 0001-event-sourced-orders.md
2222+│ └── 0002-postgres-for-write-model.md
2323+└── src/
2424+```
2525+2626+Multi-context repo (presence of `CONTEXT-MAP.md` at the root):
2727+2828+```
2929+/
3030+├── CONTEXT-MAP.md
3131+├── docs/adr/ ← system-wide decisions
3232+└── src/
3333+ ├── ordering/
3434+ │ ├── CONTEXT.md
3535+ │ └── docs/adr/ ← context-specific decisions
3636+ └── billing/
3737+ ├── CONTEXT.md
3838+ └── docs/adr/
3939+```
4040+4141+## Use the glossary's vocabulary
4242+4343+When your output names a domain concept (in an issue title, a refactor proposal, a hypothesis, a test name), use the term as defined in `CONTEXT.md`. Don't drift to synonyms the glossary explicitly avoids.
4444+4545+If the concept you need isn't in the glossary yet, that's a signal — either you're inventing language the project doesn't use (reconsider) or there's a real gap (note it for `/grill-with-docs`).
4646+4747+## Flag ADR conflicts
4848+4949+If your output contradicts an existing ADR, surface it explicitly rather than silently overriding:
5050+5151+> _Contradicts ADR-0007 (event-sourced orders) — but worth reopening because…_
···11+# Issue tracker: GitHub
22+33+Issues and PRDs for this repo live as GitHub issues. Use the `gh` CLI for all operations.
44+55+## Conventions
66+77+- **Create an issue**: `gh issue create --title "..." --body "..."`. Use a heredoc for multi-line bodies.
88+- **Read an issue**: `gh issue view <number> --comments`, filtering comments by `jq` and also fetching labels.
99+- **List issues**: `gh issue list --state open --json number,title,body,labels,comments --jq '[.[] | {number, title, body, labels: [.labels[].name], comments: [.comments[].body]}]'` with appropriate `--label` and `--state` filters.
1010+- **Comment on an issue**: `gh issue comment <number> --body "..."`
1111+- **Apply / remove labels**: `gh issue edit <number> --add-label "..."` / `--remove-label "..."`
1212+- **Close**: `gh issue close <number> --comment "..."`
1313+1414+Infer the repo from `git remote -v` — `gh` does this automatically when run inside a clone.
1515+1616+## When a skill says "publish to the issue tracker"
1717+1818+Create a GitHub issue.
1919+2020+## When a skill says "fetch the relevant ticket"
2121+2222+Run `gh issue view <number> --comments`.
···11+# Issue tracker: GitLab
22+33+Issues and PRDs for this repo live as GitLab issues. Use the [`glab`](https://gitlab.com/gitlab-org/cli) CLI for all operations.
44+55+## Conventions
66+77+- **Create an issue**: `glab issue create --title "..." --description "..."`. Use a heredoc for multi-line descriptions. Pass `--description -` to open an editor.
88+- **Read an issue**: `glab issue view <number> --comments`. Use `-F json` for machine-readable output.
99+- **List issues**: `glab issue list --state opened -F json` with appropriate `--label` filters. Note that GitLab uses `opened` (not `open`) for the state value.
1010+- **Comment on an issue**: `glab issue note <number> --message "..."`. GitLab calls comments "notes".
1111+- **Apply / remove labels**: `glab issue update <number> --label "..."` / `--unlabel "..."`. Multiple labels can be comma-separated or by repeating the flag.
1212+- **Close**: `glab issue close <number>`. `glab issue close` does not accept a closing comment, so post the explanation first with `glab issue note <number> --message "..."`, then close.
1313+- **Merge requests**: GitLab calls PRs "merge requests". Use `glab mr create`, `glab mr view`, `glab mr note`, etc. — the same shape as `gh pr ...` with `mr` in place of `pr` and `note`/`--message` in place of `comment`/`--body`.
1414+1515+Infer the repo from `git remote -v` — `glab` does this automatically when run inside a clone.
1616+1717+## When a skill says "publish to the issue tracker"
1818+1919+Create a GitLab issue.
2020+2121+## When a skill says "fetch the relevant ticket"
2222+2323+Run `glab issue view <number> --comments`.
···11+# Issue tracker: Local Markdown
22+33+Issues and PRDs for this repo live as markdown files in `.scratch/`.
44+55+## Conventions
66+77+- One feature per directory: `.scratch/<feature-slug>/`
88+- The PRD is `.scratch/<feature-slug>/PRD.md`
99+- Implementation issues are `.scratch/<feature-slug>/issues/<NN>-<slug>.md`, numbered from `01`
1010+- Triage state is recorded as a `Status:` line near the top of each issue file (see `triage-labels.md` for the role strings)
1111+- Comments and conversation history append to the bottom of the file under a `## Comments` heading
1212+1313+## When a skill says "publish to the issue tracker"
1414+1515+Create a new file under `.scratch/<feature-slug>/` (creating the directory if needed).
1616+1717+## When a skill says "fetch the relevant ticket"
1818+1919+Read the file at the referenced path. The user will normally pass the path or the issue number directly.
···11+# Triage Labels
22+33+The skills speak in terms of five canonical triage roles. This file maps those roles to the actual label strings used in this repo's issue tracker.
44+55+| Label in mattpocock/skills | Label in our tracker | Meaning |
66+| -------------------------- | -------------------- | ---------------------------------------- |
77+| `needs-triage` | `needs-triage` | Maintainer needs to evaluate this issue |
88+| `needs-info` | `needs-info` | Waiting on reporter for more information |
99+| `ready-for-agent` | `ready-for-agent` | Fully specified, ready for an AFK agent |
1010+| `ready-for-human` | `ready-for-human` | Requires human implementation |
1111+| `wontfix` | `wontfix` | Will not be actioned |
1212+1313+When a skill mentions a role (e.g. "apply the AFK-ready triage label"), use the corresponding label string from this table.
1414+1515+Edit the right-hand column to match whatever vocabulary you actually use.
+109
.agents/skills/tdd/SKILL.md
···11+---
22+name: tdd
33+description: Test-driven development with red-green-refactor loop. Use when user wants to build features or fix bugs using TDD, mentions "red-green-refactor", wants integration tests, or asks for test-first development.
44+---
55+66+# Test-Driven Development
77+88+## Philosophy
99+1010+**Core principle**: Tests should verify behavior through public interfaces, not implementation details. Code can change entirely; tests shouldn't.
1111+1212+**Good tests** are integration-style: they exercise real code paths through public APIs. They describe _what_ the system does, not _how_ it does it. A good test reads like a specification - "user can checkout with valid cart" tells you exactly what capability exists. These tests survive refactors because they don't care about internal structure.
1313+1414+**Bad tests** are coupled to implementation. They mock internal collaborators, test private methods, or verify through external means (like querying a database directly instead of using the interface). The warning sign: your test breaks when you refactor, but behavior hasn't changed. If you rename an internal function and tests fail, those tests were testing implementation, not behavior.
1515+1616+See [tests.md](tests.md) for examples and [mocking.md](mocking.md) for mocking guidelines.
1717+1818+## Anti-Pattern: Horizontal Slices
1919+2020+**DO NOT write all tests first, then all implementation.** This is "horizontal slicing" - treating RED as "write all tests" and GREEN as "write all code."
2121+2222+This produces **crap tests**:
2323+2424+- Tests written in bulk test _imagined_ behavior, not _actual_ behavior
2525+- You end up testing the _shape_ of things (data structures, function signatures) rather than user-facing behavior
2626+- Tests become insensitive to real changes - they pass when behavior breaks, fail when behavior is fine
2727+- You outrun your headlights, committing to test structure before understanding the implementation
2828+2929+**Correct approach**: Vertical slices via tracer bullets. One test → one implementation → repeat. Each test responds to what you learned from the previous cycle. Because you just wrote the code, you know exactly what behavior matters and how to verify it.
3030+3131+```
3232+WRONG (horizontal):
3333+ RED: test1, test2, test3, test4, test5
3434+ GREEN: impl1, impl2, impl3, impl4, impl5
3535+3636+RIGHT (vertical):
3737+ RED→GREEN: test1→impl1
3838+ RED→GREEN: test2→impl2
3939+ RED→GREEN: test3→impl3
4040+ ...
4141+```
4242+4343+## Workflow
4444+4545+### 1. Planning
4646+4747+When exploring the codebase, use the project's domain glossary so that test names and interface vocabulary match the project's language, and respect ADRs in the area you're touching.
4848+4949+Before writing any code:
5050+5151+- [ ] Confirm with user what interface changes are needed
5252+- [ ] Confirm with user which behaviors to test (prioritize)
5353+- [ ] Identify opportunities for [deep modules](deep-modules.md) (small interface, deep implementation)
5454+- [ ] Design interfaces for [testability](interface-design.md)
5555+- [ ] List the behaviors to test (not implementation steps)
5656+- [ ] Get user approval on the plan
5757+5858+Ask: "What should the public interface look like? Which behaviors are most important to test?"
5959+6060+**You can't test everything.** Confirm with the user exactly which behaviors matter most. Focus testing effort on critical paths and complex logic, not every possible edge case.
6161+6262+### 2. Tracer Bullet
6363+6464+Write ONE test that confirms ONE thing about the system:
6565+6666+```
6767+RED: Write test for first behavior → test fails
6868+GREEN: Write minimal code to pass → test passes
6969+```
7070+7171+This is your tracer bullet - proves the path works end-to-end.
7272+7373+### 3. Incremental Loop
7474+7575+For each remaining behavior:
7676+7777+```
7878+RED: Write next test → fails
7979+GREEN: Minimal code to pass → passes
8080+```
8181+8282+Rules:
8383+8484+- One test at a time
8585+- Only enough code to pass current test
8686+- Don't anticipate future tests
8787+- Keep tests focused on observable behavior
8888+8989+### 4. Refactor
9090+9191+After all tests pass, look for [refactor candidates](refactoring.md):
9292+9393+- [ ] Extract duplication
9494+- [ ] Deepen modules (move complexity behind simple interfaces)
9595+- [ ] Apply SOLID principles where natural
9696+- [ ] Consider what new code reveals about existing code
9797+- [ ] Run tests after each refactor step
9898+9999+**Never refactor while RED.** Get to GREEN first.
100100+101101+## Checklist Per Cycle
102102+103103+```
104104+[ ] Test describes behavior, not implementation
105105+[ ] Test uses public interface only
106106+[ ] Test would survive internal refactor
107107+[ ] Code is minimal for this test
108108+[ ] No speculative features added
109109+```
+33
.agents/skills/tdd/deep-modules.md
···11+# Deep Modules
22+33+From "A Philosophy of Software Design":
44+55+**Deep module** = small interface + lots of implementation
66+77+```
88+┌─────────────────────┐
99+│ Small Interface │ ← Few methods, simple params
1010+├─────────────────────┤
1111+│ │
1212+│ │
1313+│ Deep Implementation│ ← Complex logic hidden
1414+│ │
1515+│ │
1616+└─────────────────────┘
1717+```
1818+1919+**Shallow module** = large interface + little implementation (avoid)
2020+2121+```
2222+┌─────────────────────────────────┐
2323+│ Large Interface │ ← Many methods, complex params
2424+├─────────────────────────────────┤
2525+│ Thin Implementation │ ← Just passes through
2626+└─────────────────────────────────┘
2727+```
2828+2929+When designing interfaces, ask:
3030+3131+- Can I reduce the number of methods?
3232+- Can I simplify the parameters?
3333+- Can I hide more complexity inside?
+31
.agents/skills/tdd/interface-design.md
···11+# Interface Design for Testability
22+33+Good interfaces make testing natural:
44+55+1. **Accept dependencies, don't create them**
66+77+ ```typescript
88+ // Testable
99+ function processOrder(order, paymentGateway) {}
1010+1111+ // Hard to test
1212+ function processOrder(order) {
1313+ const gateway = new StripeGateway();
1414+ }
1515+ ```
1616+1717+2. **Return results, don't produce side effects**
1818+1919+ ```typescript
2020+ // Testable
2121+ function calculateDiscount(cart): Discount {}
2222+2323+ // Hard to test
2424+ function applyDiscount(cart): void {
2525+ cart.total -= discount;
2626+ }
2727+ ```
2828+2929+3. **Small surface area**
3030+ - Fewer methods = fewer tests needed
3131+ - Fewer params = simpler test setup
+59
.agents/skills/tdd/mocking.md
···11+# When to Mock
22+33+Mock at **system boundaries** only:
44+55+- External APIs (payment, email, etc.)
66+- Databases (sometimes - prefer test DB)
77+- Time/randomness
88+- File system (sometimes)
99+1010+Don't mock:
1111+1212+- Your own classes/modules
1313+- Internal collaborators
1414+- Anything you control
1515+1616+## Designing for Mockability
1717+1818+At system boundaries, design interfaces that are easy to mock:
1919+2020+**1. Use dependency injection**
2121+2222+Pass external dependencies in rather than creating them internally:
2323+2424+```typescript
2525+// Easy to mock
2626+function processPayment(order, paymentClient) {
2727+ return paymentClient.charge(order.total);
2828+}
2929+3030+// Hard to mock
3131+function processPayment(order) {
3232+ const client = new StripeClient(process.env.STRIPE_KEY);
3333+ return client.charge(order.total);
3434+}
3535+```
3636+3737+**2. Prefer SDK-style interfaces over generic fetchers**
3838+3939+Create specific functions for each external operation instead of one generic function with conditional logic:
4040+4141+```typescript
4242+// GOOD: Each function is independently mockable
4343+const api = {
4444+ getUser: (id) => fetch(`/users/${id}`),
4545+ getOrders: (userId) => fetch(`/users/${userId}/orders`),
4646+ createOrder: (data) => fetch('/orders', { method: 'POST', body: data }),
4747+};
4848+4949+// BAD: Mocking requires conditional logic inside the mock
5050+const api = {
5151+ fetch: (endpoint, options) => fetch(endpoint, options),
5252+};
5353+```
5454+5555+The SDK approach means:
5656+- Each mock returns one specific shape
5757+- No conditional logic in test setup
5858+- Easier to see which endpoints a test exercises
5959+- Type safety per endpoint
+10
.agents/skills/tdd/refactoring.md
···11+# Refactor Candidates
22+33+After TDD cycle, look for:
44+55+- **Duplication** → Extract function/class
66+- **Long methods** → Break into private helpers (keep tests on public interface)
77+- **Shallow modules** → Combine or deepen
88+- **Feature envy** → Move logic to where data lives
99+- **Primitive obsession** → Introduce value objects
1010+- **Existing code** the new code reveals as problematic
+61
.agents/skills/tdd/tests.md
···11+# Good and Bad Tests
22+33+## Good Tests
44+55+**Integration-style**: Test through real interfaces, not mocks of internal parts.
66+77+```typescript
88+// GOOD: Tests observable behavior
99+test("user can checkout with valid cart", async () => {
1010+ const cart = createCart();
1111+ cart.add(product);
1212+ const result = await checkout(cart, paymentMethod);
1313+ expect(result.status).toBe("confirmed");
1414+});
1515+```
1616+1717+Characteristics:
1818+1919+- Tests behavior users/callers care about
2020+- Uses public API only
2121+- Survives internal refactors
2222+- Describes WHAT, not HOW
2323+- One logical assertion per test
2424+2525+## Bad Tests
2626+2727+**Implementation-detail tests**: Coupled to internal structure.
2828+2929+```typescript
3030+// BAD: Tests implementation details
3131+test("checkout calls paymentService.process", async () => {
3232+ const mockPayment = jest.mock(paymentService);
3333+ await checkout(cart, payment);
3434+ expect(mockPayment.process).toHaveBeenCalledWith(cart.total);
3535+});
3636+```
3737+3838+Red flags:
3939+4040+- Mocking internal collaborators
4141+- Testing private methods
4242+- Asserting on call counts/order
4343+- Test breaks when refactoring without behavior change
4444+- Test name describes HOW not WHAT
4545+- Verifying through external means instead of interface
4646+4747+```typescript
4848+// BAD: Bypasses interface to verify
4949+test("createUser saves to database", async () => {
5050+ await createUser({ name: "Alice" });
5151+ const row = await db.query("SELECT * FROM users WHERE name = ?", ["Alice"]);
5252+ expect(row).toBeDefined();
5353+});
5454+5555+// GOOD: Verifies through interface
5656+test("createUser makes user retrievable", async () => {
5757+ const user = await createUser({ name: "Alice" });
5858+ const retrieved = await getUser(user.id);
5959+ expect(retrieved.name).toBe("Alice");
6060+});
6161+```
+81
.agents/skills/to-issues/SKILL.md
···11+---
22+name: to-issues
33+description: Break a plan, spec, or PRD into independently-grabbable issues on the project issue tracker using tracer-bullet vertical slices. Use when user wants to convert a plan into issues, create implementation tickets, or break down work into issues.
44+---
55+66+# To Issues
77+88+Break a plan into independently-grabbable issues using vertical slices (tracer bullets).
99+1010+The issue tracker and triage label vocabulary should have been provided to you — run `/setup-matt-pocock-skills` if not.
1111+1212+## Process
1313+1414+### 1. Gather context
1515+1616+Work from whatever is already in the conversation context. If the user passes an issue reference (issue number, URL, or path) as an argument, fetch it from the issue tracker and read its full body and comments.
1717+1818+### 2. Explore the codebase (optional)
1919+2020+If you have not already explored the codebase, do so to understand the current state of the code. Issue titles and descriptions should use the project's domain glossary vocabulary, and respect ADRs in the area you're touching.
2121+2222+### 3. Draft vertical slices
2323+2424+Break the plan into **tracer bullet** issues. Each issue is a thin vertical slice that cuts through ALL integration layers end-to-end, NOT a horizontal slice of one layer.
2525+2626+Slices may be 'HITL' or 'AFK'. HITL slices require human interaction, such as an architectural decision or a design review. AFK slices can be implemented and merged without human interaction. Prefer AFK over HITL where possible.
2727+2828+<vertical-slice-rules>
2929+- Each slice delivers a narrow but COMPLETE path through every layer (schema, API, UI, tests)
3030+- A completed slice is demoable or verifiable on its own
3131+- Prefer many thin slices over few thick ones
3232+</vertical-slice-rules>
3333+3434+### 4. Quiz the user
3535+3636+Present the proposed breakdown as a numbered list. For each slice, show:
3737+3838+- **Title**: short descriptive name
3939+- **Type**: HITL / AFK
4040+- **Blocked by**: which other slices (if any) must complete first
4141+- **User stories covered**: which user stories this addresses (if the source material has them)
4242+4343+Ask the user:
4444+4545+- Does the granularity feel right? (too coarse / too fine)
4646+- Are the dependency relationships correct?
4747+- Should any slices be merged or split further?
4848+- Are the correct slices marked as HITL and AFK?
4949+5050+Iterate until the user approves the breakdown.
5151+5252+### 5. Publish the issues to the issue tracker
5353+5454+For each approved slice, publish a new issue to the issue tracker. Use the issue body template below. Apply the `needs-triage` triage label so each issue enters the normal triage flow.
5555+5656+Publish issues in dependency order (blockers first) so you can reference real issue identifiers in the "Blocked by" field.
5757+5858+<issue-template>
5959+## Parent
6060+6161+A reference to the parent issue on the issue tracker (if the source was an existing issue, otherwise omit this section).
6262+6363+## What to build
6464+6565+A concise description of this vertical slice. Describe the end-to-end behavior, not layer-by-layer implementation.
6666+6767+## Acceptance criteria
6868+6969+- [ ] Criterion 1
7070+- [ ] Criterion 2
7171+- [ ] Criterion 3
7272+7373+## Blocked by
7474+7575+- A reference to the blocking ticket (if any)
7676+7777+Or "None - can start immediately" if no blockers.
7878+7979+</issue-template>
8080+8181+Do NOT close or modify any parent issue.
+74
.agents/skills/to-prd/SKILL.md
···11+---
22+name: to-prd
33+description: Turn the current conversation context into a PRD and publish it to the project issue tracker. Use when user wants to create a PRD from the current context.
44+---
55+66+This skill takes the current conversation context and codebase understanding and produces a PRD. Do NOT interview the user — just synthesize what you already know.
77+88+The issue tracker and triage label vocabulary should have been provided to you — run `/setup-matt-pocock-skills` if not.
99+1010+## Process
1111+1212+1. Explore the repo to understand the current state of the codebase, if you haven't already. Use the project's domain glossary vocabulary throughout the PRD, and respect any ADRs in the area you're touching.
1313+1414+2. Sketch out the major modules you will need to build or modify to complete the implementation. Actively look for opportunities to extract deep modules that can be tested in isolation.
1515+1616+A deep module (as opposed to a shallow module) is one which encapsulates a lot of functionality in a simple, testable interface which rarely changes.
1717+1818+Check with the user that these modules match their expectations. Check with the user which modules they want tests written for.
1919+2020+3. Write the PRD using the template below, then publish it to the project issue tracker. Apply the `needs-triage` triage label so it enters the normal triage flow.
2121+2222+<prd-template>
2323+2424+## Problem Statement
2525+2626+The problem that the user is facing, from the user's perspective.
2727+2828+## Solution
2929+3030+The solution to the problem, from the user's perspective.
3131+3232+## User Stories
3333+3434+A LONG, numbered list of user stories. Each user story should be in the format of:
3535+3636+1. As an <actor>, I want a <feature>, so that <benefit>
3737+3838+<user-story-example>
3939+1. As a mobile bank customer, I want to see balance on my accounts, so that I can make better informed decisions about my spending
4040+</user-story-example>
4141+4242+This list of user stories should be extremely extensive and cover all aspects of the feature.
4343+4444+## Implementation Decisions
4545+4646+A list of implementation decisions that were made. This can include:
4747+4848+- The modules that will be built/modified
4949+- The interfaces of those modules that will be modified
5050+- Technical clarifications from the developer
5151+- Architectural decisions
5252+- Schema changes
5353+- API contracts
5454+- Specific interactions
5555+5656+Do NOT include specific file paths or code snippets. They may end up being outdated very quickly.
5757+5858+## Testing Decisions
5959+6060+A list of testing decisions that were made. Include:
6161+6262+- A description of what makes a good test (only test external behavior, not implementation details)
6363+- Which modules will be tested
6464+- Prior art for the tests (i.e. similar types of tests in the codebase)
6565+6666+## Out of Scope
6767+6868+A description of the things that are out of scope for this PRD.
6969+7070+## Further Notes
7171+7272+Any further notes about the feature.
7373+7474+</prd-template>
+7
.agents/skills/zoom-out/SKILL.md
···11+---
22+name: zoom-out
33+description: Tell the agent to zoom out and give broader context or a higher-level perspective. Use when you're unfamiliar with a section of code or need to understand how it fits into the bigger picture.
44+disable-model-invocation: true
55+---
66+77+I don't know this area of code well. Go up a layer of abstraction. Give me a map of all the relevant modules and callers, using the project's domain glossary vocabulary.
+20-3
AGENTS.md
···11-# Vite+ Rules For This Repo
11+# Rules For This Project
2233-This project uses Vite+ and the `vp` CLI.
33+## Script Instructions
4455-## Repo-Specific Rules
55+This project uses Vite+ and the `vp` CLI.
6677- Do not use `pnpm`, `npm`, or Yarn directly for installs, updates, or package execution.
88- Do not use raw tool CLIs like `vite`, `vitest`, `oxlint`, or `oxfmt`; use the matching `vp` command instead.
99- Use `vp run <script>` when you need a package script that shares a name with a built-in Vite+ command.
1010- Use `vpx` instead of `npx` for one-off package binaries.
1111- Import JavaScript modules from `vite-plus` rather than `vite` or `vitest`.
1212+- Never start up a dev server e.g `vp dev` or `vp run dev`. Always use an existing sever e.g. localhost:3000
12131314## CI Notes
1415···28292930## Skill Loading
30313232+This project uses both skills installed in `.agent/skills` as standard and the TanStack Intent CLI to load skills directly from packages.
3333+3134Before substantial work:
32353336- Skill check: run `vpx @tanstack/intent@latest list`, or use skills already listed in context.
···3538- Monorepos: when working across packages, run the skill check from the workspace root and prefer the local skill for the package being changed.
3639- Multiple matches: prefer the most specific local skill for the package or concern you are changing; load additional skills only when the task spans multiple packages or concerns.
3740<!-- intent-skills:end -->
4141+4242+## Agent skills
4343+4444+### Issue tracker
4545+4646+Issues and PRDs are tracked in GitHub Issues for `DogPawHat/preloading-example`. See `docs/agents/issue-tracker.md`.
4747+4848+### Triage labels
4949+5050+This repo uses the default Matt Pocock skills triage label vocabulary. See `docs/agents/triage-labels.md`.
5151+5252+### Domain docs
5353+5454+This repo uses a single-context domain docs layout. See `docs/agents/domain.md`.
+46
docs/agents/domain.md
···11+# Domain Docs
22+33+How the engineering skills should consume this repo's domain documentation when exploring the codebase.
44+55+## Before exploring, read these
66+77+- **`CONTEXT.md`** at the repo root for project domain language and codebase concepts.
88+- **`docs/adr/`** for ADRs that touch the area you're about to work in.
99+- **`PRODUCT.md`** and **`DESIGN.md`** through the `impeccable` workflow when the task involves product, brand, UX, or UI design.
1010+1111+If any of these files don't exist, **proceed silently**. Don't flag their absence; don't suggest creating them upfront. The producer skill (`/grill-with-docs`) creates domain docs lazily when terms or decisions actually get resolved. The `impeccable` skill owns product and design context.
1212+1313+## File structure
1414+1515+Single-context repo:
1616+1717+```
1818+/
1919+├── CONTEXT.md
2020+├── PRODUCT.md
2121+├── DESIGN.md
2222+├── docs/adr/
2323+│ ├── 0001-example-decision.md
2424+│ └── 0002-example-decision.md
2525+└── src/
2626+```
2727+2828+## Use each source for its job
2929+3030+Use `CONTEXT.md` for domain terms, architectural vocabulary, invariants, and codebase concepts. Do not duplicate product strategy or visual design guidance into it.
3131+3232+Use `PRODUCT.md` for product intent, users, brand, tone, anti-references, and strategic principles.
3333+3434+Use `DESIGN.md` for visual system details, UI conventions, styling decisions, components, typography, color, and interaction patterns.
3535+3636+## Use the glossary's vocabulary
3737+3838+When your output names a domain concept (in an issue title, a refactor proposal, a hypothesis, a test name), use the term as defined in `CONTEXT.md`. Don't drift to synonyms the glossary explicitly avoids.
3939+4040+If the concept you need isn't in the glossary yet, that's a signal — either you're inventing language the project doesn't use (reconsider) or there's a real gap (note it for `/grill-with-docs`).
4141+4242+## Flag ADR conflicts
4343+4444+If your output contradicts an existing ADR, surface it explicitly rather than silently overriding:
4545+4646+> _Contradicts ADR-0007 (event-sourced orders) — but worth reopening because..._
+22
docs/agents/issue-tracker.md
···11+# Issue tracker: GitHub
22+33+Issues and PRDs for this repo live as GitHub issues. Use the `gh` CLI for all operations.
44+55+## Conventions
66+77+- **Create an issue**: `gh issue create --title "..." --body "..."`. Use a heredoc for multi-line bodies.
88+- **Read an issue**: `gh issue view <number> --comments`, filtering comments by `jq` and also fetching labels.
99+- **List issues**: `gh issue list --state open --json number,title,body,labels,comments --jq '[.[] | {number, title, body, labels: [.labels[].name], comments: [.comments[].body]}]'` with appropriate `--label` and `--state` filters.
1010+- **Comment on an issue**: `gh issue comment <number> --body "..."`
1111+- **Apply / remove labels**: `gh issue edit <number> --add-label "..."` / `--remove-label "..."`
1212+- **Close**: `gh issue close <number> --comment "..."`
1313+1414+Infer the repo from `git remote -v` — `gh` does this automatically when run inside a clone.
1515+1616+## When a skill says "publish to the issue tracker"
1717+1818+Create a GitHub issue.
1919+2020+## When a skill says "fetch the relevant ticket"
2121+2222+Run `gh issue view <number> --comments`.
+15
docs/agents/triage-labels.md
···11+# Triage Labels
22+33+The skills speak in terms of five canonical triage roles. This file maps those roles to the actual label strings used in this repo's issue tracker.
44+55+| Label in mattpocock/skills | Label in our tracker | Meaning |
66+| -------------------------- | -------------------- | ---------------------------------------- |
77+| `needs-triage` | `needs-triage` | Maintainer needs to evaluate this issue |
88+| `needs-info` | `needs-info` | Waiting on reporter for more information |
99+| `ready-for-agent` | `ready-for-agent` | Fully specified, ready for an AFK agent |
1010+| `ready-for-human` | `ready-for-human` | Requires human implementation |
1111+| `wontfix` | `wontfix` | Will not be actioned |
1212+1313+When a skill mentions a role (e.g. "apply the AFK-ready triage label"), use the corresponding label string from this table.
1414+1515+Edit the right-hand column to match whatever vocabulary you actually use.