@tianhai/pi-workflow-kit 2.1.2 → 2.4.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,59 +0,0 @@
1
- ---
2
- name: pwk-diagnose
3
- description: "Disciplined debugging loop for hard bugs and performance regressions. Use when a test fails unexpectedly, a bug is found during execution, or something is broken. Use this skill whenever the user reports a bug, says 'this doesn't work', 'something's wrong', 'help me debug', or when tests fail for unclear reasons. Works at any point in the workflow — brainstorm, execute, or standalone."
4
- ---
5
-
6
- # Diagnose
7
-
8
- A 6-phase debugging discipline. Phase 1 is the skill — spend disproportionate effort here.
9
-
10
- Invoking `/skill:pwk-diagnose` **exits the gated design phase** (the workflow guard unlocks) — diagnosis needs to write failing tests and `[DEBUG-…]` instrumentation. If you only wanted read-only investigation, use `/skill:pwk-status` (stays gated) or reinstate the lock with `/pwk-guard on`.
11
-
12
- ## Phase 1 — Build a feedback loop
13
-
14
- Create a fast, deterministic, agent-runnable pass/fail signal for the bug before doing anything else. Try in this order: failing test, curl script, CLI invocation, headless browser script.
15
-
16
- Other strategies when the basics don't work:
17
- - **Bisection** — bug appeared between two known states? Automate "boot at state X, check, repeat" to bisect
18
- - **Replay** — save a real network request or event log to disk, replay it through the code path in isolation
19
-
20
- The loop must produce the failure mode the **user** described — not a nearby but different failure. Iterate on the loop itself: can you make it faster? Sharper? More deterministic?
21
-
22
- If you genuinely cannot build a loop, stop and say so. List what you tried. Ask for access to a reproducing environment or a captured artifact.
23
-
24
- Hold at Phase 1 until you have a loop you believe in. Everything downstream — hypotheses, instrumentation, the fix — depends on that loop actually reproducing the user's symptom.
25
-
26
- ## Phase 2 — Reproduce
27
-
28
- Run the loop. Confirm:
29
- - The failure matches the user's reported symptom
30
- - The failure is reproducible across multiple runs
31
- - You've captured the exact symptom (error message, wrong output, slow timing)
32
-
33
- Then **minimize the repro** — strip it down to the smallest input, shortest path, or fewest steps that still triggers the bug. A minimized repro dramatically narrows the hypothesis space.
34
-
35
- ## Phase 3 — Hypothesise
36
-
37
- Generate 3-5 ranked hypotheses. Each must be falsifiable:
38
-
39
- > "If `<X>` is the cause, then `<changing Y>` will make the bug disappear / `<changing Z>` will make it worse."
40
-
41
- Show the ranked list to the user before testing. They often have domain knowledge that re-ranks instantly.
42
-
43
- ## Phase 4 — Instrument
44
-
45
- Each probe must map to a specific hypothesis. Change one variable at a time. Tag every debug log with a unique prefix (e.g. `[DEBUG-a4f2]`) for easy cleanup later. Prefer a debugger breakpoint over logs when available.
46
-
47
- ## Phase 5 — Fix + regression test
48
-
49
- Write the regression test **before** the fix — but only if there's a correct seam (one that exercises the real bug pattern at the call site). If no correct seam exists, note it — the codebase architecture is preventing the bug from being locked down.
50
-
51
- ## Phase 6 — Cleanup
52
-
53
- Required before declaring done:
54
- - Original repro no longer triggers
55
- - Regression test passes (or absence of seam is documented)
56
- - All `[DEBUG-...]` instrumentation removed
57
- - Ask: what would have prevented this bug?
58
- - If the answer is a repeatable pattern, append a **generic** rule to `docs/lessons.md` (strip domain specifics) so future sessions catch it early.
59
- - If the bug was caused by an architectural problem (no good test seam, tangled callers, hidden coupling), suggest writing an ADR to `docs/adr/` capturing that insight