diff --git a/.agents/skills/caveman/SKILL.md b/.agents/skills/caveman/SKILL.md deleted file mode 100644 index 85770a3..0000000 --- a/.agents/skills/caveman/SKILL.md +++ /dev/null @@ -1,49 +0,0 @@ ---- -name: caveman -description: > - Ultra-compressed communication mode. Cuts token usage ~75% by dropping - filler, articles, and pleasantries while keeping full technical accuracy. - Use when user says "caveman mode", "talk like caveman", "use caveman", - "less tokens", "be brief", or invokes /caveman. ---- - -Respond terse like smart caveman. All technical substance stay. Only fluff die. - -## Persistence - -ACTIVE EVERY RESPONSE once triggered. No revert after many turns. No filler drift. Still active if unsure. Off only when user says "stop caveman" or "normal mode". - -## Rules - -Drop: articles (a/an/the), filler (just/really/basically/actually/simply), pleasantries (sure/certainly/of course/happy to), hedging. Fragments OK. Short synonyms (big not extensive, fix not "implement a solution for"). Abbreviate common terms (DB/auth/config/req/res/fn/impl). Strip conjunctions. Use arrows for causality (X -> Y). One word when one word enough. - -Technical terms stay exact. Code blocks unchanged. Errors quoted exact. - -Pattern: `[thing] [action] [reason]. [next step].` - -Not: "Sure! I'd be happy to help you with that. The issue you're experiencing is likely caused by..." -Yes: "Bug in auth middleware. Token expiry check use `<` not `<=`. Fix:" - -### Examples - -**"Why React component re-render?"** - -> Inline obj prop -> new ref -> re-render. `useMemo`. - -**"Explain database connection pooling."** - -> Pool = reuse DB conn. Skip handshake -> fast under load. - -## Auto-Clarity Exception - -Drop caveman temporarily for: security warnings, irreversible action confirmations, multi-step sequences where fragment order risks misread, user asks to clarify or repeats question. Resume caveman after clear part done. - -Example -- destructive op: - -> **Warning:** This will permanently delete all rows in the `users` table and cannot be undone. -> -> ```sql -> DROP TABLE users; -> ``` -> -> Caveman resume. Verify backup exist first. diff --git a/.agents/skills/grill-me/SKILL.md b/.agents/skills/grill-me/SKILL.md deleted file mode 100644 index bd04394..0000000 --- a/.agents/skills/grill-me/SKILL.md +++ /dev/null @@ -1,10 +0,0 @@ ---- -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". ---- - -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. - -If a question can be answered by exploring the codebase, explore the codebase instead. diff --git a/.agents/skills/grill-with-docs/CONTEXT-FORMAT.md b/.agents/skills/grill-with-docs/CONTEXT-FORMAT.md deleted file mode 100644 index ddfa247..0000000 --- a/.agents/skills/grill-with-docs/CONTEXT-FORMAT.md +++ /dev/null @@ -1,77 +0,0 @@ -# CONTEXT.md Format - -## Structure - -```md -# {Context Name} - -{One or two sentence description of what this context is and why it exists.} - -## Language - -**Order**: -{A concise description of the term} -_Avoid_: Purchase, transaction - -**Invoice**: -A request for payment sent to a customer after delivery. -_Avoid_: Bill, payment request - -**Customer**: -A person or organization that places orders. -_Avoid_: Client, buyer, account - -## Relationships - -- An **Order** produces one or more **Invoices** -- An **Invoice** belongs to exactly one **Customer** - -## Example dialogue - -> **Dev:** "When a **Customer** places an **Order**, do we create the **Invoice** immediately?" -> **Domain expert:** "No — an **Invoice** is only generated once a **Fulfillment** is confirmed." - -## Flagged ambiguities - -- "account" was used to mean both **Customer** and **User** — resolved: these are distinct concepts. -``` - -## Rules - -- **Be opinionated.** When multiple words exist for the same concept, pick the best one and list the others as aliases to avoid. -- **Flag conflicts explicitly.** If a term is used ambiguously, call it out in "Flagged ambiguities" with a clear resolution. -- **Keep definitions tight.** One sentence max. Define what it IS, not what it does. -- **Show relationships.** Use bold term names and express cardinality where obvious. -- **Only include terms specific to this project's context.** General programming concepts (timeouts, error types, utility patterns) don't belong even if the project uses them extensively. Before adding a term, ask: is this a concept unique to this context, or a general programming concept? Only the former belongs. -- **Group terms under subheadings** when natural clusters emerge. If all terms belong to a single cohesive area, a flat list is fine. -- **Write an example dialogue.** A conversation between a dev and a domain expert that demonstrates how the terms interact naturally and clarifies boundaries between related concepts. - -## Single vs multi-context repos - -**Single context (most repos):** One `CONTEXT.md` at the repo root. - -**Multiple contexts:** A `CONTEXT-MAP.md` at the repo root lists the contexts, where they live, and how they relate to each other: - -```md -# Context Map - -## Contexts - -- [Ordering](./src/ordering/CONTEXT.md) — receives and tracks customer orders -- [Billing](./src/billing/CONTEXT.md) — generates invoices and processes payments -- [Fulfillment](./src/fulfillment/CONTEXT.md) — manages warehouse picking and shipping - -## Relationships - -- **Ordering → Fulfillment**: Ordering emits `OrderPlaced` events; Fulfillment consumes them to start picking -- **Fulfillment → Billing**: Fulfillment emits `ShipmentDispatched` events; Billing consumes them to generate invoices -- **Ordering ↔ Billing**: Shared types for `CustomerId` and `Money` -``` - -The skill infers which structure applies: - -- If `CONTEXT-MAP.md` exists, read it to find contexts -- If only a root `CONTEXT.md` exists, single context -- If neither exists, create a root `CONTEXT.md` lazily when the first term is resolved - -When multiple contexts exist, infer which one the current topic relates to. If unclear, ask. diff --git a/.agents/skills/grill-with-docs/SKILL.md b/.agents/skills/grill-with-docs/SKILL.md deleted file mode 100644 index 6dad6ad..0000000 --- a/.agents/skills/grill-with-docs/SKILL.md +++ /dev/null @@ -1,88 +0,0 @@ ---- -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. ---- - - - -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. - - - - - -## 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). - -Don't couple `CONTEXT.md` to implementation details. Only include terms that are meaningful to domain experts. - -### 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). - - diff --git a/.agents/skills/improve-codebase-architecture/LANGUAGE.md b/.agents/skills/improve-codebase-architecture/LANGUAGE.md deleted file mode 100644 index 530c276..0000000 --- a/.agents/skills/improve-codebase-architecture/LANGUAGE.md +++ /dev/null @@ -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**. diff --git a/.agents/skills/improve-codebase-architecture/SKILL.md b/.agents/skills/improve-codebase-architecture/SKILL.md deleted file mode 100644 index 05984a6..0000000 --- a/.agents/skills/improve-codebase-architecture/SKILL.md +++ /dev/null @@ -1,71 +0,0 @@ ---- -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. ---- - -# 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. - -## Glossary - -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). - -- **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 - -### 1. Explore - -Read the project's domain glossary 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: - -- Where does understanding one concept require bouncing between many small modules? -- Where are modules **shallow** — interface nearly as complex as the implementation? -- Where have pure functions been extracted just for testability, but the real bugs hide in how they're called (no **locality**)? -- Where do tightly-coupled modules leak across their seams? -- Which parts of the codebase are untested, or hard to test through their current interface? - -Apply the **deletion test** to anything you suspect is shallow: would deleting it concentrate complexity, or just move it? A "yes, concentrates" is the signal you want. - -### 2. Present candidates - -Present a numbered list of deepening opportunities. For each candidate: - -- **Files** — which files/modules are involved -- **Problem** — why the current architecture is causing friction -- **Solution** — plain English description of what would change -- **Benefits** — explained in terms of locality and leverage, and also in how tests would improve - -**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." - -**ADR conflicts**: if a candidate contradicts an existing ADR, only surface it when the friction is real enough to warrant revisiting the ADR. Mark it clearly (e.g. _"contradicts ADR-0007 — but worth reopening because…"_). Don't list every theoretical refactor an ADR forbids. - -Do NOT propose interfaces yet. Ask the user: "Which of these would you like to explore?" - -### 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. - -Side effects happen inline as decisions crystallize: - -- **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. -- **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). -- **Want to explore alternative interfaces for the deepened module?** See [INTERFACE-DESIGN.md](INTERFACE-DESIGN.md). diff --git a/.agents/skills/setup-matt-pocock-skills/SKILL.md b/.agents/skills/setup-matt-pocock-skills/SKILL.md deleted file mode 100644 index 1ebc6e1..0000000 --- a/.agents/skills/setup-matt-pocock-skills/SKILL.md +++ /dev/null @@ -1,121 +0,0 @@ ---- -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. -disable-model-invocation: true ---- - -# Setup Matt Pocock's Skills - -Scaffold the per-repo configuration that the engineering skills assume: - -- **Issue tracker** — where issues live (GitHub by default; local markdown is also supported out of the box) -- **Triage labels** — the strings used for the five canonical triage roles -- **Domain docs** — where `CONTEXT.md` and ADRs live, and the consumer rules for reading them - -This is a prompt-driven skill, not a deterministic script. Explore, present what you found, confirm with the user, then write. - -## Process - -### 1. Explore - -Look at the current repo to understand its starting state. Read whatever exists; don't assume: - -- `git remote -v` and `.git/config` — is this a GitHub repo? Which one? -- `AGENTS.md` and `CLAUDE.md` at the repo root — does either exist? Is there already an `## Agent skills` section in either? -- `CONTEXT.md` and `CONTEXT-MAP.md` at the repo root -- `docs/adr/` and any `src/*/docs/adr/` directories -- `docs/agents/` — does this skill's prior output already exist? -- `.scratch/` — sign that a local-markdown issue tracker convention is already in use - -### 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. - -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. - -**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. - -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: - -- **GitHub** — issues live in the repo's GitHub Issues (uses the `gh` CLI) -- **GitLab** — issues live in the repo's GitLab Issues (uses the [`glab`](https://gitlab.com/gitlab-org/cli) CLI) -- **Local markdown** — issues live as files under `.scratch//` 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 - -**Section B — Triage label vocabulary.** - -> 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. - -The five canonical roles: - -- `needs-triage` — maintainer needs to evaluate -- `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. - -**Section C — Domain docs.** - -> 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. - -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 - -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 contents of `docs/agents/issue-tracker.md`, `docs/agents/triage-labels.md`, `docs/agents/domain.md` - -Let them edit before writing. - -### 4. Write - -**Pick the file to edit:** - -- If `CLAUDE.md` exists, edit it. -- Else if `AGENTS.md` exists, edit it. -- If neither exists, ask the user which one to create — don't pick for them. - -Never create `AGENTS.md` when `CLAUDE.md` already exists (or vice versa) — always edit the one that's already there. - -If an `## Agent skills` block already exists in the chosen file, update its contents in-place rather than appending a duplicate. Don't overwrite user edits to the surrounding sections. - -The block: - -```markdown -## Agent skills - -### Issue tracker - -[one-line summary of where issues are tracked]. See `docs/agents/issue-tracker.md`. - -### Triage labels - -[one-line summary of the label vocabulary]. See `docs/agents/triage-labels.md`. - -### Domain docs - -[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: - -- [issue-tracker-github.md](./issue-tracker-github.md) — GitHub 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 -- [triage-labels.md](./triage-labels.md) — label mapping -- [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. - -### 5. Done - -Tell the user the setup is complete and which engineering skills will now read from these files. Mention they can edit `docs/agents/*.md` directly later — re-running this skill is only necessary if they want to switch issue trackers or restart from scratch. diff --git a/.agents/skills/setup-matt-pocock-skills/domain.md b/.agents/skills/setup-matt-pocock-skills/domain.md deleted file mode 100644 index c97d6a6..0000000 --- a/.agents/skills/setup-matt-pocock-skills/domain.md +++ /dev/null @@ -1,51 +0,0 @@ -# Domain Docs - -How the engineering skills should consume this repo's domain documentation when exploring the codebase. - -## Before exploring, read these - -- **`CONTEXT.md`** at the repo root, or -- **`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//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. - -## File structure - -Single-context repo (most repos): - -``` -/ -├── CONTEXT.md -├── docs/adr/ -│ ├── 0001-event-sourced-orders.md -│ └── 0002-postgres-for-write-model.md -└── src/ -``` - -Multi-context repo (presence of `CONTEXT-MAP.md` at the root): - -``` -/ -├── CONTEXT-MAP.md -├── docs/adr/ ← system-wide decisions -└── src/ - ├── ordering/ - │ ├── CONTEXT.md - │ └── docs/adr/ ← context-specific decisions - └── billing/ - ├── CONTEXT.md - └── docs/adr/ -``` - -## Use the glossary's vocabulary - -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`). - -## Flag ADR conflicts - -If your output contradicts an existing ADR, surface it explicitly rather than silently overriding: - -> _Contradicts ADR-0007 (event-sourced orders) — but worth reopening because…_ diff --git a/.agents/skills/setup-matt-pocock-skills/issue-tracker-github.md b/.agents/skills/setup-matt-pocock-skills/issue-tracker-github.md deleted file mode 100644 index cce77ec..0000000 --- a/.agents/skills/setup-matt-pocock-skills/issue-tracker-github.md +++ /dev/null @@ -1,22 +0,0 @@ -# Issue tracker: GitHub - -Issues and PRDs for this repo live as GitHub issues. Use the `gh` CLI for all operations. - -## Conventions - -- **Create an issue**: `gh issue create --title "..." --body "..."`. Use a heredoc for multi-line bodies. -- **Read an issue**: `gh issue view --comments`, filtering comments by `jq` and also fetching labels. -- **List issues**: `gh issue list --state open --json number,title,body,labels,comments --jq '[.[] | {number, title, body, labels: [.labels[].name], comments: [.comments[].body]}]'` with appropriate `--label` and `--state` filters. -- **Comment on an issue**: `gh issue comment --body "..."` -- **Apply / remove labels**: `gh issue edit --add-label "..."` / `--remove-label "..."` -- **Close**: `gh issue close --comment "..."` - -Infer the repo from `git remote -v` — `gh` does this automatically when run inside a clone. - -## When a skill says "publish to the issue tracker" - -Create a GitHub issue. - -## When a skill says "fetch the relevant ticket" - -Run `gh issue view --comments`. diff --git a/.agents/skills/setup-matt-pocock-skills/issue-tracker-gitlab.md b/.agents/skills/setup-matt-pocock-skills/issue-tracker-gitlab.md deleted file mode 100644 index 1993c58..0000000 --- a/.agents/skills/setup-matt-pocock-skills/issue-tracker-gitlab.md +++ /dev/null @@ -1,23 +0,0 @@ -# Issue tracker: GitLab - -Issues and PRDs for this repo live as GitLab issues. Use the [`glab`](https://gitlab.com/gitlab-org/cli) CLI for all operations. - -## Conventions - -- **Create an issue**: `glab issue create --title "..." --description "..."`. Use a heredoc for multi-line descriptions. Pass `--description -` to open an editor. -- **Read an issue**: `glab issue view --comments`. Use `-F json` for machine-readable output. -- **List issues**: `glab issue list --state opened -F json` with appropriate `--label` filters. Note that GitLab uses `opened` (not `open`) for the state value. -- **Comment on an issue**: `glab issue note --message "..."`. GitLab calls comments "notes". -- **Apply / remove labels**: `glab issue update --label "..."` / `--unlabel "..."`. Multiple labels can be comma-separated or by repeating the flag. -- **Close**: `glab issue close `. `glab issue close` does not accept a closing comment, so post the explanation first with `glab issue note --message "..."`, then close. -- **Merge requests**: GitLab calls PRs "merge requests". Use `glab mr create`, `glab mr view`, `glab mr note`, etc. — the same shape as `gh pr ...` with `mr` in place of `pr` and `note`/`--message` in place of `comment`/`--body`. - -Infer the repo from `git remote -v` — `glab` does this automatically when run inside a clone. - -## When a skill says "publish to the issue tracker" - -Create a GitLab issue. - -## When a skill says "fetch the relevant ticket" - -Run `glab issue view --comments`. diff --git a/.agents/skills/setup-matt-pocock-skills/issue-tracker-local.md b/.agents/skills/setup-matt-pocock-skills/issue-tracker-local.md deleted file mode 100644 index a2f08fb..0000000 --- a/.agents/skills/setup-matt-pocock-skills/issue-tracker-local.md +++ /dev/null @@ -1,19 +0,0 @@ -# Issue tracker: Local Markdown - -Issues and PRDs for this repo live as markdown files in `.scratch/`. - -## Conventions - -- One feature per directory: `.scratch//` -- The PRD is `.scratch//PRD.md` -- Implementation issues are `.scratch//issues/-.md`, numbered from `01` -- 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 - -## When a skill says "publish to the issue tracker" - -Create a new file under `.scratch//` (creating the directory if needed). - -## 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. diff --git a/.agents/skills/setup-matt-pocock-skills/triage-labels.md b/.agents/skills/setup-matt-pocock-skills/triage-labels.md deleted file mode 100644 index b716855..0000000 --- a/.agents/skills/setup-matt-pocock-skills/triage-labels.md +++ /dev/null @@ -1,15 +0,0 @@ -# Triage Labels - -The skills speak in terms of five canonical triage roles. This file maps those roles to the actual label strings used in this repo's issue tracker. - -| Label in mattpocock/skills | Label in our tracker | Meaning | -| -------------------------- | -------------------- | ---------------------------------------- | -| `needs-triage` | `needs-triage` | Maintainer needs to evaluate this issue | -| `needs-info` | `needs-info` | Waiting on reporter for more information | -| `ready-for-agent` | `ready-for-agent` | Fully specified, ready for an AFK agent | -| `ready-for-human` | `ready-for-human` | Requires human implementation | -| `wontfix` | `wontfix` | Will not be actioned | - -When a skill mentions a role (e.g. "apply the AFK-ready triage label"), use the corresponding label string from this table. - -Edit the right-hand column to match whatever vocabulary you actually use. diff --git a/.agents/skills/tdd/SKILL.md b/.agents/skills/tdd/SKILL.md deleted file mode 100644 index 7a98941..0000000 --- a/.agents/skills/tdd/SKILL.md +++ /dev/null @@ -1,109 +0,0 @@ ---- -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. ---- - -# Test-Driven Development - -## Philosophy - -**Core principle**: Tests should verify behavior through public interfaces, not implementation details. Code can change entirely; tests shouldn't. - -**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. - -**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. - -See [tests.md](tests.md) for examples and [mocking.md](mocking.md) for mocking guidelines. - -## Anti-Pattern: Horizontal Slices - -**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." - -This produces **crap tests**: - -- Tests written in bulk test _imagined_ behavior, not _actual_ behavior -- 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. - -``` -WRONG (horizontal): - RED: test1, test2, test3, test4, test5 - GREEN: impl1, impl2, impl3, impl4, impl5 - -RIGHT (vertical): - RED→GREEN: test1→impl1 - RED→GREEN: test2→impl2 - RED→GREEN: test3→impl3 - ... -``` - -## Workflow - -### 1. Planning - -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 -``` diff --git a/.agents/skills/tdd/deep-modules.md b/.agents/skills/tdd/deep-modules.md deleted file mode 100644 index 0d9720c..0000000 --- a/.agents/skills/tdd/deep-modules.md +++ /dev/null @@ -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? diff --git a/.agents/skills/tdd/interface-design.md b/.agents/skills/tdd/interface-design.md deleted file mode 100644 index a0a20ca..0000000 --- a/.agents/skills/tdd/interface-design.md +++ /dev/null @@ -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 diff --git a/.agents/skills/tdd/refactoring.md b/.agents/skills/tdd/refactoring.md deleted file mode 100644 index 8a44439..0000000 --- a/.agents/skills/tdd/refactoring.md +++ /dev/null @@ -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 diff --git a/.agents/skills/to-issues/SKILL.md b/.agents/skills/to-issues/SKILL.md deleted file mode 100644 index 5a40716..0000000 --- a/.agents/skills/to-issues/SKILL.md +++ /dev/null @@ -1,81 +0,0 @@ ---- -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. ---- - -# To Issues - -Break a plan into independently-grabbable issues using vertical slices (tracer bullets). - -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 an issue reference (issue number, URL, or path) as an argument, fetch it from the issue tracker 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. Issue titles and descriptions should use the project's domain glossary vocabulary, and respect ADRs in the area you're touching. - -### 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. - -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. - - -- 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 -- Prefer many thin slices over few thick ones - - -### 4. Quiz the user - -Present the proposed breakdown as a numbered list. For each slice, show: - -- **Title**: short descriptive name -- **Type**: HITL / AFK -- **Blocked by**: which other slices (if any) must complete first -- **User stories covered**: which user stories this addresses (if the source material has them) - -Ask the user: - -- Does the granularity feel right? (too coarse / too fine) -- Are the dependency relationships correct? -- Should any slices be merged or split further? -- Are the correct slices marked as HITL and AFK? - -Iterate until the user approves the breakdown. - -### 5. Publish the issues to the issue tracker - -For each approved slice, publish a new issue to the issue tracker. Use the issue body template below. Apply the `needs-triage` triage label so each issue enters the normal triage flow. - -Publish issues in dependency order (blockers first) so you can reference real issue identifiers in the "Blocked by" field. - - -## Parent - -A reference to the parent issue on the issue tracker (if the source was an existing issue, otherwise omit this section). - -## What to build - -A concise description of this vertical slice. Describe the end-to-end behavior, not layer-by-layer implementation. - -## Acceptance criteria - -- [ ] Criterion 1 -- [ ] Criterion 2 -- [ ] Criterion 3 - -## Blocked by - -- A reference to the blocking ticket (if any) - -Or "None - can start immediately" if no blockers. - - - -Do NOT close or modify any parent issue. diff --git a/.agents/skills/triage/SKILL.md b/.agents/skills/triage/SKILL.md deleted file mode 100644 index 3dee68f..0000000 --- a/.agents/skills/triage/SKILL.md +++ /dev/null @@ -1,103 +0,0 @@ ---- -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. ---- - -# Triage - -Move issues on the project issue tracker through a small state machine of triage roles. - -Every comment or issue posted to the issue tracker during triage **must** start with this disclaimer: - -``` -> *This was generated by AI during triage.* -``` - -## Reference docs - -- [AGENT-BRIEF.md](AGENT-BRIEF.md) — how to write durable agent briefs -- [OUT-OF-SCOPE.md](OUT-OF-SCOPE.md) — how the `.out-of-scope/` knowledge base works - -## Roles - -Two **category** roles: - -- `bug` — something is broken -- `enhancement` — new feature or improvement - -Five **state** roles: - -- `needs-triage` — maintainer needs to evaluate -- `needs-info` — waiting on reporter for more information -- `ready-for-agent` — fully specified, ready for an AFK agent -- `ready-for-human` — needs human implementation -- `wontfix` — will not be actioned - -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. - -State transitions: an unlabeled issue normally goes to `needs-triage` first; from there it moves to `needs-info`, `ready-for-agent`, `ready-for-human`, or `wontfix`. `needs-info` returns to `needs-triage` once the reporter replies. The maintainer can override at any time — flag transitions that look unusual and ask before proceeding. - -## Invocation - -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" -- "Let's look at #42" -- "Move #42 to ready-for-agent" -- "What's ready for agents to pick up?" - -## Show what needs attention - -Query the issue tracker and present three buckets, oldest first: - -1. **Unlabeled** — never triaged. -2. **`needs-triage`** — evaluation in progress. -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. - -## Triage a specific issue - -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. - -2. **Recommend.** Tell the maintainer your category and state recommendation with reasoning, plus a brief codebase summary relevant to the issue. Wait for direction. - -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. - -4. **Grill (if needed).** If the issue needs fleshing out, run a `/grill-with-docs` session. - -5. **Apply the outcome:** - - `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). - - `needs-info` — post triage notes (template below). - - `wontfix` (bug) — polite explanation, then close. - - `wontfix` (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. - -## Quick state override - -If the maintainer says "move #42 to ready-for-agent", trust them and apply the role directly. Confirm what you're about to do (role changes, comment, close), then act. Skip grilling. If moving to `ready-for-agent` without a grilling session, ask whether they want to write an agent brief. - -## Needs-info template - -```markdown -## Triage Notes - -**What we've established so far:** - -- point 1 -- point 2 - -**What we still need from you (@reporter):** - -- question 1 -- question 2 -``` - -Capture everything resolved during grilling under "established so far" so the work isn't lost. Questions must be specific and actionable, not "please provide more info". - -## 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. diff --git a/.agents/skills/write-a-skill/SKILL.md b/.agents/skills/write-a-skill/SKILL.md deleted file mode 100644 index 7339c8a..0000000 --- a/.agents/skills/write-a-skill/SKILL.md +++ /dev/null @@ -1,117 +0,0 @@ ---- -name: write-a-skill -description: Create new agent skills with proper structure, progressive disclosure, and bundled resources. Use when user wants to create, write, or build a new skill. ---- - -# Writing Skills - -## Process - -1. **Gather requirements** - ask user about: - - What task/domain does the skill cover? - - What specific use cases should it handle? - - Does it need executable scripts or just instructions? - - Any reference materials to include? - -2. **Draft the skill** - create: - - SKILL.md with concise instructions - - Additional reference files if content exceeds 500 lines - - Utility scripts if deterministic operations needed - -3. **Review with user** - present draft and ask: - - Does this cover your use cases? - - Anything missing or unclear? - - Should any section be more/less detailed? - -## Skill Structure - -``` -skill-name/ -├── SKILL.md # Main instructions (required) -├── REFERENCE.md # Detailed docs (if needed) -├── EXAMPLES.md # Usage examples (if needed) -└── scripts/ # Utility scripts (if needed) - └── helper.js -``` - -## SKILL.md Template - -```md ---- -name: skill-name -description: Brief description of capability. Use when [specific triggers]. ---- - -# Skill Name - -## Quick start - -[Minimal working example] - -## Workflows - -[Step-by-step processes with checklists for complex tasks] - -## Advanced features - -[Link to separate files: See [REFERENCE.md](REFERENCE.md)] -``` - -## Description Requirements - -The description is **the only thing your agent sees** when deciding which skill to load. It's surfaced in the system prompt alongside all other installed skills. Your agent reads these descriptions and picks the relevant skill based on the user's request. - -**Goal**: Give your agent just enough info to know: - -1. What capability this skill provides -2. When/why to trigger it (specific keywords, contexts, file types) - -**Format**: - -- Max 1024 chars -- Write in third person -- First sentence: what it does -- Second sentence: "Use when [specific triggers]" - -**Good example**: - -``` -Extract text and tables from PDF files, fill forms, merge documents. Use when working with PDF files or when user mentions PDFs, forms, or document extraction. -``` - -**Bad example**: - -``` -Helps with documents. -``` - -The bad example gives your agent no way to distinguish this from other document skills. - -## When to Add Scripts - -Add utility scripts when: - -- Operation is deterministic (validation, formatting) -- Same code would be generated repeatedly -- Errors need explicit handling - -Scripts save tokens and improve reliability vs generated code. - -## When to Split Files - -Split into separate files when: - -- SKILL.md exceeds 100 lines -- Content has distinct domains (finance vs sales schemas) -- Advanced features are rarely needed - -## Review Checklist - -After drafting, verify: - -- [ ] Description includes triggers ("Use when...") -- [ ] SKILL.md under 100 lines -- [ ] No time-sensitive info -- [ ] Consistent terminology -- [ ] Concrete examples included -- [ ] References one level deep diff --git a/.agents/skills/zoom-out/SKILL.md b/.agents/skills/zoom-out/SKILL.md deleted file mode 100644 index 1e7a5dc..0000000 --- a/.agents/skills/zoom-out/SKILL.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -name: zoom-out -description: Tell the agent to zoom out and give broader context or a higher-level perspective. Use when you're unfamiliar with a section of code or need to understand how it fits into the bigger picture. -disable-model-invocation: true ---- - -I don't know this area of code well. Go up a layer of abstraction. Give me a map of all the relevant modules and callers, using the project's domain glossary vocabulary. diff --git a/.claude/skills/ask-imick/PHASE-BOUNDARIES.md b/.claude/skills/ask-imick/PHASE-BOUNDARIES.md new file mode 100644 index 0000000..fb58ef9 --- /dev/null +++ b/.claude/skills/ask-imick/PHASE-BOUNDARIES.md @@ -0,0 +1,55 @@ +# Phase boundaries + +A **phase** is a chunk of work inside a session: the grilling, the implementation, the QA. The definition is fuzzy on purpose: a phase ends when you think *"ok, we're done with that"*. + +The **phase boundary** is the gap between two phases, and it is the only place this decision belongs. Mid-phase there is no decision to make: continue, or split the work that's left into subagents. Compacting mid-phase makes the agent lose the thread. + +## The five options + +| Option | What it does | +| ------------ | --------------------------------------------------------------- | +| **Continue** | Stay in the session. No context switch at all. | +| **`/clear`** | Empty the context window and start from nothing. | +| **`/handoff`** | Write a portable markdown file and seed a session anywhere with it. | +| **Subagent** | Send the task to its own context window and get a report back. | +| **`/compact`** | Compress this context and seed a fresh session with the summary. | + +## The tree + +Work top to bottom at the boundary. The first **yes** wins. + +**1. Can you continue in this session?** Two things make the answer yes: the next phase needs this phase as a **primary source**, or you have enough [smart zone](https://www.aihero.dev/ai-coding-dictionary/smart-zone) left (~150k tokens) for the next phase to fit. Grilling → implementation is the standard yes: the implementation wants the reasoning verbatim, not a summary of it. Continue costs nothing and loses nothing, so rule it out before anything else. + +**2. Is the context irrelevant to what comes next?** Is everything in this session (the exploration, the decisions, the dead ends) disposable? If so, **`/clear`**. It is the cheapest move on the board: it takes no time and hands back the whole window. `/clear` also isn't terminal: the old session stays resumable. + +The cost of getting this wrong is one-way. Clear a *relevant* context and you lose the **why** behind what you built, and no amount of reading the diff back gets it returned. + +**3. Do you need to hand off?** `/handoff` is narrow. You need it only when you are: + +- swapping to a **new harness** (Claude → Codex), +- moving to a **new directory** or repo, +- sending the work to a **colleague**, +- or forking a side task you found **mid-phase** without derailing what you're doing. + +That list is the whole clause. What `/handoff` buys is **portability**: a file that travels. If nothing is travelling, you don't need it. + +**4. Can the task be done AFK?** Is it scoped tightly enough to run with you away from the keyboard, no steering? Then send it to a **subagent** and leave this session untouched. Automated review is the standard case: the agent reads the diff and reports, and you aren't needed while it does. + +**5. Otherwise, `/compact`.** Relevant context, same harness, same directory, and you need to stay in the loop: this is where the tree lands, and it lands here often. Pass it an instruction (`/compact we're going to QA this area`) so the summary keeps what the next phase needs. + +`/compact` is the **default, not the first reach**. It sits at the bottom because the four questions above it are all cheaper or more precise. The failure mode when people start here is a fresh session that is confidently wrong about a decision the summary flattened. + +## Primary and secondary sources + +Every move except **Continue** turns a **primary source** into a **secondary source**: the session as it happened, replaced by a summary of it. The trade is always the same shape: + +| Source | Information | Noise | Room to move | +| --------------------------------- | ----------- | ----- | ------------ | +| Primary (Continue) | Full | Lots | Little | +| Secondary (`/compact`, `/handoff`) | Lossy | Less | Lots | + +This is why question 1 comes first. You only pay the lossiness when staying costs more than it saves. + +## These are judgement calls + +The questions are not objective: each has taste in it, and the same boundary can go two ways on two days. The value is in asking them **in order**, at the boundary rather than in the middle of the work. diff --git a/.claude/skills/ask-imick/SKILL.md b/.claude/skills/ask-imick/SKILL.md new file mode 100644 index 0000000..25b3ff6 --- /dev/null +++ b/.claude/skills/ask-imick/SKILL.md @@ -0,0 +1,104 @@ +--- +name: ask-imick +description: Ask which skill or flow fits your situation. A router over the skills in this repo. +disable-model-invocation: true +--- + +# Ask iMick + +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`** sharpens the idea by interview. Start here whenever you are **working in a working directory**: it's stateful, retaining what it learns in `GLOSSARY.md` and ADRs. (No working directory? Use `/grill-me` instead, covered under Standalone. Both run the same `/grilling` primitive; `grill-with-docs` is the one that leaves a paper trail, which makes it the better of the two whenever a repo is there to leave it in.) +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 (a prototype lives in its own directory, which is exactly what `/handoff` is for; see Phase boundaries): + - **`/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**. Then work the tickets one of two ways: + - **`/implement`** per ticket, **`/clear`ing context between each one**. On a local tracker that's one file per ticket under `.scratch//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. Each ticket is self-contained, so the last one's context is disposable. + - **`/implement-spec`** for the whole spec in one run. It reads the tickets as a **task graph**, runs implementer subagents across the ready **frontier** in parallel, and lands everything on one **integration branch**. Reach for it when you'd rather orchestrate the build than drive each ticket yourself. + - **No** → **`/implement`** right here, in the same context window. + + Either way, the code gets built by driving **`/tdd`** (one red-green slice at a time) and closes out with **`/code-review`**, a two-axis review (Standards + Spec) of the diff. `/implement` runs both per ticket; `/implement-spec`'s implementers each drive `/tdd`, and it runs one `/code-review` over the integration branch. 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. + + When the work goes up as a pull request, **`/pr`** shapes the body: the smallest visual that shows the change, before/after evidence that it works, and a one-way or two-way door call. It's model-invoked, so the agent reaches for it whenever it writes a PR. + +4. **`/retro`** closes the loop. After a build, and especially one that went sideways, it looks back over the session and suggests changes to the agent's **environment**, not the code: navigation pointers, automated checks, the coding standards `/code-review` enforces, steering files, tooling. Mechanical mistakes become deterministic checks; judgement calls become coding standards. The next build then starts from a better environment. + +### 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. Run `/retro` in the session it's looking back on, before you clear; after clearing, point it at that session's log instead. + +The limit on this is the **[smart zone](https://www.aihero.dev/ai-coding-dictionary/smart-zone)**: the window (~150k 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; `/compact` at the nearest phase boundary and carry on (see Phase boundaries). + +## On-ramps + +A starting situation that generates work, then merges onto the main flow. + +- **Bugs and requests piling up** → **`/triage`**. It labels each issue with what it is and who acts next, writes agent briefs, and routes big asks to `/scope-decomposer` (`needs-scoping`). With automatic triage installed (`/setup-imick-skills`), a workflow runs it on every new issue; `/triage` by hand is then the maintainer's review and override. + + 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**. + +- **Bugs waiting in the debugging queue** → **`/debug-and-fix`**. Triage labels confirmed bugs `ready-for-agent-debugging`; this takes one (`/debug-and-fix #42`, or the oldest unclaimed), claims it, runs **`/diagnosing-bugs`** on it (reproducing UI bugs live in the browser), and fixes it with a regression test and a PR when the diagnosis is clean. Otherwise it leaves the diagnosis for a person. Either way the issue ends with the outcome's labels: `ready-for-review`, `ready-for-human`, or `needs-info` back to the reporter. + +- **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. Once the fix is in, run **`/retro`** in the same session to ask what would have prevented the bug; where the real finding is that there's no good seam to lock it down, that's a job for **`/improve-codebase-architecture`**. + +- **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. + + Before an epic is planned, **`/brief`** it: a short, high-level grilling where you say what you already have in mind (must-haves, no-gos, the big product calls), ending with **manual or autopilot**. An `autopilot` epic is planned by the agent loop alone (your brief's lines as decided, confident answers directly, uncertain ones after `/dig`, the rest marked *assumed*), and stops at the spec for your approval. + + 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, so go straight to `/implement` only when the effort turned out genuinely small. + +- **An idea too big even for one map: a whole product, an MVP, a broad issue (often one triage labelled `needs-scoping`)** → **`/scope-decomposer`**. It interviews you at the high level, then breaks the idea into an **initiative** of **epics** on the issue tracker, each with one destination, one owning area, its own milestone and branch, and blocking edges between them. It never plans inside an epic: each epic waits for its **`/brief`**, then is exactly the input one **`/wayfinder`** map takes, in build order. Run it again on the initiative to add, split or merge epics that don't have a map yet. + +- **You need to see it** → **`/product-design`**, for an epic's UI. When words leave a feature abstract, it builds the real UI with you in the product itself, at the feature's real route on the epic branch: first a fast mockup on mock data, iterated live in the browser until you say "we agree", then `/to-spec` and `/to-tickets` turn the agreed mockup into production tickets. Call it at any point in an epic's life: before its map to see where you're landing, during the map when a decision needs a screen, or after. Where **`/prototype`** throws its code away once a question is answered, `/product-design` keeps it and grows it into production, and calls `/prototype` itself when you need variants to pick from. + +## Codebase health + +Not feature work, just upkeep. + +- **`/improve-codebase-architecture`** runs 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 `GLOSSARY.md` a clean glossary. +- **`/codebase-design`** is 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. + +## Phase boundaries + +A **phase** is a chunk of work inside a session: the grilling, the implementation, the QA. At the **boundary** between two of them you have five options, and picking between them is the fuzziest decision in this whole map: + +- **Continue**: stay put. Costs nothing, loses nothing. +- **`/clear`**: empty the window, when nothing here matters to what's next. +- **`/handoff`** writes a portable markdown file. Narrow: only for a **new harness**, a **new directory**, a **colleague**, or forking a side task **mid-phase**. What it buys is portability. +- **Subagent**: send a tightly-scoped task to its own window and get a report back. +- **`/compact`** compresses this context and seeds a fresh session with it. The **default**, at the bottom of the tree rather than the first reach. + +Read [PHASE-BOUNDARIES.md](PHASE-BOUNDARIES.md) for the ordered tree: the five questions, the reasoning behind each branch, and why the primary-source cost makes **Continue** the one to rule out first. Make the decision **at** a boundary; mid-phase, continue or split the rest into subagents. + +## Standalone + +Off the main flow entirely. + +- **`/grill-me`**: the same relentless interview as `/grill-with-docs`, but **stateless**: it saves nothing locally and builds no `GLOSSARY.md`. Reach for it when you are **not working in a working directory** (sharpening a plan, a design, a piece of writing, anything with no repo under it). If you are in a working directory, use `/grill-with-docs` instead: it runs the same interview and leaves a paper trail, so it is strictly the better one. +- **`/grilling`** is the interview primitive itself: rounds, the frontier, facts are the agent's job and decisions are yours. `/grill-me` and `/grill-with-docs` are the two named ways in, and `/triage`, `/wayfinder`, `/scope-decomposer` and `/improve-codebase-architecture` all run it internally. Reach for it directly only when you want the interview with no wrapper around it. +- **`/prototype`** is a small, throwaway program that answers one design question: does this state model feel right, or what should this UI look like. Throwaway is a constraint on how the code is written, not a promise to destroy it: the answer folds into the real code, and the prototype itself is kept as a **primary source** on a `prototype/` branch out of main, pointed at from the implementation issue. 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. +- **`/dig`**: mid-grilling, when one question needs more than instinct (`/dig Q3`, or a bare `/dig` for the round's lowest-confidence one). A background agent works out why it matters, the options, and what your competitors do (from `docs/agents/competitors.md`, asked once per project), and the brief comes back as a sharper recommendation while the round carries on. Where `/research` establishes what is true, `/dig` helps you choose. +- **`/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`, since research feeds the thinking rather than replacing it. +- **`/to-questionnaire`** comes in when the thing blocking you isn't in your head or the codebase but in **someone else's**, and it writes them a questionnaire to fill in. It's the inverse of `/grill-me`: instead of interviewing you about the subject, it interviews you about the **send** (who it's going to, what you need back) and aims the questions at the gap. What comes back is material for `/grill-with-docs` or `/to-spec`. +- **`/wizard`** is for the steps only a **human** can take: provisioning infrastructure, setting up credentials or CI secrets, clicking through an unfamiliar third-party dashboard, running a one-off migration or cutover. It generates an interactive bash script that opens each URL, captures each value, and writes it into `.env` and GitHub secrets, so the procedure stops being something you re-explain to an agent every time. Model-invoked, so the agent reaches for it the moment it hits a wall only you can pass. If the agent could just do it itself, it should; this is for where a human is genuinely in the loop. +- **`/wait-what`** is the corrective for a message that didn't land. Use it mid-conversation, inside any other skill, and the agent re-pitches what it just said with the context you were missing, in plain English, using the `GLOSSARY.md` vocabulary. It works after the fact; `/grill-with-docs` is the upfront cure, because a shared language agreed early is what stops the jargon arriving at all. +- **`/teach`**: learn a concept over multiple sessions, using the current directory as a stateful workspace. +- **`/writing-for-agents`** is the reference for writing documents agents consume: skills, AGENTS.md, pointed-at docs. + +## Precondition + +**`/setup-imick-skills`**: run before your first engineering flow to configure the issue tracker, triage labels, doc layout, and the areas and teams (`team.md`) the other skills assume. Custom issue trackers also work. diff --git a/.claude/skills/ask-imick/agents/openai.yaml b/.claude/skills/ask-imick/agents/openai.yaml new file mode 100644 index 0000000..68c48d5 --- /dev/null +++ b/.claude/skills/ask-imick/agents/openai.yaml @@ -0,0 +1,5 @@ +interface: + display_name: "Ask iMick" + short_description: "Find the right skill or workflow" +policy: + allow_implicit_invocation: false diff --git a/.claude/skills/brief/SKILL.md b/.claude/skills/brief/SKILL.md new file mode 100644 index 0000000..cac366a --- /dev/null +++ b/.claude/skills/brief/SKILL.md @@ -0,0 +1,60 @@ +--- +name: brief +description: Brief an epic before it's planned - a short, high-level grill-with-docs session that captures what you already have in mind, then choose whether wayfinder runs on it manually or on autopilot. +disable-model-invocation: true +--- + +# Brief + +`/scope-decomposer` sets an epic's boundaries; it doesn't know what's in the human's head about it: the must-haves they take for granted, the things they'd never want, the product calls they've already made. A **brief** gets that out before planning starts, so `/wayfinder` (manual or autopilot) starts from the human's intent instead of guessing it. + +Every epic `/scope-decomposer` creates carries `needs-briefing` and `ready-for-human`. A brief removes both, and leaves the epic on **manual** or **autopilot**. On a supersonic project, `/scope-decomposer` writes the briefs itself in its one interview; `/brief` is then only for an epic it left with `needs-briefing`. + +The tracker operations are in the tracker doc's **Initiatives and epics** section; the label strings are in `docs/agents/triage-labels.md`. If they don't exist, tell the user to run `/setup-imick-skills`. + +## Run + +1. **Pick the epic.** `/brief ` is that epic. A bare `/brief` takes the next open epic labelled `needs-briefing`, in build order (its milestone number), skipping any still blocked by an unbriefed one. Read it with its initiative, and the epics it touches. + +2. **Grill, high level.** Call the Skill tool twice, for "grilling" and "domain-modeling", and run a short session on this epic only, working in `GLOSSARY.md` and ADRs as `grill-with-docs` does. Stay at the level that changes the product: + - who it's for, and the job it does for them, + - the **must-haves** ("invite a partner by email to a shared budget"), + - the **no-gos** ("no bank connections in v1"), + - the **big product calls** ("shared or single-user?", "monthly or weekly first?"), + - anything **already decided** (a service, a stack choice, a reference product), + - on a **local-first** initiative (its Destination says so), any real service this epic can't fake. By default it uses local stand-ins only; carry that into **Already decided** as "Local first: no hosted services or accounts; local stand-ins only", naming any core integration that is the exception. + + Leave everything an agent can decide alone (which date picker, the empty-state copy) to wayfinder. A few rounds is the norm. Done when nothing the human has in mind about this epic is left unsaid: ask "anything else you already know you want or don't want here?" before moving on. + +3. **Check the scope.** A must-have that doesn't fit this epic's destination ("invitations" with roles, permissions and emails, inside a "Monthly view" epic) is a new epic, not a bullet. Say so, and suggest `/scope-decomposer ` to add it; note it under the brief's **Not here** list rather than stretching this epic. + +4. **Write the Brief**, as a section of the epic's body, after the Destination: + + ```markdown + ## Brief + + **Must have** + - <...> + + **Must not** + - <...> + + **Preferences** + - <...> + + **Already decided** + - (ADR: ) + + **Not here** + - + ``` + + Omit empty headings. Each line is the human's decision: wayfinder takes it as settled, at 100%, in either mode. + +5. **Choose the mode.** Ask, as the last question: + + > **Autopilot or manual** for this epic? On autopilot, the agent loop runs wayfinder on it by itself, decides what the brief leaves open (researching what it's unsure of), and stops at the spec for your approval. On manual, you run `/wayfinder` on it. + + Then remove `needs-briefing` and `ready-for-human`, and add `autopilot` when chosen. On autopilot, in a project whose loop isn't already in fast mode, mention **fast** too: with the `fast` label the loop also answers what would wait on them when it's confident enough, approves a confident spec and merges the verified epic, pinging them in Slack only for what it can't settle. **Supersonic** (the `supersonic` label) goes further for throwaway work: below the threshold it assumes reversible calls instead of asking, always approves the spec, and reports its assumptions in a daily digest. + +6. **Hand off.** Report the brief and the mode, then the next step: "The agent loop will plan it" (autopilot) or "Run `/wayfinder ` when you're ready" (manual). If more epics still need briefing, name the next one. diff --git a/.claude/skills/caveman b/.claude/skills/caveman deleted file mode 120000 index 9016aac..0000000 --- a/.claude/skills/caveman +++ /dev/null @@ -1 +0,0 @@ -../../.agents/skills/caveman \ No newline at end of file diff --git a/.claude/skills/code-review/SKILL.md b/.claude/skills/code-review/SKILL.md new file mode 100644 index 0000000..0f1a115 --- /dev/null +++ b/.claude/skills/code-review/SKILL.md @@ -0,0 +1,87 @@ +--- +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/spec 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 / 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. If `docs/agents/issue-tracker.md` is missing, tell the user to run `/setup-imick-skills`. + +## 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 ...HEAD` (three-dot, so the comparison is against the merge-base). Also note the list of commits via `git log ..HEAD --oneline`. + +Before going further, confirm the fixed point resolves (`git rev-parse `) 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.), fetched via the workflow in `docs/agents/issue-tracker.md`. +2. A path the user passed as an argument. +3. A 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. 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 + +**Standards sub-agent prompt** should 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** should 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, because 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. diff --git a/.claude/skills/code-review/agents/openai.yaml b/.claude/skills/code-review/agents/openai.yaml new file mode 100644 index 0000000..9076774 --- /dev/null +++ b/.claude/skills/code-review/agents/openai.yaml @@ -0,0 +1,3 @@ +interface: + display_name: "Code Review" + short_description: "Review a diff on standards and spec" diff --git a/.agents/skills/improve-codebase-architecture/DEEPENING.md b/.claude/skills/codebase-design/DEEPENING.md similarity index 80% rename from .agents/skills/improve-codebase-architecture/DEEPENING.md rename to .claude/skills/codebase-design/DEEPENING.md index ecaf5d7..cd94075 100644 --- a/.agents/skills/improve-codebase-architecture/DEEPENING.md +++ b/.claude/skills/codebase-design/DEEPENING.md @@ -1,6 +1,6 @@ # 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 @@ -8,7 +8,7 @@ When assessing a candidate for deepening, classify its dependencies. The categor ### 1. In-process -Pure computation, in-memory state, no I/O. Always deepenable — merge the modules and test through the new interface directly. No adapter needed. +Pure computation, in-memory state, no I/O. Always deepenable: merge the modules and test through the new interface directly. No adapter needed. ### 2. Local-substitutable @@ -31,7 +31,7 @@ Third-party services (Stripe, Twilio, etc.) you don't control. The deepened modu ## Testing strategy: replace, don't layer -- Old unit tests on shallow modules become waste once tests at the deepened module's interface exist — delete them. +- Old unit tests on shallow modules become waste once tests at the deepened module's interface exist; delete them. - Write new tests at the deepened module's interface. The **interface is the test surface**. - Tests assert on observable outcomes through the interface, not internal state. -- Tests should survive internal refactors — they describe behaviour, not implementation. If a test has to change when the implementation changes, it's testing past the interface. +- Tests should survive internal refactors, since they describe behaviour, not implementation. If a test has to change when the implementation changes, it's testing past the interface. diff --git a/.agents/skills/improve-codebase-architecture/INTERFACE-DESIGN.md b/.claude/skills/codebase-design/DESIGN-IT-TWICE.md similarity index 56% rename from .agents/skills/improve-codebase-architecture/INTERFACE-DESIGN.md rename to .claude/skills/codebase-design/DESIGN-IT-TWICE.md index 3197723..d099013 100644 --- a/.agents/skills/improve-codebase-architecture/INTERFACE-DESIGN.md +++ b/.claude/skills/codebase-design/DESIGN-IT-TWICE.md @@ -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 @@ -12,33 +12,33 @@ Before spawning sub-agents, write a user-facing explanation of the problem space - The constraints any new interface would need to satisfy - The dependencies it would rely on, and which category they fall into (see [DEEPENING.md](DEEPENING.md)) -- A rough illustrative code sketch to ground the constraints — not a proposal, just a way to make the constraints concrete +- A rough illustrative code sketch to ground the constraints, not a proposal, just a way to make the constraints concrete Show this to the user, then immediately proceed to Step 2. The user reads and thinks while the sub-agents work in parallel. ### 2. Spawn sub-agents -Spawn 3+ sub-agents in parallel using the Agent tool. Each must produce a **radically different** interface for the deepened module. +Spawn 3+ sub-agents in parallel. Each must produce a **radically different** interface for the deepened module. Prompt each sub-agent with a separate technical brief (file paths, coupling details, dependency category from [DEEPENING.md](DEEPENING.md), what sits behind the seam). The brief is independent of the user-facing problem-space explanation in Step 1. Give each agent a different design constraint: -- Agent 1: "Minimize the interface — aim for 1–3 entry points max. Maximise leverage per entry point." -- Agent 2: "Maximise flexibility — support many use cases and extension." -- Agent 3: "Optimise for the most common caller — make the default case trivial." +- Agent 1: "Minimize the interface: aim for 1–3 entry points max. Maximise leverage per entry point." +- Agent 2: "Maximise flexibility: support many use cases and extension." +- 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." -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 GLOSSARY.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: -1. Interface (types, methods, params — plus invariants, ordering, error modes) +1. Interface (types, methods, params, plus invariants, ordering, error modes) 2. Usage example showing how callers use it 3. What the implementation hides behind the seam 4. Dependency strategy and adapters (see [DEEPENING.md](DEEPENING.md)) -5. Trade-offs — where leverage is high, where it's thin +5. Trade-offs: where leverage is high, where it's thin ### 3. Present and compare Present designs sequentially so the user can absorb each one, then compare them in prose. Contrast by **depth** (leverage at the interface), **locality** (where change concentrates), and **seam placement**. -After comparing, give your own recommendation: which design you think is strongest and why. If elements from different designs would combine well, propose a hybrid. Be opinionated — the user wants a strong read, not a menu. +After comparing, give your own recommendation: which design you think is strongest and why. If elements from different designs would combine well, propose a hybrid. Be opinionated: the user wants a strong read, not a menu. diff --git a/.claude/skills/codebase-design/SKILL.md b/.claude/skills/codebase-design/SKILL.md new file mode 100644 index 0000000..3f63c81 --- /dev/null +++ b/.claude/skills/codebase-design/SKILL.md @@ -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. diff --git a/.claude/skills/codebase-design/agents/openai.yaml b/.claude/skills/codebase-design/agents/openai.yaml new file mode 100644 index 0000000..3180715 --- /dev/null +++ b/.claude/skills/codebase-design/agents/openai.yaml @@ -0,0 +1,3 @@ +interface: + display_name: "Codebase Design" + short_description: "Vocabulary for deep-module design" diff --git a/.claude/skills/commit-review/SKILL.md b/.claude/skills/commit-review/SKILL.md deleted file mode 100644 index 6b7eb2f..0000000 --- a/.claude/skills/commit-review/SKILL.md +++ /dev/null @@ -1,41 +0,0 @@ ---- -name: commit-review -description: "Creates a refactor commit with `refactor:` prefix and `Refs #N` footer. Runs pnpm typecheck and pnpm test as a final gate. Use when user types /commit-review after reviewing /review-work output." ---- - -# Commit the refactor - -## Workflow - -1. **Final gate** — hard precondition. If either fails, stop and report; do not commit. - - `pnpm typecheck` - - `pnpm test` -2. **Inspect what's pending**: - - `git status` - - `git diff --staged` - - `git diff` -3. **Draft the commit message** (prefix is always `refactor:`): - - ``` - refactor: (#) - - - - Refs # - ``` - -4. **Show the user**: - - The draft message - - The list of files to be staged -5. **Wait for approval**, then: - - `git add ` (specific paths, never `git add -A`) - - `git commit -m ""` - -## Invariants - -- Prefix is always `refactor:`. If the staged diff contains new functionality or a bug fix, `/review-work` was used incorrectly — stop and tell the user instead of committing under the wrong prefix. -- Never commit without typecheck + test passing. -- Never use `Closes`/`Fixes`/`Resolves` — only `Refs`. -- Never `git add -A` or `git add .`. -- Never push. -- Do not switch branches. diff --git a/.claude/skills/commit-work/SKILL.md b/.claude/skills/commit-work/SKILL.md deleted file mode 100644 index 0f14f4d..0000000 --- a/.claude/skills/commit-work/SKILL.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -name: commit-work -description: "Creates an implementation commit with a conventional commit message (feat:/fix:/chore:) chosen from the diff and the issue title. Footer references the issue with `Refs #N` (never `Closes`, so the issue does not auto-close). Runs pnpm typecheck and pnpm test as a final gate. Use when user types /commit-work after reviewing /do-work output." ---- - -# Commit the implementation - -## Workflow - -1. **Final gate** — hard precondition. If either fails, stop and report; do not commit. - - `pnpm typecheck` - - `pnpm test` -2. **Inspect what's pending**: - - `git status` - - `git diff --staged` - - `git diff` -3. **Determine the prefix** from the issue title (in conversation context from `/plan-work`) plus the diff: - - `feat:` — adds a new user-facing capability - - `fix:` — corrects a bug or incorrect behaviour - - `chore:` — config, dependency, or tooling change -4. **Draft the commit message** in this shape: - - ``` - : (#) - - - - Refs # - ``` - - Use `Refs #N`. Never `Closes #N` or `Fixes #N` — the user closes issues manually. - -5. **Show the user**: - - The draft message - - The list of files to be staged -6. **Wait for approval**, then: - - `git add ` (specific paths, never `git add -A` or `git add .`) - - `git commit -m ""` - -## Invariants - -- Never commit without typecheck + test passing. -- Never use `Closes`/`Fixes`/`Resolves` — only `Refs`. -- Never `git add -A` or `git add .` — stage specific files only. -- Never push. -- Do not switch branches. diff --git a/.claude/skills/debug-and-fix/SKILL.md b/.claude/skills/debug-and-fix/SKILL.md new file mode 100644 index 0000000..0952b20 --- /dev/null +++ b/.claude/skills/debug-and-fix/SKILL.md @@ -0,0 +1,63 @@ +--- +name: debug-and-fix +description: Take a bug from the ready-for-agent-debugging queue, diagnose it with diagnosing-bugs (reproducing UI bugs in the browser), fix it with a regression test when the diagnosis is clean, and report the outcome on the issue with the right labels. +disable-model-invocation: true +--- + +# Debug and fix + +Triage labels each confirmed bug `bug` + `ready-for-agent-debugging`: the agents' debugging queue. This skill works one bug from that queue end to end. The debugging discipline lives in `diagnosing-bugs`; this skill wraps it with the tracker: claiming the bug, choosing where the fix goes, and leaving the issue with an outcome a person can act on. + +Read the tracker doc, `docs/agents/triage-labels.md` for the label strings, and `docs/agents/team.md`. If they don't exist, tell the user to run `/setup-imick-skills`. Every comment starts with: + +``` +> *This was generated by AI while debugging.* +``` + +## Run + +1. **Pick the bug.** `/debug-and-fix #42` is that issue. A bare `/debug-and-fix` takes the oldest open, unassigned issue labelled `ready-for-agent-debugging`. Skip anything already assigned: someone else has claimed it. + +2. **Claim it** before any other work: assign it to yourself (`gh issue edit --add-assignee @me`). Read the issue, its comments and the triage notes. + +3. **Choose the branch.** If the issue sits under an epic, check out the epic's branch (named in the epic's body). Otherwise create `fix/-` from the default branch. + +4. **Diagnose.** Call the Skill tool with "diagnosing-bugs", handing it the report: the symptom, the reporter's steps, the triage notes. For a bug the user sees in the UI it reproduces in the browser first ([its BROWSER.md](../diagnosing-bugs/BROWSER.md)). Follow it through Phase 5 when the diagnosis is **clean**: + - a red-capable loop reproduced the reporter's symptom, and the repro is minimised, + - the winning hypothesis is proven, not just plausible, + - a correct seam exists for the regression test. + + Anything short of clean stops before the fix: the outcome is a diagnosis for a person, not a guess shipped as a fix. + +5. **Land the outcome**, then remove `ready-for-agent-debugging`: + + | Outcome | Labels | Assignee | Comment | + | --- | --- | --- | --- | + | **Fixed** | `bug` + `ready-for-review` | stays you | Root cause, evidence, the regression test, and the PR | + | **Diagnosed, fix needs a person** (judgment call, no correct seam, risky change) | `bug` + `ready-for-human` | the area's default person | The full diagnosis: repro, evidence, proven cause, suggested fix, and why it stopped | + | **Can't reproduce** | `needs-info` + `ready-for-human` (replacing `bug`) | the reporter if a collaborator, else the area's default person | What was tried (browser, accounts, variations) and specific questions for the reporter | + | **Works as intended** | `wontfix` + `ready-for-human` (replacing `bug`) | the area's default person | Why, with evidence; a person confirms and closes it | + + **Fixed** means, by branch: + - **`fix/` branch**: commit the regression test and the fix, push, and open a PR whose body says `Fixes #` (call the Skill tool with "pr" for its shape). Merging the PR closes the issue. + - **Epic branch**: commit there and push; there is no separate PR. The fix has landed, so close the issue with the comment, linking the commit. + + A reporter's reply to a `needs-info` comment re-runs triage, which puts the bug back in this queue when it's reproducible. + +6. **Report** to the user: the outcome, the issue and PR by name with links, and the hypothesis that turned out correct. + +## The comment + +```markdown +> *This was generated by AI while debugging.* + +## + +**Reproduction:** +**Evidence:** +**Loop:** `` +**Cause:** +**Fix:** +``` + +For **can't reproduce**, replace Cause and Fix with what was tried and the questions for the reporter, in the triage notes' "What we still need from you" form. diff --git a/.claude/skills/diagnose b/.claude/skills/diagnose deleted file mode 120000 index 7d4b7c9..0000000 --- a/.claude/skills/diagnose +++ /dev/null @@ -1 +0,0 @@ -../../.agents/skills/diagnose \ No newline at end of file diff --git a/.claude/skills/diagnosing-bugs/BROWSER.md b/.claude/skills/diagnosing-bugs/BROWSER.md new file mode 100644 index 0000000..d696a3f --- /dev/null +++ b/.claude/skills/diagnosing-bugs/BROWSER.md @@ -0,0 +1,43 @@ +# Reproducing in the browser + +For a bug the user sees in the UI. You usually can't script it yet: you don't know the exact steps, state or data that trigger it. **Explore in a real browser until it shows up, then freeze what you did into a script.** The frozen script is your Phase 1 loop; the exploration is how you find it. + +## 1. Pick a browser + +Use the first one that works in this environment, and say which you're using: + +1. **Claude in Chrome** (the `mcp__claude-in-chrome__*` tools): the user's real Chrome. Best fidelity, since it sees what the user's browser sees. Work in a **new tab**, and never act on the user's own accounts beyond what reproducing needs. +2. **`agent-browser`**: call the Skill tool with "agent-browser" when Chrome isn't connected or available (an unattended run, a CI box, a remote session). +3. **Playwright MCP** (the `mcp__playwright__*` tools), when neither of the above is available. + +If none is available, fall back to writing a Playwright script blind from the reporter's steps (Phase 1, way 4), and say the reproduction was never observed live. + +## 2. Get to the bug + +- **Run the app**: the project's dev server (call the Skill tool with "run" when you don't know how), or the preview URL of the branch the bug was reported against. +- **Sign in** only with test accounts from the project's seed, fixture or example-config files, and only on a local or preview host. Never use the user's real credentials or a production account; if the bug only shows with real data, stop and ask. +- **Recreate the state** the report implies (the right page, data, role, viewport) before following the steps. + +## 3. Follow the reporter's steps + +Do exactly what the report says, one step at a time. After each step, take a screenshot and check the console and failed network requests. Watch for the **user's symptom**, not just any error: a nearby failure is a different bug. + +When the steps don't trigger it, vary one thing at a time (browser size, account role, data, timing, a hard reload) and note what you tried. + +## 4. Capture the evidence + +When it shows up, keep, redacted per the main skill: + +- the screenshot showing the symptom, +- the console errors and the failing requests (method, URL, status, the relevant lines of the response), +- the exact steps, starting URL and account role that got there. + +This is what goes into the bug report, and what the frozen script must match. + +## 5. Freeze it into the loop + +Turn the steps into a **Playwright script** (or test, if the project already has Playwright tests) that drives the same steps headlessly and **asserts on the symptom**: the wrong text, the missing element, the console error, the failing request. Run it and watch it go red. + +That command is your Phase 1 loop: tighten it there (pin data, skip unrelated navigation, wait on the specific request rather than a timeout) and carry on with the main skill. + +If the symptom only shows in the live browser and never headlessly, say so: that difference is itself a clue (timing, extensions, cached state, real data), and the HITL script in `scripts/` becomes the fallback loop. diff --git a/.agents/skills/diagnose/SKILL.md b/.claude/skills/diagnosing-bugs/SKILL.md similarity index 53% rename from .agents/skills/diagnose/SKILL.md rename to .claude/skills/diagnosing-bugs/SKILL.md index ed55bda..9687301 100644 --- a/.agents/skills/diagnose/SKILL.md +++ b/.claude/skills/diagnosing-bugs/SKILL.md @@ -1,26 +1,32 @@ --- -name: diagnose -description: Disciplined diagnosis loop for hard bugs and performance regressions. Reproduce → minimise → hypothesise → instrument → fix → regression-test. Use when user says "diagnose this" / "debug this", reports a bug, says something is broken/throwing/failing, or describes a performance regression. +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. --- -# Diagnose +# Diagnosing Bugs A discipline for hard bugs. Skip phases only when explicitly justified. -When exploring the codebase, use the project's domain glossary to get a clear mental model of the relevant modules, and check ADRs in the area you're touching. +When exploring the codebase, read `GLOSSARY.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 +## Redact -**This is the skill.** Everything else is mechanical. If you have a fast, deterministic, agent-runnable pass/fail signal for the bug, you will find the cause — bisection, hypothesis-testing, and instrumentation all just consume that signal. If you don't have one, no amount of staring at code will save you. +This skill has you show commands, outputs and captured artifacts. **Redact every secret first**: write `` in its place. Build loops against env vars, so the credential stays in the environment rather than in what you show. Captured artifacts carry auth headers: quote only the lines that carry the signal. + +If the redacted output is not enough to diagnose the bug, say so and ask the user. + +## 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 +### Ways to construct one, in roughly this order -1. **Failing test** at whatever seam reaches the bug — unit, integration, e2e. +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. +4. **Headless browser script** (Playwright / Puppeteer) that drives the UI and asserts on DOM/console/network. For a bug the user sees in the UI, first reproduce it live in a real browser, then freeze the steps into this script: see [BROWSER.md](BROWSER.md). 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. @@ -30,39 +36,56 @@ Spend disproportionate effort here. **Be aggressive. Be creative. Refuse to give Build the right feedback loop, and the bug is 90% fixed. -### Iterate on the loop itself +### Tighten the loop -Treat the loop as a product. Once you have _a_ loop, ask: +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 loop is a debugging superpower. +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. +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, so 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. +Stop and say so explicitly. List what you tried. Ask the user for: (a) access to whatever environment reproduces it, (b) a redacted 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** (show the invocation and its output, redacted), 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`. -Do not proceed to Phase 2 until you have a loop you believe in. +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 +## Phase 2: Reproduce + minimise -Run the loop. Watch the bug appear. +Run the loop. Watch it go red as 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 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. -Do not proceed until you reproduce the bug. +### Minimise -## Phase 3 — Hypothesise +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, and 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. @@ -70,11 +93,11 @@ Each hypothesis must be **falsifiable**: state the prediction it makes. > Format: "If is the cause, then will make the bug disappear / will make it worse." -If you cannot state the prediction, the hypothesis is a vibe — discard or sharpen it. +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. +**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 +## Phase 4: Instrument Each probe must map to a specific prediction from Phase 3. **Change one variable at a time.** @@ -88,9 +111,9 @@ Tool preference: **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 +## Phase 5: Fix + regression test -Write the regression test **before the fix** — but only if there is a **correct seam** for it. +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. @@ -104,7 +127,7 @@ If a correct seam exists: 4. Watch it pass. 5. Re-run the Phase 1 feedback loop against the original (un-minimised) scenario. -## Phase 6 — Cleanup + post-mortem +## Phase 6: Cleanup Required before declaring done: @@ -112,6 +135,4 @@ Required before declaring done: - [ ] 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. +- [ ] The hypothesis that turned out correct is stated in the commit / PR message, so the next debugger learns diff --git a/.claude/skills/diagnosing-bugs/agents/openai.yaml b/.claude/skills/diagnosing-bugs/agents/openai.yaml new file mode 100644 index 0000000..a13a755 --- /dev/null +++ b/.claude/skills/diagnosing-bugs/agents/openai.yaml @@ -0,0 +1,3 @@ +interface: + display_name: "Diagnosing Bugs" + short_description: "Diagnose hard bugs and regressions" diff --git a/.agents/skills/diagnose/scripts/hitl-loop.template.sh b/.claude/skills/diagnosing-bugs/scripts/hitl-loop.template.sh similarity index 88% rename from .agents/skills/diagnose/scripts/hitl-loop.template.sh rename to .claude/skills/diagnosing-bugs/scripts/hitl-loop.template.sh index 40afc46..2431984 100644 --- a/.agents/skills/diagnose/scripts/hitl-loop.template.sh +++ b/.claude/skills/diagnosing-bugs/scripts/hitl-loop.template.sh @@ -11,6 +11,9 @@ # capture VAR "" → show question, read response into VAR # # At the end, captured values are printed as KEY=VALUE for the agent to parse. +# +# `capture` prints its value back to the terminal, where the agent reads it, +# so capture observations, and leave signing in to the user as a `step`. set -euo pipefail diff --git a/.claude/skills/dig/SKILL.md b/.claude/skills/dig/SKILL.md new file mode 100644 index 0000000..887046b --- /dev/null +++ b/.claude/skills/dig/SKILL.md @@ -0,0 +1,59 @@ +--- +name: dig +description: Dig into one grilling question in the background (why it matters, the options, what competitors do) and come back with a sharper recommendation. +disable-model-invocation: true +--- + +# Dig + +A grilling round has a question the user can't settle on instinct: a low-confidence recommendation, a "Hinges on" they want to understand. Dig into it **in the background** while the round goes on, and come back with a **brief** that makes the decision easier: why it matters, the options, what others do, and a revised recommendation. + +`/research` establishes what is true; `/dig` helps choose. Dig uses `/research` for its factual legs. + +## Run + +1. **Pick the question.** `/dig Q3` is question 3 of the current round. A bare `/dig` is the round's lowest-confidence question. Anything else (`/dig how do booking tools handle price overrides?`) is a free question. Restate it in one line, with the decisions already settled that bear on it. + +2. **Know the competitors.** Read `docs/agents/competitors.md`. If it doesn't exist, ask the user once for the products to compare against (names, URLs, and why each is relevant), then write the file: + + ```markdown + # Competitors + + Products to compare against when digging into product decisions. + + | Product | URL | Why it's relevant | + | --- | --- | --- | + | | | | + ``` + + With no repo underneath, keep the list in the conversation instead. + +3. **Dispatch** one background subagent with a self-contained prompt (it can't see this conversation): the question, the settled decisions and product context that bear on it, the competitor list, and the brief format below. Its legwork: + - Work out what the answer **changes** downstream: what each option makes easy or hard later. + - For each competitor, find how they handle it, from what they publish: product docs, help centre, pricing page, changelog, public demos, API docs. Link every claim to where it was seen; mark anything inferred rather than seen. + - Note comparable products beyond the list when they handle it notably well or differently, as suggestions. + - For a factual sub-question (an API's limits, a standard's rule), call the Skill tool with "research". + +4. **Carry on.** The question is unsettled until the brief lands; tell the user it's being dug into and continue the round with the rest of the frontier. + +5. **Deliver** the brief when the subagent reports, then re-ask the question with the revised recommendation and confidence in the grilling format. Offer any suggested new competitors for the user to approve; append the approved ones to `competitors.md`. + +## The brief + +```markdown +🔎 **Dig: Q - ** + +**Why it matters:** + +**Options:** +- **