Compare commits
41 Commits
fc6af43baa
...
Iteration/
| Author | SHA1 | Date | |
|---|---|---|---|
| c7f8b4c702 | |||
| c58773e35b | |||
| 7c8a4cd328 | |||
| a278a80b34 | |||
| 031a875ec1 | |||
| 86c38d46c5 | |||
| 208cb19f0e | |||
| 55bdc3a8d0 | |||
| 785907ce85 | |||
| 39cdbdcfef | |||
| cf5dcd28ea | |||
| ce69679b21 | |||
| 43bcb0e4ae | |||
| 2fd11daaf0 | |||
| 751cb46079 | |||
| d4d6e91256 | |||
| 696d272cb5 | |||
| 21702da413 | |||
| 841ed1ceb0 | |||
| da9c805d89 | |||
| 4902a02c87 | |||
| 2823ff13bf | |||
| 19767c4284 | |||
| 7dae5f2bf8 | |||
| 4766fed174 | |||
| d022cc8788 | |||
| bcf3e31db6 | |||
| c4f430ccb3 | |||
| 1a9db9328e | |||
| 2e130b98f5 | |||
| 5cdcdad534 | |||
| d2e08dbbec | |||
| 026d4908d8 | |||
| 31232ea899 | |||
| b38df737e1 | |||
| 346156ee9b | |||
| 0d79130e07 | |||
| b3fb8c7a82 | |||
| 44fb21eb6a | |||
| 8f738ffbe8 | |||
| 6db152bb2f |
30
.agents/rules/ponytail.md
Normal file
30
.agents/rules/ponytail.md
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
# Ponytail, lazy senior dev mode
|
||||||
|
|
||||||
|
You are a lazy senior developer. Lazy means efficient, not careless. The best code is the code never written.
|
||||||
|
|
||||||
|
Before writing any code, stop at the first rung that holds:
|
||||||
|
|
||||||
|
1. Does this need to be built at all? (YAGNI)
|
||||||
|
2. Does it already exist in this codebase? Reuse the helper, util, or pattern that's already here, don't re-write it.
|
||||||
|
3. Does the standard library already do this? Use it.
|
||||||
|
4. Does a native platform feature cover it? Use it.
|
||||||
|
5. Does an already-installed dependency solve it? Use it.
|
||||||
|
6. Can this be one line? Make it one line.
|
||||||
|
7. Only then: write the minimum code that works.
|
||||||
|
|
||||||
|
The ladder runs after you understand the problem, not instead of it: read the task and the code it touches, trace the real flow end to end, then climb.
|
||||||
|
|
||||||
|
Bug fix = root cause, not symptom: a report names a symptom. Grep every caller of the function you touch and fix the shared function once — one guard there is a smaller diff than one per caller, and patching only the path the ticket names leaves a sibling caller still broken.
|
||||||
|
|
||||||
|
Rules:
|
||||||
|
|
||||||
|
- No abstractions that weren't explicitly requested.
|
||||||
|
- No new dependency if it can be avoided.
|
||||||
|
- No boilerplate nobody asked for.
|
||||||
|
- Deletion over addition. Boring over clever. Fewest files possible.
|
||||||
|
- Shortest working diff wins, but only once you understand the problem. The smallest change in the wrong place isn't lazy, it's a second bug.
|
||||||
|
- Question complex requests: "Do you actually need X, or does Y cover it?"
|
||||||
|
- Pick the edge-case-correct option when two stdlib approaches are the same size, lazy means less code, not the flimsier algorithm.
|
||||||
|
- Mark intentional simplifications with a `ponytail:` comment. If the shortcut has a known ceiling (global lock, O(n²) scan, naive heuristic), the comment names the ceiling and the upgrade path.
|
||||||
|
|
||||||
|
Not lazy about: understanding the problem (read it fully and trace the real flow before picking a rung, a small diff you don't understand is just laziness dressed up as efficiency), input validation at trust boundaries, error handling that prevents data loss, security, accessibility, the calibration real hardware needs (the platform is never the spec ideal, a clock drifts, a sensor reads off), anything explicitly requested. Lazy code without its check is unfinished: non-trivial logic leaves ONE runnable check behind, the smallest thing that fails if the logic breaks (an assert-based demo/self-check or one small test file; no frameworks, no fixtures). Trivial one-liners need no test.
|
||||||
78
.agents/skills/ask-matt/SKILL.md
Normal file
78
.agents/skills/ask-matt/SKILL.md
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
---
|
||||||
|
name: ask-matt
|
||||||
|
description: Ask which skill or flow fits your situation. A router over the skills in this repo.
|
||||||
|
disable-model-invocation: true
|
||||||
|
---
|
||||||
|
|
||||||
|
# Ask Matt
|
||||||
|
|
||||||
|
You don't remember every skill, so ask.
|
||||||
|
|
||||||
|
A **flow** is a path through the skills. Most paths run along one **main flow**, and two **on-ramps** merge onto it. Everything else is standalone, or a vocabulary layer that runs underneath.
|
||||||
|
|
||||||
|
## The main flow: idea → ship
|
||||||
|
|
||||||
|
The route most work travels. You have an idea and want it built.
|
||||||
|
|
||||||
|
1. **`/grill-with-docs`** — sharpen the idea by interview. Start here when you **have a codebase**: it's stateful, retaining what it learns in `CONTEXT.md` and ADRs. (No codebase? Use `/grill-me` — see Standalone. Both run the same `/grilling` primitive; `grill-with-docs` is the one that leaves a paper trail.)
|
||||||
|
2. **Branch — can you settle every question in conversation?** If a question needs a runnable answer (state, business logic, a UI you have to see), detour through a prototype, bridged by **`/handoff`** in both directions (see Crossing sessions):
|
||||||
|
- **`/handoff`** out, then open a fresh session against that file,
|
||||||
|
- **`/prototype`** to answer the question with throwaway code,
|
||||||
|
- **`/handoff`** back what you learned, and reference it from the original idea thread.
|
||||||
|
3. **Branch — is this a multi-session build?**
|
||||||
|
- **Yes** → **`/to-spec`** (turn the thread into a spec), then **`/to-tickets`** to split it into tracer-bullet tickets, each declaring its **blocking edges**. On a local tracker that's one file per ticket under `.scratch/<feature>/issues/`, worked blockers-first by hand; on a real tracker the edges become native blocking links, so any ticket whose blockers are done can be grabbed — kick off **`/implement`** per ticket, **clearing context between each one**.
|
||||||
|
- **No** → **`/implement`** right here, in the same context window.
|
||||||
|
|
||||||
|
Either way, **`/implement`** builds each issue by driving **`/tdd`** internally — one red-green slice at a time — then closes out by running **`/code-review`**, a two-axis review (Standards + Spec) of the diff, before committing. Reach for **`/tdd`** on its own when you just want to build a concrete behaviour test-first without a full spec, and **`/code-review`** on its own whenever you want to review a branch or PR against a fixed point.
|
||||||
|
|
||||||
|
### Context hygiene
|
||||||
|
|
||||||
|
Keep steps 1–3 in **one unbroken context window** — don't compact or clear until after `/to-tickets` — so the grilling, spec, and tickets all build on the same thinking. Each `/implement` then starts fresh, working from the ticket.
|
||||||
|
|
||||||
|
The limit on this is the **[smart zone](https://www.aihero.dev/ai-coding-dictionary/smart-zone)**: the window (~120k tokens on state-of-the-art models) within which the model still reasons sharply. If a session approaches it before `/to-tickets`, don't push on degraded — `/handoff` and continue in a fresh thread.
|
||||||
|
|
||||||
|
## On-ramps
|
||||||
|
|
||||||
|
A starting situation that generates work, then merges onto the main flow.
|
||||||
|
|
||||||
|
- **Bugs and requests piling up** → **`/triage`**. It moves issues through triage roles and produces agent-ready issues, which **`/implement`** later picks up.
|
||||||
|
|
||||||
|
Triage is only for issues **you didn't create** — bug reports, incoming feature requests, anything that arrives raw. Tickets that `/to-tickets` produced are already agent-ready, so **don't triage them**.
|
||||||
|
|
||||||
|
- **Something's broken** → **`/diagnosing-bugs`**. For the hard ones: the bug that resists a first glance, the intermittent flake, the regression that crept in between two known-good states. It refuses to theorise until it has a **tight feedback loop** — one command that already goes red on *this* bug — then fixes with a regression test. Its post-mortem hands off to **`/improve-codebase-architecture`** when the real finding is that there's no good seam to lock the bug down.
|
||||||
|
|
||||||
|
- **A huge, foggy effort — a greenfield project or a huge feature build, too big for one session** → **`/wayfinder`**, the most cognitively demanding flow here. When the way from here to the destination isn't visible yet, it charts a **shared map** of **decision tickets** on the issue tracker and resolves them one at a time — producing **decisions, not deliverables** — until the fog is pushed back and the way is clear. Where **`/grill-with-docs`** sharpens an idea you can hold in one session, wayfinder is for the idea you can't — and it's slower and denser, so save it for exactly that, never a well-scoped feature.
|
||||||
|
|
||||||
|
When the map clears, **it hands off, it doesn't build**: merge onto the main flow at **`/to-spec`**, which collapses the map's linked decisions into a buildable plan, then `/to-tickets` and `/implement` as usual. Looping the map straight into `/implement` skips that collapse and throws the linked detail away — go straight to `/implement` only when the effort turned out genuinely small.
|
||||||
|
|
||||||
|
## Codebase health
|
||||||
|
|
||||||
|
Not feature work — upkeep.
|
||||||
|
|
||||||
|
- **`/improve-codebase-architecture`** — run whenever you have a spare moment to keep the codebase good for agents to operate in. It surfaces **deepening opportunities**; picking one _generates an idea_ you can take into the main flow at `/grill-with-docs`. It's the survey that finds the candidates; **`/codebase-design`** (below) is the bench you design the chosen one on.
|
||||||
|
|
||||||
|
## Vocabulary underneath
|
||||||
|
|
||||||
|
Two model-invoked references that run *beneath* the other skills — each the single source of truth for its vocabulary. Reach for them directly when the **words**, not the process, are the problem; or let the skills above pull them in.
|
||||||
|
|
||||||
|
- **`/domain-modeling`** — sharpen the project's *domain* language: challenge a fuzzy term, resolve an overloaded word ("account" doing three jobs), record a hard-to-reverse decision as an ADR. It's the active discipline `/grill-with-docs` drives to keep `CONTEXT.md` a clean glossary.
|
||||||
|
- **`/codebase-design`** — the deep-module vocabulary (module, interface, depth, seam, adapter, leverage, locality) for designing a module's *shape*: a lot of behaviour behind a small interface at a clean seam. `/tdd` and `/improve-codebase-architecture` both speak it.
|
||||||
|
|
||||||
|
## Crossing sessions
|
||||||
|
|
||||||
|
- **`/handoff`** — when a thread is full or you need to branch off (e.g. into a `/prototype` session), this compacts the conversation into a markdown file. You don't continue in place — you **open a new session and reference that file** to carry the context across. It's the bridge between context windows, in either direction. Use it when you want a **fresh session** but need the **current conversation preserved**.
|
||||||
|
- **`/compact`** (built-in) — stay in the **same conversation**, letting the earlier turns be summarized. Use it at **intentional breaks between phases**, when you don't mind losing the verbatim history. Don't compact mid-phase — the agent can lose its way. `/handoff` forks; `/compact` continues.
|
||||||
|
|
||||||
|
## Standalone
|
||||||
|
|
||||||
|
Off the main flow entirely.
|
||||||
|
|
||||||
|
- **`/grill-me`** — the same relentless interview as `/grill-with-docs`, but for when you have **no codebase**. Stateless: it saves nothing locally, builds no `CONTEXT.md`. Reach for it to sharpen any plan or design that doesn't live in a repo.
|
||||||
|
- **`/prototype`** — a small, throwaway program that answers one design question: does this state model feel right, or what should this UI look like. Throwaway from day one — keep the answer, delete the code. It's the detour in step 2 of the main flow, but reach for it any time a design question is hard to settle on paper.
|
||||||
|
- **`/research`** — delegate reading legwork to a **background agent**: it investigates a question against **primary sources**, then leaves a cited Markdown file in the repo. Keep working while it reads. The file it produces is something to take *into* the main flow at `/grill-with-docs` — research feeds the thinking, it doesn't replace it.
|
||||||
|
- **`/teach`** — learn a concept over multiple sessions, using the current directory as a stateful workspace.
|
||||||
|
- **`/writing-great-skills`** — reference for writing and editing skills well.
|
||||||
|
|
||||||
|
## Precondition
|
||||||
|
|
||||||
|
**`/setup-matt-pocock-skills`** — run before your first engineering flow to configure the issue tracker, triage labels, and doc layout the other skills assume. Custom issue trackers also work.
|
||||||
5
.agents/skills/ask-matt/agents/openai.yaml
Normal file
5
.agents/skills/ask-matt/agents/openai.yaml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
interface:
|
||||||
|
display_name: "Ask Matt"
|
||||||
|
short_description: "Find the right skill or workflow"
|
||||||
|
policy:
|
||||||
|
allow_implicit_invocation: false
|
||||||
89
.agents/skills/code-review/SKILL.md
Normal file
89
.agents/skills/code-review/SKILL.md
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
---
|
||||||
|
name: code-review
|
||||||
|
description: Review the changes since a fixed point (commit, branch, tag, or merge-base) along two axes — Standards (does the code follow this repo's documented coding standards?) and Spec (does the code match what the originating issue/PRD asked for?). Runs both reviews in parallel sub-agents and reports them side by side. Use when the user wants to review a branch, a PR, work-in-progress changes, or asks to "review since X".
|
||||||
|
---
|
||||||
|
|
||||||
|
Two-axis review of the diff between `HEAD` and a fixed point the user supplies:
|
||||||
|
|
||||||
|
- **Standards** — does the code conform to this repo's documented coding standards?
|
||||||
|
- **Spec** — does the code faithfully implement the originating issue / PRD / spec?
|
||||||
|
|
||||||
|
Both axes run as **parallel sub-agents** so they don't pollute each other's context, then this skill aggregates their findings.
|
||||||
|
|
||||||
|
The issue tracker should have been provided to you — run `/setup-matt-pocock-skills` if `docs/agents/issue-tracker.md` is missing.
|
||||||
|
|
||||||
|
## Process
|
||||||
|
|
||||||
|
### 1. Pin the fixed point
|
||||||
|
|
||||||
|
Whatever the user said is the fixed point — a commit SHA, branch name, tag, `main`, `HEAD~5`, etc. If they didn't specify one, ask for it.
|
||||||
|
|
||||||
|
Capture the diff command once: `git diff <fixed-point>...HEAD` (three-dot, so the comparison is against the merge-base). Also note the list of commits via `git log <fixed-point>..HEAD --oneline`.
|
||||||
|
|
||||||
|
Before going further, confirm the fixed point resolves (`git rev-parse <fixed-point>`) and the diff is non-empty. A bad ref or empty diff should fail here — not inside two parallel sub-agents.
|
||||||
|
|
||||||
|
### 2. Identify the spec source
|
||||||
|
|
||||||
|
Look for the originating spec, in this order:
|
||||||
|
|
||||||
|
1. Issue references in the commit messages (`#123`, `Closes #45`, GitLab `!67`, etc.) — fetch via the workflow in `docs/agents/issue-tracker.md`.
|
||||||
|
2. A path the user passed as an argument.
|
||||||
|
3. A PRD/spec file under `docs/`, `specs/`, or `.scratch/` matching the branch name or feature.
|
||||||
|
4. If nothing is found, ask the user where the spec is. If they say there isn't one, the **Spec** sub-agent will skip and report "no spec available".
|
||||||
|
|
||||||
|
### 3. Identify the standards sources
|
||||||
|
|
||||||
|
Anything in the repo that documents how code should be written, such as `CODING_STANDARDS.md` or `CONTRIBUTING.md`.
|
||||||
|
|
||||||
|
On top of whatever the repo documents, the Standards axis always carries the **smell baseline** below — a fixed set of Fowler code smells (_Refactoring_, ch.3) that applies even when a repo documents nothing. Two rules bind it:
|
||||||
|
|
||||||
|
- **The repo overrides.** A documented repo standard always wins; where it endorses something the baseline would flag, suppress the smell.
|
||||||
|
- **Always a judgement call.** Each smell is a labelled heuristic ("possible Feature Envy"), never a hard violation — and, like any standard here, skip anything tooling already enforces.
|
||||||
|
|
||||||
|
Each smell reads *what it is* → *how to fix*; match it against the diff:
|
||||||
|
|
||||||
|
- **Mysterious Name** — a function, variable, or type whose name doesn't reveal what it does or holds. → rename it; if no honest name comes, the design's murky.
|
||||||
|
- **Duplicated Code** — the same logic shape appears in more than one hunk or file in the change. → extract the shared shape, call it from both.
|
||||||
|
- **Feature Envy** — a method that reaches into another object's data more than its own. → move the method onto the data it envies.
|
||||||
|
- **Data Clumps** — the same few fields or params keep travelling together (a type wanting to be born). → bundle them into one type, pass that.
|
||||||
|
- **Primitive Obsession** — a primitive or string standing in for a domain concept that deserves its own type. → give the concept its own small type.
|
||||||
|
- **Repeated Switches** — the same `switch`/`if`-cascade on the same type recurs across the change. → replace with polymorphism, or one map both sites share.
|
||||||
|
- **Shotgun Surgery** — one logical change forces scattered edits across many files in the diff. → gather what changes together into one module.
|
||||||
|
- **Divergent Change** — one file or module is edited for several unrelated reasons. → split so each module changes for one reason.
|
||||||
|
- **Speculative Generality** — abstraction, parameters, or hooks added for needs the spec doesn't have. → delete it; inline back until a real need shows.
|
||||||
|
- **Message Chains** — long `a.b().c().d()` navigation the caller shouldn't depend on. → hide the walk behind one method on the first object.
|
||||||
|
- **Middle Man** — a class or function that mostly just delegates onward. → cut it, call the real target direct.
|
||||||
|
- **Refused Bequest** — a subclass or implementer that ignores or overrides most of what it inherits. → drop the inheritance, use composition.
|
||||||
|
|
||||||
|
### 4. Spawn both sub-agents in parallel
|
||||||
|
|
||||||
|
Send a single message with two `Agent` tool calls. Use the `general-purpose` subagent for both.
|
||||||
|
|
||||||
|
**Standards sub-agent prompt** — include:
|
||||||
|
|
||||||
|
- The full diff command and commit list.
|
||||||
|
- The list of standards-source files you found in step 3, **plus the smell baseline from step 3** pasted in full — the sub-agent has no other access to it.
|
||||||
|
- The brief: "Report — per file/hunk where relevant — (a) every place the diff violates a documented standard: cite the standard (file + the rule); and (b) any baseline smell you spot: name it and quote the hunk. Distinguish hard violations from judgement calls — documented-standard breaches can be hard, but baseline smells are always judgement calls, and a documented repo standard overrides the baseline. Skip anything tooling enforces. Under 400 words."
|
||||||
|
|
||||||
|
**Spec sub-agent prompt** — include:
|
||||||
|
|
||||||
|
- The diff command and commit list.
|
||||||
|
- The path or fetched contents of the spec.
|
||||||
|
- The brief: "Report: (a) requirements the spec asked for that are missing or partial; (b) behaviour in the diff that wasn't asked for (scope creep); (c) requirements that look implemented but where the implementation looks wrong. Quote the spec line for each finding. Under 400 words."
|
||||||
|
|
||||||
|
If the spec is missing, skip the Spec sub-agent and note this in the final report.
|
||||||
|
|
||||||
|
### 5. Aggregate
|
||||||
|
|
||||||
|
Present the two reports under `## Standards` and `## Spec` headings, verbatim or lightly cleaned. Do **not** merge or rerank findings — the two axes are deliberately separate (see _Why two axes_).
|
||||||
|
|
||||||
|
End with a one-line summary: total findings per axis, and the worst issue _within each axis_ (if any). Don't pick a single winner across axes — that's the reranking the separation exists to prevent.
|
||||||
|
|
||||||
|
## Why two axes
|
||||||
|
|
||||||
|
A change can pass one axis and fail the other:
|
||||||
|
|
||||||
|
- Code that follows every standard but implements the wrong thing → **Standards pass, Spec fail.**
|
||||||
|
- Code that does exactly what the issue asked but breaks the project's conventions → **Spec pass, Standards fail.**
|
||||||
|
|
||||||
|
Reporting them separately stops one axis from masking the other.
|
||||||
3
.agents/skills/code-review/agents/openai.yaml
Normal file
3
.agents/skills/code-review/agents/openai.yaml
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
interface:
|
||||||
|
display_name: "Code Review"
|
||||||
|
short_description: "Review a diff on standards and spec"
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
# Deepening
|
# Deepening
|
||||||
|
|
||||||
How to deepen a cluster of shallow modules safely, given its dependencies. Assumes the vocabulary in [LANGUAGE.md](LANGUAGE.md) — **module**, **interface**, **seam**, **adapter**.
|
How to deepen a cluster of shallow modules safely, given its dependencies. Assumes the vocabulary in [SKILL.md](SKILL.md) — **module**, **interface**, **seam**, **adapter**.
|
||||||
|
|
||||||
## Dependency categories
|
## Dependency categories
|
||||||
|
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
# Interface Design
|
# Design It Twice
|
||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
Uses the vocabulary in [LANGUAGE.md](LANGUAGE.md) — **module**, **interface**, **seam**, **adapter**, **leverage**.
|
Uses the vocabulary in [SKILL.md](SKILL.md) — **module**, **interface**, **seam**, **adapter**, **leverage**.
|
||||||
|
|
||||||
## Process
|
## Process
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@ Prompt each sub-agent with a separate technical brief (file paths, coupling deta
|
|||||||
- Agent 3: "Optimise for the most common caller — make the default case trivial."
|
- Agent 3: "Optimise for the most common caller — make the default case trivial."
|
||||||
- Agent 4 (if applicable): "Design around ports & adapters for cross-seam dependencies."
|
- Agent 4 (if applicable): "Design around ports & adapters for cross-seam dependencies."
|
||||||
|
|
||||||
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.
|
Include both [SKILL.md](SKILL.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.
|
||||||
|
|
||||||
Each sub-agent outputs:
|
Each sub-agent outputs:
|
||||||
|
|
||||||
114
.agents/skills/codebase-design/SKILL.md
Normal file
114
.agents/skills/codebase-design/SKILL.md
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
---
|
||||||
|
name: codebase-design
|
||||||
|
description: Shared vocabulary for designing deep modules. Use when the user wants to design or improve a module's interface, find deepening opportunities, decide where a seam goes, make code more testable or AI-navigable, or when another skill needs the deep-module vocabulary.
|
||||||
|
---
|
||||||
|
|
||||||
|
# Codebase Design
|
||||||
|
|
||||||
|
Design **deep modules**: a lot of behaviour behind a small interface, placed at a clean seam, testable through that interface. Use this language and these principles wherever code is being designed or restructured. The aim is leverage for callers, locality for maintainers, and testability for everyone.
|
||||||
|
|
||||||
|
## Glossary
|
||||||
|
|
||||||
|
Use these terms exactly — don't substitute "component," "service," "API," or "boundary." Consistent language is the whole point.
|
||||||
|
|
||||||
|
**Module** — anything with an interface and an implementation. Deliberately scale-agnostic: a function, class, package, or tier-spanning slice. _Avoid_: unit, component, service.
|
||||||
|
|
||||||
|
**Interface** — everything a caller must know to use the module correctly: the type signature, but also invariants, ordering constraints, error modes, required configuration, and performance characteristics. _Avoid_: API, signature (too narrow — they refer only to the type-level surface).
|
||||||
|
|
||||||
|
**Implementation** — 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.
|
||||||
|
|
||||||
|
**Depth** — 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, **shallow** when the interface is nearly as complex as the implementation.
|
||||||
|
|
||||||
|
**Seam** _(Michael Feathers)_ — a place where you can alter behaviour without editing in that place; the *location* at which a module's interface lives. Where to put the seam is its own design decision, distinct from what goes behind it. _Avoid_: boundary (overloaded with DDD's bounded context).
|
||||||
|
|
||||||
|
**Adapter** — a concrete thing that satisfies an interface at a seam. Describes *role* (what slot it fills), not substance (what's inside).
|
||||||
|
|
||||||
|
**Leverage** — what callers get from depth: more capability per unit of interface they learn. One implementation pays back across N call sites and M tests.
|
||||||
|
|
||||||
|
**Locality** — what maintainers get from depth: change, bugs, knowledge, and verification concentrate in one place rather than spreading across callers. Fix once, fixed everywhere.
|
||||||
|
|
||||||
|
## Deep vs shallow
|
||||||
|
|
||||||
|
**Deep module** = small interface + lots of implementation:
|
||||||
|
|
||||||
|
```
|
||||||
|
┌─────────────────────┐
|
||||||
|
│ Small Interface │ ← Few methods, simple params
|
||||||
|
├─────────────────────┤
|
||||||
|
│ │
|
||||||
|
│ Deep Implementation│ ← Complex logic hidden
|
||||||
|
│ │
|
||||||
|
└─────────────────────┘
|
||||||
|
```
|
||||||
|
|
||||||
|
**Shallow module** = large interface + little implementation (avoid):
|
||||||
|
|
||||||
|
```
|
||||||
|
┌─────────────────────────────────┐
|
||||||
|
│ Large Interface │ ← Many methods, complex params
|
||||||
|
├─────────────────────────────────┤
|
||||||
|
│ Thin Implementation │ ← Just passes through
|
||||||
|
└─────────────────────────────────┘
|
||||||
|
```
|
||||||
|
|
||||||
|
When designing an interface, ask:
|
||||||
|
|
||||||
|
- Can I reduce the number of methods?
|
||||||
|
- Can I simplify the parameters?
|
||||||
|
- Can I hide more complexity inside?
|
||||||
|
|
||||||
|
## Principles
|
||||||
|
|
||||||
|
- **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.
|
||||||
|
- **The 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.
|
||||||
|
- **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.
|
||||||
|
- **One adapter means a hypothetical seam. Two adapters means a real one.** Don't introduce a seam unless something actually varies across it.
|
||||||
|
|
||||||
|
## Designing for testability
|
||||||
|
|
||||||
|
Good interfaces make testing natural:
|
||||||
|
|
||||||
|
1. **Accept dependencies, don't create them.**
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
// Testable
|
||||||
|
function processOrder(order, paymentGateway) {}
|
||||||
|
|
||||||
|
// Hard to test
|
||||||
|
function processOrder(order) {
|
||||||
|
const gateway = new StripeGateway();
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **Return results, don't produce side effects.**
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
// Testable
|
||||||
|
function calculateDiscount(cart): Discount {}
|
||||||
|
|
||||||
|
// Hard to test
|
||||||
|
function applyDiscount(cart): void {
|
||||||
|
cart.total -= discount;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
3. **Small surface area.** Fewer methods = fewer tests needed. Fewer params = simpler test setup.
|
||||||
|
|
||||||
|
## Relationships
|
||||||
|
|
||||||
|
- A **Module** has exactly one **Interface** (the surface it presents to callers and tests).
|
||||||
|
- **Depth** is a property of a **Module**, measured against its **Interface**.
|
||||||
|
- A **Seam** is where a **Module**'s **Interface** lives.
|
||||||
|
- An **Adapter** sits at a **Seam** and satisfies the **Interface**.
|
||||||
|
- **Depth** produces **Leverage** for callers and **Locality** for maintainers.
|
||||||
|
|
||||||
|
## Rejected framings
|
||||||
|
|
||||||
|
- **Depth as ratio of implementation-lines to interface-lines** (Ousterhout): rewards padding the implementation. We use depth-as-leverage instead.
|
||||||
|
- **"Interface" as the TypeScript `interface` keyword or a class's public methods**: too narrow — interface here includes every fact a caller must know.
|
||||||
|
- **"Boundary"**: overloaded with DDD's bounded context. Say **seam** or **interface**.
|
||||||
|
|
||||||
|
## Going deeper
|
||||||
|
|
||||||
|
- **Deepening a cluster given its dependencies** — see [DEEPENING.md](DEEPENING.md): dependency categories, seam discipline, and replace-don't-layer testing.
|
||||||
|
- **Exploring alternative interfaces** — see [DESIGN-IT-TWICE.md](DESIGN-IT-TWICE.md): spin up parallel sub-agents to design the interface several radically different ways, then compare on depth, locality, and seam placement.
|
||||||
3
.agents/skills/codebase-design/agents/openai.yaml
Normal file
3
.agents/skills/codebase-design/agents/openai.yaml
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
interface:
|
||||||
|
display_name: "Codebase Design"
|
||||||
|
short_description: "Vocabulary for deep-module design"
|
||||||
134
.agents/skills/diagnosing-bugs/SKILL.md
Normal file
134
.agents/skills/diagnosing-bugs/SKILL.md
Normal file
@@ -0,0 +1,134 @@
|
|||||||
|
---
|
||||||
|
name: diagnosing-bugs
|
||||||
|
description: Diagnosis loop for hard bugs and performance regressions. Use when the user says "diagnose"/"debug this", or reports something broken/throwing/failing/slow.
|
||||||
|
---
|
||||||
|
|
||||||
|
# Diagnosing Bugs
|
||||||
|
|
||||||
|
A discipline for hard bugs. Skip phases only when explicitly justified.
|
||||||
|
|
||||||
|
When exploring the codebase, read `CONTEXT.md` (if it exists) to get a clear mental model of the relevant modules, and check ADRs in the area you're touching.
|
||||||
|
|
||||||
|
## Phase 1 — Build a feedback loop
|
||||||
|
|
||||||
|
**This is the skill.** Everything else is mechanical. If you have a **tight** pass/fail signal for the bug — one that goes red on _this_ bug — you will find the cause; bisection, hypothesis-testing, and instrumentation all just consume it. If you don't have one, no amount of staring at code will save you.
|
||||||
|
|
||||||
|
Spend disproportionate effort here. **Be aggressive. Be creative. Refuse to give up.**
|
||||||
|
|
||||||
|
### Ways to construct one — try them in roughly this order
|
||||||
|
|
||||||
|
1. **Failing test** at whatever seam reaches the bug — unit, integration, e2e.
|
||||||
|
2. **Curl / HTTP script** against a running dev server.
|
||||||
|
3. **CLI invocation** with a fixture input, diffing stdout against a known-good snapshot.
|
||||||
|
4. **Headless browser script** (Playwright / Puppeteer) — drives the UI, asserts on DOM/console/network.
|
||||||
|
5. **Replay a captured trace.** Save a real network request / payload / event log to disk; replay it through the code path in isolation.
|
||||||
|
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.
|
||||||
|
7. **Property / fuzz loop.** If the bug is "sometimes wrong output", run 1000 random inputs and look for the failure mode.
|
||||||
|
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.
|
||||||
|
9. **Differential loop.** Run the same input through old-version vs new-version (or two configs) and diff outputs.
|
||||||
|
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.
|
||||||
|
|
||||||
|
Build the right feedback loop, and the bug is 90% fixed.
|
||||||
|
|
||||||
|
### Tighten the loop
|
||||||
|
|
||||||
|
Treat the loop as a product. Once you have _a_ loop, **tighten** it:
|
||||||
|
|
||||||
|
- Can I make it faster? (Cache setup, skip unrelated init, narrow the test scope.)
|
||||||
|
- Can I make the signal sharper? (Assert on the specific symptom, not "didn't crash".)
|
||||||
|
- Can I make it more deterministic? (Pin time, seed RNG, isolate filesystem, freeze network.)
|
||||||
|
|
||||||
|
A 30-second flaky loop is barely better than no loop; a 2-second deterministic one is tight — a debugging superpower.
|
||||||
|
|
||||||
|
### Non-deterministic bugs
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
### When you genuinely cannot build a loop
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
### Completion criterion — a tight loop that goes red
|
||||||
|
|
||||||
|
Phase 1 is done when the loop is **tight** and **red-capable**: you can name **one command** — a script path, a test invocation, a curl — that you have **already run at least once** (paste the invocation and its output), and that is:
|
||||||
|
|
||||||
|
- [ ] **Red-capable** — it drives the actual bug code path and asserts the **user's exact symptom**, so it can go red on this bug and green once fixed. Not "runs without erroring" — it must be able to _catch this specific bug_.
|
||||||
|
- [ ] **Deterministic** — same verdict every run (flaky bugs: a pinned, high reproduction rate, per above).
|
||||||
|
- [ ] **Fast** — seconds, not minutes.
|
||||||
|
- [ ] **Agent-runnable** — you can run it unattended; a human in the loop only via `scripts/hitl-loop.template.sh`.
|
||||||
|
|
||||||
|
If you catch yourself reading code to build a theory before this command exists, **stop — jumping straight to a hypothesis is the exact failure this skill prevents.** No red-capable command, no Phase 2.
|
||||||
|
|
||||||
|
## Phase 2 — Reproduce + minimise
|
||||||
|
|
||||||
|
Run the loop. Watch it go red — the bug appears.
|
||||||
|
|
||||||
|
Confirm:
|
||||||
|
|
||||||
|
- [ ] The loop produces the failure mode the **user** described — not a different failure that happens to be nearby. Wrong bug = wrong fix.
|
||||||
|
- [ ] The failure is reproducible across multiple runs (or, for non-deterministic bugs, reproducible at a high enough rate to debug against).
|
||||||
|
- [ ] You have captured the exact symptom (error message, wrong output, slow timing) so later phases can verify the fix actually addresses it.
|
||||||
|
|
||||||
|
### Minimise
|
||||||
|
|
||||||
|
Once it's red, shrink the repro to the **smallest scenario that still goes red**. Cut inputs, callers, config, data, and steps **one at a time**, re-running the loop after each cut — keep only what's load-bearing for the failure.
|
||||||
|
|
||||||
|
Why bother: a minimal repro shrinks the hypothesis space in Phase 3 (fewer moving parts left to suspect) and becomes the clean regression test in Phase 5.
|
||||||
|
|
||||||
|
Done when **every remaining element is load-bearing** — removing any one of them makes the loop go green.
|
||||||
|
|
||||||
|
Do not proceed until you have reproduced **and** minimised.
|
||||||
|
|
||||||
|
## Phase 3 — Hypothesise
|
||||||
|
|
||||||
|
Generate **3–5 ranked hypotheses** before testing any of them. Single-hypothesis generation anchors on the first plausible idea.
|
||||||
|
|
||||||
|
Each hypothesis must be **falsifiable**: state the prediction it makes.
|
||||||
|
|
||||||
|
> Format: "If <X> is the cause, then <changing Y> will make the bug disappear / <changing Z> will make it worse."
|
||||||
|
|
||||||
|
If you cannot state the prediction, the hypothesis is a vibe — discard or sharpen it.
|
||||||
|
|
||||||
|
**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.
|
||||||
|
|
||||||
|
## Phase 4 — Instrument
|
||||||
|
|
||||||
|
Each probe must map to a specific prediction from Phase 3. **Change one variable at a time.**
|
||||||
|
|
||||||
|
Tool preference:
|
||||||
|
|
||||||
|
1. **Debugger / REPL inspection** if the env supports it. One breakpoint beats ten logs.
|
||||||
|
2. **Targeted logs** at the boundaries that distinguish hypotheses.
|
||||||
|
3. Never "log everything and grep".
|
||||||
|
|
||||||
|
**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.
|
||||||
|
|
||||||
|
**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.
|
||||||
|
|
||||||
|
## Phase 5 — Fix + regression test
|
||||||
|
|
||||||
|
Write the regression test **before the fix** — but only if there is a **correct seam** for it.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
**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.
|
||||||
|
|
||||||
|
If a correct seam exists:
|
||||||
|
|
||||||
|
1. Turn the minimised repro into a failing test at that seam.
|
||||||
|
2. Watch it fail.
|
||||||
|
3. Apply the fix.
|
||||||
|
4. Watch it pass.
|
||||||
|
5. Re-run the Phase 1 feedback loop against the original (un-minimised) scenario.
|
||||||
|
|
||||||
|
## Phase 6 — Cleanup + post-mortem
|
||||||
|
|
||||||
|
Required before declaring done:
|
||||||
|
|
||||||
|
- [ ] Original repro no longer reproduces (re-run the Phase 1 loop)
|
||||||
|
- [ ] Regression test passes (or absence of seam is documented)
|
||||||
|
- [ ] All `[DEBUG-...]` instrumentation removed (`grep` the prefix)
|
||||||
|
- [ ] Throwaway prototypes deleted (or moved to a clearly-marked debug location)
|
||||||
|
- [ ] The hypothesis that turned out correct is stated in the commit / PR message — so the next debugger learns
|
||||||
|
|
||||||
|
**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.
|
||||||
3
.agents/skills/diagnosing-bugs/agents/openai.yaml
Normal file
3
.agents/skills/diagnosing-bugs/agents/openai.yaml
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
interface:
|
||||||
|
display_name: "Diagnosing Bugs"
|
||||||
|
short_description: "Diagnose hard bugs and regressions"
|
||||||
41
.agents/skills/diagnosing-bugs/scripts/hitl-loop.template.sh
Normal file
41
.agents/skills/diagnosing-bugs/scripts/hitl-loop.template.sh
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Human-in-the-loop reproduction loop.
|
||||||
|
# Copy this file, edit the steps below, and run it.
|
||||||
|
# The agent runs the script; the user follows prompts in their terminal.
|
||||||
|
#
|
||||||
|
# Usage:
|
||||||
|
# bash hitl-loop.template.sh
|
||||||
|
#
|
||||||
|
# Two helpers:
|
||||||
|
# step "<instruction>" → show instruction, wait for Enter
|
||||||
|
# capture VAR "<question>" → show question, read response into VAR
|
||||||
|
#
|
||||||
|
# At the end, captured values are printed as KEY=VALUE for the agent to parse.
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
step() {
|
||||||
|
printf '\n>>> %s\n' "$1"
|
||||||
|
read -r -p " [Enter when done] " _
|
||||||
|
}
|
||||||
|
|
||||||
|
capture() {
|
||||||
|
local var="$1" question="$2" answer
|
||||||
|
printf '\n>>> %s\n' "$question"
|
||||||
|
read -r -p " > " answer
|
||||||
|
printf -v "$var" '%s' "$answer"
|
||||||
|
}
|
||||||
|
|
||||||
|
# --- edit below ---------------------------------------------------------
|
||||||
|
|
||||||
|
step "Open the app at http://localhost:3000 and sign in."
|
||||||
|
|
||||||
|
capture ERRORED "Click the 'Export' button. Did it throw an error? (y/n)"
|
||||||
|
|
||||||
|
capture ERROR_MSG "Paste the error message (or 'none'):"
|
||||||
|
|
||||||
|
# --- edit above ---------------------------------------------------------
|
||||||
|
|
||||||
|
printf '\n--- Captured ---\n'
|
||||||
|
printf 'ERRORED=%s\n' "$ERRORED"
|
||||||
|
printf 'ERROR_MSG=%s\n' "$ERROR_MSG"
|
||||||
74
.agents/skills/domain-modeling/SKILL.md
Normal file
74
.agents/skills/domain-modeling/SKILL.md
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
---
|
||||||
|
name: domain-modeling
|
||||||
|
description: Build and sharpen a project's domain model. Use when the user wants to pin down domain terminology or a ubiquitous language, record an architectural decision, or when another skill needs to maintain the domain model.
|
||||||
|
---
|
||||||
|
|
||||||
|
# Domain Modeling
|
||||||
|
|
||||||
|
Actively build and sharpen the project's domain model as you design. This is the *active* discipline — challenging terms, inventing edge-case scenarios, and writing the glossary and decisions down the moment they crystallise. (Merely *reading* `CONTEXT.md` for vocabulary is not this skill — that's a one-line habit any skill can do. This skill is for when you're changing the model, not just consuming it.)
|
||||||
|
|
||||||
|
## File structure
|
||||||
|
|
||||||
|
Most repos have a single context:
|
||||||
|
|
||||||
|
```
|
||||||
|
/
|
||||||
|
├── CONTEXT.md
|
||||||
|
├── docs/
|
||||||
|
│ └── adr/
|
||||||
|
│ ├── 0001-event-sourced-orders.md
|
||||||
|
│ └── 0002-postgres-for-write-model.md
|
||||||
|
└── src/
|
||||||
|
```
|
||||||
|
|
||||||
|
If a `CONTEXT-MAP.md` exists at the root, the repo has multiple contexts. The map points to where each one lives:
|
||||||
|
|
||||||
|
```
|
||||||
|
/
|
||||||
|
├── CONTEXT-MAP.md
|
||||||
|
├── docs/
|
||||||
|
│ └── adr/ ← system-wide decisions
|
||||||
|
├── src/
|
||||||
|
│ ├── ordering/
|
||||||
|
│ │ ├── CONTEXT.md
|
||||||
|
│ │ └── docs/adr/ ← context-specific decisions
|
||||||
|
│ └── billing/
|
||||||
|
│ ├── CONTEXT.md
|
||||||
|
│ └── docs/adr/
|
||||||
|
```
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
## During the session
|
||||||
|
|
||||||
|
### Challenge against the glossary
|
||||||
|
|
||||||
|
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?"
|
||||||
|
|
||||||
|
### Sharpen fuzzy language
|
||||||
|
|
||||||
|
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."
|
||||||
|
|
||||||
|
### Discuss concrete scenarios
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
### Cross-reference with code
|
||||||
|
|
||||||
|
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?"
|
||||||
|
|
||||||
|
### Update CONTEXT.md inline
|
||||||
|
|
||||||
|
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).
|
||||||
|
|
||||||
|
`CONTEXT.md` should be totally devoid of implementation details. Do not treat `CONTEXT.md` as a spec, a scratch pad, or a repository for implementation decisions. It is a glossary and nothing else.
|
||||||
|
|
||||||
|
### Offer ADRs sparingly
|
||||||
|
|
||||||
|
Only offer to create an ADR when all three are true:
|
||||||
|
|
||||||
|
1. **Hard to reverse** — the cost of changing your mind later is meaningful
|
||||||
|
2. **Surprising without context** — a future reader will wonder "why 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
|
||||||
|
|
||||||
|
If any of the three is missing, skip the ADR. Use the format in [ADR-FORMAT.md](./ADR-FORMAT.md).
|
||||||
3
.agents/skills/domain-modeling/agents/openai.yaml
Normal file
3
.agents/skills/domain-modeling/agents/openai.yaml
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
interface:
|
||||||
|
display_name: "Domain Modeling"
|
||||||
|
short_description: "Build and sharpen a domain model"
|
||||||
@@ -1,10 +1,7 @@
|
|||||||
---
|
---
|
||||||
name: grill-me
|
name: grill-me
|
||||||
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".
|
description: A relentless interview to sharpen a plan or design.
|
||||||
|
disable-model-invocation: true
|
||||||
---
|
---
|
||||||
|
|
||||||
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.
|
Run a `/grilling` session.
|
||||||
|
|
||||||
Ask the questions one at a time.
|
|
||||||
|
|
||||||
If a question can be answered by exploring the codebase, explore the codebase instead.
|
|
||||||
|
|||||||
5
.agents/skills/grill-me/agents/openai.yaml
Normal file
5
.agents/skills/grill-me/agents/openai.yaml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
interface:
|
||||||
|
display_name: "Grill Me"
|
||||||
|
short_description: "Sharpen a plan through interview"
|
||||||
|
policy:
|
||||||
|
allow_implicit_invocation: false
|
||||||
@@ -1,88 +1,7 @@
|
|||||||
---
|
---
|
||||||
name: grill-with-docs
|
name: grill-with-docs
|
||||||
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.
|
description: A relentless interview to sharpen a plan or design, which also creates docs (ADR's and glossary) as we go.
|
||||||
|
disable-model-invocation: true
|
||||||
---
|
---
|
||||||
|
|
||||||
<what-to-do>
|
Run a `/grilling` session, using the `/domain-modeling` skill.
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
Ask the questions one at a time, waiting for feedback on each question before continuing.
|
|
||||||
|
|
||||||
If a question can be answered by exploring the codebase, explore the codebase instead.
|
|
||||||
|
|
||||||
</what-to-do>
|
|
||||||
|
|
||||||
<supporting-info>
|
|
||||||
|
|
||||||
## Domain awareness
|
|
||||||
|
|
||||||
During codebase exploration, also look for existing documentation:
|
|
||||||
|
|
||||||
### File structure
|
|
||||||
|
|
||||||
Most repos have a single context:
|
|
||||||
|
|
||||||
```
|
|
||||||
/
|
|
||||||
├── CONTEXT.md
|
|
||||||
├── docs/
|
|
||||||
│ └── adr/
|
|
||||||
│ ├── 0001-event-sourced-orders.md
|
|
||||||
│ └── 0002-postgres-for-write-model.md
|
|
||||||
└── src/
|
|
||||||
```
|
|
||||||
|
|
||||||
If a `CONTEXT-MAP.md` exists at the root, the repo has multiple contexts. The map points to where each one lives:
|
|
||||||
|
|
||||||
```
|
|
||||||
/
|
|
||||||
├── CONTEXT-MAP.md
|
|
||||||
├── docs/
|
|
||||||
│ └── adr/ ← system-wide decisions
|
|
||||||
├── src/
|
|
||||||
│ ├── ordering/
|
|
||||||
│ │ ├── CONTEXT.md
|
|
||||||
│ │ └── docs/adr/ ← context-specific decisions
|
|
||||||
│ └── billing/
|
|
||||||
│ ├── CONTEXT.md
|
|
||||||
│ └── docs/adr/
|
|
||||||
```
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
## During the session
|
|
||||||
|
|
||||||
### Challenge against the glossary
|
|
||||||
|
|
||||||
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?"
|
|
||||||
|
|
||||||
### Sharpen fuzzy language
|
|
||||||
|
|
||||||
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."
|
|
||||||
|
|
||||||
### Discuss concrete scenarios
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
### Cross-reference with code
|
|
||||||
|
|
||||||
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?"
|
|
||||||
|
|
||||||
### Update CONTEXT.md inline
|
|
||||||
|
|
||||||
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).
|
|
||||||
|
|
||||||
`CONTEXT.md` should be totally devoid of implementation details. Do not treat `CONTEXT.md` as a spec, a scratch pad, or a repository for implementation decisions. It is a glossary and nothing else.
|
|
||||||
|
|
||||||
### Offer ADRs sparingly
|
|
||||||
|
|
||||||
Only offer to create an ADR when all three are true:
|
|
||||||
|
|
||||||
1. **Hard to reverse** — the cost of changing your mind later is meaningful
|
|
||||||
2. **Surprising without context** — a future reader will wonder "why 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
|
|
||||||
|
|
||||||
If any of the three is missing, skip the ADR. Use the format in [ADR-FORMAT.md](./ADR-FORMAT.md).
|
|
||||||
|
|
||||||
</supporting-info>
|
|
||||||
|
|||||||
5
.agents/skills/grill-with-docs/agents/openai.yaml
Normal file
5
.agents/skills/grill-with-docs/agents/openai.yaml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
interface:
|
||||||
|
display_name: "Grill with Docs"
|
||||||
|
short_description: "Grill a design and write its docs"
|
||||||
|
policy:
|
||||||
|
allow_implicit_invocation: false
|
||||||
12
.agents/skills/grilling/SKILL.md
Normal file
12
.agents/skills/grilling/SKILL.md
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
---
|
||||||
|
name: grilling
|
||||||
|
description: Grill the user relentlessly about a plan, decision, or idea. Use when the user wants to stress-test their thinking, or uses any 'grill' trigger phrases.
|
||||||
|
---
|
||||||
|
|
||||||
|
Interview me relentlessly about every aspect of this until we reach a shared understanding. Walk down each branch of the decision tree, resolving dependencies between decisions one-by-one. For each question, provide your recommended answer.
|
||||||
|
|
||||||
|
Ask the questions one at a time, waiting for feedback on each question before continuing. Asking multiple questions at once is bewildering.
|
||||||
|
|
||||||
|
If a *fact* can be found by exploring the environment (filesystem, tools, etc.), look it up rather than asking me. The *decisions*, though, are mine — put each one to me and wait for my answer.
|
||||||
|
|
||||||
|
Do not act on it until I confirm we have reached a shared understanding.
|
||||||
3
.agents/skills/grilling/agents/openai.yaml
Normal file
3
.agents/skills/grilling/agents/openai.yaml
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
interface:
|
||||||
|
display_name: "Grilling"
|
||||||
|
short_description: "Stress-test thinking one question at a time"
|
||||||
@@ -2,13 +2,14 @@
|
|||||||
name: handoff
|
name: handoff
|
||||||
description: Compact the current conversation into a handoff document for another agent to pick up.
|
description: Compact the current conversation into a handoff document for another agent to pick up.
|
||||||
argument-hint: "What will the next session be used for?"
|
argument-hint: "What will the next session be used for?"
|
||||||
|
disable-model-invocation: true
|
||||||
---
|
---
|
||||||
|
|
||||||
Write a handoff document summarising the current conversation so a fresh agent can continue the work. Save to the temporary directory of the user's OS - not the current workspace.
|
Write a handoff document summarising the current conversation so a fresh agent can continue the work. Save to the temporary directory of the user's OS - not the current workspace.
|
||||||
|
|
||||||
Include a "suggested skills" section in the document, which suggests skills that the agent should invoke.
|
Include a "suggested skills" section in the document, which suggests skills that the agent should invoke.
|
||||||
|
|
||||||
Do not duplicate content already captured in other artifacts (PRDs, plans, ADRs, issues, commits, diffs). Reference them by path or URL instead.
|
Do not duplicate content already captured in other artifacts (specs, plans, ADRs, issues, commits, diffs). Reference them by path or URL instead.
|
||||||
|
|
||||||
Redact any sensitive information, such as API keys, passwords, or personally identifiable information.
|
Redact any sensitive information, such as API keys, passwords, or personally identifiable information.
|
||||||
|
|
||||||
|
|||||||
5
.agents/skills/handoff/agents/openai.yaml
Normal file
5
.agents/skills/handoff/agents/openai.yaml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
interface:
|
||||||
|
display_name: "Handoff"
|
||||||
|
short_description: "Compact a conversation into a handoff"
|
||||||
|
policy:
|
||||||
|
allow_implicit_invocation: false
|
||||||
15
.agents/skills/implement/SKILL.md
Normal file
15
.agents/skills/implement/SKILL.md
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
---
|
||||||
|
name: implement
|
||||||
|
description: "Implement a piece of work based on a spec or set of tickets."
|
||||||
|
disable-model-invocation: true
|
||||||
|
---
|
||||||
|
|
||||||
|
Implement the work described by the user in the spec or tickets.
|
||||||
|
|
||||||
|
Use /tdd where possible, at pre-agreed seams.
|
||||||
|
|
||||||
|
Run typechecking regularly, single test files regularly, and the full test suite once at the end.
|
||||||
|
|
||||||
|
Once done, use /code-review to review the work.
|
||||||
|
|
||||||
|
Commit your work to the current branch.
|
||||||
5
.agents/skills/implement/agents/openai.yaml
Normal file
5
.agents/skills/implement/agents/openai.yaml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
interface:
|
||||||
|
display_name: "Implement"
|
||||||
|
short_description: "Build work from a spec or tickets"
|
||||||
|
policy:
|
||||||
|
allow_implicit_invocation: false
|
||||||
@@ -39,7 +39,7 @@ Repo name, date, and a compact legend: solid box = module, dashed line = seam, r
|
|||||||
|
|
||||||
## Candidate card
|
## Candidate card
|
||||||
|
|
||||||
The diagrams carry the weight. Prose is sparse, plain, and uses the glossary terms ([LANGUAGE.md](LANGUAGE.md)) without ceremony.
|
The diagrams carry the weight. Prose is sparse, plain, and uses the glossary terms (from the `/codebase-design` skill) without ceremony.
|
||||||
|
|
||||||
Each candidate is one `<article>`:
|
Each candidate is one `<article>`:
|
||||||
|
|
||||||
@@ -105,7 +105,7 @@ One larger card. Candidate name, one sentence on why, anchor link to its card. T
|
|||||||
|
|
||||||
## Tone
|
## Tone
|
||||||
|
|
||||||
Plain English, concise — but the architectural nouns and verbs come straight from [LANGUAGE.md](LANGUAGE.md). Concision is not an excuse to drift.
|
Plain English, concise — but the architectural nouns and verbs come straight from the `/codebase-design` skill. Concision is not an excuse to drift.
|
||||||
|
|
||||||
**Use exactly:** module, interface, implementation, depth, deep, shallow, seam, adapter, leverage, locality.
|
**Use exactly:** module, interface, implementation, depth, deep, shallow, seam, adapter, leverage, locality.
|
||||||
|
|
||||||
@@ -120,4 +120,4 @@ Plain English, concise — but the architectural nouns and verbs come straight f
|
|||||||
|
|
||||||
**Wins bullets** name the gain in glossary terms: *"locality: bugs concentrate in one module"*, *"leverage: one interface, N call sites"*, *"interface shrinks; implementation absorbs the wrappers"*. Don't write *"easier to maintain"* or *"cleaner code"* — those terms aren't in the glossary and don't earn their place.
|
**Wins bullets** name the gain in glossary terms: *"locality: bugs concentrate in one module"*, *"leverage: one interface, N call sites"*, *"interface shrinks; implementation absorbs the wrappers"*. Don't write *"easier to maintain"* or *"cleaner code"* — those terms aren't in the glossary and don't earn their place.
|
||||||
|
|
||||||
No hedging, no throat-clearing, no "it's worth noting that…". If a sentence could be a bullet, make it a bullet. If a bullet could be cut, cut it. If a term isn't in [LANGUAGE.md](LANGUAGE.md), reach for one that is before inventing a new one.
|
No hedging, no throat-clearing, no "it's worth noting that…". If a sentence could be a bullet, make it a bullet. If a bullet could be cut, cut it. If a term isn't in the `/codebase-design` glossary, reach for one that is before inventing a new one.
|
||||||
|
|||||||
@@ -1,53 +0,0 @@
|
|||||||
# Language
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
## Terms
|
|
||||||
|
|
||||||
**Module**
|
|
||||||
Anything with an interface and an implementation. Deliberately scale-agnostic — applies equally to a function, class, package, or tier-spanning slice.
|
|
||||||
_Avoid_: unit, component, service.
|
|
||||||
|
|
||||||
**Interface**
|
|
||||||
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.
|
|
||||||
_Avoid_: API, signature (too narrow — those refer only to the type-level surface).
|
|
||||||
|
|
||||||
**Implementation**
|
|
||||||
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.
|
|
||||||
|
|
||||||
**Depth**
|
|
||||||
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.
|
|
||||||
|
|
||||||
**Seam** _(from Michael Feathers)_
|
|
||||||
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.
|
|
||||||
_Avoid_: boundary (overloaded with DDD's bounded context).
|
|
||||||
|
|
||||||
**Adapter**
|
|
||||||
A concrete thing that satisfies an interface at a seam. Describes *role* (what slot it fills), not substance (what's inside).
|
|
||||||
|
|
||||||
**Leverage**
|
|
||||||
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.
|
|
||||||
|
|
||||||
**Locality**
|
|
||||||
What maintainers get from depth. Change, bugs, knowledge, and verification concentrate at one place rather than spreading across callers. Fix once, fixed everywhere.
|
|
||||||
|
|
||||||
## Principles
|
|
||||||
|
|
||||||
- **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.
|
|
||||||
- **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.
|
|
||||||
- **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.
|
|
||||||
- **One adapter means a hypothetical seam. Two adapters means a real one.** Don't introduce a seam unless something actually varies across it.
|
|
||||||
|
|
||||||
## Relationships
|
|
||||||
|
|
||||||
- A **Module** has exactly one **Interface** (the surface it presents to callers and tests).
|
|
||||||
- **Depth** is a property of a **Module**, measured against its **Interface**.
|
|
||||||
- A **Seam** is where a **Module**'s **Interface** lives.
|
|
||||||
- An **Adapter** sits at a **Seam** and satisfies the **Interface**.
|
|
||||||
- **Depth** produces **Leverage** for callers and **Locality** for maintainers.
|
|
||||||
|
|
||||||
## Rejected framings
|
|
||||||
|
|
||||||
- **Depth as ratio of implementation-lines to interface-lines** (Ousterhout): rewards padding the implementation. We use depth-as-leverage instead.
|
|
||||||
- **"Interface" as the TypeScript `interface` keyword or a class's public methods**: too narrow — interface here includes every fact a caller must know.
|
|
||||||
- **"Boundary"**: overloaded with DDD's bounded context. Say **seam** or **interface**.
|
|
||||||
@@ -1,38 +1,28 @@
|
|||||||
---
|
---
|
||||||
name: improve-codebase-architecture
|
name: improve-codebase-architecture
|
||||||
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.
|
description: Scan a codebase for deepening opportunities, present them as a visual HTML report, then grill through whichever one you pick.
|
||||||
|
disable-model-invocation: true
|
||||||
---
|
---
|
||||||
|
|
||||||
# Improve Codebase Architecture
|
# Improve Codebase Architecture
|
||||||
|
|
||||||
Surface architectural friction and propose **deepening opportunities** — refactors that turn shallow modules into deep ones. The aim is testability and AI-navigability.
|
Surface architectural friction and propose **deepening opportunities** — refactors that turn shallow modules into deep ones. The aim is testability and AI-navigability.
|
||||||
|
|
||||||
## Glossary
|
This command is _informed_ by the project's domain model and built on a shared design vocabulary:
|
||||||
|
|
||||||
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).
|
- Run the `/codebase-design` skill for the architecture vocabulary (**module**, **interface**, **depth**, **seam**, **adapter**, **leverage**, **locality**) and its principles (the deletion test, "the interface is the test surface", "one adapter = hypothetical seam, two = real"). Use these terms exactly in every suggestion — don't drift into "component," "service," "API," or "boundary."
|
||||||
|
- The domain language in `CONTEXT.md` gives names to good seams; ADRs in `docs/adr/` record decisions this command should not re-litigate.
|
||||||
- **Module** — anything with an interface and an implementation (function, class, package, slice).
|
|
||||||
- **Interface** — everything a caller must know to use the module: types, invariants, error modes, ordering, config. Not just the type signature.
|
|
||||||
- **Implementation** — the code inside.
|
|
||||||
- **Depth** — leverage at the interface: a lot of behaviour behind a small interface. **Deep** = high leverage. **Shallow** = interface nearly as complex as the implementation.
|
|
||||||
- **Seam** — where an interface lives; a place behaviour can be altered without editing in place. (Use this, not "boundary.")
|
|
||||||
- **Adapter** — a concrete thing satisfying an interface at a seam.
|
|
||||||
- **Leverage** — what callers get from depth.
|
|
||||||
- **Locality** — what maintainers get from depth: change, bugs, knowledge concentrated in one place.
|
|
||||||
|
|
||||||
Key principles (see [LANGUAGE.md](LANGUAGE.md) for the full list):
|
|
||||||
|
|
||||||
- **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.
|
|
||||||
- **The interface is the test surface.**
|
|
||||||
- **One adapter = hypothetical seam. Two adapters = real seam.**
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
## Process
|
## Process
|
||||||
|
|
||||||
### 1. Explore
|
### 1. Explore
|
||||||
|
|
||||||
Read the project's domain glossary and any ADRs in the area you're touching first.
|
**Scope before you scan — YAGNI.** Deepening a module pays off by making future changes to it easier, so put extra weight on the parts of the codebase that have recently changed. Decide *where* to look before you look:
|
||||||
|
|
||||||
|
- If the user named a direction — a module, a subsystem, a pain point — take it, and skip the inference below.
|
||||||
|
- Otherwise, walk back a good stretch of the commit history (`git log --oneline`) to find the codebase's hot spots — the files and areas that keep coming up — and let those paths pull your attention first. If the changes are scattered with no clear hot spot, widen the net.
|
||||||
|
|
||||||
|
Read the project's domain glossary (`CONTEXT.md`) and any ADRs in the area you're touching first.
|
||||||
|
|
||||||
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:
|
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:
|
||||||
|
|
||||||
@@ -50,7 +40,7 @@ Write a self-contained HTML file to the OS temp directory so nothing lands in th
|
|||||||
|
|
||||||
The report uses **Tailwind via CDN** for layout and styling, and **Mermaid via CDN** for diagrams where a graph/flow/sequence reliably communicates the structure. Mix Mermaid with hand-crafted CSS/SVG visuals — use Mermaid when relationships are graph-shaped (call graphs, dependencies, sequences), and hand-built divs/SVG when you want something more editorial (mass diagrams, cross-sections, collapse animations). Each candidate gets a **before/after visualisation**. Be visual.
|
The report uses **Tailwind via CDN** for layout and styling, and **Mermaid via CDN** for diagrams where a graph/flow/sequence reliably communicates the structure. Mix Mermaid with hand-crafted CSS/SVG visuals — use Mermaid when relationships are graph-shaped (call graphs, dependencies, sequences), and hand-built divs/SVG when you want something more editorial (mass diagrams, cross-sections, collapse animations). Each candidate gets a **before/after visualisation**. Be visual.
|
||||||
|
|
||||||
For each candidate, the same template as before, but rendered as a card:
|
For each candidate, render a card with:
|
||||||
|
|
||||||
- **Files** — which files/modules are involved
|
- **Files** — which files/modules are involved
|
||||||
- **Problem** — why the current architecture is causing friction
|
- **Problem** — why the current architecture is causing friction
|
||||||
@@ -61,7 +51,7 @@ For each candidate, the same template as before, but rendered as a card:
|
|||||||
|
|
||||||
End the report with a **Top recommendation** section: which candidate you'd tackle first and why.
|
End the report with a **Top recommendation** section: which candidate you'd tackle first and why.
|
||||||
|
|
||||||
**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."
|
**Use CONTEXT.md vocabulary for the domain, and the `/codebase-design` vocabulary for the architecture.** If `CONTEXT.md` defines "Order," talk about "the Order intake module" — not "the FooBarHandler," and not "the Order service."
|
||||||
|
|
||||||
**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 in the card (e.g. a warning callout: _"contradicts ADR-0007 — but worth reopening because…"_). Don't list every theoretical refactor an ADR forbids.
|
**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 in the card (e.g. a warning callout: _"contradicts ADR-0007 — but worth reopening because…"_). Don't list every theoretical refactor an ADR forbids.
|
||||||
|
|
||||||
@@ -71,11 +61,11 @@ Do NOT propose interfaces yet. After the file is written, ask the user: "Which o
|
|||||||
|
|
||||||
### 3. Grilling loop
|
### 3. Grilling loop
|
||||||
|
|
||||||
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.
|
Once the user picks a candidate, run the `/grilling` skill to walk the decision tree with them — constraints, dependencies, the shape of the deepened module, what sits behind the seam, what tests survive.
|
||||||
|
|
||||||
Side effects happen inline as decisions crystallize:
|
Side effects happen inline as decisions crystallize — run the `/domain-modeling` skill to keep the domain model current as you go:
|
||||||
|
|
||||||
- **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.
|
- **Naming a deepened module after a concept not in `CONTEXT.md`?** Add the term to `CONTEXT.md`. Create the file lazily if it doesn't exist.
|
||||||
- **Sharpening a fuzzy term during the conversation?** Update `CONTEXT.md` right there.
|
- **Sharpening a fuzzy term during the conversation?** Update `CONTEXT.md` right there.
|
||||||
- **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).
|
- **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.
|
||||||
- **Want to explore alternative interfaces for the deepened module?** See [INTERFACE-DESIGN.md](INTERFACE-DESIGN.md).
|
- **Want to explore alternative interfaces for the deepened module?** Run the `/codebase-design` skill and use its design-it-twice parallel sub-agent pattern.
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
interface:
|
||||||
|
display_name: "Improve Codebase Architecture"
|
||||||
|
short_description: "Find and grill architecture improvements"
|
||||||
|
policy:
|
||||||
|
allow_implicit_invocation: false
|
||||||
@@ -36,7 +36,7 @@ The right shape depends on the question:
|
|||||||
|
|
||||||
Pick whichever shape best fits the question being asked, *not* whichever is easiest to wire to a TUI. Keep it pure: no I/O, no terminal code, no `console.log` for control flow. The TUI imports it and calls into it; nothing flows the other direction.
|
Pick whichever shape best fits the question being asked, *not* whichever is easiest to wire to a TUI. Keep it pure: no I/O, no terminal code, no `console.log` for control flow. The TUI imports it and calls into it; nothing flows the other direction.
|
||||||
|
|
||||||
This is what makes the prototype useful past its own lifetime. When the question's been answered, the validated reducer / machine / function set can be lifted into the real module — the TUI shell gets deleted.
|
This is what makes the prototype useful past its own lifetime: when the question's been answered, the validated reducer / machine / function set can be lifted into the real module on its own.
|
||||||
|
|
||||||
### 4. Build the smallest TUI that exposes the state
|
### 4. Build the smallest TUI that exposes the state
|
||||||
|
|
||||||
@@ -66,9 +66,9 @@ If the host project has no task runner, just put the command at the top of the p
|
|||||||
|
|
||||||
Give the user the run command. They'll drive it themselves; the interesting moments are when they say "wait, that shouldn't be possible" or "huh, I assumed X would be different" — those are the bugs in the _idea_, which is the whole point. If they want new actions added, add them. Prototypes evolve.
|
Give the user the run command. They'll drive it themselves; the interesting moments are when they say "wait, that shouldn't be possible" or "huh, I assumed X would be different" — those are the bugs in the _idea_, which is the whole point. If they want new actions added, add them. Prototypes evolve.
|
||||||
|
|
||||||
### 7. Capture the answer
|
### 7. Capture the answer and the prototype
|
||||||
|
|
||||||
When the prototype has done its job, the answer to the question is the only thing worth keeping. If the user is around, ask what it taught them. If not, leave a `NOTES.md` next to the prototype so the answer can be filled in (or filled in by you, if you've watched the session) before the prototype gets deleted.
|
Once the prototype has answered its question, capture the answer, then capture the prototype the way the [SKILL](SKILL.md) describes. The logic-specific mapping: the validated reducer / machine / function set lifts into the real module (the decision, absorbed); the TUI shell rides along to the throwaway branch that keeps the prototype as a primary source.
|
||||||
|
|
||||||
## Anti-patterns
|
## Anti-patterns
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
name: prototype
|
name: prototype
|
||||||
description: Build a throwaway prototype to flesh out a design before committing to it. Routes between two branches — a runnable terminal app for state/business-logic questions, or several radically different UI variations toggleable from one route. Use when the user wants to prototype, sanity-check a data model or state machine, mock up a UI, explore design options, or says "prototype this", "let me play with it", "try a few designs".
|
description: Build a throwaway prototype to answer a design question. Use when the user wants to sanity-check whether a state model or logic feels right, or explore what a UI should look like.
|
||||||
---
|
---
|
||||||
|
|
||||||
# Prototype
|
# Prototype
|
||||||
@@ -21,10 +21,6 @@ The two branches produce very different artifacts — getting this wrong wastes
|
|||||||
1. **Throwaway from day one, and clearly marked as such.** Locate the prototype code close to where it will actually be used (next to the module or page it's prototyping for) so context is obvious — but name it so a casual reader can see it's a prototype, not production. For throwaway UI routes, obey whatever routing convention the project already uses; don't invent a new top-level structure.
|
1. **Throwaway from day one, and clearly marked as such.** Locate the prototype code close to where it will actually be used (next to the module or page it's prototyping for) so context is obvious — but name it so a casual reader can see it's a prototype, not production. For throwaway UI routes, obey whatever routing convention the project already uses; don't invent a new top-level structure.
|
||||||
2. **One command to run.** Whatever the project's existing task runner supports — `pnpm <name>`, `python <path>`, `bun <path>`, etc. The user must be able to start it without thinking.
|
2. **One command to run.** Whatever the project's existing task runner supports — `pnpm <name>`, `python <path>`, `bun <path>`, etc. The user must be able to start it without thinking.
|
||||||
3. **No persistence by default.** State lives in memory. Persistence is the thing the prototype is _checking_, not something it should depend on. If the question explicitly involves a database, hit a scratch DB or a local file with a clear "PROTOTYPE — wipe me" name.
|
3. **No persistence by default.** State lives in memory. Persistence is the thing the prototype is _checking_, not something it should depend on. If the question explicitly involves a database, hit a scratch DB or a local file with a clear "PROTOTYPE — wipe me" name.
|
||||||
4. **Skip the polish.** No tests, no error handling beyond what makes the prototype _runnable_, no abstractions. The point is to learn something fast and then delete it.
|
4. **Skip the polish.** No tests, no error handling beyond what makes the prototype _runnable_, no abstractions. The point is to learn something fast.
|
||||||
5. **Surface the state.** After every action (logic) or on every variant switch (UI), print or render the full relevant state so the user can see what changed.
|
5. **Surface the state.** After every action (logic) or on every variant switch (UI), print or render the full relevant state so the user can see what changed.
|
||||||
6. **Delete or absorb when done.** When the prototype has answered its question, either delete it or fold the validated decision into the real code — don't leave it rotting in the repo.
|
6. **Capture it when done.** Fold any validated decision into the real code, then capture the prototype itself as a **primary source**: commit it to a throwaway branch, out of main, and leave a context pointer to that branch on the implementation issue. Capture the answer too — the verdict and the question it settled — in the issue or a commit. The main branch keeps only the validated decision.
|
||||||
|
|
||||||
## When done
|
|
||||||
|
|
||||||
The _answer_ is the only thing worth keeping from a prototype. Capture it somewhere durable (commit message, ADR, issue, or a `NOTES.md` next to the prototype) along with the question it was answering. If the user is around, that capture is a quick conversation; if not, leave the placeholder so they (or you, on the next pass) can fill in the verdict before deleting the prototype.
|
|
||||||
|
|||||||
@@ -97,12 +97,12 @@ Surface the URL (and the `?variant=` keys). The user will flip through whenever
|
|||||||
|
|
||||||
### 6. Capture the answer and clean up
|
### 6. Capture the answer and clean up
|
||||||
|
|
||||||
Once a variant has won, write down which one and why (commit message, ADR, issue, or a `NOTES.md` next to the prototype if running AFK and the user hasn't responded yet). Then:
|
Once a variant has won, capture the answer — which variant and why — then capture the prototype the way the [SKILL](SKILL.md) describes. Fold the winner into the real code and move the rest onto the throwaway branch, not into main:
|
||||||
|
|
||||||
- **Sub-shape A** — delete the losing variants and the switcher; fold the winner into the existing page.
|
- **Sub-shape A** — fold the winner into the existing page; drop the losing variants and the switcher from main.
|
||||||
- **Sub-shape B** — promote the winning variant to a real route, delete the throwaway route and the switcher.
|
- **Sub-shape B** — promote the winning variant to a real route; drop the throwaway route and the switcher from main.
|
||||||
|
|
||||||
Don't leave variant components or the switcher lying around. They rot fast and confuse the next reader.
|
The full set of variants is the primary source, so it lands on the throwaway branch, not the bin — variant components and the switcher left in the main branch rot fast and confuse the next reader.
|
||||||
|
|
||||||
## Anti-patterns
|
## Anti-patterns
|
||||||
|
|
||||||
|
|||||||
3
.agents/skills/prototype/agents/openai.yaml
Normal file
3
.agents/skills/prototype/agents/openai.yaml
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
interface:
|
||||||
|
display_name: "Prototype"
|
||||||
|
short_description: "Prototype to answer a design question"
|
||||||
12
.agents/skills/research/SKILL.md
Normal file
12
.agents/skills/research/SKILL.md
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
---
|
||||||
|
name: research
|
||||||
|
description: Investigate a question against high-trust primary sources and capture the findings as a Markdown file in the repo. Use when the user wants a topic researched, docs or API facts gathered, or reading legwork delegated to a background agent.
|
||||||
|
---
|
||||||
|
|
||||||
|
Spin up a **background agent** to do the research, so you keep working while it reads.
|
||||||
|
|
||||||
|
Its job:
|
||||||
|
|
||||||
|
1. Investigate the question against **primary sources** — official docs, source code, specs, first-party APIs — not a secondary write-up of them. Follow every claim back to the source that owns it.
|
||||||
|
2. Write the findings to a single Markdown file, citing each claim's source.
|
||||||
|
3. Save it where the repo already keeps such notes; match the existing convention, and if there is none, put it somewhere sensible and say where.
|
||||||
3
.agents/skills/research/agents/openai.yaml
Normal file
3
.agents/skills/research/agents/openai.yaml
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
interface:
|
||||||
|
display_name: "Research"
|
||||||
|
short_description: "Research from high-trust sources"
|
||||||
14
.agents/skills/resolving-merge-conflicts/SKILL.md
Normal file
14
.agents/skills/resolving-merge-conflicts/SKILL.md
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
---
|
||||||
|
name: resolving-merge-conflicts
|
||||||
|
description: "Use when you need to resolve an in-progress git merge/rebase conflict."
|
||||||
|
---
|
||||||
|
|
||||||
|
1. **See the current state** of the merge/rebase. Check git history, and the conflicting files.
|
||||||
|
|
||||||
|
2. **Find the primary sources** for each conflict. Understand deeply why each change was made, and what the original intent was. Read the commit messages, check the PRs, check original issues/tickets.
|
||||||
|
|
||||||
|
3. **Resolve each hunk.** Preserve both intents where possible. Where incompatible, pick the one matching the merge's stated goal and note the trade-off. Do **not** invent new behaviour. Always resolve; never `--abort`.
|
||||||
|
|
||||||
|
4. Discover the project's **automated checks** and run them — typically typecheck, then tests, then format. Fix anything the merge broke.
|
||||||
|
|
||||||
|
5. **Finish the merge/rebase.** Stage everything and commit. If rebasing, continue the rebase process until all commits are rebased.
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
interface:
|
||||||
|
display_name: "Resolving Merge Conflicts"
|
||||||
|
short_description: "Resolve merge and rebase conflicts"
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
name: setup-matt-pocock-skills
|
name: setup-matt-pocock-skills
|
||||||
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.
|
description: Configure this repo for the engineering skills — set up its issue tracker, triage label vocabulary, and domain doc layout. Run once before first use of the other engineering skills.
|
||||||
disable-model-invocation: true
|
disable-model-invocation: true
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -26,16 +26,18 @@ Look at the current repo to understand its starting state. Read whatever exists;
|
|||||||
- `docs/adr/` and any `src/*/docs/adr/` directories
|
- `docs/adr/` and any `src/*/docs/adr/` directories
|
||||||
- `docs/agents/` — does this skill's prior output already exist?
|
- `docs/agents/` — does this skill's prior output already exist?
|
||||||
- `.scratch/` — sign that a local-markdown issue tracker convention is already in use
|
- `.scratch/` — sign that a local-markdown issue tracker convention is already in use
|
||||||
|
- Is the `triage` skill installed? (a `triage` skill folder alongside this one, or `triage` in your available skills.) This decides whether Section B runs at all.
|
||||||
|
- Monorepo signals — a `pnpm-workspace.yaml`, a `workspaces` field in `package.json`, or a populated `packages/*` with its own `src/`. Present only in a genuinely large multi-package repo; their absence means single-context, which is almost every repo.
|
||||||
|
|
||||||
### 2. Present findings and ask
|
### 2. Present findings and ask
|
||||||
|
|
||||||
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.
|
Summarise what's present and what's missing. Then take the sections in order — one section, one answer, then the next.
|
||||||
|
|
||||||
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.
|
Lead each section with the recommended answer so the user can accept it in a word. Give a one-line explainer only when the choice genuinely branches; skip the section entirely when exploration already settled it (Section B when `triage` isn't installed, Section C when there's no monorepo).
|
||||||
|
|
||||||
**Section A — Issue tracker.**
|
**Section A — Issue tracker.**
|
||||||
|
|
||||||
> 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.
|
> Explainer: The "issue tracker" is where issues live for this repo. Skills like `to-tickets`, `triage`, `to-spec`, 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.
|
||||||
|
|
||||||
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:
|
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:
|
||||||
|
|
||||||
@@ -44,35 +46,26 @@ Default posture: these skills were designed for GitHub. If a `git remote` points
|
|||||||
- **Local markdown** — issues live as files under `.scratch/<feature>/` in this repo (good for solo projects or repos without a remote)
|
- **Local markdown** — issues live as files under `.scratch/<feature>/` in this repo (good for solo projects or repos without a remote)
|
||||||
- **Other** (Jira, Linear, etc.) — ask the user to describe the workflow in one paragraph; the skill will record it as freeform prose
|
- **Other** (Jira, Linear, etc.) — ask the user to describe the workflow in one paragraph; the skill will record it as freeform prose
|
||||||
|
|
||||||
**Section B — Triage label vocabulary.**
|
Record the choice in `docs/agents/issue-tracker.md`. The GitHub and GitLab templates carry a "PRs as a request surface" flag, defaulted **off** — leave it off and don't raise it; a user who wants external PRs in the triage queue can flip the flag in the file later.
|
||||||
|
|
||||||
> 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.
|
**Section B — Triage label vocabulary.** Skip this section entirely if the `triage` skill isn't installed (exploration told you) — an uninstalled skill needs no labels.
|
||||||
|
|
||||||
The five canonical roles:
|
If it is installed, ask exactly one question:
|
||||||
|
|
||||||
- `needs-triage` — maintainer needs to evaluate
|
> Do you want to keep the default triage labels? (recommended: **yes**)
|
||||||
- `needs-info` — waiting on reporter
|
|
||||||
- `ready-for-agent` — fully specified, AFK-ready (an agent can pick it up with no human context)
|
|
||||||
- `ready-for-human` — needs human implementation
|
|
||||||
- `wontfix` — will not be actioned
|
|
||||||
|
|
||||||
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.
|
The defaults are the five canonical roles, each label string equal to its name: `needs-triage`, `needs-info`, `ready-for-agent`, `ready-for-human`, `wontfix`. On **yes**, write them as-is. Only if the user says no — usually because their tracker already uses other names (e.g. `bug:triage` for `needs-triage`) — collect the overrides so `triage` applies existing labels instead of creating duplicates.
|
||||||
|
|
||||||
**Section C — Domain docs.**
|
**Section C — Domain docs.** Default to **single-context** — one `CONTEXT.md` + `docs/adr/` at the repo root. This fits almost every repo; write it without asking.
|
||||||
|
|
||||||
> 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.
|
Offer **multi-context** — a root `CONTEXT-MAP.md` pointing to per-context `CONTEXT.md` files — only when exploration found monorepo signals. Then confirm which layout they want.
|
||||||
|
|
||||||
Confirm the layout:
|
|
||||||
|
|
||||||
- **Single-context** — one `CONTEXT.md` + `docs/adr/` at the repo root. Most repos are this.
|
|
||||||
- **Multi-context** — `CONTEXT-MAP.md` at the root pointing to per-context `CONTEXT.md` files (typically a monorepo).
|
|
||||||
|
|
||||||
### 3. Confirm and edit
|
### 3. Confirm and edit
|
||||||
|
|
||||||
Show the user a draft of:
|
Show the user a draft of:
|
||||||
|
|
||||||
- The `## Agent skills` block to add to whichever of `CLAUDE.md` / `AGENTS.md` is being edited (see step 4 for selection rules)
|
- The `## Agent skills` block to add to whichever of `CLAUDE.md` / `AGENTS.md` is being edited (see step 4 for selection rules)
|
||||||
- The contents of `docs/agents/issue-tracker.md`, `docs/agents/triage-labels.md`, `docs/agents/domain.md`
|
- The contents of `docs/agents/issue-tracker.md`, `docs/agents/domain.md`, and `docs/agents/triage-labels.md` (the last only when `triage` is installed)
|
||||||
|
|
||||||
Let them edit before writing.
|
Let them edit before writing.
|
||||||
|
|
||||||
@@ -106,12 +99,14 @@ The block:
|
|||||||
[one-line summary of layout — "single-context" or "multi-context"]. See `docs/agents/domain.md`.
|
[one-line summary of layout — "single-context" or "multi-context"]. See `docs/agents/domain.md`.
|
||||||
```
|
```
|
||||||
|
|
||||||
Then write the three docs files using the seed templates in this skill folder as a starting point:
|
Include the `### Triage labels` sub-block, and write `docs/agents/triage-labels.md`, only when `triage` is installed and Section B ran. When it isn't, both are omitted.
|
||||||
|
|
||||||
|
Then write the docs files using the seed templates in this skill folder as a starting point:
|
||||||
|
|
||||||
- [issue-tracker-github.md](./issue-tracker-github.md) — GitHub issue tracker
|
- [issue-tracker-github.md](./issue-tracker-github.md) — GitHub issue tracker
|
||||||
- [issue-tracker-gitlab.md](./issue-tracker-gitlab.md) — GitLab issue tracker
|
- [issue-tracker-gitlab.md](./issue-tracker-gitlab.md) — GitLab issue tracker
|
||||||
- [issue-tracker-local.md](./issue-tracker-local.md) — local-markdown issue tracker
|
- [issue-tracker-local.md](./issue-tracker-local.md) — local-markdown issue tracker
|
||||||
- [triage-labels.md](./triage-labels.md) — label mapping
|
- [triage-labels.md](./triage-labels.md) — label mapping (only if `triage` is installed)
|
||||||
- [domain.md](./domain.md) — domain doc consumer rules + layout
|
- [domain.md](./domain.md) — domain doc consumer rules + layout
|
||||||
|
|
||||||
For "other" issue trackers, write `docs/agents/issue-tracker.md` from scratch using the user's description.
|
For "other" issue trackers, write `docs/agents/issue-tracker.md` from scratch using the user's description.
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
interface:
|
||||||
|
display_name: "Setup Matt Pocock Skills"
|
||||||
|
short_description: "Configure a repo for the skills"
|
||||||
|
policy:
|
||||||
|
allow_implicit_invocation: false
|
||||||
@@ -8,7 +8,7 @@ How the engineering skills should consume this repo's domain documentation when
|
|||||||
- **`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.
|
- **`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.
|
||||||
- **`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.
|
- **`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.
|
||||||
|
|
||||||
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.
|
If any of these files don't exist, **proceed silently**. Don't flag their absence; don't suggest creating them upfront. The `/domain-modeling` skill (reached via `/grill-with-docs` and `/improve-codebase-architecture`) creates them lazily when terms or decisions actually get resolved.
|
||||||
|
|
||||||
## File structure
|
## File structure
|
||||||
|
|
||||||
@@ -42,7 +42,7 @@ Multi-context repo (presence of `CONTEXT-MAP.md` at the root):
|
|||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
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`).
|
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 `/domain-modeling`).
|
||||||
|
|
||||||
## Flag ADR conflicts
|
## Flag ADR conflicts
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,18 @@ Issues and PRDs for this repo live as GitHub issues. Use the `gh` CLI for all op
|
|||||||
|
|
||||||
Infer the repo from `git remote -v` — `gh` does this automatically when run inside a clone.
|
Infer the repo from `git remote -v` — `gh` does this automatically when run inside a clone.
|
||||||
|
|
||||||
|
## Pull requests as a triage surface
|
||||||
|
|
||||||
|
**PRs as a request surface: no.** _(Set to `yes` if this repo treats external PRs as feature requests; `/triage` reads this flag.)_
|
||||||
|
|
||||||
|
When set to `yes`, PRs run through the same labels and states as issues, using the `gh pr` equivalents:
|
||||||
|
|
||||||
|
- **Read a PR**: `gh pr view <number> --comments` and `gh pr diff <number>` for the diff.
|
||||||
|
- **List external PRs for triage**: `gh pr list --state open --json number,title,body,labels,author,authorAssociation,comments` then keep only `authorAssociation` of `CONTRIBUTOR`, `FIRST_TIME_CONTRIBUTOR`, or `NONE` (drop `OWNER`/`MEMBER`/`COLLABORATOR`).
|
||||||
|
- **Comment / label / close**: `gh pr comment`, `gh pr edit --add-label`/`--remove-label`, `gh pr close`.
|
||||||
|
|
||||||
|
GitHub shares one number space across issues and PRs, so a bare `#42` may be either — resolve with `gh pr view 42` and fall back to `gh issue view 42`.
|
||||||
|
|
||||||
## When a skill says "publish to the issue tracker"
|
## When a skill says "publish to the issue tracker"
|
||||||
|
|
||||||
Create a GitHub issue.
|
Create a GitHub issue.
|
||||||
@@ -20,3 +32,14 @@ Create a GitHub issue.
|
|||||||
## When a skill says "fetch the relevant ticket"
|
## When a skill says "fetch the relevant ticket"
|
||||||
|
|
||||||
Run `gh issue view <number> --comments`.
|
Run `gh issue view <number> --comments`.
|
||||||
|
|
||||||
|
## Wayfinding operations
|
||||||
|
|
||||||
|
Used by `/wayfinder`. The **map** is a single issue with **child** issues as tickets.
|
||||||
|
|
||||||
|
- **Map**: a single issue labelled `wayfinder:map`, holding the Notes / Decisions-so-far / Fog body. `gh issue create --label wayfinder:map`.
|
||||||
|
- **Child ticket**: an issue linked to the map as a GitHub sub-issue (`gh api` on the sub-issues endpoint). Where sub-issues aren't enabled, add the child to a task list in the map body and put `Part of #<map>` at the top of the child body. Labels: `wayfinder:<type>` (`research`/`prototype`/`grilling`/`task`). Once claimed, the ticket is assigned to the driving dev.
|
||||||
|
- **Blocking**: GitHub's **native issue dependencies** — the canonical, UI-visible representation. Add an edge with `gh api --method POST repos/<owner>/<repo>/issues/<child>/dependencies/blocked_by -F issue_id=<blocker-db-id>`, where `<blocker-db-id>` is the blocker's numeric **database id** (`gh api repos/<owner>/<repo>/issues/<n> --jq .id`, _not_ the `#number` or `node_id`). GitHub reports `issue_dependencies_summary.blocked_by` (open blockers only — the live gate). Where dependencies aren't available, fall back to a `Blocked by: #<n>, #<n>` line at the top of the child body. A ticket is unblocked when every blocker is closed.
|
||||||
|
- **Frontier query**: list the map's open children (`gh issue list --state open`, scoped to the map's sub-issues / task list), drop any with an open blocker (`issue_dependencies_summary.blocked_by > 0`, or an open issue in the `Blocked by` line) or an assignee; first in map order wins.
|
||||||
|
- **Claim**: `gh issue edit <n> --add-assignee @me` — the session's first write.
|
||||||
|
- **Resolve**: `gh issue comment <n> --body "<answer>"`, then `gh issue close <n>`, then append a context pointer (gist + link) to the map's Decisions-so-far.
|
||||||
|
|||||||
@@ -14,6 +14,18 @@ Issues and PRDs for this repo live as GitLab issues. Use the [`glab`](https://gi
|
|||||||
|
|
||||||
Infer the repo from `git remote -v` — `glab` does this automatically when run inside a clone.
|
Infer the repo from `git remote -v` — `glab` does this automatically when run inside a clone.
|
||||||
|
|
||||||
|
## Merge requests as a triage surface
|
||||||
|
|
||||||
|
**MRs as a request surface: no.** _(Set to `yes` if this repo treats external merge requests as feature requests; `/triage` reads this flag.)_
|
||||||
|
|
||||||
|
When set to `yes`, MRs run through the same labels and states as issues, using the `glab mr` equivalents:
|
||||||
|
|
||||||
|
- **Read an MR**: `glab mr view <number> --comments` and `glab mr diff <number>` for the diff.
|
||||||
|
- **List external MRs for triage**: `glab mr list -F json`, then keep only MRs whose author is not a project member/owner (a contributor's MR, not a maintainer's in-flight work).
|
||||||
|
- **Comment / label / close**: `glab mr note`, `glab mr update --label`/`--unlabel`, `glab mr close`.
|
||||||
|
|
||||||
|
Unlike GitHub, GitLab numbers issues and MRs separately, so `#42` is unambiguous once you know which surface the maintainer means.
|
||||||
|
|
||||||
## When a skill says "publish to the issue tracker"
|
## When a skill says "publish to the issue tracker"
|
||||||
|
|
||||||
Create a GitLab issue.
|
Create a GitLab issue.
|
||||||
@@ -21,3 +33,14 @@ Create a GitLab issue.
|
|||||||
## When a skill says "fetch the relevant ticket"
|
## When a skill says "fetch the relevant ticket"
|
||||||
|
|
||||||
Run `glab issue view <number> --comments`.
|
Run `glab issue view <number> --comments`.
|
||||||
|
|
||||||
|
## Wayfinding operations
|
||||||
|
|
||||||
|
Used by `/wayfinder`. The **map** is a single issue with **child** issues as tickets.
|
||||||
|
|
||||||
|
- **Map**: a single issue labelled `wayfinder:map`, holding the Notes / Decisions-so-far / Fog body. `glab issue create --label wayfinder:map`. (On GitLab tiers with native epics, an epic may hold the map instead; a labelled issue works everywhere.)
|
||||||
|
- **Child ticket**: an issue carrying `Part of #<map>` at the top of its description and labels `wayfinder:<type>` (`research`/`prototype`/`grilling`/`task`). Once claimed, the ticket is assigned to the driving dev.
|
||||||
|
- **Blocking**: GitLab's **native blocking link** — the canonical, UI-visible representation. Add it with the `/blocked_by #<n>` quick action, posted as a note (`glab issue note <child> --message "/blocked_by #<blocker>"`). Native blocking links are a Premium/Ultimate feature; on the free tier (or where unavailable) fall back to a `Blocked by: #<n>, #<n>` line at the top of the description. A ticket is unblocked when every blocker is closed.
|
||||||
|
- **Frontier query**: `glab issue list -F json` scoped to the map's children, drop any with an open blocker — a native `blocked_by` link to an open issue (`glab api projects/:id/issues/:iid/links`), or an open issue in the `Blocked by` line — or an assignee; first in map order wins.
|
||||||
|
- **Claim**: `glab issue update <n> --assignee @me` — the session's first write.
|
||||||
|
- **Resolve**: `glab issue note <n> --message "<answer>"`, then `glab issue close <n>`, then append a context pointer (gist + link) to the map's Decisions-so-far.
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
# Issue tracker: Local Markdown
|
# Issue tracker: Local Markdown
|
||||||
|
|
||||||
Issues and PRDs for this repo live as markdown files in `.scratch/`.
|
Issues and specs (you may know a spec as a PRD) for this repo live as markdown files in `.scratch/`.
|
||||||
|
|
||||||
## Conventions
|
## Conventions
|
||||||
|
|
||||||
- One feature per directory: `.scratch/<feature-slug>/`
|
- One feature per directory: `.scratch/<feature-slug>/`
|
||||||
- The PRD is `.scratch/<feature-slug>/PRD.md`
|
- The spec is `.scratch/<feature-slug>/spec.md`
|
||||||
- Implementation issues are `.scratch/<feature-slug>/issues/<NN>-<slug>.md`, numbered from `01`
|
- Implementation issues are one file per ticket at `.scratch/<feature-slug>/issues/<NN>-<slug>.md`, numbered from `01` — never a single combined tickets file
|
||||||
- Triage state is recorded as a `Status:` line near the top of each issue file (see `triage-labels.md` for the role strings)
|
- Triage state is recorded as a `Status:` line near the top of each issue file (see `triage-labels.md` for the role strings)
|
||||||
- Comments and conversation history append to the bottom of the file under a `## Comments` heading
|
- Comments and conversation history append to the bottom of the file under a `## Comments` heading
|
||||||
|
|
||||||
@@ -17,3 +17,14 @@ Create a new file under `.scratch/<feature-slug>/` (creating the directory if ne
|
|||||||
## When a skill says "fetch the relevant ticket"
|
## When a skill says "fetch the relevant ticket"
|
||||||
|
|
||||||
Read the file at the referenced path. The user will normally pass the path or the issue number directly.
|
Read the file at the referenced path. The user will normally pass the path or the issue number directly.
|
||||||
|
|
||||||
|
## Wayfinding operations
|
||||||
|
|
||||||
|
Used by `/wayfinder`. The **map** is a file with one **child** file per ticket.
|
||||||
|
|
||||||
|
- **Map**: `.scratch/<effort>/map.md` — the Notes / Decisions-so-far / Fog body.
|
||||||
|
- **Child ticket**: `.scratch/<effort>/issues/NN-<slug>.md`, numbered from `01`, with the question in the body. A `Type:` line records the ticket type (`research`/`prototype`/`grilling`/`task`); a `Status:` line records `claimed`/`resolved`.
|
||||||
|
- **Blocking**: a `Blocked by: NN, NN` line near the top. A ticket is unblocked when every file it lists is `resolved`.
|
||||||
|
- **Frontier**: scan `.scratch/<effort>/issues/` for files that are open, unblocked, and unclaimed; first by number wins.
|
||||||
|
- **Claim**: set `Status: claimed` and save before any work.
|
||||||
|
- **Resolve**: append the answer under an `## Answer` heading, set `Status: resolved`, then append a context pointer (gist + link) to the map's Decisions-so-far in `map.md`.
|
||||||
|
|||||||
@@ -1,109 +1,36 @@
|
|||||||
---
|
---
|
||||||
name: tdd
|
name: tdd
|
||||||
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.
|
description: Test-driven development. Use when the user wants to build features or fix bugs test-first, mentions "red-green-refactor", or wants integration tests.
|
||||||
---
|
---
|
||||||
|
|
||||||
# Test-Driven Development
|
# Test-Driven Development
|
||||||
|
|
||||||
## Philosophy
|
TDD is the red → green loop. This skill is the reference that makes that loop produce tests worth keeping: what a good test is, where tests go, the anti-patterns, and the rules of the loop. Every section applies on every cycle — consult them before and during the loop, not after.
|
||||||
|
|
||||||
**Core principle**: Tests should verify behavior through public interfaces, not implementation details. Code can change entirely; tests shouldn't.
|
When exploring the codebase, read `CONTEXT.md` (if it exists) so test names and interface vocabulary match the project's domain language, and respect ADRs in the area you're touching.
|
||||||
|
|
||||||
**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.
|
## What a good test is
|
||||||
|
|
||||||
**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.
|
Tests verify behavior through public interfaces, not implementation details. Code can change entirely; tests shouldn't. A good test reads like a specification — "user can checkout with valid cart" tells you exactly what capability exists — and survives refactors because it doesn't care about internal structure.
|
||||||
|
|
||||||
See [tests.md](tests.md) for examples and [mocking.md](mocking.md) for mocking guidelines.
|
See [tests.md](tests.md) for examples and [mocking.md](mocking.md) for mocking guidelines.
|
||||||
|
|
||||||
## Anti-Pattern: Horizontal Slices
|
## Seams — where tests go
|
||||||
|
|
||||||
**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."
|
A **seam** is the public boundary you test at: the interface where you observe behavior without reaching inside. Tests live at seams, never against internals.
|
||||||
|
|
||||||
This produces **crap tests**:
|
**Test only at pre-agreed seams.** Before writing any test, write down the seams under test and confirm them with the user. No test is written at an unconfirmed seam. You can't test everything — agreeing the seams up front is how testing effort lands on the critical paths and complex logic instead of every edge case.
|
||||||
|
|
||||||
- Tests written in bulk test _imagined_ behavior, not _actual_ behavior
|
Ask: "What's the public interface, and which seams should we test?"
|
||||||
- You end up testing the _shape_ of things (data structures, function signatures) rather than user-facing behavior
|
|
||||||
- Tests become insensitive to real changes - they pass when behavior breaks, fail when behavior is fine
|
|
||||||
- You outrun your headlights, committing to test structure before understanding the implementation
|
|
||||||
|
|
||||||
**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.
|
## Anti-patterns
|
||||||
|
|
||||||
```
|
- **Implementation-coupled** — mocks internal collaborators, tests private methods, or verifies through a side channel (querying the database instead of using the interface). The tell: the test breaks when you refactor but behavior hasn't changed.
|
||||||
WRONG (horizontal):
|
- **Tautological** — the assertion recomputes the expected value the way the code does (`expect(add(a, b)).toBe(a + b)`, a snapshot derived by hand the same way, a constant asserted equal to itself), so it passes by construction and can never disagree with the code. Expected values must come from an independent source of truth — a known-good literal, a worked example, the spec.
|
||||||
RED: test1, test2, test3, test4, test5
|
- **Horizontal slicing** — writing all tests first, then all implementation. Bulk tests verify _imagined_ behavior: you test the _shape_ of things rather than user-facing behavior, the tests go insensitive to real changes, and you commit to test structure before understanding the implementation. Work in **vertical slices** instead — one test → one implementation → repeat, each test a **tracer bullet** that responds to what the last cycle taught you.
|
||||||
GREEN: impl1, impl2, impl3, impl4, impl5
|
|
||||||
|
|
||||||
RIGHT (vertical):
|
## Rules of the loop
|
||||||
RED→GREEN: test1→impl1
|
|
||||||
RED→GREEN: test2→impl2
|
|
||||||
RED→GREEN: test3→impl3
|
|
||||||
...
|
|
||||||
```
|
|
||||||
|
|
||||||
## Workflow
|
- **Red before green.** Write the failing test first, then only enough code to pass it. Don't anticipate future tests or add speculative features.
|
||||||
|
- **One slice at a time.** One seam, one test, one minimal implementation per cycle.
|
||||||
### 1. Planning
|
- **Refactoring is not part of the loop.** It belongs to the review stage (see the `code-review` skill), not the red → green implementation cycle.
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
Before writing any code:
|
|
||||||
|
|
||||||
- [ ] Confirm with user what interface changes are needed
|
|
||||||
- [ ] Confirm with user which behaviors to test (prioritize)
|
|
||||||
- [ ] Identify opportunities for [deep modules](deep-modules.md) (small interface, deep implementation)
|
|
||||||
- [ ] Design interfaces for [testability](interface-design.md)
|
|
||||||
- [ ] List the behaviors to test (not implementation steps)
|
|
||||||
- [ ] Get user approval on the plan
|
|
||||||
|
|
||||||
Ask: "What should the public interface look like? Which behaviors are most important to test?"
|
|
||||||
|
|
||||||
**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.
|
|
||||||
|
|
||||||
### 2. Tracer Bullet
|
|
||||||
|
|
||||||
Write ONE test that confirms ONE thing about the system:
|
|
||||||
|
|
||||||
```
|
|
||||||
RED: Write test for first behavior → test fails
|
|
||||||
GREEN: Write minimal code to pass → test passes
|
|
||||||
```
|
|
||||||
|
|
||||||
This is your tracer bullet - proves the path works end-to-end.
|
|
||||||
|
|
||||||
### 3. Incremental Loop
|
|
||||||
|
|
||||||
For each remaining behavior:
|
|
||||||
|
|
||||||
```
|
|
||||||
RED: Write next test → fails
|
|
||||||
GREEN: Minimal code to pass → passes
|
|
||||||
```
|
|
||||||
|
|
||||||
Rules:
|
|
||||||
|
|
||||||
- One test at a time
|
|
||||||
- Only enough code to pass current test
|
|
||||||
- Don't anticipate future tests
|
|
||||||
- Keep tests focused on observable behavior
|
|
||||||
|
|
||||||
### 4. Refactor
|
|
||||||
|
|
||||||
After all tests pass, look for [refactor candidates](refactoring.md):
|
|
||||||
|
|
||||||
- [ ] Extract duplication
|
|
||||||
- [ ] Deepen modules (move complexity behind simple interfaces)
|
|
||||||
- [ ] Apply SOLID principles where natural
|
|
||||||
- [ ] Consider what new code reveals about existing code
|
|
||||||
- [ ] Run tests after each refactor step
|
|
||||||
|
|
||||||
**Never refactor while RED.** Get to GREEN first.
|
|
||||||
|
|
||||||
## Checklist Per Cycle
|
|
||||||
|
|
||||||
```
|
|
||||||
[ ] Test describes behavior, not implementation
|
|
||||||
[ ] Test uses public interface only
|
|
||||||
[ ] Test would survive internal refactor
|
|
||||||
[ ] Code is minimal for this test
|
|
||||||
[ ] No speculative features added
|
|
||||||
```
|
|
||||||
|
|||||||
3
.agents/skills/tdd/agents/openai.yaml
Normal file
3
.agents/skills/tdd/agents/openai.yaml
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
interface:
|
||||||
|
display_name: "TDD"
|
||||||
|
short_description: "Test-driven red-green-refactor"
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
# Deep Modules
|
|
||||||
|
|
||||||
From "A Philosophy of Software Design":
|
|
||||||
|
|
||||||
**Deep module** = small interface + lots of implementation
|
|
||||||
|
|
||||||
```
|
|
||||||
┌─────────────────────┐
|
|
||||||
│ Small Interface │ ← Few methods, simple params
|
|
||||||
├─────────────────────┤
|
|
||||||
│ │
|
|
||||||
│ │
|
|
||||||
│ Deep Implementation│ ← Complex logic hidden
|
|
||||||
│ │
|
|
||||||
│ │
|
|
||||||
└─────────────────────┘
|
|
||||||
```
|
|
||||||
|
|
||||||
**Shallow module** = large interface + little implementation (avoid)
|
|
||||||
|
|
||||||
```
|
|
||||||
┌─────────────────────────────────┐
|
|
||||||
│ Large Interface │ ← Many methods, complex params
|
|
||||||
├─────────────────────────────────┤
|
|
||||||
│ Thin Implementation │ ← Just passes through
|
|
||||||
└─────────────────────────────────┘
|
|
||||||
```
|
|
||||||
|
|
||||||
When designing interfaces, ask:
|
|
||||||
|
|
||||||
- Can I reduce the number of methods?
|
|
||||||
- Can I simplify the parameters?
|
|
||||||
- Can I hide more complexity inside?
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
# Interface Design for Testability
|
|
||||||
|
|
||||||
Good interfaces make testing natural:
|
|
||||||
|
|
||||||
1. **Accept dependencies, don't create them**
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
// Testable
|
|
||||||
function processOrder(order, paymentGateway) {}
|
|
||||||
|
|
||||||
// Hard to test
|
|
||||||
function processOrder(order) {
|
|
||||||
const gateway = new StripeGateway();
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
2. **Return results, don't produce side effects**
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
// Testable
|
|
||||||
function calculateDiscount(cart): Discount {}
|
|
||||||
|
|
||||||
// Hard to test
|
|
||||||
function applyDiscount(cart): void {
|
|
||||||
cart.total -= discount;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
3. **Small surface area**
|
|
||||||
- Fewer methods = fewer tests needed
|
|
||||||
- Fewer params = simpler test setup
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
# Refactor Candidates
|
|
||||||
|
|
||||||
After TDD cycle, look for:
|
|
||||||
|
|
||||||
- **Duplication** → Extract function/class
|
|
||||||
- **Long methods** → Break into private helpers (keep tests on public interface)
|
|
||||||
- **Shallow modules** → Combine or deepen
|
|
||||||
- **Feature envy** → Move logic to where data lives
|
|
||||||
- **Primitive obsession** → Introduce value objects
|
|
||||||
- **Existing code** the new code reveals as problematic
|
|
||||||
@@ -59,3 +59,19 @@ test("createUser makes user retrievable", async () => {
|
|||||||
expect(retrieved.name).toBe("Alice");
|
expect(retrieved.name).toBe("Alice");
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**Tautological tests**: Expected value restates the implementation, so the test passes by construction.
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
// BAD: Expected value is recomputed the way the code computes it
|
||||||
|
test("calculateTotal sums line items", () => {
|
||||||
|
const items = [{ price: 10 }, { price: 5 }];
|
||||||
|
const expected = items.reduce((sum, i) => sum + i.price, 0);
|
||||||
|
expect(calculateTotal(items)).toBe(expected);
|
||||||
|
});
|
||||||
|
|
||||||
|
// GOOD: Expected value is an independent, known literal
|
||||||
|
test("calculateTotal sums line items", () => {
|
||||||
|
expect(calculateTotal([{ price: 10 }, { price: 5 }])).toBe(15);
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ Treat the current directory as a teaching workspace. The state of their learning
|
|||||||
- `RESOURCES.md`: A list of resources which can be explored to ground your teaching in contextual knowledge, or to acquire knowledge and wisdom. Use the format in [RESOURCES-FORMAT.md](./RESOURCES-FORMAT.md).
|
- `RESOURCES.md`: A list of resources which can be explored to ground your teaching in contextual knowledge, or to acquire knowledge and wisdom. Use the format in [RESOURCES-FORMAT.md](./RESOURCES-FORMAT.md).
|
||||||
- `./learning-records/*.md`: A directory of learning records, which capture what the user has learned. These are loosely equivalent to architectural decision records in software development - they capture non-obvious lessons and key insights that may need to be revised later, or drive future sessions. These should be used to calculate the zone of proximal development. They are titled `0001-<dash-case-name>.md`, where the number increments each time. Use the format in [LEARNING-RECORD-FORMAT.md](./LEARNING-RECORD-FORMAT.md).
|
- `./learning-records/*.md`: A directory of learning records, which capture what the user has learned. These are loosely equivalent to architectural decision records in software development - they capture non-obvious lessons and key insights that may need to be revised later, or drive future sessions. These should be used to calculate the zone of proximal development. They are titled `0001-<dash-case-name>.md`, where the number increments each time. Use the format in [LEARNING-RECORD-FORMAT.md](./LEARNING-RECORD-FORMAT.md).
|
||||||
- `./lessons/*.html`: A directory of lessons. A **lesson** is a single, self-contained HTML output that teaches one tightly-scoped thing tied to the mission. This is the primary unit of teaching in this workspace.
|
- `./lessons/*.html`: A directory of lessons. A **lesson** is a single, self-contained HTML output that teaches one tightly-scoped thing tied to the mission. This is the primary unit of teaching in this workspace.
|
||||||
|
- `./assets/*`: Reusable **components** shared across lessons. See [Assets](#assets).
|
||||||
- `NOTES.md`: A scratchpad for you to jot down user preferences, or working notes.
|
- `NOTES.md`: A scratchpad for you to jot down user preferences, or working notes.
|
||||||
|
|
||||||
## Philosophy
|
## Philosophy
|
||||||
@@ -59,6 +60,14 @@ Each lesson should recommend a primary source for the user to read or watch. Thi
|
|||||||
|
|
||||||
Each lesson should contain a reminder to ask followup questions to the agent. The agent is their teacher, and can assist with anything that's unclear.
|
Each lesson should contain a reminder to ask followup questions to the agent. The agent is their teacher, and can assist with anything that's unclear.
|
||||||
|
|
||||||
|
## Assets
|
||||||
|
|
||||||
|
Lessons are built from reusable **components**, stored in `./assets/`: stylesheets, quiz widgets, simulators, diagram helpers — anything a second lesson could reuse.
|
||||||
|
|
||||||
|
Reuse is the default, not the exception. Before authoring a lesson, read `./assets/` and build from the components already there. When a lesson needs something new and reusable, write it as a component in `./assets/` and link to it — never inline code a future lesson would duplicate.
|
||||||
|
|
||||||
|
A shared stylesheet is the first component every workspace earns: every lesson links it, so the lessons look like one consistent course rather than a pile of one-offs. As the workspace grows, so should the component library.
|
||||||
|
|
||||||
## The Mission
|
## The Mission
|
||||||
|
|
||||||
Every lesson should be tied into the mission - the reason that the user is interested in learning about the topic.
|
Every lesson should be tied into the mission - the reason that the user is interested in learning about the topic.
|
||||||
|
|||||||
5
.agents/skills/teach/agents/openai.yaml
Normal file
5
.agents/skills/teach/agents/openai.yaml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
interface:
|
||||||
|
display_name: "Teach"
|
||||||
|
short_description: "Learn a concept in a guided workspace"
|
||||||
|
policy:
|
||||||
|
allow_implicit_invocation: false
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
---
|
---
|
||||||
name: to-issues
|
name: to-issues
|
||||||
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.
|
description: Break a plan, spec, or PRD into independently-grabbable issues on the project issue tracker using tracer-bullet vertical slices.
|
||||||
|
disable-model-invocation: true
|
||||||
---
|
---
|
||||||
|
|
||||||
# To Issues
|
# To Issues
|
||||||
@@ -19,16 +20,18 @@ Work from whatever is already in the conversation context. If the user passes an
|
|||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
|
Look for opportunities to prefactor the code to make the implementation easier. "Make the change easy, then make the easy change."
|
||||||
|
|
||||||
### 3. Draft vertical slices
|
### 3. Draft vertical slices
|
||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
<vertical-slice-rules>
|
<vertical-slice-rules>
|
||||||
|
|
||||||
- Each slice delivers a narrow but COMPLETE path through every layer (schema, API, UI, tests)
|
- Each slice delivers a narrow but COMPLETE path through every layer (schema, API, UI, tests)
|
||||||
- A completed slice is demoable or verifiable on its own
|
- A completed slice is demoable or verifiable on its own
|
||||||
- Prefer many thin slices over few thick ones
|
- Any prefactoring should be done first
|
||||||
|
|
||||||
</vertical-slice-rules>
|
</vertical-slice-rules>
|
||||||
|
|
||||||
### 4. Quiz the user
|
### 4. Quiz the user
|
||||||
@@ -36,7 +39,6 @@ Slices may be 'HITL' or 'AFK'. HITL slices require human interaction, such as an
|
|||||||
Present the proposed breakdown as a numbered list. For each slice, show:
|
Present the proposed breakdown as a numbered list. For each slice, show:
|
||||||
|
|
||||||
- **Title**: short descriptive name
|
- **Title**: short descriptive name
|
||||||
- **Type**: HITL / AFK
|
|
||||||
- **Blocked by**: which other slices (if any) must complete first
|
- **Blocked by**: which other slices (if any) must complete first
|
||||||
- **User stories covered**: which user stories this addresses (if the source material has them)
|
- **User stories covered**: which user stories this addresses (if the source material has them)
|
||||||
|
|
||||||
@@ -45,7 +47,6 @@ Ask the user:
|
|||||||
- Does the granularity feel right? (too coarse / too fine)
|
- Does the granularity feel right? (too coarse / too fine)
|
||||||
- Are the dependency relationships correct?
|
- Are the dependency relationships correct?
|
||||||
- Should any slices be merged or split further?
|
- Should any slices be merged or split further?
|
||||||
- Are the correct slices marked as HITL and AFK?
|
|
||||||
|
|
||||||
Iterate until the user approves the breakdown.
|
Iterate until the user approves the breakdown.
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
---
|
---
|
||||||
name: to-prd
|
name: to-prd
|
||||||
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.
|
description: Turn the current conversation into a PRD and publish it to the project issue tracker — no interview, just synthesis of what you've already discussed.
|
||||||
|
disable-model-invocation: true
|
||||||
---
|
---
|
||||||
|
|
||||||
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.
|
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.
|
||||||
@@ -11,7 +12,7 @@ The issue tracker and triage label vocabulary should have been provided to you
|
|||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
2. Sketch out the seams at which you're going to test the feature. Existing seams should be preferred to new ones. Use the highest seam possible. If new seams are needed, propose them at the highest point you can.
|
2. Sketch out the seams at which you're going to test the feature. Existing seams should be preferred to new ones. Use the highest seam possible. If new seams are needed, propose them at the highest point you can. The fewer seams across the codebase, the better - the ideal number is one.
|
||||||
|
|
||||||
Check with the user that these seams match their expectations.
|
Check with the user that these seams match their expectations.
|
||||||
|
|
||||||
|
|||||||
75
.agents/skills/to-spec/SKILL.md
Normal file
75
.agents/skills/to-spec/SKILL.md
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
---
|
||||||
|
name: to-spec
|
||||||
|
description: Turn the current conversation into a spec and publish it to the project issue tracker — no interview, just synthesis of what you've already discussed.
|
||||||
|
disable-model-invocation: true
|
||||||
|
---
|
||||||
|
|
||||||
|
This skill takes the current conversation context and codebase understanding and produces a spec (you may know this document as a PRD). Do NOT interview the user — just synthesize what you already know.
|
||||||
|
|
||||||
|
The issue tracker and triage label vocabulary should have been provided to you — run `/setup-matt-pocock-skills` if not.
|
||||||
|
|
||||||
|
## Process
|
||||||
|
|
||||||
|
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 spec, and respect any ADRs in the area you're touching.
|
||||||
|
|
||||||
|
2. Sketch out the seams at which you're going to test the feature. Existing seams should be preferred to new ones. Use the highest seam possible. If new seams are needed, propose them at the highest point you can. The fewer seams across the codebase, the better - the ideal number is one.
|
||||||
|
|
||||||
|
Check with the user that these seams match their expectations.
|
||||||
|
|
||||||
|
3. Write the spec using the template below, then publish it to the project issue tracker. Apply the `ready-for-agent` triage label - no need for additional triage.
|
||||||
|
|
||||||
|
<spec-template>
|
||||||
|
|
||||||
|
## Problem Statement
|
||||||
|
|
||||||
|
The problem that the user is facing, from the user's perspective.
|
||||||
|
|
||||||
|
## Solution
|
||||||
|
|
||||||
|
The solution to the problem, from the user's perspective.
|
||||||
|
|
||||||
|
## User Stories
|
||||||
|
|
||||||
|
A LONG, numbered list of user stories. Each user story should be in the format of:
|
||||||
|
|
||||||
|
1. As an <actor>, I want a <feature>, so that <benefit>
|
||||||
|
|
||||||
|
<user-story-example>
|
||||||
|
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
|
||||||
|
</user-story-example>
|
||||||
|
|
||||||
|
This list of user stories should be extremely extensive and cover all aspects of the feature.
|
||||||
|
|
||||||
|
## Implementation Decisions
|
||||||
|
|
||||||
|
A list of implementation decisions that were made. This can include:
|
||||||
|
|
||||||
|
- The modules that will be built/modified
|
||||||
|
- The interfaces of those modules that will be modified
|
||||||
|
- Technical clarifications from the developer
|
||||||
|
- Architectural decisions
|
||||||
|
- Schema changes
|
||||||
|
- API contracts
|
||||||
|
- Specific interactions
|
||||||
|
|
||||||
|
Do NOT include specific file paths or code snippets. They may end up being outdated very quickly.
|
||||||
|
|
||||||
|
Exception: if a prototype produced a snippet that encodes a decision more precisely than prose can (state machine, reducer, schema, type shape), inline it within the relevant decision and note briefly that it came from a prototype. Trim to the decision-rich parts — not a working demo, just the important bits.
|
||||||
|
|
||||||
|
## Testing Decisions
|
||||||
|
|
||||||
|
A list of testing decisions that were made. Include:
|
||||||
|
|
||||||
|
- A description of what makes a good test (only test external behavior, not implementation details)
|
||||||
|
- Which modules will be tested
|
||||||
|
- Prior art for the tests (i.e. similar types of tests in the codebase)
|
||||||
|
|
||||||
|
## Out of Scope
|
||||||
|
|
||||||
|
A description of the things that are out of scope for this spec.
|
||||||
|
|
||||||
|
## Further Notes
|
||||||
|
|
||||||
|
Any further notes about the feature.
|
||||||
|
|
||||||
|
</spec-template>
|
||||||
5
.agents/skills/to-spec/agents/openai.yaml
Normal file
5
.agents/skills/to-spec/agents/openai.yaml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
interface:
|
||||||
|
display_name: "To Spec"
|
||||||
|
short_description: "Turn a conversation into a spec"
|
||||||
|
policy:
|
||||||
|
allow_implicit_invocation: false
|
||||||
107
.agents/skills/to-tickets/SKILL.md
Normal file
107
.agents/skills/to-tickets/SKILL.md
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
---
|
||||||
|
name: to-tickets
|
||||||
|
description: Break a plan, spec, or the current conversation into a set of tracer-bullet tickets, each declaring its blocking edges, published to the configured tracker — edges as text in one file per ticket locally, or native blocking links on a real tracker.
|
||||||
|
disable-model-invocation: true
|
||||||
|
---
|
||||||
|
|
||||||
|
# To Tickets
|
||||||
|
|
||||||
|
Break a plan, spec, or conversation into a set of **tickets** — tracer-bullet vertical slices, each declaring the tickets that **block** it.
|
||||||
|
|
||||||
|
The issue tracker and triage label vocabulary should have been provided to you — run `/setup-matt-pocock-skills` if not.
|
||||||
|
|
||||||
|
## Process
|
||||||
|
|
||||||
|
### 1. Gather context
|
||||||
|
|
||||||
|
Work from whatever is already in the conversation context. If the user passes a reference (a spec path, an issue number or URL) as an argument, fetch it and read its full body and comments.
|
||||||
|
|
||||||
|
### 2. Explore the codebase (optional)
|
||||||
|
|
||||||
|
If you have not already explored the codebase, do so to understand the current state of the code. Ticket titles and descriptions should use the project's domain glossary vocabulary, and respect ADRs in the area you're touching.
|
||||||
|
|
||||||
|
Look for opportunities to prefactor the code to make the implementation easier. "Make the change easy, then make the easy change."
|
||||||
|
|
||||||
|
### 3. Draft vertical slices
|
||||||
|
|
||||||
|
Break the work into **tracer bullet** tickets.
|
||||||
|
|
||||||
|
<vertical-slice-rules>
|
||||||
|
|
||||||
|
- Each slice cuts a narrow but COMPLETE path through every layer (schema, API, UI, tests) — vertical, NOT a horizontal slice of one layer
|
||||||
|
- A completed slice is demoable or verifiable on its own
|
||||||
|
- Each slice is sized to fit in a single fresh context window
|
||||||
|
- Any prefactoring should be done first
|
||||||
|
|
||||||
|
</vertical-slice-rules>
|
||||||
|
|
||||||
|
Give each ticket its **blocking edges** — the other tickets that must complete before it can start. A ticket with no blockers can start immediately.
|
||||||
|
|
||||||
|
**Wide refactors are the exception to vertical slicing.** A **wide refactor** is one mechanical change — rename a column, retype a shared symbol — whose **blast radius** fans across the whole codebase, so a single edit breaks thousands of call sites at once and no vertical slice can land green. Don't force it into a tracer bullet; sequence it as **expand–contract**. First expand: add the new form beside the old so nothing breaks. Then migrate the call sites over in batches sized by blast radius (per package, per directory), each batch its own ticket blocked by the expand, keeping CI green batch to batch because the old form still exists. Finally contract: delete the old form once no caller remains, in a ticket blocked by every migrate batch. When even the batches can't stay green alone, keep the sequence but let them share an integration branch that all block a final integrate-and-verify ticket — green is promised only there.
|
||||||
|
|
||||||
|
### 4. Quiz the user
|
||||||
|
|
||||||
|
Present the proposed breakdown as a numbered list. For each ticket, show:
|
||||||
|
|
||||||
|
- **Title**: short descriptive name
|
||||||
|
- **Blocked by**: which other tickets (if any) must complete first
|
||||||
|
- **What it delivers**: the end-to-end behaviour this ticket makes work
|
||||||
|
|
||||||
|
Ask the user:
|
||||||
|
|
||||||
|
- Does the granularity feel right? (too coarse / too fine)
|
||||||
|
- Are the blocking edges correct — does each ticket only depend on tickets that genuinely gate it?
|
||||||
|
- Should any tickets be merged or split further?
|
||||||
|
|
||||||
|
Iterate until the user approves the breakdown.
|
||||||
|
|
||||||
|
### 5. Publish the tickets to the configured tracker
|
||||||
|
|
||||||
|
Publish the approved tickets. **How** depends on the tracker `/setup-matt-pocock-skills` configured — the tickets are the same either way, only the shape of the blocking edges changes:
|
||||||
|
|
||||||
|
- **Local files** → write one file per ticket under `.scratch/<feature-slug>/issues/<NN>-<slug>.md`, numbered from `01` in dependency order (blockers first). Each file's "Blocked by" lists the numbers/titles it depends on. Use the per-ticket file template below — one ticket per file, never a single combined file.
|
||||||
|
- **A real issue tracker (GitHub, Linear, …)** → publish one issue per ticket in dependency order (blockers first) so each ticket's blocking edges can reference real identifiers. Use the platform's native blocking / sub-issue relationship where it has one; otherwise set each ticket's "Blocked by" to the blocking issues. Apply the `ready-for-agent` triage label unless instructed otherwise — the tickets are agent-grabbable by construction.
|
||||||
|
|
||||||
|
Work the **frontier**: any ticket whose blockers are all done. For a purely linear chain that means top to bottom.
|
||||||
|
|
||||||
|
Do NOT close or modify any parent issue.
|
||||||
|
|
||||||
|
<local-ticket-template>
|
||||||
|
|
||||||
|
# <NN> — <Ticket title>
|
||||||
|
|
||||||
|
**What to build:** the end-to-end behaviour this ticket makes work, from the user's perspective — not a layer-by-layer implementation list.
|
||||||
|
|
||||||
|
**Blocked by:** the numbers/titles of the tickets that gate this one, or "None — can start immediately".
|
||||||
|
|
||||||
|
**Status:** ready-for-agent
|
||||||
|
|
||||||
|
- [ ] Acceptance criterion 1
|
||||||
|
- [ ] Acceptance criterion 2
|
||||||
|
|
||||||
|
</local-ticket-template>
|
||||||
|
|
||||||
|
<issue-template>
|
||||||
|
|
||||||
|
## Parent
|
||||||
|
|
||||||
|
A reference to the parent issue on the tracker (if the source was an existing issue, otherwise omit this section).
|
||||||
|
|
||||||
|
## What to build
|
||||||
|
|
||||||
|
The end-to-end behaviour this ticket makes work, from the user's perspective — not layer-by-layer implementation.
|
||||||
|
|
||||||
|
## Acceptance criteria
|
||||||
|
|
||||||
|
- [ ] Criterion 1
|
||||||
|
- [ ] Criterion 2
|
||||||
|
|
||||||
|
## Blocked by
|
||||||
|
|
||||||
|
- A reference to each blocking ticket, or "None — can start immediately".
|
||||||
|
|
||||||
|
</issue-template>
|
||||||
|
|
||||||
|
In either form, avoid specific file paths or code snippets — they go stale fast. Exception: if a prototype produced a snippet that encodes a decision more precisely than prose can (state machine, reducer, schema, type shape), inline it and note briefly that it came from a prototype. Trim to the decision-rich parts — not a working demo, just the important bits.
|
||||||
|
|
||||||
|
Work the frontier one ticket at a time with `/implement`, clearing context between tickets.
|
||||||
5
.agents/skills/to-tickets/agents/openai.yaml
Normal file
5
.agents/skills/to-tickets/agents/openai.yaml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
interface:
|
||||||
|
display_name: "To Tickets"
|
||||||
|
short_description: "Split a plan into tracer-bullet tickets"
|
||||||
|
policy:
|
||||||
|
allow_implicit_invocation: false
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
# Writing Agent Briefs
|
# Writing Agent Briefs
|
||||||
|
|
||||||
An agent brief is a structured comment posted on a GitHub issue when it moves to `ready-for-agent`. It is the authoritative specification that an AFK agent will work from. The original issue body and discussion are context — the agent brief is the contract.
|
An agent brief is a structured comment posted on a GitHub issue or PR when it moves to `ready-for-agent`. It is the authoritative specification that an AFK agent will work from. The original body and discussion are context — the agent brief is the contract.
|
||||||
|
|
||||||
|
The brief states **what the agent should do**, which stretches to both surfaces: for an issue, that's building the change from nothing; for a PR, it's what's left to do *to the existing diff* — finish it, close gaps, address review points. Same principles either way; the PR example below shows the difference.
|
||||||
|
|
||||||
## Principles
|
## Principles
|
||||||
|
|
||||||
@@ -143,6 +145,43 @@ checked for matches.
|
|||||||
- Bug reports (only enhancement rejections go to `.out-of-scope/`)
|
- Bug reports (only enhancement rejections go to `.out-of-scope/`)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Good agent brief (PR)
|
||||||
|
|
||||||
|
For a PR, "Current behavior" describes the state of the diff, and the brief asks the agent to finish or fix it rather than build from scratch.
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
## Agent Brief
|
||||||
|
|
||||||
|
**Category:** enhancement
|
||||||
|
**Summary:** Finish the contributor's `--json` output flag for `triage list`
|
||||||
|
|
||||||
|
**Current behavior:**
|
||||||
|
The PR adds a `--json` flag that serializes the issue list to JSON. The happy
|
||||||
|
path works and the diff matches the project's command structure. Two gaps
|
||||||
|
remain: errors are still printed as human text (not JSON), and the new flag has
|
||||||
|
no test coverage.
|
||||||
|
|
||||||
|
**Desired behavior:**
|
||||||
|
With `--json`, all output — including errors — is well-formed JSON on stdout,
|
||||||
|
and the command's exit codes are unchanged. The existing human-readable output
|
||||||
|
is untouched when the flag is absent.
|
||||||
|
|
||||||
|
**Key interfaces:**
|
||||||
|
- The command's error path should emit `{ "error": string }` under `--json`
|
||||||
|
instead of the plain-text error
|
||||||
|
- Reuse the existing serializer the PR already added; don't introduce a second
|
||||||
|
|
||||||
|
**Acceptance criteria:**
|
||||||
|
- [ ] `triage list --json` emits valid JSON for both success and error cases
|
||||||
|
- [ ] Exit codes match the non-JSON command
|
||||||
|
- [ ] A test covers the `--json` success output and one error case
|
||||||
|
- [ ] Default (non-JSON) output is byte-for-byte unchanged
|
||||||
|
|
||||||
|
**Out of scope:**
|
||||||
|
- Adding `--json` to any other command
|
||||||
|
- Changing the JSON shape of the success payload the PR already defined
|
||||||
|
```
|
||||||
|
|
||||||
### Bad agent brief
|
### Bad agent brief
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
|
|||||||
@@ -83,7 +83,11 @@ The maintainer may:
|
|||||||
|
|
||||||
## When to write to `.out-of-scope/`
|
## When to write to `.out-of-scope/`
|
||||||
|
|
||||||
Only when an **enhancement** (not a bug) is rejected as `wontfix`. The flow:
|
Only when an **enhancement** (not a bug) is *rejected* as `wontfix`. This applies to enhancement PRs exactly as it does to issues — a rejected PR is recorded here so the same request doesn't return as fresh code.
|
||||||
|
|
||||||
|
Do **not** write here when something is closed as `wontfix` because it's **already implemented**. That's a built feature, not a rejected one; recording it would poison the dedup checks with false rejections. Instead, the closing comment points to where the feature already lives.
|
||||||
|
|
||||||
|
The flow:
|
||||||
|
|
||||||
1. Maintainer decides a feature request is out of scope
|
1. Maintainer decides a feature request is out of scope
|
||||||
2. Check if a matching `.out-of-scope/` file already exists
|
2. Check if a matching `.out-of-scope/` file already exists
|
||||||
|
|||||||
@@ -1,12 +1,15 @@
|
|||||||
---
|
---
|
||||||
name: triage
|
name: triage
|
||||||
description: Triage issues through a state machine driven by triage roles. Use when user wants to create an issue, triage issues, review incoming bugs or feature requests, prepare issues for an AFK agent, or manage issue workflow.
|
description: Move issues and external PRs through a state machine of triage roles — categorise, verify, grill if needed, and write agent-ready briefs.
|
||||||
|
disable-model-invocation: true
|
||||||
---
|
---
|
||||||
|
|
||||||
# Triage
|
# Triage
|
||||||
|
|
||||||
Move issues on the project issue tracker through a small state machine of triage roles.
|
Move issues on the project issue tracker through a small state machine of triage roles.
|
||||||
|
|
||||||
|
If this repo treats external pull requests as a request surface (see the issue-tracker config), triage covers them too: **a PR is an issue with attached code** — same roles, same states, same machine, with a few deltas marked "for a PR" below. Resolve a bare `#42` to an issue or PR per the tracker config.
|
||||||
|
|
||||||
Every comment or issue posted to the issue tracker during triage **must** start with this disclaimer:
|
Every comment or issue posted to the issue tracker during triage **must** start with this disclaimer:
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -33,6 +36,8 @@ Five **state** roles:
|
|||||||
- `ready-for-human` — needs human implementation
|
- `ready-for-human` — needs human implementation
|
||||||
- `wontfix` — will not be actioned
|
- `wontfix` — will not be actioned
|
||||||
|
|
||||||
|
For a PR, the same states read against the attached code: `ready-for-agent` means a brief is attached and an agent should take the next step on the diff; `ready-for-human` means it's ready for a human to merge.
|
||||||
|
|
||||||
Every triaged issue should carry exactly one category role and one state role. If state roles conflict, flag it and ask the maintainer before doing anything else.
|
Every triaged issue should carry exactly one category role and one state role. If state roles conflict, flag it and ask the maintainer before doing anything else.
|
||||||
|
|
||||||
These are canonical role names — the actual label strings used in the issue tracker may differ. The mapping should have been provided to you - run `/setup-matt-pocock-skills` if not.
|
These are canonical role names — the actual label strings used in the issue tracker may differ. The mapping should have been provided to you - run `/setup-matt-pocock-skills` if not.
|
||||||
@@ -44,7 +49,7 @@ State transitions: an unlabeled issue normally goes to `needs-triage` first; fro
|
|||||||
The maintainer invokes `/triage` and describes what they want in natural language. Interpret the request and act. Examples:
|
The maintainer invokes `/triage` and describes what they want in natural language. Interpret the request and act. Examples:
|
||||||
|
|
||||||
- "Show me anything that needs my attention"
|
- "Show me anything that needs my attention"
|
||||||
- "Let's look at #42"
|
- "Let's look at #42" (issue or PR)
|
||||||
- "Move #42 to ready-for-agent"
|
- "Move #42 to ready-for-agent"
|
||||||
- "What's ready for agents to pick up?"
|
- "What's ready for agents to pick up?"
|
||||||
|
|
||||||
@@ -56,24 +61,28 @@ Query the issue tracker and present three buckets, oldest first:
|
|||||||
2. **`needs-triage`** — evaluation in progress.
|
2. **`needs-triage`** — evaluation in progress.
|
||||||
3. **`needs-info` with reporter activity since the last triage notes** — needs re-evaluation.
|
3. **`needs-info` with reporter activity since the last triage notes** — needs re-evaluation.
|
||||||
|
|
||||||
Show counts and a one-line summary per issue. Let the maintainer pick.
|
When PRs are in scope, include external PRs in these buckets and tag each line `[PR]` or `[issue]`. Discovery surfaces only *external* PRs (the tracker config defines who counts as external) — a collaborator's in-flight PR is not triage work. This filter is discovery-only; an explicitly named PR is always triaged regardless of author.
|
||||||
|
|
||||||
## Triage a specific issue
|
Show counts and a one-line summary per item. Let the maintainer pick.
|
||||||
|
|
||||||
1. **Gather context.** Read the full issue (body, comments, labels, reporter, dates). Parse any prior triage notes so you don't re-ask resolved questions. Explore the codebase using the project's domain glossary, respecting ADRs in the area. Read `.out-of-scope/*.md` and surface any prior rejection that resembles this issue.
|
## Triage a specific issue or PR
|
||||||
|
|
||||||
2. **Recommend.** Tell the maintainer your category and state recommendation with reasoning, plus a brief codebase summary relevant to the issue. Wait for direction.
|
1. **Gather context.** Read the full issue or PR (body, comments, labels, author, dates; for a PR, the diff too). Parse any prior triage notes so you don't re-ask resolved questions. Explore the codebase using the project's domain glossary, respecting ADRs in the area. Run two checks against the codebase: (a) **redundancy** — search for an existing implementation of the requested behavior by domain concept (not just the request's wording), and report where you looked. If found, it's an already-implemented `wontfix` (step 5). (b) **prior rejection** — read `.out-of-scope/*.md` and surface any that resembles this request.
|
||||||
|
|
||||||
3. **Reproduce (bugs only).** Before any grilling, attempt reproduction: read the reporter's steps, trace the relevant code, run tests or commands. Report what happened — successful repro with code path, failed repro, or insufficient detail (a strong `needs-info` signal). A confirmed repro makes a much stronger agent brief.
|
2. **Recommend.** Tell the maintainer your category and state recommendation with reasoning, plus a brief codebase summary relevant to the request — including whether it's already implemented. Wait for direction.
|
||||||
|
|
||||||
4. **Grill (if needed).** If the issue needs fleshing out, run a `/grill-with-docs` session.
|
3. **Verify the claim.** Before any grilling, check that the claim holds up. For a bug, reproduce it from the reporter's steps. For a PR, confirm the diff does what it claims — check it out, run the relevant tests or commands. Report what happened: confirmed (with code path), failed, or insufficient detail (a strong `needs-info` signal). A confirmed verification makes a much stronger agent brief.
|
||||||
|
|
||||||
|
4. **Grill (if needed).** If the request needs fleshing out, run the `/grilling` and `/domain-modeling` skills together — grill it into shape one question at a time, sharpening domain terms and updating `CONTEXT.md`/ADRs inline as decisions land.
|
||||||
|
|
||||||
5. **Apply the outcome:**
|
5. **Apply the outcome:**
|
||||||
- `ready-for-agent` — post an agent brief comment ([AGENT-BRIEF.md](AGENT-BRIEF.md)).
|
- `ready-for-agent` — post an agent brief comment ([AGENT-BRIEF.md](AGENT-BRIEF.md)).
|
||||||
- `ready-for-human` — same structure as an agent brief, but note why it can't be delegated (judgment calls, external access, design decisions, manual testing).
|
- `ready-for-human` — same structure as an agent brief, but note why it can't be delegated (judgment calls, external access, design decisions, manual testing).
|
||||||
- `needs-info` — post triage notes (template below).
|
- `needs-info` — post triage notes (template below).
|
||||||
- `wontfix` (bug) — polite explanation, then close.
|
- `wontfix` — close, with the comment depending on *why*:
|
||||||
- `wontfix` (enhancement) — write to `.out-of-scope/`, link to it from a comment, then close ([OUT-OF-SCOPE.md](OUT-OF-SCOPE.md)).
|
- **Already implemented** — the change already exists in the codebase. Point to where it lives; do **not** write to `.out-of-scope/` (that KB is for *rejected* requests, not built ones).
|
||||||
|
- **Rejected (bug)** — polite explanation, then close.
|
||||||
|
- **Rejected (enhancement)** — write to `.out-of-scope/`, link to it from a comment, then close ([OUT-OF-SCOPE.md](OUT-OF-SCOPE.md)).
|
||||||
- `needs-triage` — apply the role. Optional comment if there's partial progress.
|
- `needs-triage` — apply the role. Optional comment if there's partial progress.
|
||||||
|
|
||||||
## Quick state override
|
## Quick state override
|
||||||
@@ -100,4 +109,4 @@ Capture everything resolved during grilling under "established so far" so the wo
|
|||||||
|
|
||||||
## Resuming a previous session
|
## Resuming a previous session
|
||||||
|
|
||||||
If prior triage notes exist on the issue, read them, check whether the reporter has answered any outstanding questions, and present an updated picture before continuing. Don't re-ask resolved questions.
|
If prior triage notes exist on the issue or PR, read them, check whether the reporter has answered any outstanding questions, and present an updated picture before continuing. Don't re-ask resolved questions.
|
||||||
|
|||||||
5
.agents/skills/triage/agents/openai.yaml
Normal file
5
.agents/skills/triage/agents/openai.yaml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
interface:
|
||||||
|
display_name: "Triage"
|
||||||
|
short_description: "Move issues through triage roles"
|
||||||
|
policy:
|
||||||
|
allow_implicit_invocation: false
|
||||||
128
.agents/skills/wayfinder/SKILL.md
Normal file
128
.agents/skills/wayfinder/SKILL.md
Normal file
@@ -0,0 +1,128 @@
|
|||||||
|
---
|
||||||
|
name: wayfinder
|
||||||
|
description: Plan a huge chunk of work — more than one agent session can hold — as a shared map of decision tickets on your issue tracker, and resolve them one at a time until the way to the destination is clear.
|
||||||
|
disable-model-invocation: true
|
||||||
|
---
|
||||||
|
|
||||||
|
A loose idea has arrived — too big for one agent session, and wrapped in fog: the way from here to the **destination** isn't visible yet. Wayfinding is about finding that way, not charging at the destination. This skill charts the way as a **shared map** on the repo's issue tracker, then works its **decision tickets** — questions whose resolution is a decision, not slices of a build to execute — one at a time until the route is clear.
|
||||||
|
|
||||||
|
The destination varies per effort, and naming it is the first act of charting — it shapes every ticket. It might be a spec to hand off and iterate on, a decision to lock before planning starts, or a change made in place like a data-structure migration. The map is domain-agnostic — engineering work, course content, whatever fits the shape.
|
||||||
|
|
||||||
|
## Plan, don't do
|
||||||
|
|
||||||
|
Wayfinder is **planning** by default: each ticket resolves a decision, and the map is done when the way is clear — nothing left to decide before someone goes and does the thing. The pull to just do the work is usually the signal you've reached the edge of the map and it's time to hand off. An effort can override this in its **Notes** — carrying execution into the map itself — but absent that, produce decisions, not deliverables.
|
||||||
|
|
||||||
|
## Refer by name
|
||||||
|
|
||||||
|
Every map and ticket is an issue, so it has a **name** — its title. In everything the human reads — narration, the map's Decisions-so-far — refer to it by that name, never by a bare id, number, or slug. A wall of `#42, #43, #44` is illegible; names read at a glance. The id and URL don't vanish — a name wraps its link — but they ride *inside* the name, never stand in for it.
|
||||||
|
|
||||||
|
## The Map
|
||||||
|
|
||||||
|
The map is a single issue on this repo's issue tracker, labelled `wayfinder:map` — the canonical artifact. Its tickets are child issues of the map.
|
||||||
|
|
||||||
|
The map is an **index**, not a store. It lists the decisions made and points at the tickets that hold their detail; a decision lives in exactly one place — its ticket — so the map never restates it, only gists it and links.
|
||||||
|
|
||||||
|
**Where the map, its child tickets, blocking, and frontier queries physically live is tracker-specific.** The issue tracker should have been provided to you — run `/setup-matt-pocock-skills` if not. Consult the tracker doc's "Wayfinding operations" section for how _this_ repo expresses them. If no tracker has been provided, default to the local-markdown tracker.
|
||||||
|
|
||||||
|
### The map body
|
||||||
|
|
||||||
|
The whole map at low resolution, loaded once per session. Open tickets are **not** listed — they are open child issues, found by query.
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
## Destination
|
||||||
|
|
||||||
|
<what reaching the end of this map looks like — the spec, decision, or change this effort is finding its way to. One or two lines; every session orients to it before choosing a ticket.>
|
||||||
|
|
||||||
|
## Notes
|
||||||
|
|
||||||
|
<domain; skills every session should consult; standing preferences for this effort>
|
||||||
|
|
||||||
|
## Decisions so far
|
||||||
|
|
||||||
|
<!-- the index — one line per closed ticket: enough to judge relevance, then zoom the link for the detail the ticket holds -->
|
||||||
|
|
||||||
|
- [<closed ticket title>](link) — <one-line gist of the answer>
|
||||||
|
|
||||||
|
## Not yet specified
|
||||||
|
|
||||||
|
<!-- see "Fog of war": in-scope fog you can't ticket yet; graduates as the frontier advances -->
|
||||||
|
|
||||||
|
## Out of scope
|
||||||
|
|
||||||
|
<!-- see "Out of scope": work ruled beyond the destination; closed, never graduates -->
|
||||||
|
```
|
||||||
|
|
||||||
|
### Tickets
|
||||||
|
|
||||||
|
Each ticket is a **child issue** of the map; the tracker's issue id is its identity. Its body is the question, sized to one 100K token agent session:
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
## Question
|
||||||
|
|
||||||
|
<the decision or investigation this ticket resolves>
|
||||||
|
```
|
||||||
|
|
||||||
|
Each ticket carries a `wayfinder:<type>` label — one of `research`, `prototype`, `grilling`, `task` (see [Ticket Types](#ticket-types)).
|
||||||
|
|
||||||
|
A session **claims** a ticket by assigning it to the dev driving the map, **first**, before any work, so concurrent sessions skip it. That assignee _is_ the claim: an open, unassigned ticket is unclaimed.
|
||||||
|
|
||||||
|
Blocking uses the tracker's **native** dependency relationship — essential because it renders the frontier _visually_ in the tracker's own UI, so the human sees what's takeable without opening the map. Only a tracker that lacks native blocking falls back to a body convention. A ticket is **unblocked** when every ticket blocking it is closed; the **frontier** is the open, unblocked, unclaimed children — the edge of the known.
|
||||||
|
|
||||||
|
The answer isn't part of the body — it's recorded on resolution (see [Work through the map](#work-through-the-map)). Assets created while resolving a ticket are linked from the issue, not pasted in.
|
||||||
|
|
||||||
|
## Ticket Types
|
||||||
|
|
||||||
|
Every ticket is either **HITL** — human in the loop, worked *with* a human who speaks for themselves — or **AFK**, driven by the agent alone. A HITL ticket only resolves through that live exchange; the agent never stands in for the human's side of it (a grilling agent that answers its own questions has broken this).
|
||||||
|
|
||||||
|
- **Research** (AFK): Reading documentation, third-party APIs, or local resources like knowledge bases to surface a fact a decision waits on. Resolved by a `/research` **subagent**. Use when knowledge outside the current working directory is required.
|
||||||
|
- **Prototype** (HITL): Raise the fidelity of the discussion by making a cheap, rough, concrete artifact to react to — an outline, a rough take, a stub, or UI/logic code via the /prototype skill. Links the prototype as an asset. Use when "how should it look" or "how should it behave" is the key question.
|
||||||
|
- **Grilling** (HITL): Conversation via the /grilling and /domain-modeling skills, one question at a time. The default case.
|
||||||
|
- **Task** (HITL or AFK): Manual work that must happen before a *decision* can be made — nothing to decide, prototype, or research, but the discussion is blocked until it's done. Signing up for a service so its API can be judged, provisioning access, moving data so its shape can be seen. This is the one type that *does* rather than decides — and it earns its place by unblocking a decision, not by delivering the destination. The agent drives it alone where it can (AFK); otherwise it hands the human a precise checklist (HITL). Resolved when the work is done; the answer records what was done and any resulting facts (credentials location, new URLs, row counts) later tickets depend on.
|
||||||
|
|
||||||
|
## Fog of war
|
||||||
|
|
||||||
|
The map is _deliberately_ incomplete: don't chart what you can't yet see. Beyond the live tickets lies the **fog of war** — the dim view of decisions and investigations you can tell are coming but can't yet pin down, because they hang on questions still open. Resolving a ticket clears the fog ahead of it, graduating whatever's now specifiable into fresh tickets — one at a time, until the way to the destination is clear and no tickets remain.
|
||||||
|
|
||||||
|
The map's **Not yet specified** section is where that dim view is written down: the suspected question, the area to revisit later. It's the undiscovered frontier _toward_ the destination — everything here is in scope, just not sharp enough to ticket. Write as loosely or as fully as the view allows; it doubles as a signpost for collaborators reading where the effort is headed.
|
||||||
|
|
||||||
|
**Fog or ticket?** The test is whether you can state the question precisely now — _not_ whether you can answer it now.
|
||||||
|
|
||||||
|
- **Ticket when** the question is already sharp — even if it's blocked and you can't act on it yet.
|
||||||
|
- **Not yet specified when** you can't yet phrase it that sharply. Don't pre-slice the fog into ticket-sized pieces: it's coarser than a ticket, and one patch may graduate into several tickets, or none, once the frontier reaches it.
|
||||||
|
|
||||||
|
**Not yet specified** excludes what's already decided (Decisions so far), what's already a live ticket, and what's out of scope (the next section).
|
||||||
|
|
||||||
|
## Out of scope
|
||||||
|
|
||||||
|
Fog only ever gathers _toward_ the destination. The destination fixes the scope, so work beyond it is **out of scope** — it isn't fog, and it doesn't belong in **Not yet specified**. It gets its own **Out of scope** section on the map: work you've consciously ruled out of _this_ effort. Scope, not sharpness, lands it here.
|
||||||
|
|
||||||
|
Out-of-scope work never graduates — the frontier stops at the destination — so it returns only if the destination is redrawn, and then as a fresh effort, not a resumption.
|
||||||
|
|
||||||
|
Ruling something out of scope is a scoping act, not a step on the route. When a ticket that already exists turns out to sit past the destination — mis-scoped in while charting, or exposed by a resolution — **close it** (a closed ticket is unambiguously off the frontier) and leave one line in the **Out of scope** section: the gist plus why it's out of scope, linking the closed ticket. It stays out of **Decisions so far**, which records the route actually walked — a scope boundary isn't a step on it.
|
||||||
|
|
||||||
|
## Invocation
|
||||||
|
|
||||||
|
Two modes. Either way, **never resolve more than one ticket per session** — with the exception of research tickets.
|
||||||
|
|
||||||
|
### Chart the map
|
||||||
|
|
||||||
|
User invokes with a loose idea.
|
||||||
|
|
||||||
|
1. **Name the destination.** Run a `/grilling` and `/domain-modeling` session to pin down what this map is finding its way to — the spec, decision, or change. The destination fixes the scope, so it's settled first.
|
||||||
|
2. **Map the frontier.** Grill again, **breadth-first** this time: fan out across the whole space rather than deep on any one thread, surfacing the open decisions and the first steps takeable now. **If this surfaces no fog** — the way to the destination is already clear, the whole journey small enough for one session — you don't need a map. Stop and ask the user how they'd like to proceed.
|
||||||
|
3. **Create the map** (label `wayfinder:map`): Destination and Notes filled in, Decisions-so-far empty, the fog sketched into **Not yet specified**.
|
||||||
|
4. **Create the tickets you can specify now** as child issues of the map — then wire blocking edges in a **second pass** (issues need ids before they can reference each other). Wiring sorts them into the frontier and the blocked; everything you can't yet specify stays in the fog — the **Not yet specified** section.
|
||||||
|
5. **Fire the research subagents.** For each `research` ticket you just created, spin up a `/research` subagent to resolve it in parallel, capturing its findings on a throwaway `research/<name>` branch with a context pointer from the ticket.
|
||||||
|
6. Stop — charting is one session's work; it hand-resolves nothing.
|
||||||
|
|
||||||
|
### Work through the map
|
||||||
|
|
||||||
|
User invokes with a map (URL or number). A ticket is **optional** — without one, you pick the next decision, not the user.
|
||||||
|
|
||||||
|
1. Load the **map** — the low-res view, not every ticket body.
|
||||||
|
2. Choose the ticket. If the user named one, use it. Otherwise take the first frontier ticket in order. **Claim it**: assign it to yourself before any work.
|
||||||
|
3. Resolve it — **zoom as needed**: fetch the full body of any related or closed ticket on demand; invoke the skills the `## Notes` block names. If in doubt, use `/grilling` and `/domain-modeling`.
|
||||||
|
4. Record the resolution: post the answer as a **resolution comment**, **close** the issue, and **append a context pointer** to the map's Decisions-so-far.
|
||||||
|
5. Add newly-surfaced tickets (create-then-wire); graduate any fog the answer has made specifiable, clearing each graduated patch from **Not yet specified** so it lives only as its new ticket. If the answer reveals a ticket — this one or another — sits beyond the destination, **rule it out of scope** rather than resolving it on the route. If the decision invalidates other parts of the map, update or delete those tickets.
|
||||||
|
|
||||||
|
The user may run unblocked tickets in parallel, so expect other sessions to be editing the tracker concurrently.
|
||||||
5
.agents/skills/wayfinder/agents/openai.yaml
Normal file
5
.agents/skills/wayfinder/agents/openai.yaml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
interface:
|
||||||
|
display_name: "Wayfinder"
|
||||||
|
short_description: "Map a large effort as decision tickets"
|
||||||
|
policy:
|
||||||
|
allow_implicit_invocation: false
|
||||||
201
.agents/skills/writing-great-skills/GLOSSARY.md
Normal file
201
.agents/skills/writing-great-skills/GLOSSARY.md
Normal file
@@ -0,0 +1,201 @@
|
|||||||
|
# Glossary — Building Great Skills
|
||||||
|
|
||||||
|
The domain model for what makes a skill great. A skill exists to wrangle determinism out of a stochastic system; the root virtue is **Predictability**, and every term below is a lever on it. This is the disclosed reference for [`writing-great-skills`](SKILL.md).
|
||||||
|
|
||||||
|
The terms are grouped by axis: **Invocation** (how a skill is reached), **Information Hierarchy** (how its content is arranged), **Steering** (how the agent's runtime behaviour is shaped), and **Pruning** (how it is kept lean). Each **failure mode** lives beside the lever that cures it, tagged _failure mode_.
|
||||||
|
|
||||||
|
**Bold terms** in any definition are themselves defined in this glossary; find them by their heading.
|
||||||
|
|
||||||
|
## Predictability
|
||||||
|
|
||||||
|
The degree to which a skill makes the agent behave the same _way_ on every run — the same process, not the same output (a brainstorming skill should _predictably_ diverge; its tokens vary, its behaviour doesn't). The root virtue every other term serves — cost and maintainability are symptoms of it, not rivals.
|
||||||
|
|
||||||
|
_Avoid_: consistency, reliability, robustness, output-determinism
|
||||||
|
|
||||||
|
## Invocation
|
||||||
|
|
||||||
|
How a skill is reached — and the two loads you pay for the choice.
|
||||||
|
|
||||||
|
### Model-Invoked
|
||||||
|
|
||||||
|
A skill that keeps its **description** field, so the agent can see it and fire it autonomously — and the human can still type its name, so model-invocation always _includes_ user reach. There is no model-only state: a description only ever _adds_ agent discovery, never removes the human's. Pays a permanent **context load** on every turn in exchange for that discoverability. Reachable by other skills, because the description that makes it agent-discoverable makes it invocable. A model-invoked skill whose content is all **reference** is also one home for shared reference: another skill can invoke it, so reference needed by several skills lives in one place. Pick model-invocation only when the agent must reach the skill on its own; if it never fires except by hand, drop the description and pay no context load.
|
||||||
|
|
||||||
|
_Avoid_: ability, tool, capability
|
||||||
|
|
||||||
|
### User-Invoked
|
||||||
|
|
||||||
|
A skill with its **description** stripped — invisible to the agent and reachable only by the human typing its name (user-_only_, where **model-invoked** is user-_and-agent_). Trades agent-discoverability for zero **context load**. Because it has no description, nothing but the human can reach it: no other skill can fire it.
|
||||||
|
|
||||||
|
_Avoid_: procedure, workflow, command
|
||||||
|
|
||||||
|
### Description
|
||||||
|
|
||||||
|
The skill's machine-readable trigger, and the one **context pointer** a **model-invoked** skill is forced to keep loaded at all times. Its mere presence _is_ the invocation axis: keep it and the skill is model-invoked (and reachable by other skills); delete it and the skill is **user-invoked**, reachable only by the human. The source of a model-invoked skill's **context load**.
|
||||||
|
|
||||||
|
_Avoid_: frontmatter, summary
|
||||||
|
|
||||||
|
### Context Pointer
|
||||||
|
|
||||||
|
A reference held in the agent's context that names some out-of-context material and encodes the condition for reaching it. The **description** is the top-level context pointer (context window → skill); pointers to disclosed files are the same object one level down. Its wording, not the target, decides _when_ the agent reaches — and _how reliably_. A must-have target behind a weakly worded pointer is a variance bug: fix the wording first, and inline the material only if sharpening fails.
|
||||||
|
|
||||||
|
_Avoid_: link, reference, import
|
||||||
|
|
||||||
|
### Context Load
|
||||||
|
|
||||||
|
The cost a **model-invoked** skill imposes on the agent's context window — its **description**, always loaded, spending both tokens and attention. What **user-invoked** skills escape by having no description, and the brake on splitting into more model-invoked skills.
|
||||||
|
|
||||||
|
_Avoid_: token cost, context bloat
|
||||||
|
|
||||||
|
### Cognitive Load
|
||||||
|
|
||||||
|
The cost a **user-invoked** skill imposes on the human — what they must hold in their head: which skills exist and when to reach for each (the human is the index). What **model-invocation** removes by being agent-discoverable, and the brake on splitting into more user-invoked skills. Not a cost to minimise: it is the price of human agency, the reason some skills stay user-invoked. Spend it where human judgement matters; remove it where it does not.
|
||||||
|
|
||||||
|
_Avoid_: human index, burden, overhead
|
||||||
|
|
||||||
|
### Router Skill
|
||||||
|
|
||||||
|
A **user-invoked** skill whose job is to point at your other user-invoked skills — naming each and when to reach for it — so the human has one skill to remember instead of many. It can only hint, never fire them: user-invoked skills have no **description**, so nothing but the human can reach them. The cure for **cognitive load** when user-invoked skills multiply.
|
||||||
|
|
||||||
|
_Avoid_: dispatcher, menu, registry, index, router procedure
|
||||||
|
|
||||||
|
### Granularity
|
||||||
|
|
||||||
|
How finely you divide skills. Finer division spends one of the two loads: more **model-invoked** skills spend **context load** (more descriptions crowding the window and competing for attention); more **user-invoked** skills spend **cognitive load** (more for the human to remember and reach for). Two cuts guide the division. By **invocation**, split off a model-invoked skill where you have a distinct **leading word** to trigger it — a trigger word you actually use in your prompts. By **sequence**, split a run of **steps** where a step's **post-completion steps** need hiding, since isolating it in its own context clears what follows. Beware the reverse: merging sequences exposes each step's post-completion steps to what follows, inviting premature completion.
|
||||||
|
|
||||||
|
_Avoid_: chunking, modularity
|
||||||
|
|
||||||
|
## Information Hierarchy
|
||||||
|
|
||||||
|
How a skill's content is arranged, and how far down the ladder each piece sits.
|
||||||
|
|
||||||
|
### Information Hierarchy
|
||||||
|
|
||||||
|
A skill's content ranked by how immediately the agent needs it — a single ladder, produced by two cuts: in-file or behind a pointer, and step or reference. The rungs:
|
||||||
|
|
||||||
|
- **Steps** — in-file, primary
|
||||||
|
- **Reference**, in-file — secondary
|
||||||
|
- **Reference**, disclosed — behind a **context pointer**
|
||||||
|
|
||||||
|
A skill with no **steps** uses just the bottom two rungs — often a legitimately flat peer-set (e.g. every rule of a review on one rung), which is a fine arrangement, not a smell. The hierarchy is independent of invocation: a skill can be model- or user-invoked whether it is all steps, all reference, or both. When a skill has steps, in-file reference that should be disclosed buries them and turns attending to them into a coin-flip — a variance lever, not just a legibility one. Keep the top of the ladder legible; push down it whatever you can.
|
||||||
|
|
||||||
|
_Avoid_: structure, organization, layout
|
||||||
|
|
||||||
|
### Steps
|
||||||
|
|
||||||
|
The ordered actions the agent performs — when a skill has them, the primary tier of its content, and the part that earns its place in SKILL.md. Not every skill has steps: a skill can be all steps (`tdd`), all **reference** (a review), or both, independent of invocation. Every step ends on a **completion criterion**, clear or vague.
|
||||||
|
|
||||||
|
_Avoid_: workflow, instructions, choreography
|
||||||
|
|
||||||
|
### Reference
|
||||||
|
|
||||||
|
Material the agent refers to on demand — definitions, facts, parameters, examples, conditional instructions. When a skill has **steps** it is secondary to them; when a skill has none it is the entire content; or it lives outside any skill entirely — see **External Reference**. Reached via **context pointers**, and the prime candidate for **progressive disclosure**.
|
||||||
|
|
||||||
|
_Avoid_: supporting material, docs, background
|
||||||
|
|
||||||
|
### External Reference
|
||||||
|
|
||||||
|
**Reference** that lives outside the skill system — a plain file, no **description**, no **steps**, not invocable — that any skill can point at. The home for shared reference that needn't fire on its own, and the only shared home two **user-invoked** skills can use, since neither has a description and so neither can fire the other.
|
||||||
|
|
||||||
|
_Avoid_: doc, resource, knowledge base
|
||||||
|
|
||||||
|
### Progressive Disclosure
|
||||||
|
|
||||||
|
Moving **reference** down the ladder — out of SKILL.md and behind a **context pointer** — so the top stays legible. Not primarily a token optimisation; it is how the **information hierarchy** is protected. Licensed by **branching**: disclose what only some branches need, inline what every path needs, and if a pointer fires unreliably on must-have material, sharpen its wording, and pull it back inline only if that fails.
|
||||||
|
|
||||||
|
_Avoid_: lazy loading, chunking
|
||||||
|
|
||||||
|
### Co-location
|
||||||
|
|
||||||
|
Keeping the material an agent needs at once in one place — a concept's definition, rules, and caveats under a single heading, not scattered across the file — so reading one part brings its neighbours with it. The within-file companion to the **Information Hierarchy**: the hierarchy ranks _how far down_ a piece sits; co-location decides _what sits beside it_ once there. There is no formula for the right format of a body of **reference**; the test is that a skill should read like documentation written for the agent, and grouped material reads that way where scattered material does not. Distinct from **Duplication**: that repeats one meaning in two places, where scattering fragments a single meaning across many.
|
||||||
|
|
||||||
|
_Avoid_: grouping, clustering, cohesion
|
||||||
|
|
||||||
|
### Sprawl
|
||||||
|
|
||||||
|
_Failure mode._ A skill that is simply too long — too many lines in SKILL.md — independent of whether they are stale or repeated. Even an all-live, all-unique skill can sprawl. It costs readability (the agent wades through more before it can act, and attention thins across the excess), maintainability (every extra line is one more to keep **relevant**), and tokens. The cure is the **information hierarchy**: push **reference** down behind **context pointers**, and split by **branch** or sequence so each path carries only what it needs. Distinct from **sediment** (length from stale accumulation) and **duplication** (length from repeated meaning) — sprawl is length itself, whatever its cause.
|
||||||
|
|
||||||
|
_Avoid_: bloat, length, size, verbosity
|
||||||
|
|
||||||
|
## Steering
|
||||||
|
|
||||||
|
The levers that shape the agent's runtime behaviour toward **Predictability**.
|
||||||
|
|
||||||
|
### Branch
|
||||||
|
|
||||||
|
A distinct way a skill can be invoked — a case the skill handles — so different runs take different paths through it. A skill with many steps may carry many branches; a linear one has none.
|
||||||
|
|
||||||
|
_Avoid_: path, case, fork
|
||||||
|
|
||||||
|
### Leading Word
|
||||||
|
|
||||||
|
A compact concept — also called a _Leitwort_ — already living in the model's pretraining, that the agent thinks with while running the skill. It encodes a behavioural principle in the fewest possible tokens by invoking priors the model already holds (e.g. _lesson_, _proximal zone of development_, _fog of war_, _tracer bullets_). Repeated as a token, never as a sentence, it accumulates a distributed definition across the skill and anchors a whole region of behaviour. Coining your own works if you define it clearly, but a made-up word recruits no priors — you pay in definition tokens what a pretrained word gives free. Reach for an existing word first.
|
||||||
|
|
||||||
|
A leading word serves **predictability** twice. In the body it anchors **execution** — the agent reaches for the same behaviour every time the concept appears, and inside flat reference it focuses attention on a class of thing to look for, recruiting the right checks each run. In the **description** it anchors **invocation** — and not only within the skill: when the same word lives in your prompts, your docs, and your codebase, the agent links that shared language to the skill and fires it more reliably. Word a description with the leading words you actually use when you want the skill.
|
||||||
|
|
||||||
|
_Avoid_: keyword, term, motif
|
||||||
|
|
||||||
|
### Completion Criterion
|
||||||
|
|
||||||
|
The condition that tells the agent a unit of work is done — the target it judges against. Two properties make it a lever, not just a quality. Its **clarity** (can the agent tell done from not-done?) resists **premature completion** — a vague bound ("understanding reached") lets the agent declare done and slip to the next step; this axis needs _steps_ to bite, since premature completion is a between-steps failure. Its **demand** (how much it requires) sets **legwork** — "every modified model accounted for" forces thorough work where "produce a change list" does not — and this axis is _not_ step-bound: it can bind a body of flat reference too, which is how a skill with no steps still carries an exhaustiveness bar ("every rule applied"). The strongest criteria are both checkable and exhaustive.
|
||||||
|
|
||||||
|
_Avoid_: done condition, exit condition, stopping rule
|
||||||
|
|
||||||
|
### Legwork
|
||||||
|
|
||||||
|
The work an agent does behind the scenes within a single step — reading files, exploring the codebase, making changes, digging up what it needs rather than offloading to the user. It lives below the step structure: never written as its own step, latent in the wording, controlled by the agent rather than the skill. The within-step counterpart to **post-completion steps**' across-step pull. Raised by a **leading word** (_comprehensive_, _thorough_) or a **completion criterion** that demands the work be exhaustive — including the demand axis applied to flat reference, which is what drives a skill of flat reference to cover all its rungs. Goes thin either when that demand is missing or when **premature completion** cuts the step short.
|
||||||
|
|
||||||
|
_Avoid_: scope, effort, diligence, coverage
|
||||||
|
|
||||||
|
### Post-Completion Steps
|
||||||
|
|
||||||
|
The **steps** that follow the current step. Visible, they pull the agent forward into **premature completion** — the more it sees, the stronger the tug; the defence is to hide them by splitting the sequence of steps into two.
|
||||||
|
|
||||||
|
_Avoid_: horizon, fog of war, lookahead
|
||||||
|
|
||||||
|
### Premature Completion
|
||||||
|
|
||||||
|
_Failure mode._ Ending the current step before it is genuinely done, because the agent's attention slips to being done rather than to the work. A between-steps failure: it needs **steps** to occur — a skill with no steps that quits early isn't premature completion but thin **legwork** under an unmet demand. A tug-of-war between two forces: visible **post-completion steps** (the pull forward) and the **completion criterion**'s clarity (the resistance — a sharp, checkable bar holds; a vague one gives way). Fuzziness is the necessary condition: a sharp bound resists the pull no matter how many later steps are visible, so a step that never rushes needs no defending. Two levers hold a step that does, but reach for them in order: **sharpen the bound first** — it is local and cheap. Only when the criterion is irreducibly fuzzy _and_ you actually observe the rush do you **hide the later steps** — and hiding only works across a real context boundary (a user-invoked hand-off or a subagent dispatch; an inline model-invoked call leaves the later steps in context and clears nothing). One cause of thin legwork, but distinct from it: legwork can be thin even when a step runs to full completion.
|
||||||
|
|
||||||
|
_Avoid_: premature closure, the rush, rushing, shortcutting
|
||||||
|
|
||||||
|
### Negation
|
||||||
|
|
||||||
|
_Failure mode._ Steering by prohibition — telling the agent what _not_ to do — which drags the forbidden behaviour into context and makes it _more_ available, not less. _Don't think of an elephant_, and the elephant is all there is; _never write verbose comments_, and verbosity is the pattern the agent has just read. The negation is a weak modifier the strongly-activated concept overruns, so the ban half-reads as an instruction to do the thing. Its **leading word** is the _elephant_: whatever a prohibition names into the frame. Cure: prompt the **positive** — describe the target behaviour ("write one-line comments") so the banned one is never spoken. A prohibition earns its place only as a hard guardrail on a behaviour you cannot phrase positively; even then, pair it with the positive target so attention lands on what to do.
|
||||||
|
|
||||||
|
_Avoid_: ironic rebound, don't-prompting, the pink elephant
|
||||||
|
|
||||||
|
## Pruning
|
||||||
|
|
||||||
|
Keeping a skill lean — each remedy paired with the failure it cures.
|
||||||
|
|
||||||
|
### Single Source of Truth
|
||||||
|
|
||||||
|
The desired state where each meaning lives in exactly one authoritative place, so a change to the skill's behaviour is a change in one place. **Duplication** is its violation.
|
||||||
|
|
||||||
|
_Avoid_: home, canonical location
|
||||||
|
|
||||||
|
### Duplication
|
||||||
|
|
||||||
|
_Failure mode._ The same meaning given more than one **single source of truth**. It costs maintenance (change one place, you must change the others), costs tokens, and inflates prominence — repeating a meaning weights it on the ladder past its real rank. The accidental inverse of a **leading word**, which raises attention on purpose by repeating a token, never the meaning.
|
||||||
|
|
||||||
|
_Avoid_: repetition, redundancy
|
||||||
|
|
||||||
|
### Relevance
|
||||||
|
|
||||||
|
Whether a line still bears on what the skill does — the lens for what to keep. A line loses relevance either by never bearing on the task (mere exposition, or a **branch** that should be disclosed) or by going stale: drifting out of date as the behaviour or world it describes changes. Shorter skills are easier to keep relevant, because each line is cheaper to check. Distinct from **no-op**: relevance asks whether a line bears on the task, not whether it changes behaviour.
|
||||||
|
|
||||||
|
_Avoid_: load-bearing, staleness, freshness
|
||||||
|
|
||||||
|
### Sediment
|
||||||
|
|
||||||
|
_Failure mode._ Layers of old content that settle in a skill and are never cleared, because adding feels safe and removing feels risky — so stale and irrelevant lines accumulate and you must core down through them to find what is still live. The default fate of any skill without a pruning discipline; the slow erosion of **relevance**, as opposed to **duplication**'s repeated meaning.
|
||||||
|
|
||||||
|
_Avoid_: accretion, bloat, cruft, rot
|
||||||
|
|
||||||
|
### No-Op
|
||||||
|
|
||||||
|
_Failure mode._ An instruction that changes nothing because the model already does it by default — you pay load to tell the agent what it would do anyway. The test: does a line change behaviour versus the default? A line can be perfectly **relevant** and still be a no-op. The same priors that make a **leading word** free make a no-op worthless.
|
||||||
|
|
||||||
|
A leading word is a _technique_; No-Op is a _verdict_ on a line — and they cross. A leading word too weak to beat the default is a no-op (_be thorough_ when the agent is already thorough-ish), and the fix is a stronger word that passes the verdict (_relentless_), not a different technique. So the No-Op test — does it change behaviour versus the default? — is also how you grade whether a leading word is earning its repetitions. This is model-relative, not reader-relative: two people disagreeing over whether a line is a no-op disagree about the default, and settle it by running the skill, not by debate.
|
||||||
|
|
||||||
|
_Avoid_: redundant instruction, restating the obvious, belaboring
|
||||||
83
.agents/skills/writing-great-skills/SKILL.md
Normal file
83
.agents/skills/writing-great-skills/SKILL.md
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
---
|
||||||
|
name: writing-great-skills
|
||||||
|
description: Reference for writing and editing skills well — the vocabulary and principles that make a skill predictable.
|
||||||
|
disable-model-invocation: true
|
||||||
|
---
|
||||||
|
|
||||||
|
A skill exists to wrangle determinism out of a stochastic system. **Predictability** — the agent taking the same _process_ every run, not producing the same output — is the root virtue; every lever below serves it.
|
||||||
|
|
||||||
|
**Bold terms** are defined in [`GLOSSARY.md`](GLOSSARY.md); look them up there for the full meaning.
|
||||||
|
|
||||||
|
## Invocation
|
||||||
|
|
||||||
|
Two choices, trading different costs:
|
||||||
|
|
||||||
|
- A **model-invoked** skill keeps a **description**, so the agent can fire it autonomously _and_ other skills can reach it (you can still type its name too). It contributes to **context load** — the description sits in the window every turn. Mechanics: omit `disable-model-invocation`, and write a model-facing description with rich trigger phrasing ("Use when the user wants…, mentions…").
|
||||||
|
- A **user-invoked** skill strips the description from the agent's reach: only you, typing its name, can invoke it — and no other skill can. Zero context load, but it spends **cognitive load**: _you_ are the index that must remember it exists. Mechanics: set `disable-model-invocation: true`; the `description` becomes human-facing — a one-line summary, trigger lists stripped.
|
||||||
|
|
||||||
|
Pick model-invocation only when the agent must reach the skill on its own, or another skill must. If it only ever fires by hand, make it user-invoked and pay no context load.
|
||||||
|
|
||||||
|
When user-invoked skills multiply past what you can remember, that piled-up cognitive load is cured by a **router skill**: one user-invoked skill that names the others and when to reach for each.
|
||||||
|
|
||||||
|
## Writing the description
|
||||||
|
|
||||||
|
A model-invoked **description** does two jobs — state what the skill is, and list the **branches** that should trigger it. Every word increases **context load**, so a description earns even harder pruning than the body:
|
||||||
|
|
||||||
|
- **Front-load the skill's leading word** — the description is where it does its invocation work.
|
||||||
|
- **One trigger per branch.** Synonyms that rename a single branch are **duplication** — "build features using TDD … asks for test-first development" is one branch written twice. Collapse them; keep only genuinely distinct branches.
|
||||||
|
- **Cut identity that's already in the body.** Keep the description to triggers, plus any "when another skill needs…" reach clause.
|
||||||
|
|
||||||
|
## Information hierarchy
|
||||||
|
|
||||||
|
A skill is built from two content types — **steps** and **reference** — that mix freely: a skill can be all steps, all reference, or both. The core decision is which to use and where each sits on the **information hierarchy**, a ladder ranked by how immediately the agent needs the material:
|
||||||
|
|
||||||
|
1. **In-skill step** — an ordered action in `SKILL.md`, the primary tier: what the agent does, in order. Each step ends on a **completion criterion**, the condition that tells the agent the work is done. Make it _checkable_ (can the agent tell done from not-done?) and, where it matters, _exhaustive_ ("every modified model accounted for", not "produce a change list") — a vague criterion invites **premature completion**.
|
||||||
|
2. **In-skill reference** — a definition, rule, or fact in `SKILL.md`, consulted on demand. Often a legitimately flat peer-set (every rule of a review on one rung) — a fine arrangement, not a smell. _This skill is all reference._
|
||||||
|
3. **External reference** — reference pushed out of `SKILL.md` into a separate file, reached by a **context pointer**, loaded only when the pointer fires. (Spans _disclosed_ reference — a sibling file like `GLOSSARY.md`, still part of the skill — through fully **external reference** that lives outside the skill system and any skill can point at.)
|
||||||
|
|
||||||
|
A demanding completion criterion drives thorough **legwork** — the digging the agent does within the work — whether the skill has steps or not, since "every rule applied" binds flat reference just as "every step done" binds a sequence.
|
||||||
|
|
||||||
|
Push too little down and the top bloats; push too much and you hide material the agent actually needs. That tension is the whole decision.
|
||||||
|
|
||||||
|
**Progressive disclosure** is the move down the ladder — out of `SKILL.md` into a linked file — so the top stays legible. Mechanics: a linked `.md` file in the skill folder, named for what it holds (this skill discloses its full definitions to `GLOSSARY.md`). Some skills are used in more than one way, and each distinct way is a **branch** — different runs taking different paths through the skill. Branching is the cleanest disclosure test: inline what every branch needs, and push behind a pointer what only some branches reach. A **context pointer**'s _wording_, not its target, decides when and how reliably the agent reaches the material.
|
||||||
|
|
||||||
|
Where the ladder decides _how far down_ a piece sits, **co-location** decides _what sits beside it_ once there: keep a concept's definition, rules, and caveats under one heading rather than scattered, so reading one part brings its neighbours with it.
|
||||||
|
|
||||||
|
## When to split
|
||||||
|
|
||||||
|
**Granularity** is how finely you divide skills, and each cut spends one of the two loads, so split only when the cut earns it. Two cuts:
|
||||||
|
|
||||||
|
- **By invocation** — split off a **model-invoked** skill when you have a distinct **leading word** that should trigger it on its own, or another skill must reach it. You pay **context load** for the new always-loaded **description**, so that independent reach has to be worth it.
|
||||||
|
- **By sequence** — split a run of **steps** when the steps still ahead (a step's **post-completion steps**) tempt the agent to rush the one in front of it (**premature completion**). Keeping them out of view encourages the agent to do more **legwork** on the current task.
|
||||||
|
|
||||||
|
## Pruning
|
||||||
|
|
||||||
|
Keep each meaning in a **single source of truth**: one authoritative place, so changing the behaviour is a one-place edit.
|
||||||
|
|
||||||
|
Check every line for **relevance**: does it still bear on what the skill does?
|
||||||
|
|
||||||
|
Then hunt **no-ops** sentence by sentence, not just line by line: run the no-op test on each sentence in isolation, and when one fails, delete the whole sentence rather than trim words from it. Be aggressive — most prose that fails should go, not be rewritten.
|
||||||
|
|
||||||
|
## Leading words
|
||||||
|
|
||||||
|
A **leading word** is a compact concept already living in the model's pretraining that the agent thinks with while running the skill (e.g. _lesson_, _fog of war_, _tracer bullets_). Repeated throughout the text (though not necessarily - a strong leading word might only be needed once), it accumulates a distributed definition and anchors a whole region of behaviour in the fewest tokens, by recruiting priors the model already holds.
|
||||||
|
|
||||||
|
It serves predictability twice. In the body it anchors _execution_: the agent reaches for the same behaviour every time the word appears. In the description it anchors _invocation_: when the same word lives in your prompts, docs, and code, the agent links that shared language to the skill and fires it more reliably.
|
||||||
|
|
||||||
|
Hunt for opportunities to refactor skills to use leading words. A triad spelled out at three sites (**duplication**), a description spending a sentence to gesture at one idea — each is a passage begging to **collapse** into a single token. Examples include:
|
||||||
|
|
||||||
|
- "fast, deterministic, low-overhead" -> _tight_ — one quality restated across a phase — into a single pretrained word (a _tight_ loop).
|
||||||
|
- "a loop you believe in" -> _red_ — converts a fuzzy gate into a binary observable state (the loop goes _red_ on the bug, or it doesn't).
|
||||||
|
|
||||||
|
You win twice over: fewer tokens, _and_ a sharper hook for the agent to hang its thinking on. Assume every skill is carrying restatements that leading words retire — go find them.
|
||||||
|
|
||||||
|
## Failure modes
|
||||||
|
|
||||||
|
Use these to diagnose issues the user may be having with the skill.
|
||||||
|
|
||||||
|
- **Premature completion** — ending a step before it's genuinely done, attention slipping to _being done_. Defence, in order: sharpen the completion criterion first (cheap, local); only if it is irreducibly fuzzy _and_ you observe the rush, hide the post-completion steps by splitting (the sequence cut).
|
||||||
|
- **Duplication** — the same meaning in more than one place. Costs maintenance and tokens, and inflates a meaning's prominence on the ladder past its real rank.
|
||||||
|
- **Sediment** — stale layers that settle because adding feels safe and removing feels risky. The default fate of any skill without a pruning discipline.
|
||||||
|
- **Sprawl** — a skill simply too long, even when every line is live and unique. Hurts readability and maintainability and wastes tokens. The cure is the ladder: disclose **reference** behind pointers, and split by **branch** or sequence so each path carries only what it needs.
|
||||||
|
- **No-op** — a line the model already obeys by default, so you pay load to say nothing. The test: does it change behaviour versus the default? A weak leading word (_be thorough_ when the agent is already thorough-ish) is a no-op; the fix is a stronger word (_relentless_), not a different technique.
|
||||||
|
- **Negation** — steering by prohibition backfires: _don't think of an elephant_ names the elephant and makes it more available, not less. Prompt the **positive** — state the target behaviour so the banned one is never spoken; keep a prohibition only as a hard guardrail you can't phrase positively, and even then pair it with what to do instead.
|
||||||
5
.agents/skills/writing-great-skills/agents/openai.yaml
Normal file
5
.agents/skills/writing-great-skills/agents/openai.yaml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
interface:
|
||||||
|
display_name: "Writing Great Skills"
|
||||||
|
short_description: "Principles for predictable skills"
|
||||||
|
policy:
|
||||||
|
allow_implicit_invocation: false
|
||||||
1
.claude/skills/ask-matt
Symbolic link
1
.claude/skills/ask-matt
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../../.agents/skills/ask-matt
|
||||||
1
.claude/skills/code-review
Symbolic link
1
.claude/skills/code-review
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../../.agents/skills/code-review
|
||||||
1
.claude/skills/codebase-design
Symbolic link
1
.claude/skills/codebase-design
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../../.agents/skills/codebase-design
|
||||||
1
.claude/skills/diagnosing-bugs
Symbolic link
1
.claude/skills/diagnosing-bugs
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../../.agents/skills/diagnosing-bugs
|
||||||
1
.claude/skills/domain-modeling
Symbolic link
1
.claude/skills/domain-modeling
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../../.agents/skills/domain-modeling
|
||||||
1
.claude/skills/grilling
Symbolic link
1
.claude/skills/grilling
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../../.agents/skills/grilling
|
||||||
1
.claude/skills/implement
Symbolic link
1
.claude/skills/implement
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../../.agents/skills/implement
|
||||||
1
.claude/skills/research
Symbolic link
1
.claude/skills/research
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../../.agents/skills/research
|
||||||
1
.claude/skills/resolving-merge-conflicts
Symbolic link
1
.claude/skills/resolving-merge-conflicts
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../../.agents/skills/resolving-merge-conflicts
|
||||||
1
.claude/skills/to-spec
Symbolic link
1
.claude/skills/to-spec
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../../.agents/skills/to-spec
|
||||||
1
.claude/skills/to-tickets
Symbolic link
1
.claude/skills/to-tickets
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../../.agents/skills/to-tickets
|
||||||
1
.claude/skills/wayfinder
Symbolic link
1
.claude/skills/wayfinder
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../../.agents/skills/wayfinder
|
||||||
1
.claude/skills/writing-great-skills
Symbolic link
1
.claude/skills/writing-great-skills
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../../.agents/skills/writing-great-skills
|
||||||
@@ -24,7 +24,7 @@ export JUNHONG_DATABASE_SSLMODE="disable"
|
|||||||
export JUNHONG_REDIS_ADDRESS="cxd.whcxd.cn"
|
export JUNHONG_REDIS_ADDRESS="cxd.whcxd.cn"
|
||||||
export JUNHONG_REDIS_PORT="16299"
|
export JUNHONG_REDIS_PORT="16299"
|
||||||
export JUNHONG_REDIS_PASSWORD="cpNbWtAaqgo1YJmbMp3h"
|
export JUNHONG_REDIS_PASSWORD="cpNbWtAaqgo1YJmbMp3h"
|
||||||
export JUNHONG_REDIS_DB="6"
|
export JUNHONG_REDIS_DB="7"
|
||||||
|
|
||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
# JWT 配置(必填)
|
# JWT 配置(必填)
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ name: 构建并部署到测试环境(无 SSH)
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- Iteration/7-11
|
||||||
- dev
|
- dev
|
||||||
- test
|
- test
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ jobs:
|
|||||||
- name: 设置镜像标签
|
- name: 设置镜像标签
|
||||||
id: tag
|
id: tag
|
||||||
run: |
|
run: |
|
||||||
if [ "${{ github.ref }}" = "refs/heads/main" ]; then
|
if [ "${{ github.ref }}" = "refs/heads/Iteration/7-11" ]; then
|
||||||
echo "tag=latest" >> $GITHUB_OUTPUT
|
echo "tag=latest" >> $GITHUB_OUTPUT
|
||||||
elif [ "${{ github.ref }}" = "refs/heads/dev" ]; then
|
elif [ "${{ github.ref }}" = "refs/heads/dev" ]; then
|
||||||
echo "tag=dev" >> $GITHUB_OUTPUT
|
echo "tag=dev" >> $GITHUB_OUTPUT
|
||||||
@@ -61,8 +61,8 @@ jobs:
|
|||||||
docker push ${{ env.WORKER_IMAGE }}:${{ steps.tag.outputs.tag }}
|
docker push ${{ env.WORKER_IMAGE }}:${{ steps.tag.outputs.tag }}
|
||||||
docker push ${{ env.WORKER_IMAGE }}:${{ github.sha }}
|
docker push ${{ env.WORKER_IMAGE }}:${{ github.sha }}
|
||||||
|
|
||||||
- name: 部署到本地(仅 main 分支)
|
- name: 部署到本地(仅 Iteration/7-11 分支)
|
||||||
if: github.ref == 'refs/heads/main'
|
if: github.ref == 'refs/heads/Iteration/7-11'
|
||||||
run: |
|
run: |
|
||||||
# 确保部署目录存在(仅需日志目录,配置已嵌入二进制文件)
|
# 确保部署目录存在(仅需日志目录,配置已嵌入二进制文件)
|
||||||
mkdir -p ${{ env.DEPLOY_DIR }}/logs
|
mkdir -p ${{ env.DEPLOY_DIR }}/logs
|
||||||
|
|||||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -107,3 +107,6 @@ docs/admin-openapi.yaml
|
|||||||
|
|
||||||
# /teach skill 的个人学习工作区,不进入项目提交历史
|
# /teach skill 的个人学习工作区,不进入项目提交历史
|
||||||
.claude/teach-workspace/
|
.claude/teach-workspace/
|
||||||
|
scripts/batch_package_purchase/assets.example_购买结果_20260715_115804.csv
|
||||||
|
scripts/batch_package_purchase/assets.example_购买结果_20260715_115814.csv
|
||||||
|
scripts/migration/output
|
||||||
|
|||||||
159
.scratch/tech-global-audit/PRD.md
Normal file
159
.scratch/tech-global-audit/PRD.md
Normal file
@@ -0,0 +1,159 @@
|
|||||||
|
# PRD:TECH 全局多视角审计与外部集成追踪
|
||||||
|
|
||||||
|
Status: ready-for-agent
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Problem Statement
|
||||||
|
|
||||||
|
当前系统只有账号操作日志、资产操作日志和手动轮询日志等局部实现。它们的操作者、资源、结果和查询结构不一致,账号与资产审计使用裸 goroutine 写入,进程退出或数据库短暂失败时会丢失;资金、审批、配置和跨模块业务又缺少统一审计。现有记录无法从一次请求、一个业务链路或多个受影响资源串联完整过程。
|
||||||
|
|
||||||
|
Gateway、运营商、企业微信和支付等外部交互也没有通用 Integration Log。七月迭代的状态同步、审批和资金处理如果继续各建日志,将无法解释“为什么没有请求上游”“哪次回调改变了业务状态”以及“某次资金变化对应哪个审批”。
|
||||||
|
|
||||||
|
Access Log 当前只递归脱敏请求体,响应体仍原样记录,登录 Token、个人数据和敏感配置存在泄漏风险;回调和文件路由也缺少专门的正文记录策略。
|
||||||
|
|
||||||
|
## Solution
|
||||||
|
|
||||||
|
一次停机发布切换到四类边界清晰的记录:Access Log 负责 HTTP 调试,Audit Event 负责不可变业务审计,现有钱包流水/订单/退款等 Domain Ledger 继续作为领域事实,Integration Log 负责外部交互和未实际发出的同步尝试。Audit Event 通过资源关系表关联一个操作涉及的多个资源,并用 `request_id/correlation_id/parent_event_id` 串联请求和跨任务业务链路。
|
||||||
|
|
||||||
|
本次切换覆盖全部现有敏感写操作:新旧业务统一使用 Audit Writer,旧账号、资产和手动轮询审计表停止新增,不双写;历史数据保留原表并通过 Query 只读投影到新审计中心。切换准备或验证失败则本次版本整体不放量,不能以局部模块继续写旧表作为中间态。
|
||||||
|
|
||||||
|
## User Stories
|
||||||
|
|
||||||
|
1. 作为审计人员,我希望回答谁在什么入口对哪些资源做了什么,结果、风险和前后变化是什么。
|
||||||
|
2. 作为运维人员,我希望按 `request_id` 或 `correlation_id` 查看一次请求或完整业务链路中的审计、任务、外部交互和领域流水。
|
||||||
|
3. 作为资产运营人员,我希望从卡、设备、退款、订单、钱包等资源查看跨模块时间线,而不被普通无变化轮询淹没。
|
||||||
|
4. 作为财务人员,我希望资金审计能关联审批、业务单、钱包流水和资产处理,同时明确钱包流水才是金额事实。
|
||||||
|
5. 作为安全人员,我希望集中查看失败、拒绝、高风险和严重事件,并确保敏感字段默认脱敏。
|
||||||
|
6. 作为集成运维人员,我希望看到 Gateway、运营商、企微和支付的脱敏请求结果,以及合并、限流、提前完成等未发请求原因。
|
||||||
|
7. 作为历史数据查询者,我希望旧账号、资产和手动轮询记录仍可只读检索,但发布后不再出现新旧两份不一致记录。
|
||||||
|
8. 作为普通代理或企业用户,我希望只能在原业务详情看到自己有权限资源的脱敏轨迹,不能进入平台全局审计中心。
|
||||||
|
|
||||||
|
## Implementation Decisions
|
||||||
|
|
||||||
|
### 四类记录的权威边界
|
||||||
|
|
||||||
|
- Access Log 存储在现有日志文件/日志平台,只用于 HTTP 调试、性能和 `request_id` 检索,不作为业务事实或业务审计权威。
|
||||||
|
- Audit Event 存储在 PostgreSQL,回答操作者、动作、资源、结果、风险和字段变化。事件创建后不可更新或删除;普通读操作不创建 Audit Event,敏感读取例外。
|
||||||
|
- Domain Ledger 继续由钱包流水、订单、退款、充值、企微审批实例、套餐使用记录等业务表承担。审计 Query 可以链接或投影这些记录,但 Audit Event 不替代领域事实。
|
||||||
|
- Integration Log 存储 Gateway、运营商回调、企微、微信/支付宝及其他外部交互,也记录业务同步尝试在发请求前被 `merged/rate_limited/completed/cancelled` 的解释结果。
|
||||||
|
- 普通高频轮询成功且状态未变化只写 Integration Log;状态变化、人工强制触发、连续失败或高风险异常再写 Audit Event。
|
||||||
|
- Outbox 和通用异步任务状态是可靠投递/执行事实,不塞入 Audit Event JSON。审计链路 Query 通过稳定 ID 关联它们。
|
||||||
|
|
||||||
|
### Audit Event 数据模型
|
||||||
|
|
||||||
|
- 新建 `tb_audit_event`,核心字段包括:不可变唯一 `event_id`、`occurred_at`、类别、动作编码/名称、操作者快照、入口来源、租户/店铺/企业标签、结果、风险、摘要、错误码/摘要、前后数据、元数据、请求/关联/父事件 ID、IP/User-Agent/路径/方法、`content_hash` 和创建时间。
|
||||||
|
- `result` 为 string 类型:`success/failed/denied/partial`;`risk_level` 为 string:`normal/warning/high/critical`。操作者、来源、类别和动作均使用集中常量或注册表,不允许各 Service 自由拼接 magic string。
|
||||||
|
- `actor_kind` 至少支持 `admin_user/agent_user/enterprise_user/personal_customer/open_api_account/system_task/carrier_callback/wecom_callback`。系统和回调允许 `actor_id=NULL`,但 `actor_name` 必须是可读快照。
|
||||||
|
- `source` 表示入口而不是人员,至少支持 `admin_api/personal_api/open_api/asynq/scheduled_job/gateway/carrier_callback.* /wecom_callback/wecom_polling/data_migration`。
|
||||||
|
- 新建 `tb_audit_event_resource`,每个事件可关联多个 `primary/affected/reference` 资源;字段为事件内部 ID、资源类型、可空资源 ID、资源键快照、关系和创建时间。一个事件至少有一个 `primary` 资源。
|
||||||
|
- 资源关系使用复合唯一索引,资源 ID 和资源键各有时间线索引;不建立数据库外键或 GORM 关联标签。
|
||||||
|
- `content_hash` 基于脱敏、标准化后的不可变事件内容生成,用于完整性核对,不包含数据库自增 ID。Repository 不提供 Update/Delete 方法。
|
||||||
|
- `before_data`、`after_data`、`metadata` 分别最多 16KB;超限时保存截断标志、原字节数、摘要和受控任务/制品引用,批量明细留在对应业务任务表或对象存储。
|
||||||
|
|
||||||
|
### 动作注册表与写入可靠性
|
||||||
|
|
||||||
|
- 建立 Action Registry,定义稳定动作编码、中文名称、类别、默认风险、允许的资源类型和敏感字段规则;DTO 枚举说明、筛选项和前端名称都从同一注册表生成。
|
||||||
|
- 至少覆盖账号/角色/权限、店铺、资产、套餐、钱包/资金、订单/退款/充值、企微、支付与系统配置、数据同步、导入导出及登录安全的本期动作。未经注册的动作不得写入生产审计。
|
||||||
|
- 钱包余额、人工退款结果、代理钱包回退、线下充值入账、账号角色/权限、支付/企微/关键系统配置、人工卡状态、敏感店铺业务员归属及手工绑定企微审批号等成功事件必须与业务变更同事务 `AppendWithTx`;审计失败则业务事务回滚。
|
||||||
|
- 旧 MVC Service 未迁移为 DDD 时通过统一 Audit Writer Adapter 接入新模型,不要求为审计一次性重构全部业务;但当前触碰的复杂资金、审批和卡状态用例仍按各自 Spec 迁入 Application/Domain。
|
||||||
|
- 业务已经回滚的 `failed/denied` 事件使用独立短事务写入,禁止裸 goroutine。该审计再失败时保留原业务错误,同时写 `critical` 应用日志和监控指标。
|
||||||
|
- 异步系统事件与状态变化通过原业务事务或 Outbox 可靠关联,不使用 `go func()`。Asynq/Outbox 载荷必须传递 `event_id/request_id/correlation_id/parent_event_id`。
|
||||||
|
- `request_id` 由现有中间件生成并贯穿同一 HTTP 请求;`correlation_id` 在退款、充值、审批、钱包、卡状态等跨请求业务起点生成并贯穿 Outbox/Asynq/Integration Log;`parent_event_id` 表示直接因果,不用于替代 correlation。
|
||||||
|
- 对全部旧审计调用建立切换清单和自动检查。发布产物中禁止继续调用旧 `account_audit/asset_audit` 写服务或直接 Create 旧日志模型;启动装配不再注入旧 Writer。
|
||||||
|
|
||||||
|
### Integration Log
|
||||||
|
|
||||||
|
- 新建 `tb_integration_log`,至少保存唯一 `integration_id`、provider、方向、operation、外部单号、资源、触发来源/场景/序列/尝试、计划/开始时间、结果、HTTP/渠道码及摘要、脱敏请求响应摘要、耗时、是否改变状态、元数据、请求/关联 ID、可空 Audit Event ID 和创建时间。
|
||||||
|
- `direction` 为 `inbound/outbound`。`result` 至少支持 `success/failed/not_found/invalid_payload/ignored/merged/rate_limited/completed/cancelled`;实施可增加内部 `pending` 执行态,但公开 DTO 必须返回中文结果名称并保持终态语义明确。
|
||||||
|
- 一次外部尝试使用稳定 `integration_id`。实际调用前先持久化可恢复的尝试事实,完成后条件更新终态;若发出请求后响应未知,必须记录“结果未知”,不得伪装为普通失败并盲目重发具有副作用的外部请求。
|
||||||
|
- 数据同步按 UR#94 记录 `trigger_source/scene/series/attempt`;同序列详情一次返回 0/3/5 全部尝试。合并、互斥、限频和已达预期即使没有 HTTP 状态也必须可解释。
|
||||||
|
- 运营商/支付/企微入站回调先保存脱敏摘要和幂等标识,再进入业务处理;原始加密报文、完整回调正文、签名和附件不进入普通审计详情。
|
||||||
|
- Integration Log 只保存外部交互事实,不存业务审批/支付/卡状态的权威状态;业务改变时通过 `audit_event_id/correlation_id` 关联。
|
||||||
|
|
||||||
|
### 脱敏与 Access Log 修正
|
||||||
|
|
||||||
|
- 永不进入 Audit/Integration/Access 正文的数据包括密码、操作密码、验证码、Access/Refresh Token、Secret、回调 Token/EncodingAESKey、支付私钥/公钥原文、完整身份证、对象存储签名 URL、企微 `media_id` 和 Authorization/Cookie。Sanitizer 直接删除或只保留字段存在/长度,不把原值保存成可逆掩码。
|
||||||
|
- 手机号、IP、ICCID、钱包金额和第三方交易号允许在受控审计存储中作为业务快照,但普通 Query 默认脱敏;完整查看需要 `audit:sensitive:view`,导出需要独立 `audit:export` 和字段授权。
|
||||||
|
- 查看完整敏感值本身写高风险 Audit Event,携带被查看事件/资源和操作者;不能因为已有全局查看权限跳过二次审计。
|
||||||
|
- Access Log 的响应体必须和请求体使用同一递归 Sanitizer,再执行 50KB 限制;当前 `truncateBody(c.Response().Body())` 原样记录行为必须移除。
|
||||||
|
- 路由级策略:登录/Token/支付或企微配置只记字段名和长度;支付、企微、运营商回调只记摘要与哈希;文件上传下载不记文件内容和签名 URL;普通 JSON 脱敏后最多 50KB。
|
||||||
|
- 非 JSON 解析失败不能直接原样记录敏感回调或文件;应先应用路由策略和安全文本截断。Query 参数和 Header 同样覆盖 token、secret、sign、nonce、authorization、cookie 等字段。
|
||||||
|
|
||||||
|
### 一次性切换与历史投影
|
||||||
|
|
||||||
|
- 本需求是经用户确认的全局例外:在同一次停机发布中完成新表/索引、Audit Writer、Integration Writer、现有敏感写入口、Query API 和必要前端切换。不得按模块长期双轨运行。
|
||||||
|
- 旧 `tb_account_operation_log`、`tb_asset_operation_log` 和 `tb_polling_manual_trigger_log` 发布后停止新写入,不删除、不回填新表。数据库权限或运行时写入护栏应使意外旧写尽快暴露,不能静默继续。
|
||||||
|
- 旧手动轮询日志当前还承担进度状态。切换时其用户可见的手动触发、进度和监控接口保持原契约,但运行状态由七月公共异步任务状态承接,外部尝试由 Integration Log 承接;不得因停写旧表使运维功能消失。
|
||||||
|
- 历史 Query 使用 `UNION ALL` 把旧账号、资产和手动轮询记录规范化为只读投影,返回 `record_source=legacy_account/legacy_asset/legacy_polling` 和确定性历史事件键;旧记录不伪造不存在的 correlation、风险或多资源关系。
|
||||||
|
- 现有 `GET /api/admin/assets/{identifier}/operation-logs` 在过渡期保留兼容响应,但读取新 Audit Event 与旧资产投影,不再直接绑定旧表;新前端以全局资源时间线为准。
|
||||||
|
- 发布门禁要求旧写入口清单为零、新旧 Query 样本对账通过、关键事务审计失败回滚通过、Access Log 脱敏通过。任一失败则在开放流量前整体停止发布。
|
||||||
|
- 数据迁移全部为增量且可回滚。新系统一旦接收生产写入,已生成 Audit/Integration/Outbox 记录不得删除回滚;应用采用前向修复,不能回到旧 Writer 形成新的分裂历史。
|
||||||
|
|
||||||
|
### 查询 API 与权限
|
||||||
|
|
||||||
|
- 全局审计中心提供:
|
||||||
|
- `GET /api/admin/audit/events` 及 `/{event_id}`
|
||||||
|
- `GET /api/admin/audit/actors`、`/{kind}/{id}/summary`、`/{kind}/{id}/events`
|
||||||
|
- `GET /api/admin/audit/resources/search`、`/{type}/{id}/timeline`
|
||||||
|
- `GET /api/admin/audit/requests/{request_id}/timeline`
|
||||||
|
- `GET /api/admin/audit/correlations/{correlation_id}/timeline`
|
||||||
|
- `GET /api/admin/audit/risks/overview`、`/events`
|
||||||
|
- `GET /api/admin/audit/integrations` 及 `/{id}`
|
||||||
|
- `GET /api/admin/audit/finance/timeline`
|
||||||
|
- `POST /api/admin/audit/exports`
|
||||||
|
- 所有列表服务端分页,默认 20、最大 100,稳定时间+ID排序。公共关键词只匹配已有索引支持的摘要、资源键、操作者和请求 ID,不对 JSONB 做无索引模糊扫描。
|
||||||
|
- 资源搜索先查询业务读模型返回候选 `resource_type/id/key/display_name`,再打开时间线;静态 `/resources/search` 必须先于动态资源路由。`include_related=true` 只展开事件已直接关联资源,不递归遍历图。
|
||||||
|
- Request Timeline 组合数据库中可关联的 Audit Event、Outbox/任务摘要和 Integration Log;Access Log 仍在文件/日志平台,API 只返回事件内已快照的 HTTP 摘要和 `request_id` 日志检索标识,不在请求时扫描本地日志文件。
|
||||||
|
- Finance Timeline 组合 Audit Event 与钱包流水、订单、退款、充值和企微实例,每条明确 `record_source`;金额结论以 Domain Ledger 为准。
|
||||||
|
- 权限码至少拆分 `audit:global:view/actor:view/resource:view/request:view/risk:view/integration:view/finance:view/sensitive:view/export`。超级管理员拥有全量;普通平台角色按授权和原数据范围取交集。
|
||||||
|
- 代理和企业账号不能进入全局、人员、风险、资金全局或外部集成中心;在业务详情查看资源轨迹时,Query 必须重新执行店铺/企业权限和字段脱敏。前端隐藏 Tab 不是授权边界。
|
||||||
|
- 审计导出复用统一 Export DataSource,创建时快照过滤条件、数据范围、字段授权和脱敏级别;敏感查看权限不自动授予敏感导出权限,权限解析失败时拒绝而非回退全字段。
|
||||||
|
|
||||||
|
### 前端审计中心
|
||||||
|
|
||||||
|
- `/operations/audit` 使用工作台式 Tab:全局事件、人员行为、资源轨迹、请求/业务链路、资金审计、风险事件、外部集成;Tab 和字段以后端权限为准。
|
||||||
|
- 全局事件表展示时间、风险、操作者、操作、主要资源、来源、结果和 request ID;行详情抽屉分为事件摘要、操作者/入口、关联资源、结构化字段差异、请求/业务链路和错误/外部交互。
|
||||||
|
- 资源轨迹先搜索候选再选择,普通无变化轮询不进入业务时间线;外部集成 Tab 可按 provider、operation、方向、结果、资源、触发来源/场景/序列筛选,并连续展示 0/3/5 尝试。
|
||||||
|
- 人员、风险、请求和业务链路使用服务端汇总/时间线,不由前端下载全量事件再聚合。第一版不做自动封禁、风险处置工单或自由拖拽关系图。
|
||||||
|
- 敏感字段默认掩码;有权限用户点击“显示敏感数据”后重新请求受控接口并产生敏感读取审计。无权限、历史字段不存在和数据已按策略删除均使用明确但不泄密的状态。
|
||||||
|
|
||||||
|
### 保留、清理与可观测性
|
||||||
|
|
||||||
|
- 资金、权限、审批和关键配置 Audit Event 保留 5 年;普通资产/业务 Audit Event 保留 2 年;Audit Event 默认不由在线应用删除。
|
||||||
|
- Integration Log 默认 180 天;Gateway 无变化成功记录 30 天,异常或状态变化记录 180 天;Access Log 保留 30 天。清理按时间/主键分批执行并记录结果。
|
||||||
|
- 达到单表维护阈值后按月分区并归档超期分区,本期不为尚未达到阈值预建复杂分区管理,但表和 Query 必须支持后续演进。
|
||||||
|
- 应用运行账号不提供 Audit Event Update/Delete 能力;归档/清理由独立受控维护身份执行。Integration Log 只允许执行态到终态的受控条件更新,不允许事后改写请求结果。
|
||||||
|
- 监控 Audit/Integration 写入失败、失败短事务失败、旧表意外新增、Outbox 积压、Integration Log 增长/清理、敏感读取和导出次数。
|
||||||
|
|
||||||
|
## Testing Decisions
|
||||||
|
|
||||||
|
- 领域/Application 测试覆盖事件不可变、多资源至少一个 primary、动作注册、风险默认值、内容哈希稳定、16KB 截断和禁止字段删除。
|
||||||
|
- PostgreSQL 集成测试验证唯一/查询索引、关键业务与 Audit Event 同事务、审计写入失败回滚、失败/拒绝短事务、重复事件幂等和资源时间线。
|
||||||
|
- 对账号、角色权限、资产、套餐、钱包、退款、充值、配置、导入导出、登录安全和手动同步建立切换清单;自动测试或静态检查证明生产装配不再调用旧 Writer,旧三表发布后无新增。
|
||||||
|
- 历史投影测试使用旧账号/资产/手动轮询样本,验证 `UNION ALL` 的字段映射、确定性历史键、分页排序、`record_source` 和新旧交界时间无重复/漏项。
|
||||||
|
- Integration 测试覆盖 outbound 成功/失败/响应未知、inbound 回调、未发送的 merged/rate_limited/completed、同序列 0/3/5、状态变化关联 Audit Event 和重复回调。
|
||||||
|
- Access Log 测试覆盖嵌套 JSON、数组、非 JSON、登录/Token、支付/企微/运营商回调、上传下载和响应体,证明 Token、Secret、操作密码、签名 URL、Authorization、Cookie 等不落盘且 50KB 生效。
|
||||||
|
- 权限测试覆盖超级管理员、不同平台角色、代理和企业;验证 Tab、API、字段、资源范围、敏感查看与导出权限相互独立,越权资源不泄露存在性。
|
||||||
|
- Query 性能测试使用代表性事件/资源/Integration 数据,验证分页和常用过滤使用索引、无 JSONB 全表模糊扫描、无资源/操作者 N+1,满足项目 P95/P99 目标。
|
||||||
|
- HTTP 集成测试穿过真实 Fiber 认证、Handler、Query/GORM 和统一错误响应;新 Handler 同步注册两个 OpenAPI 文档生成器并验证静态/动态路由顺序。
|
||||||
|
- 停机发布演练覆盖暂停 Worker、迁移、旧写护栏、新 Writer 切换、样本对账、恢复 Worker、放量前失败退出和放量后的前向修复;已生成审计数据不得通过清表回滚。
|
||||||
|
- 前端验收覆盖七个视角、权限空态、历史投影、资源候选、request/correlation 跳转、0/3/5 序列、敏感二次查看、导出和错误状态。
|
||||||
|
|
||||||
|
## Out of Scope
|
||||||
|
|
||||||
|
- 不把 Access Log、Audit Event、Domain Ledger 和 Integration Log 合并成一张万能日志表。
|
||||||
|
- 不把普通列表、详情和未读数查询全部写成业务审计;只审计敏感读取。
|
||||||
|
- 不在线回填旧日志到新表,不长期双写新旧审计,不删除旧历史表。
|
||||||
|
- 不为数据同步另建 `tb_card_sync_execution` 或独立同步审计页面。
|
||||||
|
- 不把整个旧业务仓库一次性迁成 DDD;只统一其审计 Adapter,复杂用例按各自需求迁移。
|
||||||
|
- 不建设自动风控封禁、风险处置工单、自由关系图或实时行为分析平台。
|
||||||
|
- 不在 API 请求中扫描本地 Access Log 文件,也不把日志文件升级为业务权威存储。
|
||||||
|
- 不允许应用用户修改/删除 Audit Event,不在普通审计详情暴露完整外部报文和密钥。
|
||||||
|
|
||||||
|
## Further Notes
|
||||||
|
|
||||||
|
- 用户已明确确认一次性全局切换,覆盖标准稿中的“旧写停止、不双写、历史只读投影”口径;这不是可由实现阶段改回渐进双写的建议项。
|
||||||
|
- 当前已核实旧账号/资产审计使用裸 goroutine,Access Log 响应体未脱敏;这两项是发布前必须消除的现存缺陷。
|
||||||
|
- 当前手动轮询日志兼做进度存储,切断旧表时必须先由公共异步任务状态承接,不得违反 UR#94“轮询管理外部行为保持现状”的确认结论。
|
||||||
|
- 本需求较大,进入实现前应依据本 Spec 拆成可独立验证的纵向切片,但不得按“先建表、再 Service、再 Handler”的水平层级拆分,也不得改变一次停机切换这一最终发布门禁。
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# 01 — 交付不可变 Audit Event 写入闭环
|
||||||
|
|
||||||
|
**What to build:** 业务用例可以通过统一 Audit Writer 写入不可变、多资源、可串联且默认脱敏的审计事件。成功事件能够与业务事实共用事务,失败或拒绝事件使用独立短事务保留;未注册动作、缺少主要资源或审计写入失败时按明确策略阻止错误事实落地。
|
||||||
|
|
||||||
|
**Blocked by:** `.scratch/tech-public-foundation/issues/01-public-migration-ownership-and-gates.md` — 01 — 建立公共迁移所有权与检查门禁
|
||||||
|
|
||||||
|
**Status:** ready-for-agent
|
||||||
|
|
||||||
|
**架构通道:** 主通道为 Application + Port/Adapter,辅助通道为 Infrastructure。
|
||||||
|
|
||||||
|
**完整业务边界:** 本票收口 Audit Event、事件资源、动作注册表、统一 Sanitizer、内容哈希、大小控制和 Writer 可靠性,并用一个代表性敏感写操作验证公开接缝。明确不迁移其他旧 Service,不提供完整审计查询中心,不用 Audit Event 替代领域流水。
|
||||||
|
|
||||||
|
- [ ] Audit Event 支持稳定事件 ID、操作者与入口快照、结果、风险、前后数据、请求/关联/父事件 ID、HTTP 摘要、内容哈希和创建时间;事件资源支持 `primary/affected/reference`,且每个事件至少包含一个 `primary`。
|
||||||
|
- [ ] 动作注册表集中定义稳定动作编码、中文名称、类别、默认风险、允许资源类型和敏感字段规则;未经注册的动作不能写入生产审计。
|
||||||
|
- [ ] 统一 Sanitizer 删除禁止字段;`before_data`、`after_data`、`metadata` 分别执行 16KB 上限,超限后保存截断标志、原字节数、摘要和受控制品引用。
|
||||||
|
- [ ] `content_hash` 基于脱敏、标准化后的不可变内容生成,不包含数据库自增 ID;相同内容哈希稳定,Repository 不提供 Update/Delete 能力。
|
||||||
|
- [ ] `AppendWithTx` 与业务事实使用同一 GORM 事务,任一步失败整体回滚;已经回滚的 `failed/denied` 使用独立短事务,二次失败保留原业务错误并产生 critical 日志和指标。
|
||||||
|
- [ ] 真实 PostgreSQL 集成测试覆盖不可变约束、多资源、动作注册、风险默认值、哈希、截断、禁止字段、重复事件幂等和事务回滚。
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# 02 — 交付可恢复的 Integration Log 尝试闭环
|
||||||
|
|
||||||
|
**What to build:** 外部调用和未实际发出的同步尝试都能以稳定 Integration ID 建立可恢复事实,并通过受控条件更新进入明确终态。入站回调在业务处理前保存脱敏摘要和幂等标识,出站响应未知时保留未知结论而不伪装成普通失败。
|
||||||
|
|
||||||
|
**Blocked by:** `.scratch/tech-public-foundation/issues/01-public-migration-ownership-and-gates.md` — 01 — 建立公共迁移所有权与检查门禁
|
||||||
|
|
||||||
|
**Status:** ready-for-agent
|
||||||
|
|
||||||
|
**架构通道:** 主通道为 Infrastructure,辅助通道为 Application + Port/Adapter。
|
||||||
|
|
||||||
|
**完整业务边界:** 本票收口 Integration Log 模型、Writer、执行态到终态的条件更新、入站摘要和未发送结果语义。明确不接管 Gateway、支付、企微或运营商的业务状态机,不把外部交互记录作为业务权威状态。
|
||||||
|
|
||||||
|
- [ ] Integration Log 支持 provider、方向、operation、外部单号、资源、触发来源/场景/序列/尝试、计划与开始时间、结果、渠道摘要、脱敏请求响应摘要、耗时、状态变化标志和关联 ID。
|
||||||
|
- [ ] 方向固定为 `inbound/outbound`;公开终态至少覆盖成功、失败、未找到、无效载荷、忽略、合并、限频、提前完成和取消,并返回对应中文名称。
|
||||||
|
- [ ] 实际外部调用前持久化稳定尝试身份,完成后使用预期状态条件更新;并发完成、重复回调或重复消费不能改写既有终态。
|
||||||
|
- [ ] 请求已发出但响应未知时记录明确的未知结论和恢复策略,不自动把具有副作用的请求当成普通失败盲目重发。
|
||||||
|
- [ ] 入站回调先保存脱敏摘要、内容哈希和幂等标识;原始密文、完整正文、签名、附件和密钥不进入普通记录。
|
||||||
|
- [ ] PostgreSQL 集成测试覆盖出站成功、明确失败、响应未知、未发送终态、入站回调、重复回调、条件更新冲突和 Audit Event 关联。
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
# 03 — 完成 Access Log 全路由敏感信息防泄漏
|
||||||
|
|
||||||
|
**What to build:** 当前项目所有敏感 HTTP 路由均使用统一的请求、响应、Query 和 Header 脱敏及路由级安全摘要策略。即使正文不是 JSON、解析失败或属于文件载荷,也不会把可复用凭证、完整回调或文件内容写入 Access Log。
|
||||||
|
|
||||||
|
**Blocked by:**
|
||||||
|
|
||||||
|
- `.scratch/tech-public-foundation/issues/09-access-log-recursive-redaction.md` — 09 — 统一 Access Log 请求与响应递归脱敏
|
||||||
|
- `.scratch/tech-public-foundation/issues/10-sensitive-route-safe-summaries.md` — 10 — 为敏感接口提供安全摘要策略
|
||||||
|
|
||||||
|
**Status:** ready-for-agent
|
||||||
|
|
||||||
|
**架构通道:** Infrastructure。
|
||||||
|
|
||||||
|
**完整业务边界:** 本票将公共 Access Log 安全能力应用到当前仓库真实路由并建立固定回归矩阵。明确不修改业务响应,不创建审计事实,不把 Access Log 升级为业务权威存储。
|
||||||
|
|
||||||
|
- [ ] 登录、Token、支付与企微配置路由只记录字段存在性、长度和安全结果,不记录密码、验证码、Token、Secret、密钥或完整配置值。
|
||||||
|
- [ ] 支付、企微和运营商回调只记录事件类型、安全资源标识、大小、内容类型、摘要哈希与处理结果,不记录密文、完整正文、签名或附件。
|
||||||
|
- [ ] 上传、下载和导出路由不记录文件字节、Base64、multipart 正文、临时凭证或签名 URL,只保留脱敏文件元数据和任务标识。
|
||||||
|
- [ ] Query 和 Header 覆盖 token、secret、sign、nonce、authorization、cookie 等大小写变体;请求和响应均先脱敏再执行 50KB 截断。
|
||||||
|
- [ ] 非 JSON、XML、表单、二进制及解析失败场景均按路由策略安全降级,不能回退记录原文。
|
||||||
|
- [ ] 真实 Fiber 测试捕获最终 Access Log,覆盖敏感路由矩阵,并断言测试凭证、操作密码、回调原文、签名 URL、Authorization 和 Cookie 均未落盘。
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# 04 — 迁移账号、角色与权限敏感操作到统一审计
|
||||||
|
|
||||||
|
**What to build:** 账号、角色和权限敏感操作通过统一 Audit Writer 记录操作者、动作、目标资源、结果、风险和前后变化。关键成功审计与业务修改同事务,拒绝和失败审计可可靠保留,这些入口不再调用旧账号审计 Writer。
|
||||||
|
|
||||||
|
**Blocked by:** 01 — 交付不可变 Audit Event 写入闭环
|
||||||
|
|
||||||
|
**Status:** ready-for-agent
|
||||||
|
|
||||||
|
**架构通道:** 主通道为简单写 Application,辅助通道为旧 MVC Adapter。
|
||||||
|
|
||||||
|
**完整业务边界:** 本票收口现有账号、角色和权限敏感写入口的统一审计接入。明确不重构整个账号模块,不迁移无关读取,不删除或回填旧账号历史表。
|
||||||
|
|
||||||
|
- [ ] 账号创建、修改、启停、删除、角色分配及权限变更使用注册动作和统一资源类型,成功、拒绝和失败语义明确。
|
||||||
|
- [ ] 账号角色或权限关键成功事件与业务事实使用同一 GORM 事务;审计失败时业务修改回滚。
|
||||||
|
- [ ] 权限拒绝与业务失败通过独立短事务记录,不向客户端泄露底层错误或资源是否存在。
|
||||||
|
- [ ] 事件包含操作者与入口快照、请求/关联标识、变更前后事实和直接受影响资源,敏感字段按统一规则删除或脱敏。
|
||||||
|
- [ ] 生产装配中的上述入口不再调用旧账号审计 Service,也不直接创建旧账号日志模型;静态检查和真实用例测试可证明该边界。
|
||||||
|
- [ ] 测试覆盖事务成功、审计失败回滚、拒绝、业务失败、重复请求和数据权限边界,不改变旧历史查询结果。
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# 05 — 迁移卡资产生命周期操作到统一审计
|
||||||
|
|
||||||
|
**What to build:** 卡分配、回收、删除、停复机、实名策略和状态变化等资产生命周期操作统一产生可关联的 Audit Event,并以多资源关系表达卡、设备、店铺、订单等直接影响对象。复杂卡状态规则仍由完整业务用例收口,不在审计 Adapter 中复制。
|
||||||
|
|
||||||
|
**Blocked by:** 01 — 交付不可变 Audit Event 写入闭环
|
||||||
|
|
||||||
|
**Status:** ready-for-agent
|
||||||
|
|
||||||
|
**架构通道:** 复杂卡状态用例采用 Application/Domain;其他入口采用旧 MVC Adapter。
|
||||||
|
|
||||||
|
**完整业务边界:** 本票迁移现有卡资产生命周期写入口的审计能力。明确不重新设计周期轮询、队列、卡资格或重排策略,不迁移本需求未触碰的资产规则,不删除旧资产历史表。
|
||||||
|
|
||||||
|
- [ ] 卡分配、回收、删除、手工停复机、实名策略和业务状态变化均映射到已注册动作,成功、拒绝和失败结果保持一致。
|
||||||
|
- [ ] 事件至少关联一个主要卡资源,并按实际影响关联设备、来源/目标店铺、订单或其他直接资源;不递归制造资源关系。
|
||||||
|
- [ ] 关键状态变更成功审计与业务事实同事务;失败或拒绝使用独立短事务,重复状态请求不制造重复业务副作用或虚假变化。
|
||||||
|
- [ ] `request_id/correlation_id/parent_event_id` 在 HTTP、业务用例和后续异步链路中按各自职责传播。
|
||||||
|
- [ ] 当前卡资产入口不再调用旧资产审计 Writer 或直接创建旧资产日志模型,但兼容历史读取仍可工作。
|
||||||
|
- [ ] 测试覆盖权限拒绝、状态条件更新、事务回滚、多资源时间线、敏感 ICCID 默认脱敏和重复请求。
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# 06 — 迁移设备与资产导入操作到统一审计
|
||||||
|
|
||||||
|
**What to build:** 设备分配、回收、绑定、控制操作以及卡和设备导入任务通过统一 Audit Writer 留下稳定、脱敏、可检索的事件。批量操作只在事件中保存命令摘要和计数,逐项明细继续由业务任务或受控制品承担。
|
||||||
|
|
||||||
|
**Blocked by:** 01 — 交付不可变 Audit Event 写入闭环
|
||||||
|
|
||||||
|
**Status:** ready-for-agent
|
||||||
|
|
||||||
|
**架构通道:** 主通道为简单写 Application/旧 MVC Adapter,辅助通道为 Infrastructure。
|
||||||
|
|
||||||
|
**完整业务边界:** 本票收口设备生命周期与现有资产导入入口的审计接入。明确不重构整个设备 Service,不建立通用批量任务表,不把大批量明细塞入 Audit Event JSON。
|
||||||
|
|
||||||
|
- [ ] 设备分配、回收、系列绑定、绑卡/解绑、停复机、限速、WiFi 设置、切卡、重启和恢复出厂映射为注册动作。
|
||||||
|
- [ ] 卡和设备导入任务创建、完成与失败事件关联任务、操作者、来源文件安全摘要和结果计数,不保存文件内容、签名 URL 或完整逐项数据。
|
||||||
|
- [ ] 批量事件超过大小限制时记录截断元数据、原始计数、摘要及受控任务/制品引用,查询仍能定位权威明细。
|
||||||
|
- [ ] 关键业务修改与成功审计同事务;拒绝和失败可靠保留,重复任务或重复控制请求不制造重复成功事件。
|
||||||
|
- [ ] 相关生产入口不再调用旧资产审计 Writer;自动检查覆盖直接旧模型 Create 和隐藏装配注入。
|
||||||
|
- [ ] 真实用例测试覆盖单项与批量、事务回滚、部分结果摘要、多资源关系、权限范围和敏感字段删除。
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# 07 — 迁移店铺、套餐和关键配置操作到统一审计
|
||||||
|
|
||||||
|
**What to build:** 店铺敏感归属、套餐管理以及支付、企微和关键系统配置的现有写操作统一记录注册动作、操作者、目标资源和前后变化。关键配置与权限相关成功审计和业务事实同事务,敏感配置原值永不进入审计正文。
|
||||||
|
|
||||||
|
**Blocked by:** 01 — 交付不可变 Audit Event 写入闭环
|
||||||
|
|
||||||
|
**Status:** ready-for-agent
|
||||||
|
|
||||||
|
**架构通道:** 主通道为简单写 Application,辅助通道为旧 MVC Adapter。
|
||||||
|
|
||||||
|
**完整业务边界:** 本票迁移当前已有店铺、套餐和关键配置敏感入口。明确不接管各业务 PRD 尚未实现的状态机,不主动迁移无关 CRUD,不创建配置专用审计表。
|
||||||
|
|
||||||
|
- [ ] 店铺敏感业务员归属、关键账号关联和其他已识别敏感变更使用稳定动作及店铺/人员资源关系。
|
||||||
|
- [ ] 套餐创建、修改、上下架、授权或其他已存在敏感管理入口记录业务命令摘要和直接受影响资源。
|
||||||
|
- [ ] 支付、企微及关键系统配置变更只记录 Key、安全类型与脱敏前后摘要,不保存 Secret、Token、EncodingAESKey、私钥、公钥原文或签名材料。
|
||||||
|
- [ ] 关键配置和权限相关成功审计与业务事实同事务;拒绝、校验失败和持久化失败按公共失败策略记录。
|
||||||
|
- [ ] 相关旧账号/资产审计调用与零散配置日志不再承担这些操作的权威审计,生产装配可被自动检查验证。
|
||||||
|
- [ ] 测试覆盖配置审计失败回滚、店铺越权、套餐批量摘要、敏感字段删除、重复更新和统一中文错误。
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
# 08 — 迁移现有资金与订单敏感操作到统一审计
|
||||||
|
|
||||||
|
**What to build:** 当前钱包变更、充值、退款和订单资金敏感操作通过统一 Audit Event 关联业务单、钱包、钱包流水、操作者和完整业务链路。金额结论继续以 Domain Ledger 为准,关键成功审计与资金事实同事务且只产生一次。
|
||||||
|
|
||||||
|
**Blocked by:**
|
||||||
|
|
||||||
|
- 01 — 交付不可变 Audit Event 写入闭环
|
||||||
|
- `.scratch/tech-public-foundation/issues/02-transactional-public-outbox-write.md` — 02 — 在业务事务中可靠写入公共 Outbox
|
||||||
|
|
||||||
|
**Status:** ready-for-agent
|
||||||
|
|
||||||
|
**架构通道:** 主通道为复杂写 Application/Domain,辅助通道为 Port/Adapter。
|
||||||
|
|
||||||
|
**完整业务边界:** 本票迁移仓库当前存在的钱包、充值、退款和订单资金敏感入口,完整收口所触碰用例的金额、并发、幂等和可靠事件边界。明确不用 Audit Event 替代钱包流水、订单或退款事实,不重写未触碰资金用例。
|
||||||
|
|
||||||
|
- [ ] 钱包余额变更、代理钱包回退、线下充值入账、人工退款结果及现有订单资金操作使用注册动作和稳定 correlation。
|
||||||
|
- [ ] Audit Event 关联审批或业务单、钱包、钱包流水及直接受影响资产;每条投影明确领域流水才是金额权威。
|
||||||
|
- [ ] 余额、流水、成功审计和必要 Outbox 在同一 GORM 事务内提交;审计或 Outbox 写入失败时资金事实整体回滚。
|
||||||
|
- [ ] 状态条件更新、钱包版本或稳定业务键保证重复请求、Worker 重投和并发处理不重复改变余额、流水或成功审计。
|
||||||
|
- [ ] 明确失败、拒绝和结果异常使用独立短事务记录安全摘要,不把第三方支付密钥、完整凭证或底层错误返回客户端。
|
||||||
|
- [ ] PostgreSQL 集成测试覆盖正常资金变化、审计失败、Outbox 失败、乐观锁冲突、重复业务键、并发处理和金额事实对账。
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
# 09 — 承接手动轮询状态并记录同步外部尝试
|
||||||
|
|
||||||
|
**What to build:** 现有手动触发、进度和监控接口保持用户契约,但运行状态由公共异步任务契约承接;Gateway 实际请求及合并、互斥、限频、提前完成等未发送尝试进入 Integration Log,只有状态变化、人工强制、连续失败或高风险异常进入 Audit Event。
|
||||||
|
|
||||||
|
**Blocked by:**
|
||||||
|
|
||||||
|
- 01 — 交付不可变 Audit Event 写入闭环
|
||||||
|
- 02 — 交付可恢复的 Integration Log 尝试闭环
|
||||||
|
- `.scratch/tech-public-foundation/issues/02-transactional-public-outbox-write.md` — 02 — 在业务事务中可靠写入公共 Outbox
|
||||||
|
- `.scratch/tech-public-foundation/issues/03-outbox-at-least-once-delivery.md` — 03 — 完成 Outbox 到 Asynq 的至少一次投递闭环
|
||||||
|
- `.scratch/tech-public-foundation/issues/06-unified-async-task-contract.md` — 06 — 冻结统一异步任务五态和查询契约
|
||||||
|
|
||||||
|
**Status:** ready-for-agent
|
||||||
|
|
||||||
|
**架构通道:** 主通道为 Application + Infrastructure,辅助通道为 Query。
|
||||||
|
|
||||||
|
**完整业务边界:** 本票收口旧手动轮询日志承担的运行状态替代、外部尝试记录和兼容接口。明确不改变轮询配置、间隔、Redis 分片队列、任务类型、卡级开关、并发控制或失败重排,不新建同步专用运行表。
|
||||||
|
|
||||||
|
- [ ] 手动触发、进度与监控公开契约继续可用,状态、计数、失败摘要和恢复行为映射到公共异步任务五态。
|
||||||
|
- [ ] 实际 Gateway 请求在调用前建立 Integration Log,完成后记录结果、耗时、状态变化和脱敏上游摘要。
|
||||||
|
- [ ] 合并、互斥、限频、已达预期和取消即使未产生 HTTP 请求也有可解释终态,不伪造 HTTP 状态。
|
||||||
|
- [ ] 同步序列传播 `request_id/correlation_id/series_id/attempt`;同序列查询可连续看到立即、3 分钟、5 分钟的全部尝试。
|
||||||
|
- [ ] 普通无变化成功只写 Integration Log;状态变化、人工强制、连续失败或高风险异常按注册规则关联 Audit Event。
|
||||||
|
- [ ] 回归测试固定现有轮询配置、队列、开关和监控基线,验证切换前后调度事实不变且旧手动轮询表不再承担新增运行状态。
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# 10 — 提供旧审计历史统一只读投影
|
||||||
|
|
||||||
|
**What to build:** 审计查询可以把旧账号、旧资产和旧手动轮询记录规范化为统一只读历史事件,并与新 Audit Event 稳定分页排序。现有资产操作日志兼容接口继续可用,但不再直接绑定旧资产日志表。
|
||||||
|
|
||||||
|
**Blocked by:** 01 — 交付不可变 Audit Event 写入闭环
|
||||||
|
|
||||||
|
**Status:** ready-for-agent
|
||||||
|
|
||||||
|
**架构通道:** Query。
|
||||||
|
|
||||||
|
**完整业务边界:** 本票收口三个旧历史来源的 `UNION ALL` 投影、确定性历史键和资产兼容读取。明确不在线回填新表,不修改或删除旧记录,不伪造历史中不存在的 correlation、风险或多资源关系。
|
||||||
|
|
||||||
|
- [ ] 旧账号、资产和手动轮询记录分别返回 `legacy_account/legacy_asset/legacy_polling` 来源及确定性历史事件键。
|
||||||
|
- [ ] 字段映射保留可证明的操作者、操作、资源、结果、时间和摘要;不存在的关联、风险或资源关系显式为空而非推测填充。
|
||||||
|
- [ ] 新旧记录使用稳定时间加 ID/历史键排序,分页跨越切换时间时无重复、漏项或顺序漂移。
|
||||||
|
- [ ] 资产操作日志兼容接口同时读取新 Audit Event 与旧资产投影,并保持原业务调用方所需响应兼容性。
|
||||||
|
- [ ] Query 不返回可用于业务写入的聚合对象,不对旧 JSON 做无索引模糊扫描,不产生 N+1 查询。
|
||||||
|
- [ ] PostgreSQL 投影测试覆盖三类历史样本、字段映射、确定性键、分页排序、新旧交界和兼容接口。
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
# 11 — 交付全局事件和资源轨迹查询闭环
|
||||||
|
|
||||||
|
**What to build:** 获得授权的平台用户可以分页查看全局审计事件与详情,先搜索业务资源候选,再打开包含新事件和历史投影的资源时间线。资源权限与字段脱敏由后端重新校验,代理或企业用户只能在原业务范围查看允许的资源轨迹。
|
||||||
|
|
||||||
|
**Blocked by:**
|
||||||
|
|
||||||
|
- 01 — 交付不可变 Audit Event 写入闭环
|
||||||
|
- 05 — 迁移卡资产生命周期操作到统一审计
|
||||||
|
- 06 — 迁移设备与资产导入操作到统一审计
|
||||||
|
- 10 — 提供旧审计历史统一只读投影
|
||||||
|
|
||||||
|
**Status:** ready-for-agent
|
||||||
|
|
||||||
|
**架构通道:** Query。
|
||||||
|
|
||||||
|
**完整业务边界:** 本票收口事件列表/详情、资源候选搜索和资源时间线 API 及权限、分页、索引和 DTO 投影。明确不递归遍历资源图,不扫描 JSONB,不通过聚合根读取,不实现其他审计视角。
|
||||||
|
|
||||||
|
- [ ] 事件列表和详情支持注册动作、操作者、来源、结果、风险、时间、资源和请求标识等有索引过滤,默认 20、最大 100,并稳定按时间与 ID 排序。
|
||||||
|
- [ ] 资源搜索先查询业务读模型返回类型、ID、Key 和显示名;静态搜索路由先于动态资源路由注册。
|
||||||
|
- [ ] 资源时间线组合新 Audit Event 和旧投影,`include_related=true` 只展开事件直接关联资源,不递归遍历关系图。
|
||||||
|
- [ ] 超级管理员、平台角色、代理和企业按权限码与原数据范围取交集;越权查询不泄露资源是否存在。
|
||||||
|
- [ ] DTO 默认脱敏并返回结果、风险等中文名称;公共关键词不对 JSONB 执行无索引模糊扫描。
|
||||||
|
- [ ] 真实 Fiber、认证、GORM 和 PostgreSQL 测试覆盖路由顺序、分页、筛选、权限、历史交界、无 N+1 和常用查询索引;新增 Handler 同步两个文档生成器。
|
||||||
21
.scratch/tech-global-audit/issues/12-actor-risk-query.md
Normal file
21
.scratch/tech-global-audit/issues/12-actor-risk-query.md
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
# 12 — 交付人员行为和风险事件查询闭环
|
||||||
|
|
||||||
|
**What to build:** 获得相应权限的平台用户可以查看操作者列表、行为摘要、个人事件时间线以及风险概览和风险事件列表。所有聚合均由服务端完成,并严格隔离代理、企业和无对应权限的平台角色。
|
||||||
|
|
||||||
|
**Blocked by:**
|
||||||
|
|
||||||
|
- 04 — 迁移账号、角色与权限敏感操作到统一审计
|
||||||
|
- 11 — 交付全局事件和资源轨迹查询闭环
|
||||||
|
|
||||||
|
**Status:** ready-for-agent
|
||||||
|
|
||||||
|
**架构通道:** Query。
|
||||||
|
|
||||||
|
**完整业务边界:** 本票收口人员与风险两个读取视角、服务端汇总和权限边界。明确不建设自动封禁、风险处置工单、实时行为分析或前端全量下载聚合。
|
||||||
|
|
||||||
|
- [ ] 操作者查询支持 actor kind、稳定 ID、名称快照、入口、动作、结果、风险和时间过滤,并提供摘要及稳定分页事件时间线。
|
||||||
|
- [ ] 风险概览按风险等级、结果、类别、动作和时间窗口进行有索引汇总,风险事件列表可进一步检索详情。
|
||||||
|
- [ ] `audit:actor:view` 与 `audit:risk:view` 独立授权;代理和企业账号不能进入人员或风险全局视角。
|
||||||
|
- [ ] 平台角色的权限与数据范围取交集,失败、拒绝、高风险和严重事件不会因缺失可选关联而被错误过滤。
|
||||||
|
- [ ] 汇总使用服务端 SQL 和批量投影,不下载全量事件、不对 JSONB 模糊扫描、不产生操作者或资源 N+1。
|
||||||
|
- [ ] HTTP 与性能测试覆盖超级管理员、不同平台角色、代理、企业、空态、筛选空态及代表性数据量;OpenAPI 文档同步更新。
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
# 13 — 交付请求、业务链路和外部集成时间线
|
||||||
|
|
||||||
|
**What to build:** 运维人员可以按 request ID 或 correlation ID 查看同一请求或完整业务链路中的 Audit Event、Integration Log、Outbox 和异步任务摘要,并可按外部提供方、操作、方向、结果、资源、场景和序列检索外部尝试。
|
||||||
|
|
||||||
|
**Blocked by:**
|
||||||
|
|
||||||
|
- 02 — 交付可恢复的 Integration Log 尝试闭环
|
||||||
|
- 09 — 承接手动轮询状态并记录同步外部尝试
|
||||||
|
- 11 — 交付全局事件和资源轨迹查询闭环
|
||||||
|
- `.scratch/tech-public-foundation/issues/02-transactional-public-outbox-write.md` — 02 — 在业务事务中可靠写入公共 Outbox
|
||||||
|
- `.scratch/tech-public-foundation/issues/06-unified-async-task-contract.md` — 06 — 冻结统一异步任务五态和查询契约
|
||||||
|
|
||||||
|
**Status:** ready-for-agent
|
||||||
|
|
||||||
|
**架构通道:** Query。
|
||||||
|
|
||||||
|
**完整业务边界:** 本票收口请求时间线、关联时间线和 Integration Log 列表/详情查询。明确不在 API 请求中扫描本地 Access Log,不复制 Outbox/任务完整载荷,不把外部交互结果解释成业务权威状态。
|
||||||
|
|
||||||
|
- [ ] Request Timeline 组合可关联的审计事件、外部尝试、Outbox 和任务安全摘要,并返回 Access Log 检索标识而不读取日志文件。
|
||||||
|
- [ ] Correlation Timeline 以稳定 correlation 串联跨请求、回调和异步处理,`parent_event_id` 只表达直接因果,不替代 correlation。
|
||||||
|
- [ ] Integration 查询支持 provider、operation、方向、结果、资源、触发来源、场景、序列、尝试和时间过滤,列表默认 20、最大 100。
|
||||||
|
- [ ] 同一同步序列能够按尝试顺序连续展示立即、3 分钟、5 分钟结果,包括合并、限频和提前完成等未发送终态。
|
||||||
|
- [ ] 原始外部正文、密文、签名、附件、Outbox 载荷和任务敏感失败明细不进入普通查询 DTO。
|
||||||
|
- [ ] 真实链路测试覆盖单请求、多请求 correlation、异步传播、重复尝试、0/3/5 序列、权限隔离和常用查询索引;OpenAPI 文档同步更新。
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
# 14 — 交付资金审计时间线
|
||||||
|
|
||||||
|
**What to build:** 财务人员可以按业务单、钱包、审批、资产和时间查看组合时间线,统一展示 Audit Event、钱包流水、订单、退款、充值和审批实例,并清楚区分每条记录来源及金额权威。
|
||||||
|
|
||||||
|
**Blocked by:**
|
||||||
|
|
||||||
|
- 08 — 迁移现有资金与订单敏感操作到统一审计
|
||||||
|
- 13 — 交付请求、业务链路和外部集成时间线
|
||||||
|
|
||||||
|
**Status:** ready-for-agent
|
||||||
|
|
||||||
|
**架构通道:** Query。
|
||||||
|
|
||||||
|
**完整业务边界:** 本票收口资金审计的只读组合投影、权限、分页和对账语义。明确不通过查询修改资金状态,不把 Audit Event 当作金额账本,不迁移未触碰的资金写用例。
|
||||||
|
|
||||||
|
- [ ] 时间线组合 Audit Event、钱包流水、订单、退款、充值和审批实例,每条返回明确 `record_source`、时间、业务标识和安全摘要。
|
||||||
|
- [ ] 金额、余额和资金结论始终取自 Domain Ledger;审计事件只解释操作者、动作、风险、前后变化和关联关系。
|
||||||
|
- [ ] 支持钱包、店铺、业务单、审批、资产、动作、结果、风险和时间等有索引过滤,并使用稳定时间加来源 ID 排序。
|
||||||
|
- [ ] `audit:finance:view` 独立授权,代理和企业不能进入全局资金视角;平台角色权限与原资金数据范围取交集。
|
||||||
|
- [ ] 金额、手机号、第三方交易号等字段默认按权限脱敏,不因某条关联缺失泄露其他资源存在性。
|
||||||
|
- [ ] 对账和性能测试覆盖多来源同链路、退款与充值、审批关联、无重复漏项、无 N+1 和代表性数据量;OpenAPI 文档同步更新。
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
# 15 — 交付敏感值二次查看与自审计闭环
|
||||||
|
|
||||||
|
**What to build:** 审计详情默认返回掩码或安全状态;具有独立敏感查看权限的用户可以针对明确事件或资源二次请求允许展示的完整值,而该查看行为本身会产生高风险 Audit Event,并保留被查看对象、操作者和请求链路。
|
||||||
|
|
||||||
|
**Blocked by:**
|
||||||
|
|
||||||
|
- 01 — 交付不可变 Audit Event 写入闭环
|
||||||
|
- 11 — 交付全局事件和资源轨迹查询闭环
|
||||||
|
- 12 — 交付人员行为和风险事件查询闭环
|
||||||
|
|
||||||
|
**Status:** ready-for-agent
|
||||||
|
|
||||||
|
**架构通道:** 主通道为 Query,辅助通道为简单写 Application。
|
||||||
|
|
||||||
|
**完整业务边界:** 本票收口敏感字段受控读取、字段级授权和读取自审计。明确不恢复已被策略删除的原值,不允许超级管理员绕过二次审计,不授予导出权限。
|
||||||
|
|
||||||
|
- [ ] 普通详情对手机号、IP、ICCID、钱包金额和第三方交易号等受控字段默认脱敏;禁止字段始终不可恢复。
|
||||||
|
- [ ] 二次查看要求 `audit:sensitive:view`、明确目标和字段范围,并重新校验平台角色、数据范围与资源权限。
|
||||||
|
- [ ] 成功或被拒绝的敏感查看产生注册的高风险 Audit Event,关联被查看事件/资源、操作者、入口和 request ID。
|
||||||
|
- [ ] 审计写入失败时敏感值不返回;重复查看每次都保留独立读取事实,不因已有全局权限跳过。
|
||||||
|
- [ ] 无权限、历史字段不存在、原值已删除和资源越权返回明确但不泄密的统一错误或状态。
|
||||||
|
- [ ] 真实 Fiber 和 PostgreSQL 测试覆盖授权查看、越权、审计失败、禁止字段、历史缺失、并发请求及自审计事件查询;OpenAPI 文档同步更新。
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
# 16 — 交付审计导出与字段授权快照
|
||||||
|
|
||||||
|
**What to build:** 获得审计导出权限的用户可以从支持的审计视角创建异步导出任务。任务创建时固化过滤条件、数据范围、字段授权和脱敏等级,后续角色变更或任务重试不会扩大导出内容。
|
||||||
|
|
||||||
|
**Blocked by:**
|
||||||
|
|
||||||
|
- 11 — 交付全局事件和资源轨迹查询闭环
|
||||||
|
- 12 — 交付人员行为和风险事件查询闭环
|
||||||
|
- 13 — 交付请求、业务链路和外部集成时间线
|
||||||
|
- 14 — 交付资金审计时间线
|
||||||
|
- 15 — 交付敏感值二次查看与自审计闭环
|
||||||
|
|
||||||
|
**Status:** ready-for-agent
|
||||||
|
|
||||||
|
**架构通道:** 主通道为 Query + Export DataSource,辅助通道为 Application。
|
||||||
|
|
||||||
|
**完整业务边界:** 本票收口审计导出 Scene、字段能力、权限快照、异步任务和导出审计。明确不创建第二套导出框架,不把敏感查看权限等同敏感导出权限,不在权限解析失败时回退全字段。
|
||||||
|
|
||||||
|
- [ ] 审计导出复用统一 Export DataSource 和任务契约,支持经批准的事件、资源、链路、集成、风险和资金过滤条件。
|
||||||
|
- [ ] 创建任务时快照操作者、权限、数据范围、字段集合、脱敏等级和过滤条件;Worker 只使用快照执行。
|
||||||
|
- [ ] `audit:export` 与 `audit:sensitive:view` 独立;导出完整敏感字段需要额外字段授权,解析失败一律拒绝。
|
||||||
|
- [ ] 文件不包含禁止字段、完整外部报文、密钥、签名 URL 或未授权业务数据;下载继续遵守安全摘要和临时访问策略。
|
||||||
|
- [ ] 创建、完成、失败和下载等敏感导出行为产生统一 Audit Event,并能关联导出任务与请求链路。
|
||||||
|
- [ ] 测试覆盖权限快照、角色变更、字段空集、敏感权限分离、任务重试、导出审计、越权和文件内容检查。
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user