@tianhai/pi-workflow-kit 0.18.1 → 1.1.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.
- package/README.md +79 -62
- package/agents/pwk-hazard-reviewer.md +24 -0
- package/agents/pwk-smell-reviewer.md +17 -0
- package/agents/pwk-spec-reviewer.md +14 -0
- package/agents/pwk-tracing-reviewer.md +14 -0
- package/docs/developer-usage-guide.md +39 -44
- package/docs/lessons.md +2 -7
- package/docs/oversight-model.md +20 -14
- package/docs/workflow-phases.md +64 -30
- package/extensions/workflow-guard.ts +194 -92
- package/package.json +20 -4
- package/skills/pwk-brainstorming/SKILL.md +30 -27
- package/skills/pwk-code-review/SKILL.md +46 -0
- package/skills/pwk-diagnose/SKILL.md +5 -2
- package/skills/pwk-executing-tasks/SKILL.md +92 -328
- package/skills/pwk-finalizing/SKILL.md +23 -106
- package/skills/pwk-status/SKILL.md +28 -0
- package/skills/pwk-writing-plans/SKILL.md +49 -328
- package/docs/plans/2026-06-03-karpathy-guidelines-ab-comparison.md +0 -166
- package/docs/plans/completed/2026-04-11-checkpoint-review-gates-design.md +0 -50
- package/docs/plans/completed/2026-04-11-checkpoint-review-gates-implementation.md +0 -98
- package/docs/plans/completed/2026-04-11-finalizing-merge-options-design.md +0 -33
- package/docs/plans/completed/2026-04-11-finalizing-merge-options-implementation.md +0 -75
- package/docs/plans/completed/2026-04-11-workspace-setup-design.md +0 -28
- package/docs/plans/completed/2026-04-11-workspace-setup-implementation.md +0 -57
- package/docs/plans/completed/2026-04-15-bash-guard-design.md +0 -39
- package/docs/plans/completed/2026-04-15-bash-guard-implementation.md +0 -229
- package/docs/plans/completed/2026-04-21-workflow-guard-safe-commands-design.md +0 -172
- package/docs/plans/completed/2026-04-21-workflow-guard-safe-commands-implementation.md +0 -168
- package/docs/plans/completed/2026-04-22-go-readonly-safe-commands-implementation.md +0 -54
- package/docs/plans/completed/2026-04-28-executing-tasks-redesign-design.md +0 -171
- package/docs/plans/completed/2026-04-28-executing-tasks-redesign-implementation.md +0 -208
- package/docs/plans/completed/2026-04-28-executing-tasks-redesign-progress.md +0 -14
- package/docs/plans/completed/2026-05-01-incorporate-mattpocock-skills-design.md +0 -154
- package/docs/plans/completed/2026-05-01-incorporate-mattpocock-skills-implementation.md +0 -315
- package/docs/plans/completed/2026-05-01-incorporate-mattpocock-skills-progress.md +0 -15
- package/docs/plans/completed/2026-05-08-checkpoint-gates-design.md +0 -235
- package/docs/plans/completed/2026-05-08-checkpoint-gates-implementation.md +0 -83
- package/docs/plans/completed/2026-05-08-checkpoint-gates-progress.md +0 -11
- package/docs/plans/completed/2026-05-08-lessons-learned-design.md +0 -76
- package/docs/plans/completed/2026-05-08-lessons-learned-implementation.md +0 -219
- package/docs/plans/completed/2026-05-08-lessons-learned-progress.md +0 -15
- package/docs/plans/completed/2026-05-08-migrate-earendil-works-design.md +0 -39
- package/docs/plans/completed/2026-05-08-migrate-earendil-works-implementation.md +0 -45
- package/docs/plans/completed/2026-05-08-migrate-earendil-works-progress.md +0 -10
- package/docs/plans/completed/2026-05-08-worktree-handoff-design.md +0 -118
- package/docs/plans/completed/2026-05-08-worktree-handoff-implementation.md +0 -140
- package/docs/plans/completed/2026-05-08-worktree-handoff-progress.md +0 -10
- package/docs/plans/completed/2026-05-20-generic-lessons-design.md +0 -70
- package/docs/plans/completed/2026-05-20-generic-lessons-implementation.md +0 -114
- package/docs/plans/completed/2026-05-20-generic-lessons-progress.md +0 -11
- package/docs/plans/completed/2026-05-22-agentic-agile-enhancements-design.md +0 -77
- package/docs/plans/completed/2026-05-22-agentic-agile-enhancements-implementation.md +0 -473
- package/docs/plans/completed/2026-05-25-design-review-split-implementation.md +0 -622
- package/docs/plans/completed/2026-05-25-design-review-split-progress.md +0 -16
- package/docs/plans/completed/2026-05-25-pr5-improvements-implementation.md +0 -273
- package/docs/plans/completed/2026-05-25-pr5-improvements-progress.md +0 -17
- package/docs/plans/completed/2026-06-03-add-verify-skill-design.md +0 -51
- package/docs/plans/completed/2026-06-03-add-verify-skill-implementation.md +0 -111
- package/docs/plans/completed/2026-06-03-add-verify-skill-progress.md +0 -11
- package/docs/plans/completed/2026-06-03-verify-skill-design.md +0 -176
- package/docs/plans/completed/2026-06-09-code-review-fixes-implementation.md +0 -74
- package/docs/plans/completed/2026-06-09-code-review-fixes-progress.md +0 -14
- package/docs/plans/completed/2026-06-09-incremental-workflow-and-rename-design.md +0 -186
- package/docs/plans/completed/2026-06-09-incremental-workflow-and-rename-implementation.md +0 -675
- package/docs/plans/completed/2026-06-09-incremental-workflow-and-rename-progress.md +0 -18
- package/docs/plans/completed/2026-06-09-incremental-workflow-and-rename-verification-report.md +0 -81
- package/docs/plans/completed/2026-06-09-verification-fixes-implementation.md +0 -69
- package/docs/plans/completed/2026-06-09-verification-fixes-progress.md +0 -14
- package/skills/pwk-design-review/SKILL.md +0 -115
- package/skills/pwk-verify/SKILL.md +0 -170
package/docs/plans/completed/2026-06-09-incremental-workflow-and-rename-verification-report.md
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
# Verification Report: Incremental workflow and skill rename
|
|
2
|
-
|
|
3
|
-
**Date:** 2026-06-09
|
|
4
|
-
**Scope:** 10 commits on `incremental-workflow-and-rename` — pwk- prefix rename, feature-based planning, design-review repositioning, verify phase in workflow-guard
|
|
5
|
-
**Reviewer:** AI verify skill (security + optimization + traceability)
|
|
6
|
-
|
|
7
|
-
## Summary
|
|
8
|
-
|
|
9
|
-
| Pass | Critical | High | Medium | Low |
|
|
10
|
-
|------|----------|------|--------|-----|
|
|
11
|
-
| Security | 0 | 0 | 0 | 0 |
|
|
12
|
-
| Optimization | — | 0 | 0 | 3 |
|
|
13
|
-
| Traceability | 0 | 0 | 2 | 1 |
|
|
14
|
-
| **Total** | **0** | **0** | **2** | **4** |
|
|
15
|
-
|
|
16
|
-
## 🔴 Security Findings
|
|
17
|
-
|
|
18
|
-
No findings. This is a documentation/configuration-only change — no HTTP endpoints, no SQL queries, no user inputs, no secrets, no auth logic. No external attack surface.
|
|
19
|
-
|
|
20
|
-
## 🟡 Optimization Findings
|
|
21
|
-
|
|
22
|
-
### [O-001] P2 — Stale `shouldBlockFilePath` docstring
|
|
23
|
-
|
|
24
|
-
**Location:** `extensions/workflow-guard.ts:150`
|
|
25
|
-
|
|
26
|
-
**Issue:** JSDoc says "Only writes under docs/plans/ are allowed during brainstorm and plan phases" — missing the verify phase added in this change.
|
|
27
|
-
|
|
28
|
-
**Fix:** Change to "...during brainstorm, plan, and verify phases."
|
|
29
|
-
|
|
30
|
-
### [O-002] P2 — Stale `DESTRUCTIVE_PATTERNS` comment
|
|
31
|
-
|
|
32
|
-
**Location:** `extensions/workflow-guard.ts:15`
|
|
33
|
-
|
|
34
|
-
**Issue:** Comment says "Destructive commands blocked in brainstorm/plan phases" — missing verify.
|
|
35
|
-
|
|
36
|
-
**Fix:** Change to "...in brainstorm/plan/verify phases."
|
|
37
|
-
|
|
38
|
-
### [O-003] P2 — Inconsistent backtick formatting
|
|
39
|
-
|
|
40
|
-
**Location:** `skills/pwk-executing-tasks/SKILL.md:158`
|
|
41
|
-
|
|
42
|
-
**Issue:** `**Read \`docs/lessons.md\` if it exists**` is missing the closing backtick. All other skills use backtick-enclosed format: `**Read \`docs/lessons.md\`**`.
|
|
43
|
-
|
|
44
|
-
**Fix:** Add closing backtick: `**Read \`docs/lessons.md\` if it exists**`
|
|
45
|
-
|
|
46
|
-
## 🔵 Traceability Findings
|
|
47
|
-
|
|
48
|
-
### [T-001] Medium — `writing-plans` hazard check runs before feature identification
|
|
49
|
-
|
|
50
|
-
**Location:** `skills/pwk-writing-plans/SKILL.md:11-27`
|
|
51
|
-
|
|
52
|
-
**Issue:** Step 1 evaluates the hazard checklist (database, auth, etc.) *before* reading the Features table to identify the next `⬜ pending` feature. The hazard prompt says "This feature involves..." but the feature isn't known yet. Flow is: read design doc → evaluate hazards → *then* read Features table → mark `🔄 planned`.
|
|
53
|
-
|
|
54
|
-
**Fix:** Move the Features table reading before the hazard check. Flow should be: read design doc → find next `⬜ pending` feature → mark `🔄 planned` → *then* evaluate hazards for that specific feature.
|
|
55
|
-
|
|
56
|
-
### [T-002] Medium — `executing-tasks` step 2 re-reads full Features table every task
|
|
57
|
-
|
|
58
|
-
**Location:** `skills/pwk-executing-tasks/SKILL.md:158`
|
|
59
|
-
|
|
60
|
-
**Issue:** Per-task step 2 says "Read the design doc's Features table for context on the overall feature set." This re-reads the entire table on every task execution — redundant and imprecise.
|
|
61
|
-
|
|
62
|
-
**Fix:** Change to "skim the Features table for current feature status" to avoid re-processing the whole table.
|
|
63
|
-
|
|
64
|
-
### [T-003] Low — `design-review` trivial case may target nonexistent plan doc
|
|
65
|
-
|
|
66
|
-
**Location:** `skills/pwk-design-review/SKILL.md:12-22`
|
|
67
|
-
|
|
68
|
-
**Issue:** Step 1 allows proceeding if either doc exists. Step 2 says to append to the plan doc. If only the design doc exists (no plan doc yet), the agent would try to append to a nonexistent file. Edge case since design-review runs after writing-plans, but the instructions don't enforce this.
|
|
69
|
-
|
|
70
|
-
**Fix:** In step 2, add: "If no plan doc exists, skip and say: 'No plan doc found. Run `/skill:pwk-writing-plans` first.'"
|
|
71
|
-
|
|
72
|
-
## Remediation Task List
|
|
73
|
-
|
|
74
|
-
| ID | Priority | Finding | Estimated Effort |
|
|
75
|
-
|----|----------|---------|-----------------|
|
|
76
|
-
| O-001 | P2 | Stale `shouldBlockFilePath` docstring missing verify | small |
|
|
77
|
-
| O-002 | P2 | Stale `DESTRUCTIVE_PATTERNS` comment missing verify | small |
|
|
78
|
-
| O-003 | P2 | Missing closing backtick in executing-tasks lessons reference | small |
|
|
79
|
-
| T-001 | Medium | Hazard check ordering in writing-plans (should run after feature identification) | small |
|
|
80
|
-
| T-002 | Medium | executing-tasks re-reads full Features table every task | small |
|
|
81
|
-
| T-003 | Low | design-review trivial case may target nonexistent plan doc | small |
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
# Implementation Plan: Verification findings fix
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
|
|
5
|
-
Fix 6 findings from `docs/plans/2026-06-09-incremental-workflow-and-rename-verification-report.md`.
|
|
6
|
-
|
|
7
|
-
All findings are small effort — documentation/comment fixes and minor instruction reordering.
|
|
8
|
-
|
|
9
|
-
## Task 1: Fix stale comments in workflow-guard.ts
|
|
10
|
-
|
|
11
|
-
<!-- tdd: trivial -->
|
|
12
|
-
|
|
13
|
-
Fix O-001 and O-002.
|
|
14
|
-
|
|
15
|
-
Files:
|
|
16
|
-
- `extensions/workflow-guard.ts`
|
|
17
|
-
|
|
18
|
-
Steps:
|
|
19
|
-
1. Change `shouldBlockFilePath` JSDoc: "during brainstorm and plan phases" → "during brainstorm, plan, and verify phases"
|
|
20
|
-
2. Change `DESTRUCTIVE_PATTERNS` comment: "blocked in brainstorm/plan phases" → "blocked in brainstorm/plan/verify phases"
|
|
21
|
-
|
|
22
|
-
## Task 2: Fix backtick formatting in executing-tasks
|
|
23
|
-
|
|
24
|
-
<!-- tdd: trivial -->
|
|
25
|
-
|
|
26
|
-
Fix O-003.
|
|
27
|
-
|
|
28
|
-
Files:
|
|
29
|
-
- `skills/pwk-executing-tasks/SKILL.md`
|
|
30
|
-
|
|
31
|
-
Steps:
|
|
32
|
-
1. In per-task step 2, change `**Read \`docs/lessons.md` if it exists**` to `**Read \`docs/lessons.md\` if it exists**` (add closing backtick)
|
|
33
|
-
|
|
34
|
-
## Task 3: Reorder writing-plans hazard check after feature identification
|
|
35
|
-
|
|
36
|
-
<!-- tdd: trivial -->
|
|
37
|
-
|
|
38
|
-
Fix T-001. The hazard checklist currently runs before reading the Features table. Move the Features table reading to before the hazard check so the prompt can say "This feature involves..." accurately.
|
|
39
|
-
|
|
40
|
-
Files:
|
|
41
|
-
- `skills/pwk-writing-plans/SKILL.md`
|
|
42
|
-
|
|
43
|
-
Steps:
|
|
44
|
-
1. Move the Features table paragraph (currently at the end of step 1) to just after the design doc reading, before the hazard checklist
|
|
45
|
-
2. Verify the flow is now: read design doc → find next `⬜ pending` feature → mark `🔄 planned` → evaluate hazards for that feature
|
|
46
|
-
|
|
47
|
-
## Task 4: Narrow executing-tasks Features table read
|
|
48
|
-
|
|
49
|
-
<!-- tdd: trivial -->
|
|
50
|
-
|
|
51
|
-
Fix T-002.
|
|
52
|
-
|
|
53
|
-
Files:
|
|
54
|
-
- `skills/pwk-executing-tasks/SKILL.md`
|
|
55
|
-
|
|
56
|
-
Steps:
|
|
57
|
-
1. In per-task step 2, change "Read the design doc's Features table for context on the overall feature set" to "Check the current feature's status in the design doc's Features table"
|
|
58
|
-
|
|
59
|
-
## Task 5: Add plan doc guard to design-review trivial case
|
|
60
|
-
|
|
61
|
-
<!-- tdd: trivial -->
|
|
62
|
-
|
|
63
|
-
Fix T-003.
|
|
64
|
-
|
|
65
|
-
Files:
|
|
66
|
-
- `skills/pwk-design-review/SKILL.md`
|
|
67
|
-
|
|
68
|
-
Steps:
|
|
69
|
-
1. In step 2, add a guard before the triviality check: "If no plan doc was found in step 1, skip this check and say: 'No plan doc found to append to. Run `/skill:pwk-writing-plans` first.' and stop."
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
# Progress: Verification fixes
|
|
2
|
-
|
|
3
|
-
Plan: docs/plans/2026-06-09-verification-fixes-implementation.md
|
|
4
|
-
Branch: incremental-workflow-and-rename
|
|
5
|
-
Started: 2026-06-09T23:10:00
|
|
6
|
-
Last updated: 2026-06-09T23:10:00
|
|
7
|
-
|
|
8
|
-
| # | Status | Task | Commit |
|
|
9
|
-
|---|--------|------|--------|
|
|
10
|
-
| 1 | ✅ done | Fix stale comments in workflow-guard.ts (O-001, O-002) | c5ab39f |
|
|
11
|
-
| 2 | ✅ done | Fix backtick formatting in executing-tasks (O-003) | c5ab39f |
|
|
12
|
-
| 3 | ✅ done | Reorder writing-plans hazard check after feature identification (T-001) | c5ab39f |
|
|
13
|
-
| 4 | ✅ done | Narrow executing-tasks Features table read (T-002) | c5ab39f |
|
|
14
|
-
| 5 | ✅ done | Add plan doc guard to design-review trivial case (T-003) | c5ab39f |
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: pwk-design-review
|
|
3
|
-
description: "Audit a plan and design doc for production risks — security, scalability, fault tolerance, and operational hazards. Use after writing-plans for non-trivial features, when the plan has concrete code that makes hazard checks meaningful."
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Design Review
|
|
7
|
-
|
|
8
|
-
Read-only exploration of the design and plan docs. You **may** edit the plan doc to append review findings. You may **not** edit source code or configuration.
|
|
9
|
-
|
|
10
|
-
## Process
|
|
11
|
-
|
|
12
|
-
1. **Find the design and plan docs** — look for `docs/plans/*-design.md` and `docs/plans/*-implementation.md`. If neither exists, say "No design or plan doc found. Run `/skill:pwk-brainstorming` first." and stop. Read the plan doc for concrete code context alongside the design doc for architectural context.
|
|
13
|
-
|
|
14
|
-
2. **Check triviality** — if a plan doc was found in step 1 and the design doc notes "Simple change — no design review needed", append a brief section to the plan doc:
|
|
15
|
-
|
|
16
|
-
```markdown
|
|
17
|
-
## Architectural Review
|
|
18
|
-
|
|
19
|
-
**Status**: Skipped — trivial change. No high-risk operations detected.
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
Then say: "Review complete — no action needed. Ready to execute? Run `/skill:pwk-executing-tasks`" and stop.
|
|
23
|
-
|
|
24
|
-
If no plan doc was found, skip this check and say: "No plan doc found to append to. Run `/skill:pwk-writing-plans` first." and stop.
|
|
25
|
-
|
|
26
|
-
3. **Read the design and plan docs in full** — understand the architecture from the design doc, and concrete code from the plan doc. The plan doc's implementation details (SQL queries, type definitions, function bodies) are what the hazard checks audit.
|
|
27
|
-
|
|
28
|
-
4. **🏛️ Architectural Pillars Review** — evaluate the design against the 6 Pillars of Production-Grade Design:
|
|
29
|
-
|
|
30
|
-
1. **Robustness & Fault Tolerance**: How expected failures are handled, subsystem isolation, graceful degradation.
|
|
31
|
-
2. **Atomicity & Consistency**: Database transactions, state rollback on error, endpoint idempotency.
|
|
32
|
-
3. **Security & Access Control**: Input validation/sanitization, authorization checks at the boundary.
|
|
33
|
-
4. **Scalability & Performance**: Connection pooling, closing resource leaks, preventing N+1 queries.
|
|
34
|
-
5. **Backwards Compatibility**: Schema migration safety, zero-downtime deployment, API versioning.
|
|
35
|
-
6. **Testability**: Injection seams for external dependencies (APIs, system clocks, randomizers) to keep tests 100% deterministic.
|
|
36
|
-
|
|
37
|
-
For each pillar, write a 1-2 sentence assessment. Flag any concerns.
|
|
38
|
-
|
|
39
|
-
5. **⚠️ High-Risk Hazard Audit** — evaluate the design against the 8 High-Risk Production Hazards. For each hazard, write either `[SAFE]` (with a 1-sentence justification) or `[TRIGGERED]` (detailing the mitigation):
|
|
40
|
-
|
|
41
|
-
1. **Unbounded Redis Deletions / Operations**: Multi-key deletion or scans (e.g. `KEYS` or raw `SCAN` loops) that block single-threaded performance.
|
|
42
|
-
2. **In-Memory OOM Loops**: Fetching complete database datasets into server memory (e.g., raw `select *`) to filter, sort, or map in runtime heap.
|
|
43
|
-
3. **Unbounded Concurrency Spikes**: Running concurrent network requests (e.g. unthrottled `Promise.all`) without strict batch limits.
|
|
44
|
-
4. **Missing High-Frequency Indexes**: Running queries on unindexed columns, forcing expensive table-scans under load.
|
|
45
|
-
5. **Nested/Long-Running Transactions**: Holding database connections and locks open while awaiting slow external HTTP, disk, or cryptographic tasks.
|
|
46
|
-
6. **Unrestricted Uploads & Temp Flooding**: Writing uploaded data directly to local temporary paths without validation limits or explicit `finally` cleanup blocks.
|
|
47
|
-
7. **Raw Query String Interpolation**: Merging raw variables into SQL queries or shell command inputs (susceptible to injection).
|
|
48
|
-
8. **Silent Swallowing Loops**: Background workers or cron tasks silently catching and suppressing exceptions without logging, back-offs, or alerts.
|
|
49
|
-
|
|
50
|
-
6. **🔍 Socratic Risk Discovery** — put on your **SRE Hat** and audit the proposed logic against 3 heuristics to identify novel or domain-specific risks:
|
|
51
|
-
|
|
52
|
-
- **The "Scale to 100x" Heuristic**: If this operation is run 100x/sec or on 100k items, what breaks? (Memory, CPU, Disk I/O, sockets, database connection limits).
|
|
53
|
-
- **The "Hostile World" Heuristic**: If a malicious actor has complete control over these inputs (headers, payloads, IDs), how can they exploit, crash, or extract data?
|
|
54
|
-
- **The "Silent Error" Heuristic**: If this downstream dependency or query hangs or fails silently, how does our server react? Is there a timeout, a back-off, or logging?
|
|
55
|
-
|
|
56
|
-
For each heuristic, note any risks discovered. If a risk overlaps with a triggered hazard, cross-reference it.
|
|
57
|
-
|
|
58
|
-
7. **Present findings** — show the full review to the user. For each triggered hazard or Socratic risk, propose a concrete mitigation. Wait for user feedback and incorporate changes.
|
|
59
|
-
|
|
60
|
-
8. **Append to plan doc** — add a `## Architectural Review` section to the plan doc (not the design doc — review is per-feature, and the plan doc is the per-feature artifact). Two cases:
|
|
61
|
-
|
|
62
|
-
**All clear** (no hazards triggered, no Socratic risks):
|
|
63
|
-
```markdown
|
|
64
|
-
## Architectural Review
|
|
65
|
-
|
|
66
|
-
**Status**: ✅ No high-risk hazards detected.
|
|
67
|
-
|
|
68
|
-
**Pillars reviewed**: All 6 — no concerns.
|
|
69
|
-
**Hazards audited**: All 8 [SAFE].
|
|
70
|
-
**Socratic risks**: None identified.
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
**Hazards or risks found**:
|
|
74
|
-
```markdown
|
|
75
|
-
## Architectural Review
|
|
76
|
-
|
|
77
|
-
**Status**: ⚠️ High-risk operations detected — see mitigations below.
|
|
78
|
-
|
|
79
|
-
### Pillar Assessments
|
|
80
|
-
- **Robustness**: [assessment]
|
|
81
|
-
- **Atomicity**: [assessment]
|
|
82
|
-
- **Security**: [assessment]
|
|
83
|
-
- **Scalability**: [assessment]
|
|
84
|
-
- **Backwards Compatibility**: [assessment]
|
|
85
|
-
- **Testability**: [assessment]
|
|
86
|
-
|
|
87
|
-
### Hazard Audit
|
|
88
|
-
- 1. Unbounded Redis: [SAFE / TRIGGERED — mitigation]
|
|
89
|
-
- 2. In-Memory OOM: [SAFE / TRIGGERED — mitigation]
|
|
90
|
-
- 3. Unbounded Concurrency: [SAFE / TRIGGERED — mitigation]
|
|
91
|
-
- 4. Missing Indexes: [SAFE / TRIGGERED — mitigation]
|
|
92
|
-
- 5. Long-Running Transactions: [SAFE / TRIGGERED — mitigation]
|
|
93
|
-
- 6. Unrestricted Uploads: [SAFE / TRIGGERED — mitigation]
|
|
94
|
-
- 7. Query Interpolation: [SAFE / TRIGGERED — mitigation]
|
|
95
|
-
- 8. Silent Swallowing: [SAFE / TRIGGERED — mitigation]
|
|
96
|
-
|
|
97
|
-
### ⚠️ High-Risk Operations & Mitigations
|
|
98
|
-
[Detailed mitigation for each TRIGGERED hazard and Socratic risk]
|
|
99
|
-
|
|
100
|
-
### Socratic Risks
|
|
101
|
-
- **Scale to 100x**: [finding or "none identified"]
|
|
102
|
-
- **Hostile World**: [finding or "none identified"]
|
|
103
|
-
- **Silent Error**: [finding or "none identified"]
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
## Principles
|
|
107
|
-
|
|
108
|
-
- Be specific — every `[TRIGGERED]` hazard must include a concrete mitigation, not just "be careful"
|
|
109
|
-
- Be honest — if the design is risky and the risk can't be mitigated easily, say so
|
|
110
|
-
- Be proportional — a simple CRUD endpoint doesn't need the same depth as a batch processing pipeline
|
|
111
|
-
- Don't redesign — flag risks and propose mitigations, but the design owner decides
|
|
112
|
-
|
|
113
|
-
## After the review
|
|
114
|
-
|
|
115
|
-
Ask: "Review complete. Ready to execute? Run `/skill:pwk-executing-tasks`"
|
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: pwk-verify
|
|
3
|
-
description: "Post-implementation code verification with three expert review passes — security, optimization, and traceability. Use after executing-tasks and before finalizing to catch issues that pass tests but break in production. Runs the 'last prompt' pattern: adversarial security review, dead code and duplication audit, and end-to-end contract verification across every layer. Use this skill whenever the user says 'verify', 'review the code', 'check for issues', 'security review', 'the last prompt', 'audit', or when code has been implemented and needs a quality gate before shipping."
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Verify
|
|
7
|
-
|
|
8
|
-
Three expert review passes over the implemented codebase. Read-only — you **may** write the verification report to `docs/plans/`, but you **may not** modify source code.
|
|
9
|
-
|
|
10
|
-
The core insight: code that passes tests is not code that's ready. Working code can have security holes, dead branches, duplicated logic, and broken contracts between layers — especially when AI generates across many files without maintaining a single mental model of the whole system. This skill catches what tests miss.
|
|
11
|
-
|
|
12
|
-
## Process
|
|
13
|
-
|
|
14
|
-
1. **Check what's been done** — run `git log --oneline` and `git diff --stat` to understand the scope of recent changes. If nothing has been implemented, say "No code changes found. Run `/skill:pwk-executing-tasks` first." and stop.
|
|
15
|
-
|
|
16
|
-
2. **Identify the project's layers** — before reviewing, map the codebase's architecture. Look for layer boundaries: UI/handlers/routes → services/business logic → repositories/data access → database/models. Note the patterns: does the project use controllers, handlers, or routes? Services or use cases? Repositories or DAOs? This map drives the traceability pass.
|
|
17
|
-
|
|
18
|
-
3. **Run three expert review passes** — each pass adopts a distinct adversarial framing. Do them sequentially. For each pass, read the relevant code deeply — don't skim. Then write findings.
|
|
19
|
-
|
|
20
|
-
4. **Compile the report** — write all findings to `docs/plans/*-verification-report.md`. Present the report to the user and wait for feedback.
|
|
21
|
-
|
|
22
|
-
5. **Offer to create a remediation plan** — after the report, ask: "Want me to create a fix plan from these findings? Run `/skill:pwk-writing-plans` to turn the task list into executable tasks."
|
|
23
|
-
|
|
24
|
-
## Pass 1 — Security Review 🔴
|
|
25
|
-
|
|
26
|
-
**Framing:** A junior developer wrote this code. Now the best security expert on the team is reviewing it — adversarial, suspicious of everything. Trust nothing.
|
|
27
|
-
|
|
28
|
-
**What to look for:**
|
|
29
|
-
|
|
30
|
-
- **Input validation** — every external input (HTTP params, form data, headers, query strings, environment variables) must be validated and sanitized. Unvalidated input is a critical finding.
|
|
31
|
-
- **Authentication & authorization** — every endpoint that handles user data must have auth checks. Are there endpoints that skip auth? Can one user access another user's data by changing an ID?
|
|
32
|
-
- **Injection** — SQL queries built by string concatenation, unsanitized shell commands, template injection, XSS in HTML output. Any raw variable interpolated into a query or command is critical.
|
|
33
|
-
- **Secrets** — API keys, passwords, tokens hardcoded in source files. Check environment variable loading — are defaults set to empty or to actual secrets?
|
|
34
|
-
- **Data exposure** — are sensitive fields (passwords, tokens, PII) logged, returned in API responses, or stored unencrypted?
|
|
35
|
-
- **Dependency risks** — known-vulnerable packages (if `package.json`/`go.mod`/`requirements.txt` is present).
|
|
36
|
-
|
|
37
|
-
**Severity classification:**
|
|
38
|
-
|
|
39
|
-
| Severity | Definition |
|
|
40
|
-
|----------|-----------|
|
|
41
|
-
| Critical | Exploitable right now — auth bypass, injection, data leak |
|
|
42
|
-
| High | Likely exploitable — missing validation on sensitive endpoint, weak auth |
|
|
43
|
-
| Medium | Harder to exploit but real risk — verbose error messages leaking internals, missing rate limits |
|
|
44
|
-
| Low | Best practice violations — missing CSP headers, no HSTS, long session timeouts |
|
|
45
|
-
|
|
46
|
-
## Pass 2 — Optimization Review 🟡
|
|
47
|
-
|
|
48
|
-
**Framing:** A code quality expert looking for waste — things that make the codebase harder to maintain, slower to run, or more confusing than necessary.
|
|
49
|
-
|
|
50
|
-
**What to look for:**
|
|
51
|
-
|
|
52
|
-
- **Dead code** — functions, methods, types, or exports that are never called anywhere in the codebase. Search for definitions and verify they have callers.
|
|
53
|
-
- **Duplication** — the same logic implemented in slightly different ways across multiple files. AI-generated code is especially prone to this — if context was lost between sessions, the AI solved the same sub-problem differently in two places. Flag each pair with file paths and line numbers.
|
|
54
|
-
- **Over-engineering** — abstractions, interfaces, or layers that add complexity without earning their keep (only one implementation, no real variation across the seam).
|
|
55
|
-
- **Under-engineering** — god functions, 200-line blocks, deeply nested conditionals that should be extracted.
|
|
56
|
-
- **Performance concerns** — N+1 queries, unbounded loops, unnecessary copies of large data structures, missing pagination on list endpoints.
|
|
57
|
-
|
|
58
|
-
**Priority classification:**
|
|
59
|
-
|
|
60
|
-
| Priority | Definition |
|
|
61
|
-
|----------|-----------|
|
|
62
|
-
| P0 | Dead code in a critical path or duplicated logic that will diverge |
|
|
63
|
-
| P1 | Significant duplication or over-engineering that increases maintenance cost |
|
|
64
|
-
| P2 | Minor cleanups — long functions, missing pagination, style inconsistencies |
|
|
65
|
-
|
|
66
|
-
## Pass 3 — Traceability Review 🔵
|
|
67
|
-
|
|
68
|
-
**Framing:** An integration expert tracing every user-facing action end-to-end — from UI to database and back. The AI generates code file-by-file, and the seams between files are where bugs hide.
|
|
69
|
-
|
|
70
|
-
**What to look for:**
|
|
71
|
-
|
|
72
|
-
1. **Map every entry point** — list all handlers, routes, controllers, or event listeners that receive external input.
|
|
73
|
-
2. **Trace each call chain** — for each entry point, follow the call: handler → service → repository → database. At each boundary, verify:
|
|
74
|
-
- **Function name** — does the caller use the exact function name the callee exposes?
|
|
75
|
-
- **Argument names** — does the caller pass `userId` when the function expects `user_id`? Does `id` mean the same thing in both layers?
|
|
76
|
-
- **Argument types** — is a string passed where an integer is expected? Is an object shape different from what the next layer destructures?
|
|
77
|
-
- **Return shape** — does the caller expect fields that the callee actually returns? Are response DTOs consistent across layers?
|
|
78
|
-
3. **Check error propagation** — when a database query returns no results, does the service layer handle it? Does the handler return 404 or 500? Do errors propagate cleanly or get swallowed silently?
|
|
79
|
-
4. **Verify the round-trip** — if the UI calls `getUser(id)` and displays `user.name`, trace that `name` actually exists in the DB schema, gets selected by the query, mapped by the repository, passed through the service, included in the response, and rendered by the UI.
|
|
80
|
-
|
|
81
|
-
**This is the pass that catches the most bugs.** AI-generated code will often have a frontend calling `getUserProfile(userId)` and a backend exposing `get_user_profile(user_id)` — both work in isolation, neither works together.
|
|
82
|
-
|
|
83
|
-
**Severity classification:**
|
|
84
|
-
|
|
85
|
-
| Severity | Definition |
|
|
86
|
-
|----------|-----------|
|
|
87
|
-
| Critical | Call chain is completely broken — function doesn't exist or signature is fundamentally wrong |
|
|
88
|
-
| High | Signature mismatch — wrong arg names, wrong types, missing required fields |
|
|
89
|
-
| Medium | Silent error handling — errors swallowed without logging or user feedback |
|
|
90
|
-
| Low | Inconsistent naming conventions that could confuse future developers |
|
|
91
|
-
|
|
92
|
-
## Report Format
|
|
93
|
-
|
|
94
|
-
Write findings to `docs/plans/*-verification-report.md` using this structure:
|
|
95
|
-
|
|
96
|
-
```markdown
|
|
97
|
-
# Verification Report: <feature/topic>
|
|
98
|
-
|
|
99
|
-
**Date:** <ISO date>
|
|
100
|
-
**Scope:** <summary of what was reviewed>
|
|
101
|
-
**Reviewer:** AI verify skill (security + optimization + traceability)
|
|
102
|
-
|
|
103
|
-
## Summary
|
|
104
|
-
|
|
105
|
-
| Pass | Critical | High | Medium | Low |
|
|
106
|
-
|------|----------|------|--------|-----|
|
|
107
|
-
| Security | X | X | X | X |
|
|
108
|
-
| Optimization | — | X | X | X |
|
|
109
|
-
| Traceability | X | X | X | X |
|
|
110
|
-
| **Total** | **X** | **X** | **X** | **X** |
|
|
111
|
-
|
|
112
|
-
## 🔴 Security Findings
|
|
113
|
-
|
|
114
|
-
### [S-001] Critical — <short title>
|
|
115
|
-
|
|
116
|
-
**Location:** `path/to/file.ts:line`
|
|
117
|
-
|
|
118
|
-
**Issue:** <what's wrong and why it matters>
|
|
119
|
-
|
|
120
|
-
**Fix:** <concrete remediation step>
|
|
121
|
-
|
|
122
|
-
### [S-002] High — <short title>
|
|
123
|
-
...
|
|
124
|
-
|
|
125
|
-
## 🟡 Optimization Findings
|
|
126
|
-
|
|
127
|
-
### [O-001] P0 — <short title>
|
|
128
|
-
|
|
129
|
-
**Location:** `path/to/file.ts:line` and `path/to/other.ts:line`
|
|
130
|
-
|
|
131
|
-
**Issue:** <what's wrong>
|
|
132
|
-
|
|
133
|
-
**Fix:** <concrete remediation step>
|
|
134
|
-
|
|
135
|
-
### [O-002] P1 — <short title>
|
|
136
|
-
...
|
|
137
|
-
|
|
138
|
-
## 🔵 Traceability Findings
|
|
139
|
-
|
|
140
|
-
### [T-001] Critical — <short title>
|
|
141
|
-
|
|
142
|
-
**Entry point:** `path/to/handler.ts:line`
|
|
143
|
-
**Call chain:** handler → service → repository → DB
|
|
144
|
-
**Broken at:** <which boundary>
|
|
145
|
-
**Issue:** <what's wrong — e.g., handler passes `userId` but service expects `user_id`>
|
|
146
|
-
|
|
147
|
-
**Fix:** <concrete remediation step>
|
|
148
|
-
|
|
149
|
-
### [T-002] High — <short title>
|
|
150
|
-
...
|
|
151
|
-
|
|
152
|
-
## Remediation Task List
|
|
153
|
-
|
|
154
|
-
Convert findings into actionable tasks:
|
|
155
|
-
|
|
156
|
-
| ID | Priority | Finding | Estimated Effort |
|
|
157
|
-
|----|----------|---------|-----------------|
|
|
158
|
-
| S-001 | Critical | <one-liner> | <small/medium/large> |
|
|
159
|
-
| T-001 | Critical | <one-liner> | <small/medium/large> |
|
|
160
|
-
| O-001 | P0 | <one-liner> | <small/medium/large> |
|
|
161
|
-
| ...
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
## Principles
|
|
165
|
-
|
|
166
|
-
- **Be specific** — every finding must include a file path and line reference. "There might be security issues" is useless.
|
|
167
|
-
- **Be adversarial** — actively look for problems. If you don't find any, say so — but don't phone it in.
|
|
168
|
-
- **Be proportional** — a small config change doesn't need the same depth as a new API endpoint. Adjust your review depth to the scope of changes.
|
|
169
|
-
- **Don't fix anything** — this is read-only. Find and report. The user decides what to fix and when.
|
|
170
|
-
- **Focus on seams** — the traceability pass is where the most value lives. Code within a single file is usually coherent; the bugs hide between files.
|