add skill: grill-with-docs (docs-anchored Socratic interview)

This commit is contained in:
Łukasz Boryń 2026-05-28 23:10:18 +02:00
parent f08223c3b2
commit 03f9ef5be8
8 changed files with 373 additions and 0 deletions

View File

@ -34,6 +34,8 @@ skill list.
scenarios as the unit of work. scenarios as the unit of work.
- **diagnose** — six-phase bug hunt: feedback loop → reproduce → - **diagnose** — six-phase bug hunt: feedback loop → reproduce →
hypothesise → instrument → fix with regression test → cleanup. hypothesise → instrument → fix with regression test → cleanup.
- **grill-with-docs** — docs-anchored Socratic interview; updates
`CONTEXT.md` inline, offers ADRs only on the three-of-three rule.
## Adding a skill ## Adding a skill

View File

@ -77,3 +77,5 @@ Hand off to [tdd-bdd](../tdd-bdd/SKILL.md):
- [../tdd-bdd/SKILL.md](../tdd-bdd/SKILL.md) — phase 5 is a tdd-bdd cycle. - [../tdd-bdd/SKILL.md](../tdd-bdd/SKILL.md) — phase 5 is a tdd-bdd cycle.
- [../tdd-bdd/refactoring-r.md](../tdd-bdd/refactoring-r.md) — file - [../tdd-bdd/refactoring-r.md](../tdd-bdd/refactoring-r.md) — file
architectural follow-ups here. architectural follow-ups here.
- [../grill-with-docs/SKILL.md](../grill-with-docs/SKILL.md) — phase 3
hypothesis names should use canonical terms from `CONTEXT.md`.

View File

@ -0,0 +1,79 @@
# ADR format
ADRs live in `docs/adr/` with sequential numbering: `0001-<slug>.md`,
`0002-<slug>.md`, etc. Create `docs/adr/` lazily — only when the first
ADR is needed.
## Template
```md
# {Short title of the decision}
{1–3 sentences: context, what was decided, and why.}
```
That's it. An ADR can be a single paragraph. The value is recording
*that* a decision was made and *why* — not in filling out sections.
## Optional sections
Add only when they add genuine value. Most ADRs won't need them.
- **Status** frontmatter (`proposed | accepted | deprecated | superseded
by ADR-NNNN`) — when decisions are revisited.
- **Considered Options** — when rejected alternatives are worth
remembering.
- **Consequences** — when non-obvious downstream effects need calling
out.
## Numbering
Scan `docs/adr/` for the highest existing number and increment by one.
## When to offer an ADR — three-of-three test
All three must hold. If any one is missing, skip the ADR.
1. **Hard to reverse.** The cost of changing your mind later is
meaningful.
2. **Surprising without context.** A future reader will look at the code
and wonder *"why on earth did they do it this way?"*
3. **The result of a real trade-off.** There were genuine alternatives
and you picked one for specific reasons.
### What qualifies
- **Architectural shape.** "Monorepo." "Write model is event-sourced,
read model is projected into Postgres." "Bookdown chapters are knit
per-chapter to bound render time."
- **Integration patterns between contexts.** "Ordering and Billing
communicate via domain events, not synchronous HTTP."
- **Technology choices that carry lock-in.** Database, message bus, auth
provider, deployment target, pipeline framework (`targets` vs
`drake`). Not every library — only the ones that would take a quarter
to swap.
- **Boundary and scope decisions.** "Customer data is owned by the
Customer context; others reference by ID only." The *no*-s are as
valuable as the *yes*-s.
- **Deliberate deviations from the obvious path.** "Manual SQL instead
of an ORM because X." "`data.table` instead of `dplyr` in `R/inf/`
because of memory." Stops the next engineer from "fixing" something
deliberate.
- **Constraints not visible in the code.** "Can't use cloud X because of
compliance." "Response times must be < 200 ms because of partner
contract."
- **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.
### What does NOT qualify
- Easy to reverse: a function rename, a config tweak. You'll just
reverse it.
- Not surprising: the obvious choice nobody would question.
- No real alternative: there was nothing to weigh.
---
_Format adapted from
<https://github.com/mattpocock/skills/blob/main/skills/engineering/grill-with-docs/ADR-FORMAT.md>._

View File

@ -0,0 +1,80 @@
# CONTEXT.md format
## Structure
```md
# {Context Name}
{One or two sentences: what this context is and why it exists.}
## Language
**Order**:
A customer's request for fulfillment. Persisted from acceptance through
delivery.
_Avoid_: Purchase, transaction.
**Invoice**:
A request for payment sent to a customer after delivery.
_Avoid_: Bill, payment request.
**Customer**:
A person or organization that places orders.
_Avoid_: Client, buyer, account.
```
## Rules
- **Be opinionated.** When multiple words exist for the same concept,
pick one and list the rest under `_Avoid_`.
- **Keep definitions tight.** One or two sentences. Define what it *is*,
not what it does.
- **Only terms specific to this context.** General programming concepts
(timeouts, error types, utility patterns, language idioms like
`box::use`) don't belong even if used heavily. Before adding a term,
ask: is this a concept unique to this project, or general programming?
Only the former.
- **Group under subheadings** when natural clusters emerge. Flat list is
fine for single-cluster contexts.
- **No implementation details.** `CONTEXT.md` is a glossary, not a spec,
not a scratchpad, not a decision log.
## Single vs multi-context repos
**Single context (most repos):** one `CONTEXT.md` at the repo root.
**Multi-context:** a `CONTEXT-MAP.md` at the repo root lists the contexts,
where they live, and how they relate:
```md
# Context Map
## Contexts
- [Ordering](./src/ordering/CONTEXT.md) — receives and tracks customer orders
- [Billing](./src/billing/CONTEXT.md) — generates invoices and processes payments
- [Fulfillment](./src/fulfillment/CONTEXT.md) — warehouse picking and shipping
## Relationships
- **Ordering → Fulfillment**: Ordering emits `OrderPlaced` events;
Fulfillment consumes them to start picking.
- **Fulfillment → Billing**: Fulfillment emits `ShipmentDispatched`
events; Billing consumes them to generate invoices.
- **Ordering ↔ Billing**: Shared types for `CustomerId` and `Money`.
```
Decision rule:
- If `CONTEXT-MAP.md` exists → multi-context. Read it to find contexts.
- Else if a single root `CONTEXT.md` exists → single-context.
- Else (neither) → create a root `CONTEXT.md` lazily when the first term
is resolved. Switch to multi-context only on observing ≥ 2 obvious
sub-roots *and* a second term that clearly belongs to one of them.
When multiple contexts exist, infer which one the current topic relates
to. If unclear, ask.
---
_Format adapted from
<https://github.com/mattpocock/skills/blob/main/skills/engineering/grill-with-docs/CONTEXT-FORMAT.md>._

View File

@ -0,0 +1,87 @@
---
name: grill-with-docs
description: Interview the user about a plan, cross-checking every term against the repo's CONTEXT.md / glossary and the code itself; update CONTEXT.md inline as terms resolve; offer ADRs only when the decision is hard to reverse, surprising, and the result of a real trade-off. Use when the user says "grill with docs", "/grill-with-docs", "stress-test this plan", "challenge my plan against the codebase", "is my language right", or wants to align a design with the project's domain vocabulary before implementation.
---
# grill-with-docs
## When to use
- User says "grill with docs", "/grill-with-docs", "stress-test this plan",
"challenge against the codebase", "align my language".
- A non-trivial plan is on the table and the repo has (or should have)
domain vocabulary worth pinning down.
- Skip when no codebase exists yet — use [`/grill-me`](../../productivity/grill-me/SKILL.md)
instead (plan-only ambiguity removal).
## Protocol
1. **One question at a time.** Wait for the answer before the next.
2. **Codebase first.** If the answer is on disk — `box::use` imports,
`tar_meta()`, function signatures, an existing `CONTEXT.md` — read
instead of asking.
3. **Challenge against the glossary.** When the user's term contradicts
`CONTEXT.md`, surface it: *"Your glossary defines 'target' as a
`tar_target`; you seem to mean a therapeutic target. Which?"*
4. **Sharpen fuzzy language.** Propose a canonical term and record losers
under `_Avoid_`. *"You're saying 'account' — do you mean Customer or
User? Different things."*
5. **Stress-test with concrete scenarios.** Invent edge cases that force
the user to pin down boundaries. *"What does the target return when
no tissue passes the threshold?"*
6. **Cross-reference with code.** If a stated mechanism contradicts the
code, name file and line. *"`_targets.R:14` sets `format = 'qs2'` —
that contradicts the parquet write you just described."*
7. **Update `CONTEXT.md` inline.** One term resolved → one edit. Never
batched. Format: see [CONTEXT-FORMAT.md](CONTEXT-FORMAT.md).
8. **Offer ADRs sparingly** (three-of-three rule, see
[ADR-FORMAT.md](ADR-FORMAT.md)). Default is *no*.
## File layout the skill expects
```
/
├── CONTEXT.md # single-context default
├── CONTEXT-MAP.md # only when ≥2 obvious sub-roots exist
├── docs/adr/
│ └── 0001-<slug>.md
└── src/ (or R/, app/, ...)
```
Create files **lazily** — only when there's a real first thing to write.
No `CONTEXT.md` yet? Create it when the first term is resolved. No
`docs/adr/`? Create it when the first ADR is needed. Confirm the *first*
write to any new file in the repo before proceeding.
### Single vs multi-context
- **Default: single.** One `CONTEXT.md` at the root.
- **Switch to multi** only when you observe **≥ 2 obvious sub-roots** in
the repo (e.g. `R/plot/`, `R/inf/`, `R/ibd/`; or `src/ordering/`,
`src/billing/`). On the second resolved term that clearly belongs to
one of them, propose `CONTEXT-MAP.md` at the root + per-context
`CONTEXT.md` under each sub-root.
## Language references — R
- [examples-r.md](examples-r.md) — full worked transcript in a
targets-pipeline style repo (the "what is a target?" conflict), plus
the resulting `CONTEXT.md` skeleton and what does *not* belong in it.
## Guardrails
- **Never** monologue. One question, wait, then the next.
- **Never** record general programming concepts in `CONTEXT.md` (timeouts,
utility patterns, language idioms). Only domain-specific terms.
- **Never** write implementation details into `CONTEXT.md`. It's a
glossary, not a spec.
- **Never** open an ADR unless all three of {hard to reverse, surprising
without context, real trade-off} are true. When in doubt, don't.
- **Never** create a `CONTEXT.md` / `docs/adr/` in the repo without
confirming the first such write.
## See also
- [../tdd-bdd/SKILL.md](../tdd-bdd/SKILL.md) — once vocabulary is pinned,
the Given/When/Then scenarios should use the canonical terms.
- [../diagnose/SKILL.md](../diagnose/SKILL.md) — hypothesis names in
diagnose post-mortems should match `CONTEXT.md` terminology.
- [../../productivity/grill-me/SKILL.md](../../productivity/grill-me/SKILL.md)
— plan-only sibling. No codebase needed; no docs updated. Use that one
for greenfield, this one for established repos.

View File

@ -0,0 +1,116 @@
# Worked example — R / bookdown / targets
A short transcript of a `/grill-with-docs` session in a targets-pipeline
style repo, followed by the `CONTEXT.md` skeleton it would produce.
## The conflict: "target"
User: *"I want to add a new target for the CR expression chapter — one
per tissue."*
Agent (one question at a time):
> **Q1.** When you say "target" — do you mean a `targets::tar_target()` in
> the pipeline, or a therapeutic target (a gene/protein of interest)?
> Both terms live in this repo: `_targets.R` uses the pipeline meaning,
> `Rmd/indication1_rmd/CR_genetics.Rmd` uses the biological meaning.
> Which?
User: *"The pipeline one."*
> **Q2.** Good — recording that as the canonical use in `CONTEXT.md` and
> demoting the biological sense to `_Avoid_: therapeutic target (use
> "gene of interest" instead)`. Confirm?
User: *"yes"*
Agent edits `CONTEXT.md` inline (see skeleton below).
> **Q3.** "One per tissue" — by tissue do you mean the `tissue` column in
> the MODB metadata (`R/indication/get_modb_bulk_config.R:42`) or the
> single-cell `cell.type` axis (`Rmd/indication2_rmd/expression_sc.Rmd`)?
> They are *different things* in this repo — six tissues vs 28 cell
> types. Which?
User: *"MODB tissue column."*
> **Q4.** Read the code: `R/indication/get_modb_bulk_config.R` shows
> tissues are `"lung"`, `"colon"`, `"liver"`, `"skin"`, `"kidney"`,
> `"heart"`. Confirm those six are the universe, or do you also want
> `"blood"` from the MSSM dataset?
…and so on. Each resolved term goes straight into `CONTEXT.md`.
## Stress-test scenario the agent should invent
> **Q5.** What should the target return when a tissue has zero significant
> genes? An empty tibble (so downstream `bind_rows` works), `NULL` (so
> downstream `purrr::compact` drops it), or an error?
Forces the user to commit to the contract before any test is written.
Hands cleanly to `/tdd-bdd` once locked.
## Cross-reference contradiction the agent surfaces
> User: *"…and the target writes a parquet file to `data_cache/`."*
>
> **Agent:** Stop — `_targets.R:14` sets `tar_option_set(format =
> "qs2")`. Targets in this repo are cached by `targets` itself, not as
> parquet. Writing to `data_cache/` would make the result invisible to
> `targets`' invalidation. Did you mean to bypass the cache, or use the
> default `qs2` format?
## When `CONTEXT-MAP.md` kicks in
This repo has three obvious sub-roots (`R/indication1/`, `R/indication2/`,
`R/indication3/`) *and* three corresponding `Rmd/` trees. On the second
resolved term that clearly belongs to one of them, the agent proposes a
`CONTEXT-MAP.md` at the root and a per-context `CONTEXT.md` under each
`R/<context>/`. Single-context users (most R packages) never see this.
## Resulting `CONTEXT.md` skeleton
After Q1–Q5 above, the agent has written:
```md
# target-assessment-report
Bookdown + targets pipeline that assembles per-tissue gene-of-interest
evidence for the target-assessment programme.
## Language
**Target**:
A `targets::tar_target()` node in `_targets.R`. The unit of pipeline
caching and invalidation.
_Avoid_: therapeutic target (use "gene of interest"), milestone, goal.
**Gene of interest**:
A gene under evaluation in a target-assessment dossier. Identified by
Ensembl gene ID (`ENSG…`) plus an HGNC symbol.
_Avoid_: therapeutic target, candidate, hit.
**Tissue**:
One of six bulk tissues from MODB: lung, colon, liver, skin, kidney,
heart. Distinct from single-cell `cell.type`.
_Avoid_: organ, sample type.
**Dataset**:
A MODB bulk dataset identified by `DS<NNN>`, configured under
`data_config/indication_pf/`.
_Avoid_: cohort, study, sample set.
```
Note: zero implementation details. No mention of `dplyr`, no function
signatures. `CONTEXT.md` is a glossary; design notes belong in ADRs.
## What would *not* get written
- "We use `box::use` for module imports" → general R idiom, not domain-
specific. Out.
- "The CR expression chapter knits in ~45 seconds" → operational
detail, not glossary material. Could become an ADR if a deliberate
trade-off ("we knit per-chapter to keep render time bounded") drove it.
- "We cache targets with `qs2`" → ADR-worthy if there was a real choice
(qs2 vs RDS vs parquet); glossary-worthy if the *word* "cache" needs
disambiguating. Often both.

View File

@ -102,3 +102,5 @@ from step 0 is a *plan*; it is not a queue of tests to enqueue at once.
## See also ## See also
- [../diagnose/SKILL.md](../diagnose/SKILL.md) — chasing an existing bug? - [../diagnose/SKILL.md](../diagnose/SKILL.md) — chasing an existing bug?
Run `/diagnose` first; phase 5 hands back here for the regression test. Run `/diagnose` first; phase 5 hands back here for the regression test.
- [../grill-with-docs/SKILL.md](../grill-with-docs/SKILL.md) — run before
step 0 so scenarios use the canonical `CONTEXT.md` vocabulary.

View File

@ -32,3 +32,8 @@ description: Run a Socratic loop that removes ambiguity from a task before any i
- No implementation, no file edits during grilling. - No implementation, no file edits during grilling.
- No leading questions ("you want X, right?"). Ask open questions. - No leading questions ("you want X, right?"). Ask open questions.
- If the user gets impatient, offer to stop early with the current understanding. - If the user gets impatient, offer to stop early with the current understanding.
## See also
- [../../engineering/grill-with-docs/SKILL.md](../../engineering/grill-with-docs/SKILL.md)
— same energy, but anchored to the repo's `CONTEXT.md` and code. Use
that one when a codebase exists to grill against.