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