@athenaflow/plugin-matt-pocock-skills 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +24 -0
- package/.codex-plugin/plugin.json +16 -0
- package/NOTICE.md +11 -0
- package/dist/0.1.1/.agents/plugins/marketplace.json +14 -0
- package/dist/0.1.1/GENERATED.md +12 -0
- package/dist/0.1.1/claude/plugin/.claude-plugin/plugin.json +24 -0
- package/dist/0.1.1/claude/plugin/NOTICE.md +11 -0
- package/dist/0.1.1/claude/plugin/package.json +21 -0
- package/dist/0.1.1/claude/plugin/skills/diagnose/SKILL.md +117 -0
- package/dist/0.1.1/claude/plugin/skills/diagnose/agents/claude.yaml +2 -0
- package/dist/0.1.1/claude/plugin/skills/diagnose/agents/openai.yaml +4 -0
- package/dist/0.1.1/claude/plugin/skills/diagnose/scripts/hitl-loop.template.sh +41 -0
- package/dist/0.1.1/claude/plugin/skills/grill-me/SKILL.md +10 -0
- package/dist/0.1.1/claude/plugin/skills/grill-me/agents/claude.yaml +2 -0
- package/dist/0.1.1/claude/plugin/skills/grill-me/agents/openai.yaml +4 -0
- package/dist/0.1.1/claude/plugin/skills/grill-with-docs/ADR-FORMAT.md +47 -0
- package/dist/0.1.1/claude/plugin/skills/grill-with-docs/CONTEXT-FORMAT.md +77 -0
- package/dist/0.1.1/claude/plugin/skills/grill-with-docs/SKILL.md +88 -0
- package/dist/0.1.1/claude/plugin/skills/grill-with-docs/agents/claude.yaml +2 -0
- package/dist/0.1.1/claude/plugin/skills/grill-with-docs/agents/openai.yaml +4 -0
- package/dist/0.1.1/claude/plugin/skills/improve-codebase-architecture/DEEPENING.md +37 -0
- package/dist/0.1.1/claude/plugin/skills/improve-codebase-architecture/INTERFACE-DESIGN.md +44 -0
- package/dist/0.1.1/claude/plugin/skills/improve-codebase-architecture/LANGUAGE.md +53 -0
- package/dist/0.1.1/claude/plugin/skills/improve-codebase-architecture/SKILL.md +71 -0
- package/dist/0.1.1/claude/plugin/skills/improve-codebase-architecture/agents/claude.yaml +2 -0
- package/dist/0.1.1/claude/plugin/skills/improve-codebase-architecture/agents/openai.yaml +4 -0
- package/dist/0.1.1/claude/plugin/skills/prototype/LOGIC.md +79 -0
- package/dist/0.1.1/claude/plugin/skills/prototype/SKILL.md +30 -0
- package/dist/0.1.1/claude/plugin/skills/prototype/UI.md +112 -0
- package/dist/0.1.1/claude/plugin/skills/prototype/agents/claude.yaml +2 -0
- package/dist/0.1.1/claude/plugin/skills/prototype/agents/openai.yaml +4 -0
- package/dist/0.1.1/claude/plugin/skills/setup-matt-pocock-skills/SKILL.md +120 -0
- package/dist/0.1.1/claude/plugin/skills/setup-matt-pocock-skills/agents/claude.yaml +3 -0
- package/dist/0.1.1/claude/plugin/skills/setup-matt-pocock-skills/agents/openai.yaml +4 -0
- package/dist/0.1.1/claude/plugin/skills/setup-matt-pocock-skills/domain.md +51 -0
- package/dist/0.1.1/claude/plugin/skills/setup-matt-pocock-skills/issue-tracker-github.md +22 -0
- package/dist/0.1.1/claude/plugin/skills/setup-matt-pocock-skills/issue-tracker-gitlab.md +23 -0
- package/dist/0.1.1/claude/plugin/skills/setup-matt-pocock-skills/issue-tracker-local.md +19 -0
- package/dist/0.1.1/claude/plugin/skills/setup-matt-pocock-skills/triage-labels.md +15 -0
- package/dist/0.1.1/claude/plugin/skills/tdd/SKILL.md +109 -0
- package/dist/0.1.1/claude/plugin/skills/tdd/agents/claude.yaml +2 -0
- package/dist/0.1.1/claude/plugin/skills/tdd/agents/openai.yaml +4 -0
- package/dist/0.1.1/claude/plugin/skills/tdd/deep-modules.md +33 -0
- package/dist/0.1.1/claude/plugin/skills/tdd/interface-design.md +31 -0
- package/dist/0.1.1/claude/plugin/skills/tdd/mocking.md +59 -0
- package/dist/0.1.1/claude/plugin/skills/tdd/refactoring.md +10 -0
- package/dist/0.1.1/claude/plugin/skills/tdd/tests.md +61 -0
- package/dist/0.1.1/claude/plugin/skills/to-issues/SKILL.md +83 -0
- package/dist/0.1.1/claude/plugin/skills/to-issues/agents/claude.yaml +2 -0
- package/dist/0.1.1/claude/plugin/skills/to-issues/agents/openai.yaml +4 -0
- package/dist/0.1.1/claude/plugin/skills/to-prd/SKILL.md +76 -0
- package/dist/0.1.1/claude/plugin/skills/to-prd/agents/claude.yaml +2 -0
- package/dist/0.1.1/claude/plugin/skills/to-prd/agents/openai.yaml +4 -0
- package/dist/0.1.1/claude/plugin/skills/triage/AGENT-BRIEF.md +168 -0
- package/dist/0.1.1/claude/plugin/skills/triage/OUT-OF-SCOPE.md +101 -0
- package/dist/0.1.1/claude/plugin/skills/triage/SKILL.md +103 -0
- package/dist/0.1.1/claude/plugin/skills/triage/agents/claude.yaml +2 -0
- package/dist/0.1.1/claude/plugin/skills/triage/agents/openai.yaml +4 -0
- package/dist/0.1.1/claude/plugin/skills/zoom-out/SKILL.md +6 -0
- package/dist/0.1.1/claude/plugin/skills/zoom-out/agents/claude.yaml +3 -0
- package/dist/0.1.1/claude/plugin/skills/zoom-out/agents/openai.yaml +4 -0
- package/dist/0.1.1/codex/plugin/.codex-plugin/plugin.json +16 -0
- package/dist/0.1.1/codex/plugin/NOTICE.md +11 -0
- package/dist/0.1.1/codex/plugin/package.json +21 -0
- package/dist/0.1.1/codex/plugin/skills/diagnose/SKILL.md +117 -0
- package/dist/0.1.1/codex/plugin/skills/diagnose/agents/claude.yaml +2 -0
- package/dist/0.1.1/codex/plugin/skills/diagnose/agents/openai.yaml +4 -0
- package/dist/0.1.1/codex/plugin/skills/diagnose/scripts/hitl-loop.template.sh +41 -0
- package/dist/0.1.1/codex/plugin/skills/grill-me/SKILL.md +10 -0
- package/dist/0.1.1/codex/plugin/skills/grill-me/agents/claude.yaml +2 -0
- package/dist/0.1.1/codex/plugin/skills/grill-me/agents/openai.yaml +4 -0
- package/dist/0.1.1/codex/plugin/skills/grill-with-docs/ADR-FORMAT.md +47 -0
- package/dist/0.1.1/codex/plugin/skills/grill-with-docs/CONTEXT-FORMAT.md +77 -0
- package/dist/0.1.1/codex/plugin/skills/grill-with-docs/SKILL.md +88 -0
- package/dist/0.1.1/codex/plugin/skills/grill-with-docs/agents/claude.yaml +2 -0
- package/dist/0.1.1/codex/plugin/skills/grill-with-docs/agents/openai.yaml +4 -0
- package/dist/0.1.1/codex/plugin/skills/improve-codebase-architecture/DEEPENING.md +37 -0
- package/dist/0.1.1/codex/plugin/skills/improve-codebase-architecture/INTERFACE-DESIGN.md +44 -0
- package/dist/0.1.1/codex/plugin/skills/improve-codebase-architecture/LANGUAGE.md +53 -0
- package/dist/0.1.1/codex/plugin/skills/improve-codebase-architecture/SKILL.md +71 -0
- package/dist/0.1.1/codex/plugin/skills/improve-codebase-architecture/agents/claude.yaml +2 -0
- package/dist/0.1.1/codex/plugin/skills/improve-codebase-architecture/agents/openai.yaml +4 -0
- package/dist/0.1.1/codex/plugin/skills/prototype/LOGIC.md +79 -0
- package/dist/0.1.1/codex/plugin/skills/prototype/SKILL.md +30 -0
- package/dist/0.1.1/codex/plugin/skills/prototype/UI.md +112 -0
- package/dist/0.1.1/codex/plugin/skills/prototype/agents/claude.yaml +2 -0
- package/dist/0.1.1/codex/plugin/skills/prototype/agents/openai.yaml +4 -0
- package/dist/0.1.1/codex/plugin/skills/setup-matt-pocock-skills/SKILL.md +120 -0
- package/dist/0.1.1/codex/plugin/skills/setup-matt-pocock-skills/agents/claude.yaml +3 -0
- package/dist/0.1.1/codex/plugin/skills/setup-matt-pocock-skills/agents/openai.yaml +4 -0
- package/dist/0.1.1/codex/plugin/skills/setup-matt-pocock-skills/domain.md +51 -0
- package/dist/0.1.1/codex/plugin/skills/setup-matt-pocock-skills/issue-tracker-github.md +22 -0
- package/dist/0.1.1/codex/plugin/skills/setup-matt-pocock-skills/issue-tracker-gitlab.md +23 -0
- package/dist/0.1.1/codex/plugin/skills/setup-matt-pocock-skills/issue-tracker-local.md +19 -0
- package/dist/0.1.1/codex/plugin/skills/setup-matt-pocock-skills/triage-labels.md +15 -0
- package/dist/0.1.1/codex/plugin/skills/tdd/SKILL.md +109 -0
- package/dist/0.1.1/codex/plugin/skills/tdd/agents/claude.yaml +2 -0
- package/dist/0.1.1/codex/plugin/skills/tdd/agents/openai.yaml +4 -0
- package/dist/0.1.1/codex/plugin/skills/tdd/deep-modules.md +33 -0
- package/dist/0.1.1/codex/plugin/skills/tdd/interface-design.md +31 -0
- package/dist/0.1.1/codex/plugin/skills/tdd/mocking.md +59 -0
- package/dist/0.1.1/codex/plugin/skills/tdd/refactoring.md +10 -0
- package/dist/0.1.1/codex/plugin/skills/tdd/tests.md +61 -0
- package/dist/0.1.1/codex/plugin/skills/to-issues/SKILL.md +83 -0
- package/dist/0.1.1/codex/plugin/skills/to-issues/agents/claude.yaml +2 -0
- package/dist/0.1.1/codex/plugin/skills/to-issues/agents/openai.yaml +4 -0
- package/dist/0.1.1/codex/plugin/skills/to-prd/SKILL.md +76 -0
- package/dist/0.1.1/codex/plugin/skills/to-prd/agents/claude.yaml +2 -0
- package/dist/0.1.1/codex/plugin/skills/to-prd/agents/openai.yaml +4 -0
- package/dist/0.1.1/codex/plugin/skills/triage/AGENT-BRIEF.md +168 -0
- package/dist/0.1.1/codex/plugin/skills/triage/OUT-OF-SCOPE.md +101 -0
- package/dist/0.1.1/codex/plugin/skills/triage/SKILL.md +103 -0
- package/dist/0.1.1/codex/plugin/skills/triage/agents/claude.yaml +2 -0
- package/dist/0.1.1/codex/plugin/skills/triage/agents/openai.yaml +4 -0
- package/dist/0.1.1/codex/plugin/skills/zoom-out/SKILL.md +6 -0
- package/dist/0.1.1/codex/plugin/skills/zoom-out/agents/claude.yaml +3 -0
- package/dist/0.1.1/codex/plugin/skills/zoom-out/agents/openai.yaml +4 -0
- package/dist/0.1.1/release.json +18 -0
- package/package.json +25 -0
- package/skills/diagnose/SKILL.md +117 -0
- package/skills/diagnose/agents/claude.yaml +2 -0
- package/skills/diagnose/agents/openai.yaml +4 -0
- package/skills/diagnose/scripts/hitl-loop.template.sh +41 -0
- package/skills/grill-me/SKILL.md +10 -0
- package/skills/grill-me/agents/claude.yaml +2 -0
- package/skills/grill-me/agents/openai.yaml +4 -0
- package/skills/grill-with-docs/ADR-FORMAT.md +47 -0
- package/skills/grill-with-docs/CONTEXT-FORMAT.md +77 -0
- package/skills/grill-with-docs/SKILL.md +88 -0
- package/skills/grill-with-docs/agents/claude.yaml +2 -0
- package/skills/grill-with-docs/agents/openai.yaml +4 -0
- package/skills/improve-codebase-architecture/DEEPENING.md +37 -0
- package/skills/improve-codebase-architecture/INTERFACE-DESIGN.md +44 -0
- package/skills/improve-codebase-architecture/LANGUAGE.md +53 -0
- package/skills/improve-codebase-architecture/SKILL.md +71 -0
- package/skills/improve-codebase-architecture/agents/claude.yaml +2 -0
- package/skills/improve-codebase-architecture/agents/openai.yaml +4 -0
- package/skills/prototype/LOGIC.md +79 -0
- package/skills/prototype/SKILL.md +30 -0
- package/skills/prototype/UI.md +112 -0
- package/skills/prototype/agents/claude.yaml +2 -0
- package/skills/prototype/agents/openai.yaml +4 -0
- package/skills/setup-matt-pocock-skills/SKILL.md +120 -0
- package/skills/setup-matt-pocock-skills/agents/claude.yaml +3 -0
- package/skills/setup-matt-pocock-skills/agents/openai.yaml +4 -0
- package/skills/setup-matt-pocock-skills/domain.md +51 -0
- package/skills/setup-matt-pocock-skills/issue-tracker-github.md +22 -0
- package/skills/setup-matt-pocock-skills/issue-tracker-gitlab.md +23 -0
- package/skills/setup-matt-pocock-skills/issue-tracker-local.md +19 -0
- package/skills/setup-matt-pocock-skills/triage-labels.md +15 -0
- package/skills/tdd/SKILL.md +109 -0
- package/skills/tdd/agents/claude.yaml +2 -0
- package/skills/tdd/agents/openai.yaml +4 -0
- package/skills/tdd/deep-modules.md +33 -0
- package/skills/tdd/interface-design.md +31 -0
- package/skills/tdd/mocking.md +59 -0
- package/skills/tdd/refactoring.md +10 -0
- package/skills/tdd/tests.md +61 -0
- package/skills/to-issues/SKILL.md +83 -0
- package/skills/to-issues/agents/claude.yaml +2 -0
- package/skills/to-issues/agents/openai.yaml +4 -0
- package/skills/to-prd/SKILL.md +76 -0
- package/skills/to-prd/agents/claude.yaml +2 -0
- package/skills/to-prd/agents/openai.yaml +4 -0
- package/skills/triage/AGENT-BRIEF.md +168 -0
- package/skills/triage/OUT-OF-SCOPE.md +101 -0
- package/skills/triage/SKILL.md +103 -0
- package/skills/triage/agents/claude.yaml +2 -0
- package/skills/triage/agents/openai.yaml +4 -0
- package/skills/zoom-out/SKILL.md +6 -0
- package/skills/zoom-out/agents/claude.yaml +3 -0
- package/skills/zoom-out/agents/openai.yaml +4 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# UI Prototype
|
|
2
|
+
|
|
3
|
+
Generate **several radically different UI variations** on a single route, switchable from a floating bottom bar. The user flips between variants in the browser, picks one (or steals bits from each), then throws the rest away.
|
|
4
|
+
|
|
5
|
+
If the question is about logic/state rather than what something looks like — wrong branch. Use [LOGIC.md](LOGIC.md).
|
|
6
|
+
|
|
7
|
+
## When this is the right shape
|
|
8
|
+
|
|
9
|
+
- "What should this page look like?"
|
|
10
|
+
- "I want to see a few options for this dashboard before committing."
|
|
11
|
+
- "Try a different layout for the settings screen."
|
|
12
|
+
- Any time the user would otherwise spend a day picking between three vague mockups in their head.
|
|
13
|
+
|
|
14
|
+
## Two sub-shapes — strongly prefer sub-shape A
|
|
15
|
+
|
|
16
|
+
A UI prototype is much easier to judge when it's **butting up against the rest of the app** — real header, real sidebar, real data, real density. A throwaway route on its own is a vacuum: every variant looks fine in isolation. Default to sub-shape A whenever there's a plausible existing page to host the variants. Only reach for sub-shape B if the prototype genuinely has no nearby home.
|
|
17
|
+
|
|
18
|
+
### Sub-shape A — adjustment to an existing page (preferred)
|
|
19
|
+
|
|
20
|
+
The route already exists. Variants are rendered **on the same route**, gated by a `?variant=` URL search param. The existing data fetching, params, and auth all stay — only the rendering swaps. This is the default; pick it unless there's a specific reason not to.
|
|
21
|
+
|
|
22
|
+
If the prototype is for something that doesn't yet have a page but *would naturally live inside one* (a new section of the dashboard, a new card on the settings screen, a new step in an existing flow) — that's still sub-shape A. Mount the variants inside the host page.
|
|
23
|
+
|
|
24
|
+
### Sub-shape B — a new page (last resort)
|
|
25
|
+
|
|
26
|
+
Only use this when the thing being prototyped genuinely has no existing page to live inside — e.g. an entirely new top-level surface, or a flow that can't be embedded anywhere sensible.
|
|
27
|
+
|
|
28
|
+
Create a **throwaway route** following whatever routing convention the project already uses — don't invent a new top-level structure. Name it so it's obviously a prototype (e.g. include the word `prototype` in the path or filename). Same `?variant=` pattern.
|
|
29
|
+
|
|
30
|
+
Before committing to sub-shape B, sanity-check: is there really no existing page this could be embedded in? An empty route hides design problems that a populated one would expose.
|
|
31
|
+
|
|
32
|
+
In both sub-shapes the floating bottom bar is identical.
|
|
33
|
+
|
|
34
|
+
## Process
|
|
35
|
+
|
|
36
|
+
### 1. State the question and pick N
|
|
37
|
+
|
|
38
|
+
Default to **3 variants**. More than 5 stops being radically different and starts being noise — cap there.
|
|
39
|
+
|
|
40
|
+
Write down the plan in one line, in the prototype's location or a top-of-file comment:
|
|
41
|
+
|
|
42
|
+
> "Three variants of the settings page, switchable via `?variant=`, on the existing `/settings` route."
|
|
43
|
+
|
|
44
|
+
This works whether the user is here to push back or not.
|
|
45
|
+
|
|
46
|
+
### 2. Generate radically different variants
|
|
47
|
+
|
|
48
|
+
Draft each variant. Hold each one to:
|
|
49
|
+
|
|
50
|
+
- The page's purpose and the data it has access to.
|
|
51
|
+
- The project's component library / styling system (TailwindCSS, shadcn, MUI, plain CSS, whatever).
|
|
52
|
+
- A clear exported component name, e.g. `VariantA`, `VariantB`, `VariantC`.
|
|
53
|
+
|
|
54
|
+
Variants must be **structurally different** — different layout, different information hierarchy, different primary affordance, not just different colours. Three slightly-tweaked card grids isn't a UI prototype, it's wallpaper. If two drafts come out too similar, redo one with explicit "do not use a card grid" guidance.
|
|
55
|
+
|
|
56
|
+
### 3. Wire them together
|
|
57
|
+
|
|
58
|
+
Create a single switcher component on the route:
|
|
59
|
+
|
|
60
|
+
```tsx
|
|
61
|
+
// pseudo-code — adapt to the project's framework
|
|
62
|
+
const variant = searchParams.get('variant') ?? 'A';
|
|
63
|
+
return (
|
|
64
|
+
<>
|
|
65
|
+
{variant === 'A' && <VariantA {...data} />}
|
|
66
|
+
{variant === 'B' && <VariantB {...data} />}
|
|
67
|
+
{variant === 'C' && <VariantC {...data} />}
|
|
68
|
+
<PrototypeSwitcher variants={['A','B','C']} current={variant} />
|
|
69
|
+
</>
|
|
70
|
+
);
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
For sub-shape A (existing page): keep all the existing data fetching above the switcher; only the rendered subtree changes per variant.
|
|
74
|
+
|
|
75
|
+
For sub-shape B (new page): the throwaway route under `/prototype/<name>` mounts the same switcher.
|
|
76
|
+
|
|
77
|
+
### 4. Build the floating switcher
|
|
78
|
+
|
|
79
|
+
A small fixed-position bar at the bottom-centre of the screen with three pieces:
|
|
80
|
+
|
|
81
|
+
- **Left arrow** — cycles to the previous variant (wraps around).
|
|
82
|
+
- **Variant label** — shows the current variant key and, if the variant exports a name, that name too. e.g. `B — Sidebar layout`.
|
|
83
|
+
- **Right arrow** — cycles forward (wraps around).
|
|
84
|
+
|
|
85
|
+
Behaviour:
|
|
86
|
+
|
|
87
|
+
- Clicking an arrow updates the URL search param (use the framework's router — `router.replace` on Next, `navigate` on React Router, etc) so the variant is shareable and reload-stable.
|
|
88
|
+
- Keyboard: `←` and `→` arrow keys also cycle. Don't intercept arrow keys when an `<input>`, `<textarea>`, or `[contenteditable]` is focused.
|
|
89
|
+
- Visually distinct from the page (e.g. high-contrast pill, subtle shadow) so it's obviously not part of the design being evaluated.
|
|
90
|
+
- Hidden in production builds — gate on `process.env.NODE_ENV !== 'production'` or an equivalent check, so a stray prototype merge can't ship the bar to users.
|
|
91
|
+
|
|
92
|
+
Put the switcher in a single shared component so both sub-shapes can reuse it. Locate it wherever shared UI lives in the project.
|
|
93
|
+
|
|
94
|
+
### 5. Hand it over
|
|
95
|
+
|
|
96
|
+
Surface the URL (and the `?variant=` keys). The user will flip through whenever they get to it. The interesting feedback is usually **"I want the header from B with the sidebar from C"** — that's the actual design they want.
|
|
97
|
+
|
|
98
|
+
### 6. Capture the answer and clean up
|
|
99
|
+
|
|
100
|
+
Once a variant has won, write down which one and why (commit message, ADR, issue, or a `NOTES.md` next to the prototype if running AFK and the user hasn't responded yet). Then:
|
|
101
|
+
|
|
102
|
+
- **Sub-shape A** — delete the losing variants and the switcher; fold the winner into the existing page.
|
|
103
|
+
- **Sub-shape B** — promote the winning variant to a real route, delete the throwaway route and the switcher.
|
|
104
|
+
|
|
105
|
+
Don't leave variant components or the switcher lying around. They rot fast and confuse the next reader.
|
|
106
|
+
|
|
107
|
+
## Anti-patterns
|
|
108
|
+
|
|
109
|
+
- **Variants that differ only in colour or copy.** That's a tweak, not a prototype. Real variants disagree about structure.
|
|
110
|
+
- **Sharing too much code between variants.** A shared `<Header>` is fine; a shared `<Layout>` defeats the point. Each variant should be free to throw out the layout.
|
|
111
|
+
- **Wiring variants to real mutations.** Read-only prototypes are fine. If a variant needs to mutate, point it at a stub — the question is "what should this look like", not "does the backend work".
|
|
112
|
+
- **Promoting the prototype directly to production.** The variant code was written under prototype constraints (no tests, minimal error handling). Rewrite it properly when you fold it in.
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: setup-matt-pocock-skills
|
|
3
|
+
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.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Setup Matt Pocock's Skills
|
|
7
|
+
|
|
8
|
+
Scaffold the per-repo configuration that the engineering skills assume:
|
|
9
|
+
|
|
10
|
+
- **Issue tracker** — where issues live (GitHub by default; local markdown is also supported out of the box)
|
|
11
|
+
- **Triage labels** — the strings used for the five canonical triage roles
|
|
12
|
+
- **Domain docs** — where `CONTEXT.md` and ADRs live, and the consumer rules for reading them
|
|
13
|
+
|
|
14
|
+
This is a prompt-driven skill, not a deterministic script. Explore, present what you found, confirm with the user, then write.
|
|
15
|
+
|
|
16
|
+
## Process
|
|
17
|
+
|
|
18
|
+
### 1. Explore
|
|
19
|
+
|
|
20
|
+
Look at the current repo to understand its starting state. Read whatever exists; don't assume:
|
|
21
|
+
|
|
22
|
+
- `git remote -v` and `.git/config` — is this a GitHub repo? Which one?
|
|
23
|
+
- `AGENTS.md` and `CLAUDE.md` at the repo root — does either exist? Is there already an `## Agent skills` section in either?
|
|
24
|
+
- `CONTEXT.md` and `CONTEXT-MAP.md` at the repo root
|
|
25
|
+
- `docs/adr/` and any `src/*/docs/adr/` directories
|
|
26
|
+
- `docs/agents/` — does this skill's prior output already exist?
|
|
27
|
+
- `.scratch/` — sign that a local-markdown issue tracker convention is already in use
|
|
28
|
+
|
|
29
|
+
### 2. Present findings and ask
|
|
30
|
+
|
|
31
|
+
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.
|
|
32
|
+
|
|
33
|
+
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.
|
|
34
|
+
|
|
35
|
+
**Section A — Issue tracker.**
|
|
36
|
+
|
|
37
|
+
> 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.
|
|
38
|
+
|
|
39
|
+
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:
|
|
40
|
+
|
|
41
|
+
- **GitHub** — issues live in the repo's GitHub Issues (uses the `gh` CLI)
|
|
42
|
+
- **GitLab** — issues live in the repo's GitLab Issues (uses the [`glab`](https://gitlab.com/gitlab-org/cli) CLI)
|
|
43
|
+
- **Local markdown** — issues live as files under `.scratch/<feature>/` in this repo (good for solo projects or repos without a remote)
|
|
44
|
+
- **Other** (Jira, Linear, etc.) — ask the user to describe the workflow in one paragraph; the skill will record it as freeform prose
|
|
45
|
+
|
|
46
|
+
**Section B — Triage label vocabulary.**
|
|
47
|
+
|
|
48
|
+
> 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.
|
|
49
|
+
|
|
50
|
+
The five canonical roles:
|
|
51
|
+
|
|
52
|
+
- `needs-triage` — maintainer needs to evaluate
|
|
53
|
+
- `needs-info` — waiting on reporter
|
|
54
|
+
- `ready-for-agent` — fully specified, AFK-ready (an agent can pick it up with no human context)
|
|
55
|
+
- `ready-for-human` — needs human implementation
|
|
56
|
+
- `wontfix` — will not be actioned
|
|
57
|
+
|
|
58
|
+
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.
|
|
59
|
+
|
|
60
|
+
**Section C — Domain docs.**
|
|
61
|
+
|
|
62
|
+
> 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.
|
|
63
|
+
|
|
64
|
+
Confirm the layout:
|
|
65
|
+
|
|
66
|
+
- **Single-context** — one `CONTEXT.md` + `docs/adr/` at the repo root. Most repos are this.
|
|
67
|
+
- **Multi-context** — `CONTEXT-MAP.md` at the root pointing to per-context `CONTEXT.md` files (typically a monorepo).
|
|
68
|
+
|
|
69
|
+
### 3. Confirm and edit
|
|
70
|
+
|
|
71
|
+
Show the user a draft of:
|
|
72
|
+
|
|
73
|
+
- The `## Agent skills` block to add to whichever of `CLAUDE.md` / `AGENTS.md` is being edited (see step 4 for selection rules)
|
|
74
|
+
- The contents of `docs/agents/issue-tracker.md`, `docs/agents/triage-labels.md`, `docs/agents/domain.md`
|
|
75
|
+
|
|
76
|
+
Let them edit before writing.
|
|
77
|
+
|
|
78
|
+
### 4. Write
|
|
79
|
+
|
|
80
|
+
**Pick the file to edit:**
|
|
81
|
+
|
|
82
|
+
- If `CLAUDE.md` exists, edit it.
|
|
83
|
+
- Else if `AGENTS.md` exists, edit it.
|
|
84
|
+
- If neither exists, ask the user which one to create — don't pick for them.
|
|
85
|
+
|
|
86
|
+
Never create `AGENTS.md` when `CLAUDE.md` already exists (or vice versa) — always edit the one that's already there.
|
|
87
|
+
|
|
88
|
+
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.
|
|
89
|
+
|
|
90
|
+
The block:
|
|
91
|
+
|
|
92
|
+
```markdown
|
|
93
|
+
## Agent skills
|
|
94
|
+
|
|
95
|
+
### Issue tracker
|
|
96
|
+
|
|
97
|
+
[one-line summary of where issues are tracked]. See `docs/agents/issue-tracker.md`.
|
|
98
|
+
|
|
99
|
+
### Triage labels
|
|
100
|
+
|
|
101
|
+
[one-line summary of the label vocabulary]. See `docs/agents/triage-labels.md`.
|
|
102
|
+
|
|
103
|
+
### Domain docs
|
|
104
|
+
|
|
105
|
+
[one-line summary of layout — "single-context" or "multi-context"]. See `docs/agents/domain.md`.
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Then write the three docs files using the seed templates in this skill folder as a starting point:
|
|
109
|
+
|
|
110
|
+
- [issue-tracker-github.md](./issue-tracker-github.md) — GitHub issue tracker
|
|
111
|
+
- [issue-tracker-gitlab.md](./issue-tracker-gitlab.md) — GitLab issue tracker
|
|
112
|
+
- [issue-tracker-local.md](./issue-tracker-local.md) — local-markdown issue tracker
|
|
113
|
+
- [triage-labels.md](./triage-labels.md) — label mapping
|
|
114
|
+
- [domain.md](./domain.md) — domain doc consumer rules + layout
|
|
115
|
+
|
|
116
|
+
For "other" issue trackers, write `docs/agents/issue-tracker.md` from scratch using the user's description.
|
|
117
|
+
|
|
118
|
+
### 5. Done
|
|
119
|
+
|
|
120
|
+
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.
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
interface:
|
|
2
|
+
display_name: "Setup Matt Pocock Skills"
|
|
3
|
+
short_description: "Scaffold per-repo config (issue tracker, triage labels, domain doc layout) consumed by the other skills"
|
|
4
|
+
default_prompt: "Scaffold this repo with CONTEXT.md, docs/adr/, an issue-tracker doc, and a triage-labels doc."
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Domain Docs
|
|
2
|
+
|
|
3
|
+
How the engineering skills should consume this repo's domain documentation when exploring the codebase.
|
|
4
|
+
|
|
5
|
+
## Before exploring, read these
|
|
6
|
+
|
|
7
|
+
- **`CONTEXT.md`** at the repo root, or
|
|
8
|
+
- **`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.
|
|
9
|
+
- **`docs/adr/`** — read ADRs that touch the area you're about to work in. In multi-context repos, also check `src/<context>/docs/adr/` for context-scoped decisions.
|
|
10
|
+
|
|
11
|
+
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.
|
|
12
|
+
|
|
13
|
+
## File structure
|
|
14
|
+
|
|
15
|
+
Single-context repo (most repos):
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
/
|
|
19
|
+
├── CONTEXT.md
|
|
20
|
+
├── docs/adr/
|
|
21
|
+
│ ├── 0001-event-sourced-orders.md
|
|
22
|
+
│ └── 0002-postgres-for-write-model.md
|
|
23
|
+
└── src/
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Multi-context repo (presence of `CONTEXT-MAP.md` at the root):
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
/
|
|
30
|
+
├── CONTEXT-MAP.md
|
|
31
|
+
├── docs/adr/ ← system-wide decisions
|
|
32
|
+
└── src/
|
|
33
|
+
├── ordering/
|
|
34
|
+
│ ├── CONTEXT.md
|
|
35
|
+
│ └── docs/adr/ ← context-specific decisions
|
|
36
|
+
└── billing/
|
|
37
|
+
├── CONTEXT.md
|
|
38
|
+
└── docs/adr/
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Use the glossary's vocabulary
|
|
42
|
+
|
|
43
|
+
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.
|
|
44
|
+
|
|
45
|
+
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`).
|
|
46
|
+
|
|
47
|
+
## Flag ADR conflicts
|
|
48
|
+
|
|
49
|
+
If your output contradicts an existing ADR, surface it explicitly rather than silently overriding:
|
|
50
|
+
|
|
51
|
+
> _Contradicts ADR-0007 (event-sourced orders) — but worth reopening because…_
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Issue tracker: GitHub
|
|
2
|
+
|
|
3
|
+
Issues and PRDs for this repo live as GitHub issues. Use the `gh` CLI for all operations.
|
|
4
|
+
|
|
5
|
+
## Conventions
|
|
6
|
+
|
|
7
|
+
- **Create an issue**: `gh issue create --title "..." --body "..."`. Use a heredoc for multi-line bodies.
|
|
8
|
+
- **Read an issue**: `gh issue view <number> --comments`, filtering comments by `jq` and also fetching labels.
|
|
9
|
+
- **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.
|
|
10
|
+
- **Comment on an issue**: `gh issue comment <number> --body "..."`
|
|
11
|
+
- **Apply / remove labels**: `gh issue edit <number> --add-label "..."` / `--remove-label "..."`
|
|
12
|
+
- **Close**: `gh issue close <number> --comment "..."`
|
|
13
|
+
|
|
14
|
+
Infer the repo from `git remote -v` — `gh` does this automatically when run inside a clone.
|
|
15
|
+
|
|
16
|
+
## When a skill says "publish to the issue tracker"
|
|
17
|
+
|
|
18
|
+
Create a GitHub issue.
|
|
19
|
+
|
|
20
|
+
## When a skill says "fetch the relevant ticket"
|
|
21
|
+
|
|
22
|
+
Run `gh issue view <number> --comments`.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Issue tracker: GitLab
|
|
2
|
+
|
|
3
|
+
Issues and PRDs for this repo live as GitLab issues. Use the [`glab`](https://gitlab.com/gitlab-org/cli) CLI for all operations.
|
|
4
|
+
|
|
5
|
+
## Conventions
|
|
6
|
+
|
|
7
|
+
- **Create an issue**: `glab issue create --title "..." --description "..."`. Use a heredoc for multi-line descriptions. Pass `--description -` to open an editor.
|
|
8
|
+
- **Read an issue**: `glab issue view <number> --comments`. Use `-F json` for machine-readable output.
|
|
9
|
+
- **List issues**: `glab issue list -F json` with appropriate `--label` filters.
|
|
10
|
+
- **Comment on an issue**: `glab issue note <number> --message "..."`. GitLab calls comments "notes".
|
|
11
|
+
- **Apply / remove labels**: `glab issue update <number> --label "..."` / `--unlabel "..."`. Multiple labels can be comma-separated or by repeating the flag.
|
|
12
|
+
- **Close**: `glab issue close <number>`. `glab issue close` does not accept a closing comment, so post the explanation first with `glab issue note <number> --message "..."`, then close.
|
|
13
|
+
- **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`.
|
|
14
|
+
|
|
15
|
+
Infer the repo from `git remote -v` — `glab` does this automatically when run inside a clone.
|
|
16
|
+
|
|
17
|
+
## When a skill says "publish to the issue tracker"
|
|
18
|
+
|
|
19
|
+
Create a GitLab issue.
|
|
20
|
+
|
|
21
|
+
## When a skill says "fetch the relevant ticket"
|
|
22
|
+
|
|
23
|
+
Run `glab issue view <number> --comments`.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Issue tracker: Local Markdown
|
|
2
|
+
|
|
3
|
+
Issues and PRDs for this repo live as markdown files in `.scratch/`.
|
|
4
|
+
|
|
5
|
+
## Conventions
|
|
6
|
+
|
|
7
|
+
- One feature per directory: `.scratch/<feature-slug>/`
|
|
8
|
+
- The PRD is `.scratch/<feature-slug>/PRD.md`
|
|
9
|
+
- Implementation issues are `.scratch/<feature-slug>/issues/<NN>-<slug>.md`, numbered from `01`
|
|
10
|
+
- Triage state is recorded as a `Status:` line near the top of each issue file (see `triage-labels.md` for the role strings)
|
|
11
|
+
- Comments and conversation history append to the bottom of the file under a `## Comments` heading
|
|
12
|
+
|
|
13
|
+
## When a skill says "publish to the issue tracker"
|
|
14
|
+
|
|
15
|
+
Create a new file under `.scratch/<feature-slug>/` (creating the directory if needed).
|
|
16
|
+
|
|
17
|
+
## When a skill says "fetch the relevant ticket"
|
|
18
|
+
|
|
19
|
+
Read the file at the referenced path. The user will normally pass the path or the issue number directly.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Triage Labels
|
|
2
|
+
|
|
3
|
+
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.
|
|
4
|
+
|
|
5
|
+
| Label in mattpocock/skills | Label in our tracker | Meaning |
|
|
6
|
+
| -------------------------- | -------------------- | ---------------------------------------- |
|
|
7
|
+
| `needs-triage` | `needs-triage` | Maintainer needs to evaluate this issue |
|
|
8
|
+
| `needs-info` | `needs-info` | Waiting on reporter for more information |
|
|
9
|
+
| `ready-for-agent` | `ready-for-agent` | Fully specified, ready for an AFK agent |
|
|
10
|
+
| `ready-for-human` | `ready-for-human` | Requires human implementation |
|
|
11
|
+
| `wontfix` | `wontfix` | Will not be actioned |
|
|
12
|
+
|
|
13
|
+
When a skill mentions a role (e.g. "apply the AFK-ready triage label"), use the corresponding label string from this table.
|
|
14
|
+
|
|
15
|
+
Edit the right-hand column to match whatever vocabulary you actually use.
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: tdd
|
|
3
|
+
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.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Test-Driven Development
|
|
7
|
+
|
|
8
|
+
## Philosophy
|
|
9
|
+
|
|
10
|
+
**Core principle**: Tests should verify behavior through public interfaces, not implementation details. Code can change entirely; tests shouldn't.
|
|
11
|
+
|
|
12
|
+
**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.
|
|
13
|
+
|
|
14
|
+
**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.
|
|
15
|
+
|
|
16
|
+
See [tests.md](tests.md) for examples and [mocking.md](mocking.md) for mocking guidelines.
|
|
17
|
+
|
|
18
|
+
## Anti-Pattern: Horizontal Slices
|
|
19
|
+
|
|
20
|
+
**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."
|
|
21
|
+
|
|
22
|
+
This produces **crap tests**:
|
|
23
|
+
|
|
24
|
+
- Tests written in bulk test _imagined_ behavior, not _actual_ behavior
|
|
25
|
+
- You end up testing the _shape_ of things (data structures, function signatures) rather than user-facing behavior
|
|
26
|
+
- Tests become insensitive to real changes - they pass when behavior breaks, fail when behavior is fine
|
|
27
|
+
- You outrun your headlights, committing to test structure before understanding the implementation
|
|
28
|
+
|
|
29
|
+
**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.
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
WRONG (horizontal):
|
|
33
|
+
RED: test1, test2, test3, test4, test5
|
|
34
|
+
GREEN: impl1, impl2, impl3, impl4, impl5
|
|
35
|
+
|
|
36
|
+
RIGHT (vertical):
|
|
37
|
+
RED→GREEN: test1→impl1
|
|
38
|
+
RED→GREEN: test2→impl2
|
|
39
|
+
RED→GREEN: test3→impl3
|
|
40
|
+
...
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Workflow
|
|
44
|
+
|
|
45
|
+
### 1. Planning
|
|
46
|
+
|
|
47
|
+
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.
|
|
48
|
+
|
|
49
|
+
Before writing any code:
|
|
50
|
+
|
|
51
|
+
- [ ] Confirm with user what interface changes are needed
|
|
52
|
+
- [ ] Confirm with user which behaviors to test (prioritize)
|
|
53
|
+
- [ ] Identify opportunities for [deep modules](deep-modules.md) (small interface, deep implementation)
|
|
54
|
+
- [ ] Design interfaces for [testability](interface-design.md)
|
|
55
|
+
- [ ] List the behaviors to test (not implementation steps)
|
|
56
|
+
- [ ] Get user approval on the plan
|
|
57
|
+
|
|
58
|
+
Ask: "What should the public interface look like? Which behaviors are most important to test?"
|
|
59
|
+
|
|
60
|
+
**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.
|
|
61
|
+
|
|
62
|
+
### 2. Tracer Bullet
|
|
63
|
+
|
|
64
|
+
Write ONE test that confirms ONE thing about the system:
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
RED: Write test for first behavior → test fails
|
|
68
|
+
GREEN: Write minimal code to pass → test passes
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
This is your tracer bullet - proves the path works end-to-end.
|
|
72
|
+
|
|
73
|
+
### 3. Incremental Loop
|
|
74
|
+
|
|
75
|
+
For each remaining behavior:
|
|
76
|
+
|
|
77
|
+
```
|
|
78
|
+
RED: Write next test → fails
|
|
79
|
+
GREEN: Minimal code to pass → passes
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Rules:
|
|
83
|
+
|
|
84
|
+
- One test at a time
|
|
85
|
+
- Only enough code to pass current test
|
|
86
|
+
- Don't anticipate future tests
|
|
87
|
+
- Keep tests focused on observable behavior
|
|
88
|
+
|
|
89
|
+
### 4. Refactor
|
|
90
|
+
|
|
91
|
+
After all tests pass, look for [refactor candidates](refactoring.md):
|
|
92
|
+
|
|
93
|
+
- [ ] Extract duplication
|
|
94
|
+
- [ ] Deepen modules (move complexity behind simple interfaces)
|
|
95
|
+
- [ ] Apply SOLID principles where natural
|
|
96
|
+
- [ ] Consider what new code reveals about existing code
|
|
97
|
+
- [ ] Run tests after each refactor step
|
|
98
|
+
|
|
99
|
+
**Never refactor while RED.** Get to GREEN first.
|
|
100
|
+
|
|
101
|
+
## Checklist Per Cycle
|
|
102
|
+
|
|
103
|
+
```
|
|
104
|
+
[ ] Test describes behavior, not implementation
|
|
105
|
+
[ ] Test uses public interface only
|
|
106
|
+
[ ] Test would survive internal refactor
|
|
107
|
+
[ ] Code is minimal for this test
|
|
108
|
+
[ ] No speculative features added
|
|
109
|
+
```
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Deep Modules
|
|
2
|
+
|
|
3
|
+
From "A Philosophy of Software Design":
|
|
4
|
+
|
|
5
|
+
**Deep module** = small interface + lots of implementation
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
┌─────────────────────┐
|
|
9
|
+
│ Small Interface │ ← Few methods, simple params
|
|
10
|
+
├─────────────────────┤
|
|
11
|
+
│ │
|
|
12
|
+
│ │
|
|
13
|
+
│ Deep Implementation│ ← Complex logic hidden
|
|
14
|
+
│ │
|
|
15
|
+
│ │
|
|
16
|
+
└─────────────────────┘
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
**Shallow module** = large interface + little implementation (avoid)
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
┌─────────────────────────────────┐
|
|
23
|
+
│ Large Interface │ ← Many methods, complex params
|
|
24
|
+
├─────────────────────────────────┤
|
|
25
|
+
│ Thin Implementation │ ← Just passes through
|
|
26
|
+
└─────────────────────────────────┘
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
When designing interfaces, ask:
|
|
30
|
+
|
|
31
|
+
- Can I reduce the number of methods?
|
|
32
|
+
- Can I simplify the parameters?
|
|
33
|
+
- Can I hide more complexity inside?
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Interface Design for Testability
|
|
2
|
+
|
|
3
|
+
Good interfaces make testing natural:
|
|
4
|
+
|
|
5
|
+
1. **Accept dependencies, don't create them**
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
// Testable
|
|
9
|
+
function processOrder(order, paymentGateway) {}
|
|
10
|
+
|
|
11
|
+
// Hard to test
|
|
12
|
+
function processOrder(order) {
|
|
13
|
+
const gateway = new StripeGateway();
|
|
14
|
+
}
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
2. **Return results, don't produce side effects**
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
// Testable
|
|
21
|
+
function calculateDiscount(cart): Discount {}
|
|
22
|
+
|
|
23
|
+
// Hard to test
|
|
24
|
+
function applyDiscount(cart): void {
|
|
25
|
+
cart.total -= discount;
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
3. **Small surface area**
|
|
30
|
+
- Fewer methods = fewer tests needed
|
|
31
|
+
- Fewer params = simpler test setup
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# When to Mock
|
|
2
|
+
|
|
3
|
+
Mock at **system boundaries** only:
|
|
4
|
+
|
|
5
|
+
- External APIs (payment, email, etc.)
|
|
6
|
+
- Databases (sometimes - prefer test DB)
|
|
7
|
+
- Time/randomness
|
|
8
|
+
- File system (sometimes)
|
|
9
|
+
|
|
10
|
+
Don't mock:
|
|
11
|
+
|
|
12
|
+
- Your own classes/modules
|
|
13
|
+
- Internal collaborators
|
|
14
|
+
- Anything you control
|
|
15
|
+
|
|
16
|
+
## Designing for Mockability
|
|
17
|
+
|
|
18
|
+
At system boundaries, design interfaces that are easy to mock:
|
|
19
|
+
|
|
20
|
+
**1. Use dependency injection**
|
|
21
|
+
|
|
22
|
+
Pass external dependencies in rather than creating them internally:
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
// Easy to mock
|
|
26
|
+
function processPayment(order, paymentClient) {
|
|
27
|
+
return paymentClient.charge(order.total);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Hard to mock
|
|
31
|
+
function processPayment(order) {
|
|
32
|
+
const client = new StripeClient(process.env.STRIPE_KEY);
|
|
33
|
+
return client.charge(order.total);
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
**2. Prefer SDK-style interfaces over generic fetchers**
|
|
38
|
+
|
|
39
|
+
Create specific functions for each external operation instead of one generic function with conditional logic:
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
// GOOD: Each function is independently mockable
|
|
43
|
+
const api = {
|
|
44
|
+
getUser: (id) => fetch(`/users/${id}`),
|
|
45
|
+
getOrders: (userId) => fetch(`/users/${userId}/orders`),
|
|
46
|
+
createOrder: (data) => fetch('/orders', { method: 'POST', body: data }),
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// BAD: Mocking requires conditional logic inside the mock
|
|
50
|
+
const api = {
|
|
51
|
+
fetch: (endpoint, options) => fetch(endpoint, options),
|
|
52
|
+
};
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
The SDK approach means:
|
|
56
|
+
- Each mock returns one specific shape
|
|
57
|
+
- No conditional logic in test setup
|
|
58
|
+
- Easier to see which endpoints a test exercises
|
|
59
|
+
- Type safety per endpoint
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Refactor Candidates
|
|
2
|
+
|
|
3
|
+
After TDD cycle, look for:
|
|
4
|
+
|
|
5
|
+
- **Duplication** → Extract function/class
|
|
6
|
+
- **Long methods** → Break into private helpers (keep tests on public interface)
|
|
7
|
+
- **Shallow modules** → Combine or deepen
|
|
8
|
+
- **Feature envy** → Move logic to where data lives
|
|
9
|
+
- **Primitive obsession** → Introduce value objects
|
|
10
|
+
- **Existing code** the new code reveals as problematic
|