@beremaran/ralphie 0.0.0-stage → 0.2.0

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.
Files changed (37) hide show
  1. package/CHANGELOG.md +832 -0
  2. package/LICENSE +21 -0
  3. package/README.md +53 -2
  4. package/dist/ralphie.js +33691 -0
  5. package/docs/README.md +71 -0
  6. package/docs/architecture.md +159 -0
  7. package/docs/cli-reference.md +126 -0
  8. package/docs/configuration.md +269 -0
  9. package/docs/development.md +248 -0
  10. package/docs/getting-started.md +134 -0
  11. package/docs/operations-and-recovery.md +328 -0
  12. package/docs/safety.md +189 -0
  13. package/docs/workflows.md +411 -0
  14. package/package.json +83 -3
  15. package/vendor/mattpocock-skills/LICENSE +21 -0
  16. package/vendor/mattpocock-skills/code-review/SKILL.md +87 -0
  17. package/vendor/mattpocock-skills/code-review/agents/openai.yaml +3 -0
  18. package/vendor/mattpocock-skills/codebase-design/DEEPENING.md +37 -0
  19. package/vendor/mattpocock-skills/codebase-design/DESIGN-IT-TWICE.md +44 -0
  20. package/vendor/mattpocock-skills/codebase-design/SKILL.md +114 -0
  21. package/vendor/mattpocock-skills/codebase-design/agents/openai.yaml +3 -0
  22. package/vendor/mattpocock-skills/diagnosing-bugs/SKILL.md +138 -0
  23. package/vendor/mattpocock-skills/diagnosing-bugs/agents/openai.yaml +3 -0
  24. package/vendor/mattpocock-skills/diagnosing-bugs/scripts/hitl-loop.template.sh +44 -0
  25. package/vendor/mattpocock-skills/implement/SKILL.md +15 -0
  26. package/vendor/mattpocock-skills/implement/agents/openai.yaml +5 -0
  27. package/vendor/mattpocock-skills/lock.json +37 -0
  28. package/vendor/mattpocock-skills/tdd/SKILL.md +38 -0
  29. package/vendor/mattpocock-skills/tdd/agents/openai.yaml +3 -0
  30. package/vendor/mattpocock-skills/tdd/mocking.md +59 -0
  31. package/vendor/mattpocock-skills/tdd/tests.md +77 -0
  32. package/vendor/mattpocock-skills/to-tickets/SKILL.md +105 -0
  33. package/vendor/mattpocock-skills/to-tickets/agents/openai.yaml +5 -0
  34. package/vendor/mattpocock-skills/triage/AGENT-BRIEF.md +207 -0
  35. package/vendor/mattpocock-skills/triage/OUT-OF-SCOPE.md +105 -0
  36. package/vendor/mattpocock-skills/triage/SKILL.md +112 -0
  37. package/vendor/mattpocock-skills/triage/agents/openai.yaml +5 -0
@@ -0,0 +1,44 @@
1
+ # Design It Twice
2
+
3
+ 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.
4
+
5
+ Uses the vocabulary in [SKILL.md](SKILL.md): **module**, **interface**, **seam**, **adapter**, **leverage**.
6
+
7
+ ## Process
8
+
9
+ ### 1. Frame the problem space
10
+
11
+ Before spawning sub-agents, write a user-facing explanation of the problem space for the chosen candidate:
12
+
13
+ - The constraints any new interface would need to satisfy
14
+ - The dependencies it would rely on, and which category they fall into (see [DEEPENING.md](DEEPENING.md))
15
+ - A rough illustrative code sketch to ground the constraints, not a proposal, just a way to make the constraints concrete
16
+
17
+ Show this to the user, then immediately proceed to Step 2. The user reads and thinks while the sub-agents work in parallel.
18
+
19
+ ### 2. Spawn sub-agents
20
+
21
+ Spawn 3+ sub-agents in parallel. Each must produce a **radically different** interface for the deepened module.
22
+
23
+ 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:
24
+
25
+ - Agent 1: "Minimize the interface: aim for 1–3 entry points max. Maximise leverage per entry point."
26
+ - Agent 2: "Maximise flexibility: support many use cases and extension."
27
+ - Agent 3: "Optimise for the most common caller: make the default case trivial."
28
+ - Agent 4 (if applicable): "Design around ports & adapters for cross-seam dependencies."
29
+
30
+ 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.
31
+
32
+ Each sub-agent outputs:
33
+
34
+ 1. Interface (types, methods, params, plus invariants, ordering, error modes)
35
+ 2. Usage example showing how callers use it
36
+ 3. What the implementation hides behind the seam
37
+ 4. Dependency strategy and adapters (see [DEEPENING.md](DEEPENING.md))
38
+ 5. Trade-offs: where leverage is high, where it's thin
39
+
40
+ ### 3. Present and compare
41
+
42
+ 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**.
43
+
44
+ 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.
@@ -0,0 +1,114 @@
1
+ ---
2
+ name: codebase-design
3
+ 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.
4
+ ---
5
+
6
+ # Codebase Design
7
+
8
+ 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.
9
+
10
+ ## Glossary
11
+
12
+ Use these terms exactly: don't substitute "component," "service," "API," or "boundary." Consistent language is the whole point.
13
+
14
+ **Module**: anything with an interface and an implementation. Deliberately scale-agnostic: a function, class, package, or tier-spanning slice. _Avoid_: unit, component, service.
15
+
16
+ **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).
17
+
18
+ **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.
19
+
20
+ **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.
21
+
22
+ **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).
23
+
24
+ **Adapter**: a concrete thing that satisfies an interface at a seam. Describes *role* (what slot it fills), not substance (what's inside).
25
+
26
+ **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.
27
+
28
+ **Locality**: what maintainers get from depth. Change, bugs, knowledge, and verification concentrate in one place rather than spreading across callers. Fix once, fixed everywhere.
29
+
30
+ ## Deep vs shallow
31
+
32
+ **Deep module** = small interface + lots of implementation:
33
+
34
+ ```
35
+ ┌─────────────────────┐
36
+ │ Small Interface │ ← Few methods, simple params
37
+ ├─────────────────────┤
38
+ │ │
39
+ │ Deep Implementation│ ← Complex logic hidden
40
+ │ │
41
+ └─────────────────────┘
42
+ ```
43
+
44
+ **Shallow module** = large interface + little implementation (avoid):
45
+
46
+ ```
47
+ ┌─────────────────────────────────┐
48
+ │ Large Interface │ ← Many methods, complex params
49
+ ├─────────────────────────────────┤
50
+ │ Thin Implementation │ ← Just passes through
51
+ └─────────────────────────────────┘
52
+ ```
53
+
54
+ When designing an interface, ask:
55
+
56
+ - Can I reduce the number of methods?
57
+ - Can I simplify the parameters?
58
+ - Can I hide more complexity inside?
59
+
60
+ ## Principles
61
+
62
+ - **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.
63
+ - **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.
64
+ - **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.
65
+ - **One adapter means a hypothetical seam. Two adapters means a real one.** Don't introduce a seam unless something actually varies across it.
66
+
67
+ ## Designing for testability
68
+
69
+ Good interfaces make testing natural:
70
+
71
+ 1. **Accept dependencies, don't create them.**
72
+
73
+ ```typescript
74
+ // Testable
75
+ function processOrder(order, paymentGateway) {}
76
+
77
+ // Hard to test
78
+ function processOrder(order) {
79
+ const gateway = new StripeGateway();
80
+ }
81
+ ```
82
+
83
+ 2. **Return results, don't produce side effects.**
84
+
85
+ ```typescript
86
+ // Testable
87
+ function calculateDiscount(cart): Discount {}
88
+
89
+ // Hard to test
90
+ function applyDiscount(cart): void {
91
+ cart.total -= discount;
92
+ }
93
+ ```
94
+
95
+ 3. **Small surface area.** Fewer methods = fewer tests needed. Fewer params = simpler test setup.
96
+
97
+ ## Relationships
98
+
99
+ - A **Module** has exactly one **Interface** (the surface it presents to callers and tests).
100
+ - **Depth** is a property of a **Module**, measured against its **Interface**.
101
+ - A **Seam** is where a **Module**'s **Interface** lives.
102
+ - An **Adapter** sits at a **Seam** and satisfies the **Interface**.
103
+ - **Depth** produces **Leverage** for callers and **Locality** for maintainers.
104
+
105
+ ## Rejected framings
106
+
107
+ - **Depth as ratio of implementation-lines to interface-lines** (Ousterhout): rewards padding the implementation. We use depth-as-leverage instead.
108
+ - **"Interface" as the TypeScript `interface` keyword or a class's public methods**: too narrow: interface here includes every fact a caller must know.
109
+ - **"Boundary"**: overloaded with DDD's bounded context. Say **seam** or **interface**.
110
+
111
+ ## Going deeper
112
+
113
+ - **Deepening a cluster given its dependencies**, see [DEEPENING.md](DEEPENING.md): dependency categories, seam discipline, and replace-don't-layer testing.
114
+ - **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.
@@ -0,0 +1,3 @@
1
+ interface:
2
+ display_name: "Codebase Design"
3
+ short_description: "Vocabulary for deep-module design"
@@ -0,0 +1,138 @@
1
+ ---
2
+ name: diagnosing-bugs
3
+ description: Diagnosis loop for hard bugs and performance regressions. Use when the user says "diagnose"/"debug this", or reports something broken/throwing/failing/slow.
4
+ ---
5
+
6
+ # Diagnosing Bugs
7
+
8
+ A discipline for hard bugs. Skip phases only when explicitly justified.
9
+
10
+ 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.
11
+
12
+ ## Redact
13
+
14
+ This skill has you show commands, outputs and captured artifacts. **Redact every secret first**: write `<REDACTED>` 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.
15
+
16
+ If the redacted output is not enough to diagnose the bug, say so and ask the user.
17
+
18
+ ## Phase 1: Build a feedback loop
19
+
20
+ **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.
21
+
22
+ Spend disproportionate effort here. **Be aggressive. Be creative. Refuse to give up.**
23
+
24
+ ### Ways to construct one, in roughly this order
25
+
26
+ 1. **Failing test** at whatever seam reaches the bug: unit, integration, e2e.
27
+ 2. **Curl / HTTP script** against a running dev server.
28
+ 3. **CLI invocation** with a fixture input, diffing stdout against a known-good snapshot.
29
+ 4. **Headless browser script** (Playwright / Puppeteer) that drives the UI and asserts on DOM/console/network.
30
+ 5. **Replay a captured trace.** Save a real network request / payload / event log to disk; replay it through the code path in isolation.
31
+ 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.
32
+ 7. **Property / fuzz loop.** If the bug is "sometimes wrong output", run 1000 random inputs and look for the failure mode.
33
+ 8. **Bisection harness.** If the bug appeared between two known states (commit, dataset, version), automate "boot at state X, check, repeat" so you can `git bisect run` it.
34
+ 9. **Differential loop.** Run the same input through old-version vs new-version (or two configs) and diff outputs.
35
+ 10. **HITL bash script.** Last resort. If a human must click, drive _them_ with `scripts/hitl-loop.template.sh` so the loop is still structured. Captured output feeds back to you.
36
+
37
+ Build the right feedback loop, and the bug is 90% fixed.
38
+
39
+ ### Tighten the loop
40
+
41
+ Treat the loop as a product. Once you have _a_ loop, **tighten** it:
42
+
43
+ - Can I make it faster? (Cache setup, skip unrelated init, narrow the test scope.)
44
+ - Can I make the signal sharper? (Assert on the specific symptom, not "didn't crash".)
45
+ - Can I make it more deterministic? (Pin time, seed RNG, isolate filesystem, freeze network.)
46
+
47
+ A 30-second flaky loop is barely better than no loop; a 2-second deterministic one is tight, a debugging superpower.
48
+
49
+ ### Non-deterministic bugs
50
+
51
+ 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.
52
+
53
+ ### When you genuinely cannot build a loop
54
+
55
+ 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.
56
+
57
+ ### Completion criterion: a tight loop that goes red
58
+
59
+ 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:
60
+
61
+ - [ ] **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_.
62
+ - [ ] **Deterministic**: same verdict every run (flaky bugs: a pinned, high reproduction rate, per above).
63
+ - [ ] **Fast**: seconds, not minutes.
64
+ - [ ] **Agent-runnable**: you can run it unattended; a human in the loop only via `scripts/hitl-loop.template.sh`.
65
+
66
+ 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.
67
+
68
+ ## Phase 2: Reproduce + minimise
69
+
70
+ Run the loop. Watch it go red as the bug appears.
71
+
72
+ Confirm:
73
+
74
+ - [ ] The loop produces the failure mode the **user** described, not a different failure that happens to be nearby. Wrong bug = wrong fix.
75
+ - [ ] The failure is reproducible across multiple runs (or, for non-deterministic bugs, reproducible at a high enough rate to debug against).
76
+ - [ ] You have captured the exact symptom (error message, wrong output, slow timing) so later phases can verify the fix actually addresses it.
77
+
78
+ ### Minimise
79
+
80
+ 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.
81
+
82
+ 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.
83
+
84
+ Done when **every remaining element is load-bearing**: removing any one of them makes the loop go green.
85
+
86
+ Do not proceed until you have reproduced **and** minimised.
87
+
88
+ ## Phase 3: Hypothesise
89
+
90
+ Generate **3–5 ranked hypotheses** before testing any of them. Single-hypothesis generation anchors on the first plausible idea.
91
+
92
+ Each hypothesis must be **falsifiable**: state the prediction it makes.
93
+
94
+ > Format: "If <X> is the cause, then <changing Y> will make the bug disappear / <changing Z> will make it worse."
95
+
96
+ If you cannot state the prediction, the hypothesis is a vibe: discard or sharpen it.
97
+
98
+ **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.
99
+
100
+ ## Phase 4: Instrument
101
+
102
+ Each probe must map to a specific prediction from Phase 3. **Change one variable at a time.**
103
+
104
+ Tool preference:
105
+
106
+ 1. **Debugger / REPL inspection** if the env supports it. One breakpoint beats ten logs.
107
+ 2. **Targeted logs** at the boundaries that distinguish hypotheses.
108
+ 3. Never "log everything and grep".
109
+
110
+ **Tag every debug log** with a unique prefix, e.g. `[DEBUG-a4f2]`. Cleanup at the end becomes a single grep. Untagged logs survive; tagged logs die.
111
+
112
+ **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.
113
+
114
+ ## Phase 5: Fix + regression test
115
+
116
+ Write the regression test **before the fix**, but only if there is a **correct seam** for it.
117
+
118
+ 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.
119
+
120
+ **If no correct seam exists, that itself is the finding.** Note it. The codebase architecture is preventing the bug from being locked down. Flag this for the next phase.
121
+
122
+ If a correct seam exists:
123
+
124
+ 1. Turn the minimised repro into a failing test at that seam.
125
+ 2. Watch it fail.
126
+ 3. Apply the fix.
127
+ 4. Watch it pass.
128
+ 5. Re-run the Phase 1 feedback loop against the original (un-minimised) scenario.
129
+
130
+ ## Phase 6: Cleanup
131
+
132
+ Required before declaring done:
133
+
134
+ - [ ] Original repro no longer reproduces (re-run the Phase 1 loop)
135
+ - [ ] Regression test passes (or absence of seam is documented)
136
+ - [ ] All `[DEBUG-...]` instrumentation removed (`grep` the prefix)
137
+ - [ ] Throwaway prototypes deleted (or moved to a clearly-marked debug location)
138
+ - [ ] The hypothesis that turned out correct is stated in the commit / PR message, so the next debugger learns
@@ -0,0 +1,3 @@
1
+ interface:
2
+ display_name: "Diagnosing Bugs"
3
+ short_description: "Diagnose hard bugs and regressions"
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env bash
2
+ # Human-in-the-loop reproduction loop.
3
+ # Copy this file, edit the steps below, and run it.
4
+ # The agent runs the script; the user follows prompts in their terminal.
5
+ #
6
+ # Usage:
7
+ # bash hitl-loop.template.sh
8
+ #
9
+ # Two helpers:
10
+ # step "<instruction>" → show instruction, wait for Enter
11
+ # capture VAR "<question>" → show question, read response into VAR
12
+ #
13
+ # At the end, captured values are printed as KEY=VALUE for the agent to parse.
14
+ #
15
+ # `capture` prints its value back to the terminal, where the agent reads it,
16
+ # so capture observations, and leave signing in to the user as a `step`.
17
+
18
+ set -euo pipefail
19
+
20
+ step() {
21
+ printf '\n>>> %s\n' "$1"
22
+ read -r -p " [Enter when done] " _
23
+ }
24
+
25
+ capture() {
26
+ local var="$1" question="$2" answer
27
+ printf '\n>>> %s\n' "$question"
28
+ read -r -p " > " answer
29
+ printf -v "$var" '%s' "$answer"
30
+ }
31
+
32
+ # --- edit below ---------------------------------------------------------
33
+
34
+ step "Open the app at http://localhost:3000 and sign in."
35
+
36
+ capture ERRORED "Click the 'Export' button. Did it throw an error? (y/n)"
37
+
38
+ capture ERROR_MSG "Paste the error message (or 'none'):"
39
+
40
+ # --- edit above ---------------------------------------------------------
41
+
42
+ printf '\n--- Captured ---\n'
43
+ printf 'ERRORED=%s\n' "$ERRORED"
44
+ printf 'ERROR_MSG=%s\n' "$ERROR_MSG"
@@ -0,0 +1,15 @@
1
+ ---
2
+ name: implement
3
+ description: "Implement a piece of work based on a spec or set of tickets."
4
+ disable-model-invocation: true
5
+ ---
6
+
7
+ Implement the work described by the user in the spec or tickets.
8
+
9
+ Use /tdd where possible, at pre-agreed seams.
10
+
11
+ Run typechecking regularly, single test files regularly, and the full test suite once at the end.
12
+
13
+ Once done, use /code-review to review the work.
14
+
15
+ Commit your work to the current branch.
@@ -0,0 +1,5 @@
1
+ interface:
2
+ display_name: "Implement"
3
+ short_description: "Build work from a spec or tickets"
4
+ policy:
5
+ allow_implicit_invocation: false
@@ -0,0 +1,37 @@
1
+ {
2
+ "repository": "https://github.com/mattpocock/skills",
3
+ "commit": "4588b32ecab9ecc9fc8cc6b6c5e7d675b6004b0d",
4
+ "skills": {
5
+ "code-review": "skills/engineering/code-review",
6
+ "codebase-design": "skills/engineering/codebase-design",
7
+ "diagnosing-bugs": "skills/engineering/diagnosing-bugs",
8
+ "implement": "skills/engineering/implement",
9
+ "tdd": "skills/engineering/tdd",
10
+ "to-tickets": "skills/engineering/to-tickets",
11
+ "triage": "skills/engineering/triage"
12
+ },
13
+ "files": {
14
+ "LICENSE": "f1dd2c09108dde1a5f56097cee8461b3ea834499",
15
+ "code-review/SKILL.md": "e28d7acbf7b3bb4d7817b7eb5d9c105af03f6ec4",
16
+ "code-review/agents/openai.yaml": "9076774ba327f49068db9273feceda03bfe940fa",
17
+ "codebase-design/DEEPENING.md": "cd94075cfd754d147555c5d747a16431ed4c7dd8",
18
+ "codebase-design/DESIGN-IT-TWICE.md": "d0990138c35c800bd821289a73115e52680c1620",
19
+ "codebase-design/SKILL.md": "3f63c8146dd2604b419c929e9876b90c30d410e9",
20
+ "codebase-design/agents/openai.yaml": "3180715edb37f6e96bec42f92f00169faa8886ef",
21
+ "diagnosing-bugs/SKILL.md": "1b929e29fb519c26b500d3eda744177986883ac8",
22
+ "diagnosing-bugs/agents/openai.yaml": "a13a755a77634ce61a649a3a0d905a66d3865b35",
23
+ "diagnosing-bugs/scripts/hitl-loop.template.sh": "243198464a8401a7ba1d63b3708fa43c3d067665",
24
+ "implement/SKILL.md": "7a0b11f5f4fe9505ea5c7983c3083ba1bf754f69",
25
+ "implement/agents/openai.yaml": "f8794dc153b409052a9167baf10858cf01b36175",
26
+ "tdd/SKILL.md": "250871ccdfefa7525309acfebda090edf4046882",
27
+ "tdd/agents/openai.yaml": "651b838a7663e027b1b8884491e867f26bb9a021",
28
+ "tdd/mocking.md": "71cbfee674d93244ce81d1830b930ca9a69200bd",
29
+ "tdd/tests.md": "7ab86479f925a1f9e8ba680af33cb3b12e015381",
30
+ "to-tickets/SKILL.md": "e868c831fcfb1e124e010bcdf84a429ec879160f",
31
+ "to-tickets/agents/openai.yaml": "24605a5db64e4fc750b999aa94aea126bee814ee",
32
+ "triage/AGENT-BRIEF.md": "1462fcd9e8cc21921158c296149dc05d9be39d20",
33
+ "triage/OUT-OF-SCOPE.md": "c9fba2f77ee0619975ec8488c0d4861a0c7e3151",
34
+ "triage/SKILL.md": "3fd5617e906cf9b71a6b17424791adb905fc248b",
35
+ "triage/agents/openai.yaml": "acb366cf0f2527e8925ff1223b77610ac0b1be4c"
36
+ }
37
+ }
@@ -0,0 +1,38 @@
1
+ ---
2
+ name: tdd
3
+ description: Test-driven development. Use when the user wants to build features or fix bugs test-first, mentions "red-green-refactor", or wants integration tests.
4
+ ---
5
+
6
+ # Test-Driven Development
7
+
8
+ TDD is the red → green loop. This skill is the reference that makes that loop produce tests worth keeping: what a good test is, where tests go, the anti-patterns, and the rules of the loop. Every section applies on every cycle: consult them before and during the loop, not after.
9
+
10
+ When exploring the codebase, read `GLOSSARY.md` (if it exists) so test names and interface vocabulary match the project's domain language, and respect ADRs in the area you're touching.
11
+
12
+ ## What a good test is
13
+
14
+ Tests verify behavior through public interfaces, not implementation details. Code can change entirely; tests shouldn't. A good test reads like a specification: "user can checkout with valid cart" tells you exactly what capability exists, and it survives refactors because it doesn't care about internal structure.
15
+
16
+ See [tests.md](tests.md) for examples and [mocking.md](mocking.md) for mocking guidelines.
17
+
18
+ ## Seams: where tests go
19
+
20
+ A **seam** is the public boundary you test at: the interface where you observe behavior without reaching inside. Tests live at seams, never against internals.
21
+
22
+ **Test only at pre-agreed seams.** Before writing any test, write down the seams under test and confirm them with the user. No test is written at an unconfirmed seam. You can't test everything, so agreeing the seams up front is how testing effort lands on the critical paths and complex logic instead of every edge case.
23
+
24
+ Ask: "What's the public interface, and which seams should we test?"
25
+
26
+ When the shape of that interface is itself in question (how deep the module is, where the seam belongs, what the interface should expose), call the Skill tool with "codebase-design" for the vocabulary. It is the shared source of the module, interface, depth, seam, adapter, leverage and locality terms, and it is a reference to consult, not a session to run.
27
+
28
+ ## Anti-patterns
29
+
30
+ - **Implementation-coupled**: mocks internal collaborators, tests private methods, or verifies through a side channel (querying the database instead of using the interface). The tell: the test breaks when you refactor but behavior hasn't changed.
31
+ - **Tautological**: the assertion recomputes the expected value the way the code does (`expect(add(a, b)).toBe(a + b)`, a snapshot derived by hand the same way, a constant asserted equal to itself), so it passes by construction and can never disagree with the code. Expected values must come from an independent source of truth: a known-good literal, a worked example, the spec.
32
+ - **Horizontal slicing**: writing all tests first, then all implementation. Bulk tests verify _imagined_ behavior: you test the _shape_ of things rather than user-facing behavior, the tests go insensitive to real changes, and you commit to test structure before understanding the implementation. Work in **vertical slices** instead: one test → one implementation → repeat, each test a **tracer bullet** that responds to what the last cycle taught you.
33
+
34
+ ## Rules of the loop
35
+
36
+ - **Red before green.** Write the failing test first, then only enough code to pass it. Don't anticipate future tests or add speculative features.
37
+ - **One slice at a time.** One seam, one test, one minimal implementation per cycle.
38
+ - **Refactoring is not part of the loop.** It belongs to the review stage (see the `code-review` skill), not the red → green implementation cycle.
@@ -0,0 +1,3 @@
1
+ interface:
2
+ display_name: "TDD"
3
+ short_description: "Test-driven red-green-refactor"
@@ -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,77 @@
1
+ # Good and Bad Tests
2
+
3
+ ## Good Tests
4
+
5
+ **Integration-style**: Test through real interfaces, not mocks of internal parts.
6
+
7
+ ```typescript
8
+ // GOOD: Tests observable behavior
9
+ test("user can checkout with valid cart", async () => {
10
+ const cart = createCart();
11
+ cart.add(product);
12
+ const result = await checkout(cart, paymentMethod);
13
+ expect(result.status).toBe("confirmed");
14
+ });
15
+ ```
16
+
17
+ Characteristics:
18
+
19
+ - Tests behavior users/callers care about
20
+ - Uses public API only
21
+ - Survives internal refactors
22
+ - Describes WHAT, not HOW
23
+ - One logical assertion per test
24
+
25
+ ## Bad Tests
26
+
27
+ **Implementation-detail tests**: Coupled to internal structure.
28
+
29
+ ```typescript
30
+ // BAD: Tests implementation details
31
+ test("checkout calls paymentService.process", async () => {
32
+ const mockPayment = jest.mock(paymentService);
33
+ await checkout(cart, payment);
34
+ expect(mockPayment.process).toHaveBeenCalledWith(cart.total);
35
+ });
36
+ ```
37
+
38
+ Red flags:
39
+
40
+ - Mocking internal collaborators
41
+ - Testing private methods
42
+ - Asserting on call counts/order
43
+ - Test breaks when refactoring without behavior change
44
+ - Test name describes HOW not WHAT
45
+ - Verifying through external means instead of interface
46
+
47
+ ```typescript
48
+ // BAD: Bypasses interface to verify
49
+ test("createUser saves to database", async () => {
50
+ await createUser({ name: "Alice" });
51
+ const row = await db.query("SELECT * FROM users WHERE name = ?", ["Alice"]);
52
+ expect(row).toBeDefined();
53
+ });
54
+
55
+ // GOOD: Verifies through interface
56
+ test("createUser makes user retrievable", async () => {
57
+ const user = await createUser({ name: "Alice" });
58
+ const retrieved = await getUser(user.id);
59
+ expect(retrieved.name).toBe("Alice");
60
+ });
61
+ ```
62
+
63
+ **Tautological tests**: Expected value restates the implementation, so the test passes by construction.
64
+
65
+ ```typescript
66
+ // BAD: Expected value is recomputed the way the code computes it
67
+ test("calculateTotal sums line items", () => {
68
+ const items = [{ price: 10 }, { price: 5 }];
69
+ const expected = items.reduce((sum, i) => sum + i.price, 0);
70
+ expect(calculateTotal(items)).toBe(expected);
71
+ });
72
+
73
+ // GOOD: Expected value is an independent, known literal
74
+ test("calculateTotal sums line items", () => {
75
+ expect(calculateTotal([{ price: 10 }, { price: 5 }])).toBe(15);
76
+ });
77
+ ```