pi-gauntlet 4.0.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 (46) hide show
  1. package/CHANGELOG.md +300 -0
  2. package/LICENSE +24 -0
  3. package/README.md +278 -0
  4. package/agents/code-reviewer.md +48 -0
  5. package/agents/conformance-reviewer.md +139 -0
  6. package/agents/implementer.md +40 -0
  7. package/agents/spec-council-member.md +47 -0
  8. package/agents/spec-council-synthesizer.md +39 -0
  9. package/agents/spec-reviewer.md +47 -0
  10. package/agents/spec-summarizer.md +42 -0
  11. package/bin/install-agents.mjs +141 -0
  12. package/extensions/phase-tracker.ts +622 -0
  13. package/extensions/plan-tracker.ts +308 -0
  14. package/extensions/verify-before-ship.ts +132 -0
  15. package/package.json +43 -0
  16. package/skills/brainstorming/SKILL.md +290 -0
  17. package/skills/dispatching-parallel-agents/SKILL.md +192 -0
  18. package/skills/finishing-a-development-branch/SKILL.md +311 -0
  19. package/skills/receiving-code-review/SKILL.md +200 -0
  20. package/skills/requesting-code-review/SKILL.md +115 -0
  21. package/skills/requesting-code-review/code-reviewer.md +166 -0
  22. package/skills/roasting-the-spec/SKILL.md +139 -0
  23. package/skills/subagent-driven-development/SKILL.md +223 -0
  24. package/skills/subagent-driven-development/code-quality-reviewer-prompt.md +25 -0
  25. package/skills/subagent-driven-development/implementer-prompt.md +113 -0
  26. package/skills/subagent-driven-development/spec-reviewer-prompt.md +68 -0
  27. package/skills/systematic-debugging/SKILL.md +151 -0
  28. package/skills/systematic-debugging/condition-based-waiting-example.ts +158 -0
  29. package/skills/systematic-debugging/condition-based-waiting.md +115 -0
  30. package/skills/systematic-debugging/defense-in-depth.md +122 -0
  31. package/skills/systematic-debugging/find-polluter.sh +63 -0
  32. package/skills/systematic-debugging/reference/rationalizations.md +61 -0
  33. package/skills/systematic-debugging/root-cause-tracing.md +169 -0
  34. package/skills/test-driven-development/SKILL.md +230 -0
  35. package/skills/test-driven-development/reference/examples.md +99 -0
  36. package/skills/test-driven-development/reference/rationalizations.md +65 -0
  37. package/skills/test-driven-development/reference/when-stuck.md +31 -0
  38. package/skills/test-driven-development/testing-anti-patterns.md +299 -0
  39. package/skills/using-git-worktrees/SKILL.md +193 -0
  40. package/skills/verification-before-completion/SKILL.md +169 -0
  41. package/skills/verification-before-completion/reference/conformance-check.md +220 -0
  42. package/skills/writing-plans/SKILL.md +244 -0
  43. package/skills/writing-skills/SKILL.md +429 -0
  44. package/skills/writing-skills/reference/anthropic-best-practices.md +1130 -0
  45. package/skills/writing-skills/reference/persuasion.md +187 -0
  46. package/skills/writing-skills/reference/testing-skills-with-subagents.md +384 -0
@@ -0,0 +1,429 @@
1
+ ---
2
+ name: writing-skills
3
+ description: Use when creating new skills, editing existing skills, or verifying skills work before deployment
4
+ ---
5
+
6
+ > **Related skills:** Test new skills with `/skill:test-driven-development` discipline. Verify they work with `/skill:verification-before-completion`.
7
+
8
+ # Writing Skills
9
+
10
+ ## Overview
11
+
12
+ **Writing skills IS test-driven development applied to process documentation.**
13
+
14
+ Write a pressure scenario for a subagent, watch it fail (baseline), write the skill, watch tests pass (agent complies), then refactor to close loopholes.
15
+
16
+ **Core principle:** If you didn't watch an agent fail without the skill, you don't know if the skill teaches the right thing.
17
+
18
+ **Violating the letter of the rules is violating the spirit of the rules.** This cuts off the entire class of "I'm following the spirit" rationalizations agents reach for under pressure — yours and the ones reading the skills you write.
19
+
20
+ **REQUIRED BACKGROUND:** Read `/skill:test-driven-development` first. This skill applies RED → GREEN → REFACTOR to documentation.
21
+
22
+ ## Where Skills Live in Pi
23
+
24
+ Pi discovers skills from multiple roots (see `docs/skills.md` in `@earendil-works/pi-coding-agent` for the full list). The common ones:
25
+
26
+ | Path | Scope | Typical Use |
27
+ |---|---|---|
28
+ | `.pi/skills/<name>/SKILL.md` | Project, pi-only | Workflow methodology authored in-repo |
29
+ | `.agents/skills/<name>/SKILL.md` (any ancestor) | Cross-harness, project | Skills shared with Claude Code, Codex, etc. |
30
+ | `~/.pi/agent/skills/<name>/SKILL.md` | User-global, pi-only | Personal skills |
31
+ | `~/.agents/skills/<name>/SKILL.md` | User-global, cross-harness | Personal skills shared with other harnesses |
32
+ | Installed packages (`skills/` dir, `pi.skills` in `package.json`) | Package-scoped | Reusable skill libraries like `pi-gauntlet` |
33
+
34
+ Each skill directory contains:
35
+ ```
36
+ SKILL.md # required entry point
37
+ reference/ # optional progressive-disclosure files
38
+ <topic>.md # read directly when SKILL.md points at it
39
+ <supporting>.md # prompt templates, examples
40
+ ```
41
+
42
+ `reference/` is the pi pattern for keeping SKILL.md tight while still shipping deep guidance. See `.pi/skills/test-driven-development/reference/` and `.pi/skills/systematic-debugging/reference/` for working examples.
43
+
44
+ ### Reference Files Bundled With This Skill
45
+
46
+ Read directly when SKILL.md tells you to (path is given inline). The progressive-disclosure pattern is *which file to read when*, not a special tool:
47
+
48
+ | Topic | File | When to load |
49
+ |-------|------|--------------|
50
+ | `writing-skills-anthropic-best-practices` | `reference/anthropic-best-practices.md` | Anthropic's canonical guide to authoring SKILL.md — concision, degrees of freedom, progressive disclosure, evaluation-driven development. Read when designing a skill from scratch or restructuring an existing one. |
51
+ | `writing-skills-persuasion` | `reference/persuasion.md` | Cialdini's seven principles applied to skill design. Read when authoring a discipline-enforcing skill that must hold up under pressure. Cites Meincke et al. (2025): N=28,000 LLM conversations, compliance 33% → 72% with persuasion techniques. |
52
+ | `writing-skills-testing-with-subagents` | `reference/testing-skills-with-subagents.md` | RED-GREEN-REFACTOR for skills: pressure scenarios, rationalization tables, meta-testing, bulletproofing checklist. Read before running baseline scenarios via the `subagent` tool. |
53
+
54
+ ## When to Create a Skill
55
+
56
+ **Create when:**
57
+ - The technique was not obvious to you the first time
58
+ - You will reference it across projects or services
59
+ - The pattern is broad (not tied to one file or feature)
60
+ - Other agents would benefit
61
+
62
+ **Don't create for:**
63
+ - One-off solutions
64
+ - Standard practices documented elsewhere
65
+ - Project-specific conventions (use `AGENTS.md` or a service-level `doc/`)
66
+ - Mechanically enforceable rules at ship time (use the `verify-before-ship` extension from `pi-gauntlet` — runtime enforcement beats documentation). Note: only ship-command verification is mechanised today; TDD, debug, and phase enforcement are skill-only.
67
+
68
+ ## SKILL.md Structure
69
+
70
+ **Frontmatter (YAML):**
71
+
72
+ ```yaml
73
+ ---
74
+ name: skill-name-with-hyphens
75
+ description: Use when <specific triggering conditions and symptoms>
76
+ ---
77
+ ```
78
+
79
+ - `name`: letters, numbers, hyphens only.
80
+ - `description`: third-person, ONLY describes when to use, NOT what the skill does.
81
+ - Start with "Use when…"
82
+ - Include symptoms, situations, contexts
83
+ - **Never summarize the skill's workflow** (see CSO section below for why)
84
+ - Aim for under 500 characters; max 1024 for full frontmatter
85
+
86
+ **Body skeleton:**
87
+
88
+ ```markdown
89
+ > **Related skills:** <pointers to skills the user should run before/after/with this one>
90
+
91
+ # Skill Name
92
+
93
+ ## Overview
94
+ What is this? Core principle in 1-2 sentences.
95
+
96
+ ## Boundaries
97
+ - Reads: <what files/state this skill touches read-only>
98
+ - Writes: <what it writes>
99
+ - Does NOT: <explicit no-touch list>
100
+
101
+ ## When to Use
102
+ Bullet list of symptoms. When NOT to use.
103
+
104
+ ## The Process / Core Pattern
105
+ Numbered steps OR before/after comparison.
106
+
107
+ ## Quick Reference
108
+ Table or bullets for scanning common operations.
109
+
110
+ ## Common Mistakes
111
+ What goes wrong + fixes.
112
+
113
+ ## Red Flags
114
+ Phrases/situations that mean STOP and reconsider.
115
+ ```
116
+
117
+ ## Claude Search Optimization (CSO)
118
+
119
+ The harness reads `description` to decide which skills to load. Optimize for "should I read this skill right now?".
120
+
121
+ **Description = trigger, NOT summary.**
122
+
123
+ ```yaml
124
+ # ❌ BAD: summarizes workflow — agent may follow this instead of reading the skill
125
+ description: Use when executing plans — dispatches subagent per task with code review between tasks
126
+
127
+ # ❌ BAD: process detail
128
+ description: Use for TDD — write test first, watch it fail, write minimal code, refactor
129
+
130
+ # ✅ GOOD: trigger only
131
+ description: Use when executing implementation plans with independent tasks in the current session
132
+
133
+ # ✅ GOOD: trigger only
134
+ description: Use when implementing any feature or bugfix, before writing implementation code
135
+ ```
136
+
137
+ **Why this matters:** When a description summarizes the workflow, the agent treats it as a shortcut and skips the skill body. Testing showed a description that said "code review between tasks" caused agents to do ONE review even though the skill body specified TWO. Changing the description to a pure trigger fixed the compliance.
138
+
139
+ **Keyword coverage:** use the words an agent would search for — error messages ("ENOTEMPTY", "race condition"), symptoms ("flaky", "hanging"), tool names, file types.
140
+
141
+ **Naming:** active voice, verb-first.
142
+ - ✅ `creating-skills`, not `skill-creation`
143
+ - ✅ `condition-based-waiting`, not `async-test-helpers`
144
+ - ✅ `root-cause-tracing`, not `debugging-techniques`
145
+
146
+ ## Cross-References
147
+
148
+ Use skill name with explicit requirement markers. **Never** force-load with `@` syntax — that burns context before the file is needed.
149
+
150
+ - ✅ `**REQUIRED SUB-SKILL:** Use /skill:test-driven-development`
151
+ - ✅ `**REQUIRED BACKGROUND:** You MUST understand /skill:systematic-debugging`
152
+ - ✅ `> **Related skills:** Pair with /skill:verification-before-completion`
153
+ - ❌ `@.pi/skills/test-driven-development/SKILL.md`
154
+
155
+ ## Token Efficiency
156
+
157
+ `description` is loaded into every conversation. `SKILL.md` is loaded when the agent decides to read it. `reference/*.md` is loaded only when SKILL.md instructs the agent to read a specific file.
158
+
159
+ **Targets:**
160
+ - Frequently-loaded skills: <250 lines
161
+ - Specialized skills: <500 lines
162
+ - Anything beyond: split into `reference/` files
163
+
164
+ **Techniques:**
165
+ - **Move deep content to `reference/`** — like `.pi/skills/test-driven-development/reference/{rationalizations,examples,when-stuck}.md`. SKILL.md mentions them; agent loads them on demand.
166
+ - **Cross-reference, don't duplicate.** Point to other skills rather than restating.
167
+ - **Compress examples.** One clear example beats three.
168
+ - **Skip the obvious.** Pi agents already know git, ripgrep, mise; don't explain.
169
+
170
+ Verify:
171
+ ```bash
172
+ wc -l .pi/skills/<name>/SKILL.md
173
+ ```
174
+
175
+ ## Pi Tooling References
176
+
177
+ If a skill leans on pi capabilities, name them explicitly:
178
+
179
+ | Capability | How to reference it |
180
+ |---|---|
181
+ | Plan/phase persistence | `plan_tracker` tool (provided by the `pi-gauntlet` package's `plan-tracker` extension) |
182
+ | Progressive disclosure | Direct `read` of `reference/<topic>.md` paths named inline in SKILL.md |
183
+ | Runtime enforcement | `verify-before-ship` extension from `pi-gauntlet` (advisory warning before `git commit` / `git push` / `gh pr create` when no canonical verification command has succeeded since the last source edit) |
184
+ | Subagent dispatch | `subagent` tool from `pi-cohort`; baseline subagents from `pi-gauntlet` are `implementer`, `code-reviewer`, `spec-reviewer`, `conformance-reviewer`. Consumer repos can add project-specific subagents under `.pi/agents/`. |
185
+
186
+ Don't invent capabilities. Don't reference Claude Code's `Task` tool, OpenCode hooks, or Codex `spawn_agent` unless the skill is explicitly for that harness.
187
+
188
+ ## The Iron Law (Same as TDD)
189
+
190
+ ```
191
+ NO SKILL WITHOUT A FAILING TEST FIRST
192
+ ```
193
+
194
+ Applies to new skills AND edits to existing skills.
195
+
196
+ Wrote a skill before testing it? Delete it. Start over.
197
+ Edited a skill without testing? Same violation.
198
+
199
+ **No exceptions:**
200
+ - Not for "simple additions"
201
+ - Not for "just adding a section"
202
+ - Not for "documentation updates"
203
+ - Don't keep untested changes as "reference"
204
+ - Don't "adapt" while running tests
205
+ - Delete means delete
206
+
207
+ ## Bulletproofing Skills Against Rationalization
208
+
209
+ Discipline-enforcing skills (like TDD, verification-before-completion) have to survive a reader under pressure. The reader will look for loopholes. Your job is to close them in the skill before they have to be re-closed in production.
210
+
211
+ Read `.pi/skills/writing-skills/reference/persuasion.md` for the research foundation: Cialdini's seven principles plus Meincke et al. (2025), which measured LLM compliance climbing from 33% to 72% when persuasion techniques were applied to disciplinary prompts. The techniques below operationalize that research.
212
+
213
+ ### Close every loophole explicitly
214
+
215
+ Don't just state the rule — forbid the specific workaround.
216
+
217
+ **Bad:**
218
+ ```markdown
219
+ Write code before test? Delete it.
220
+ ```
221
+
222
+ **Good:**
223
+ ```markdown
224
+ Write code before test? Delete it. Start over.
225
+
226
+ **No exceptions:**
227
+ - Don't keep it as "reference"
228
+ - Don't "adapt" it while writing tests
229
+ - Don't look at it
230
+ - Delete means delete
231
+ ```
232
+
233
+ ### Anchor the Spirit vs Letter principle early
234
+
235
+ State once, near the top:
236
+
237
+ ```markdown
238
+ **Violating the letter of the rules is violating the spirit of the rules.**
239
+ ```
240
+
241
+ This sentence is doing real work. Without it, "I'm following the spirit" becomes the universal jailbreak for every other rule in the skill.
242
+
243
+ ### Build the rationalization table from real baselines
244
+
245
+ Every excuse a baseline subagent gave goes in a two-column table. Don't invent rationalizations; harvest them.
246
+
247
+ ```markdown
248
+ | Excuse | Reality |
249
+ |--------|---------|
250
+ | "Too simple to test" | Simple code breaks. Test takes 30 seconds. |
251
+ | "I'll test after" | Tests passing immediately prove nothing. |
252
+ | "Tests after achieve same goals" | Tests-after = "what does this do?" Tests-first = "what should this do?" |
253
+ ```
254
+
255
+ ### Provide a Red Flags self-check list
256
+
257
+ Agents under pressure rarely catch themselves on principle. They catch themselves on pattern recognition. Give them the patterns:
258
+
259
+ ```markdown
260
+ ## Red Flags — STOP and Start Over
261
+
262
+ - Code before test
263
+ - "I already manually tested it"
264
+ - "Tests after achieve the same purpose"
265
+ - "It's about spirit not ritual"
266
+ - "This is different because…"
267
+
268
+ **All of these mean: Delete code. Start over with TDD.**
269
+ ```
270
+
271
+ ### Common rationalizations for skipping skill testing
272
+
273
+ The meta-form of every other rationalization table. Keep handy when *writing* a skill, because skipping the baseline-scenario step is the original sin that produces everything else.
274
+
275
+ | Excuse | Reality |
276
+ |--------|---------|
277
+ | "Skill is obviously clear" | Clear to you ≠ clear to other agents. Test it. |
278
+ | "It's just a reference" | References have gaps. Test retrieval. |
279
+ | "Testing is overkill" | Untested skills have issues. Always. 15 min testing saves hours. |
280
+ | "I'll test if problems emerge" | Problems = agents can't use the skill in production. Test before deploying. |
281
+ | "Too tedious to test" | Less tedious than debugging the bad skill in production. |
282
+ | "I'm confident it's good" | Overconfidence guarantees issues. Test anyway. |
283
+ | "Academic review is enough" | Reading ≠ using. Test application scenarios. |
284
+ | "No time to test" | Deploying untested = fixing untested later. |
285
+
286
+ **All of these mean: Test before deploying. No exceptions.**
287
+
288
+ ### Update the description with violation symptoms
289
+
290
+ The description fires when an agent is *about* to violate the rule the skill enforces. Symptoms in the trigger > workflow summary.
291
+
292
+ ## RED-GREEN-REFACTOR for Skills
293
+
294
+ ### RED — Watch the baseline fail
295
+
296
+ Pick a pressure scenario where you predict the agent will get it wrong without the skill. Run it via the `subagent` tool against a fresh-context worker. Capture verbatim:
297
+
298
+ - What choices did the subagent make?
299
+ - What rationalizations did it use?
300
+ - Which pressures triggered the violation?
301
+
302
+ ```ts
303
+ subagent({
304
+ agent: "worker",
305
+ context: "fresh",
306
+ task: "<scenario prompt that creates the pressure>"
307
+ })
308
+ ```
309
+
310
+ ### GREEN — Write the minimal skill
311
+
312
+ Address those specific rationalizations. Don't add content for hypothetical cases.
313
+
314
+ Re-run the same scenario. Subagent should now comply.
315
+
316
+ ### REFACTOR — Close loopholes
317
+
318
+ Agent found a new rationalization? Add an explicit counter. Re-test.
319
+
320
+ Build the rationalization table from each iteration:
321
+
322
+ ```markdown
323
+ | Excuse | Reality |
324
+ |---|---|
325
+ | "Too simple to test" | Simple code breaks. The test takes 30 seconds. |
326
+ | "I'll test after" | Tests passing immediately prove nothing. |
327
+ | "I'm following the spirit" | Violating the letter of the rules is violating the spirit. |
328
+ ```
329
+
330
+ Add a Red Flags list so agents can self-check:
331
+
332
+ ```markdown
333
+ ## Red Flags — STOP
334
+
335
+ - Code before test
336
+ - "I already manually tested it"
337
+ - "Tests after achieve the same purpose"
338
+ ```
339
+
340
+ ## Skill Types and How to Test Each
341
+
342
+ | Type | Examples | Test with | Success |
343
+ |---|---|---|---|
344
+ | **Discipline-enforcing** | TDD, verification-before-completion | Pressure scenarios (time + sunk cost + exhaustion) | Agent follows rule under pressure |
345
+ | **Technique** | condition-based-waiting, root-cause-tracing | Application + variation + missing-info scenarios | Agent applies correctly to new case |
346
+ | **Pattern** | reducing-complexity | Recognition + application + counter-example scenarios | Agent recognizes when/when-not to apply |
347
+ | **Reference** | API docs, library guides | Retrieval + application + gap scenarios | Agent finds and uses information |
348
+
349
+ ## Skill Creation Checklist
350
+
351
+ Use `plan_tracker` to create tasks for each item:
352
+
353
+ **RED — Failing Test**
354
+ - [ ] Create pressure scenarios (3+ combined pressures for discipline skills)
355
+ - [ ] Run scenarios WITHOUT the skill — document baseline verbatim
356
+ - [ ] Identify patterns in rationalizations / failures
357
+
358
+ **GREEN — Minimal Skill**
359
+ - [ ] Name: letters, numbers, hyphens only
360
+ - [ ] Frontmatter has `name` and `description` (max 1024 chars total)
361
+ - [ ] Description starts with "Use when…", trigger only, no workflow
362
+ - [ ] Keywords for search (errors, symptoms, tools, file types)
363
+ - [ ] Overview + Boundaries + The Process sections
364
+ - [ ] One excellent example (not multi-language)
365
+ - [ ] Re-run scenarios WITH skill — verify compliance
366
+
367
+ **REFACTOR — Close Loopholes**
368
+ - [ ] Identify new rationalizations from testing
369
+ - [ ] Add explicit counters (discipline skills)
370
+ - [ ] Build rationalization table
371
+ - [ ] Add Red Flags list
372
+ - [ ] Re-test until bulletproof
373
+
374
+ **Pi-specific**
375
+ - [ ] If discipline skill *and* the rule is mechanically detectable at a tool boundary: consider an `extensions/*.ts` hook (high bar — runtime hooks are deliberately slim; only add ones that beat false-positive heuristics)
376
+ - [ ] If skill has >500 lines: split deep content into `reference/<topic>.md` and instruct the agent to read the specific file inline
377
+ - [ ] Skill location: project-scoped lives under `.pi/skills/`; cross-harness skills shared with Claude Code under `.agents/skills/`; reusable workflow skills belong in a package like `pi-gauntlet`
378
+ - [ ] Update routing: link from `AGENTS.md` if cross-cutting
379
+
380
+ **Deployment**
381
+ - [ ] Commit skill to git
382
+ - [ ] If broadly useful: consider upstream PR to `obra/superpowers`
383
+
384
+ ## STOP Before Moving to the Next Skill
385
+
386
+ After writing any skill, complete its deployment checklist before starting another one.
387
+
388
+ Do **not** batch-create skills without testing each. Do **not** move on because "the next one is small." Deploying an untested skill is deploying untested code; the framework's whole leverage is that the discipline survives, and the discipline doesn't survive a batch.
389
+
390
+ ## Anti-Patterns
391
+
392
+ **Narrative example** — "In session 2025-10-03, we found …"
393
+ Too specific. Not reusable. Cut it.
394
+
395
+ **Multi-language dilution** — `example.js`, `example.py`, `example.go`
396
+ Maintenance burden, mediocre quality. Pick one language that best illustrates the pattern.
397
+
398
+ **Code in flowcharts** — DOT graphs with `step1 [label="import fs"]`
399
+ Can't copy-paste. Use markdown code blocks.
400
+
401
+ **Generic labels** — `helper1`, `step3`, `pattern4`
402
+ Labels should carry semantic meaning.
403
+
404
+ **Documentation that mechanizes** — if it's enforceable with a regex, lint rule, or `verify-before-ship` hook at a tool boundary, automate it. Don't waste skill tokens on rules a deterministic check can enforce.
405
+
406
+ ## Red Flags — STOP
407
+
408
+ - Wrote a skill without running a baseline scenario first
409
+ - Edited a skill without re-running the relevant baseline
410
+ - Description starts with "This skill does…" (summary instead of trigger)
411
+ - Code-then-test ordering in the skill body
412
+ - Force-loading other skills with `@`
413
+ - SKILL.md over 500 lines with no `reference/` split
414
+ - Referencing tools that don't exist in pi (Claude Code's `Task`, OpenCode hooks, etc.) for a pi-scope skill
415
+ - About to ship multiple skills in a batch without testing each
416
+ - "I'll test it later" — that means never
417
+ - "It's about spirit, not ritual" — that's the rationalization the skill exists to defeat
418
+
419
+ ## The Bottom Line
420
+
421
+ Creating skills IS TDD for process documentation. Same Iron Law. Same cycle. Same benefits.
422
+
423
+ RED (baseline) → GREEN (skill) → REFACTOR (close loopholes).
424
+
425
+ If you follow TDD for code, follow it for skills.
426
+
427
+ ## Project overrides
428
+
429
+ If `.pi/gauntlet-overrides.md` exists, read it. Any sections relevant to this skill — by name match, by topic (routing, verification, worktrees, etc.), or by workflow convention — override or extend the instructions above. Project-local `AGENTS.md` is already in context — check it for project-specific routing tables, service paths, and verification commands.