@rune-kit/rune 2.2.6 → 2.3.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 (69) hide show
  1. package/README.md +1 -1
  2. package/docs/SKILL-TEMPLATE.md +15 -0
  3. package/docs/index.html +76 -7
  4. package/docs/script.js +33 -6
  5. package/docs/style.css +62 -0
  6. package/package.json +7 -5
  7. package/skills/adversary/SKILL.md +12 -0
  8. package/skills/audit/SKILL.md +63 -1
  9. package/skills/autopsy/SKILL.md +12 -0
  10. package/skills/ba/SKILL.md +9 -0
  11. package/skills/brainstorm/SKILL.md +11 -0
  12. package/skills/completion-gate/SKILL.md +15 -1
  13. package/skills/context-engine/SKILL.md +83 -1
  14. package/skills/context-pack/SKILL.md +160 -0
  15. package/skills/cook/SKILL.md +657 -958
  16. package/skills/cook/references/deviation-rules.md +19 -0
  17. package/skills/cook/references/error-recovery.md +37 -0
  18. package/skills/cook/references/exit-conditions.md +31 -0
  19. package/skills/cook/references/loop-detection.md +39 -0
  20. package/skills/cook/references/mid-run-signals.md +31 -0
  21. package/skills/cook/references/output-format.md +40 -0
  22. package/skills/cook/references/pack-detection.md +82 -0
  23. package/skills/cook/references/pause-resume-template.md +38 -0
  24. package/skills/cook/references/rfc-template.md +52 -0
  25. package/skills/cook/references/sharp-edges.md +24 -0
  26. package/skills/cook/references/subagent-status.md +38 -0
  27. package/skills/db/SKILL.md +12 -0
  28. package/skills/debug/SKILL.md +34 -2
  29. package/skills/deploy/SKILL.md +10 -0
  30. package/skills/design/SKILL.md +9 -0
  31. package/skills/docs/SKILL.md +12 -0
  32. package/skills/docs-seeker/SKILL.md +11 -0
  33. package/skills/fix/SKILL.md +36 -3
  34. package/skills/incident/SKILL.md +10 -0
  35. package/skills/launch/SKILL.md +12 -0
  36. package/skills/logic-guardian/SKILL.md +11 -0
  37. package/skills/marketing/SKILL.md +13 -0
  38. package/skills/mcp-builder/SKILL.md +13 -0
  39. package/skills/onboard/SKILL.md +54 -2
  40. package/skills/perf/SKILL.md +11 -0
  41. package/skills/plan/SKILL.md +342 -688
  42. package/skills/plan/references/completeness-scoring.md +37 -0
  43. package/skills/plan/references/outcome-block.md +41 -0
  44. package/skills/plan/references/plan-templates.md +193 -0
  45. package/skills/plan/references/wave-planning.md +44 -0
  46. package/skills/plan/references/workflow-registry.md +53 -0
  47. package/skills/preflight/SKILL.md +86 -1
  48. package/skills/rescue/SKILL.md +10 -0
  49. package/skills/retro/SKILL.md +11 -0
  50. package/skills/review/SKILL.md +100 -1
  51. package/skills/review-intake/SKILL.md +11 -0
  52. package/skills/safeguard/SKILL.md +12 -0
  53. package/skills/scaffold/SKILL.md +10 -0
  54. package/skills/scope-guard/SKILL.md +11 -0
  55. package/skills/scout/SKILL.md +9 -0
  56. package/skills/sentinel/SKILL.md +307 -425
  57. package/skills/sentinel/references/config-protection.md +52 -0
  58. package/skills/sentinel/references/destructive-commands.md +40 -0
  59. package/skills/sentinel/references/domain-hooks.md +73 -0
  60. package/skills/sentinel/references/framework-patterns.md +46 -0
  61. package/skills/sentinel/references/owasp-patterns.md +69 -0
  62. package/skills/sentinel/references/secret-patterns.md +40 -0
  63. package/skills/sentinel/references/skill-content-guard.md +55 -0
  64. package/skills/session-bridge/SKILL.md +60 -2
  65. package/skills/skill-forge/SKILL.md +47 -2
  66. package/skills/skill-router/SKILL.md +33 -1
  67. package/skills/surgeon/SKILL.md +12 -0
  68. package/skills/team/SKILL.md +35 -1
  69. package/skills/test/SKILL.md +167 -1
@@ -1,958 +1,657 @@
1
- ---
2
- name: cook
3
- description: "Feature implementation orchestrator. ALWAYS use this skill for ANY code change — implement, build, add feature, create, fix bug, or any task that modifies source code. This is the default route for 70% of all requests. Runs full TDD cycle: understand → plan → test → implement → quality → verify → commit."
4
- context: fork
5
- agent: general-purpose
6
- metadata:
7
- author: runedev
8
- version: "1.3.0"
9
- layer: L1
10
- model: sonnet
11
- group: orchestrator
12
- tools: "Read, Write, Edit, Bash, Glob, Grep"
13
- ---
14
-
15
- # cook
16
-
17
- ## Purpose
18
-
19
- The primary orchestrator for feature implementation. Coordinates the entire L2 mesh in a phased TDD workflow. Handles 70% of all user requests — any task that modifies source code routes through cook.
20
-
21
- <HARD-GATE>
22
- Before starting ANY implementation:
23
- 1. You MUST understand the codebase first (Phase 1)
24
- 2. You MUST have a plan before writing code (Phase 2)
25
- 3. You MUST write failing tests before implementation (Phase 3) — unless explicitly skipped
26
- This applies to EVERY feature regardless of perceived simplicity.
27
- </HARD-GATE>
28
-
29
- ## Workflow Chains (Predefined)
30
-
31
- Cook supports predefined workflow chains for common task types. Use these as shortcuts instead of manually determining phases:
32
-
33
- ```
34
- /rune cook feature → Full TDD pipeline (all phases)
35
- /rune cook bugfix → Diagnose → fix → verify (Phase 1 → 4 → 6 → 7)
36
- /rune cook refactor → Understand → plan → implement → quality (Phase 1 → 2 → 4 → 5 → 6 → 7)
37
- /rune cook security → Full pipeline + sentinel@opus + sast (all phases, security-escalated)
38
- /rune cook hotfix → Minimal: fix → verify → commit (Phase 4 → 6 → 7, skip scout if user provides context)
39
- ```
40
-
41
- **Chain selection**: If user invokes `/rune cook` without a chain type, auto-detect from the task description:
42
- - Contains "bug", "fix", "broken", "error" `bugfix`
43
- - Contains "refactor", "clean", "restructure" → `refactor`
44
- - Contains "security", "auth", "vulnerability", "CVE" → `security`
45
- - Contains "urgent", "hotfix", "production" → `hotfix`
46
- - Default → `feature`
47
-
48
- ## Phase Skip Rules
49
-
50
- Not every task needs every phase:
51
-
52
- ```
53
- Simple bug fix: Phase 1 → 4 → 6 → 7
54
- Small refactor: Phase 1 → 4 → 5 → 6 → 7
55
- New feature: Phase 1 1.52 3 → 4 → 5 → 6 → 7 → 8
56
- Complex feature: All phases + brainstorm in Phase 2
57
- Security-sensitive: All phases + sentinel escalated to opus
58
- Fast mode: Phase 1 → 4 → 6 → 7 (auto-detected, see below)
59
- Multi-session: Phase 0 (resume) 3 4 → 5 → 6 → 7 (one plan phase per session)
60
- ```
61
-
62
- Determine complexity BEFORE starting. Create TodoWrite with applicable phases.
63
-
64
- ## Fast Mode (Auto-Detect)
65
-
66
- Cook auto-detects small changes and streamlines the pipeline:
67
-
68
- ```
69
- IF all of these are true:
70
- - Total estimated change < 30 LOC
71
- - Single file affected
72
- - No security-relevant code (auth, crypto, payments, .env)
73
- - No public API changes
74
- - No database schema changes
75
- THEN: Fast Mode activated
76
- - Skip Phase 2 (PLAN) change is too small for a formal plan
77
- - Skip Phase 3 (TEST) unless existing tests cover the area
78
- - Skip Phase 5b (SENTINEL) non-security code
79
- - Skip Phase 8 (BRIDGE) not worth persisting
80
- - KEEP Phase 5a (PREFLIGHT) and Phase 6 (VERIFY) always run quality checks
81
- ```
82
-
83
- **Announce fast mode**: "Fast mode: small change detected (<30 LOC, single file, non-security). Streamlined pipeline."
84
- **Override**: User can say "full pipeline" to force all phases even on small changes.
85
-
86
- ## Phase 0.5: ENVIRONMENT CHECK (First Run Only)
87
-
88
- **Goal**: Verify the developer's environment can run this project before wasting time on planning.
89
-
90
- **SUB-SKILL**: Use `rune:sentinel-env`
91
-
92
- **Auto-trigger conditions** (ALL must be true):
93
- - No `.rune/` directory exists (first cook run in this project)
94
- - OR `npm install` / `pip install` / build just failed with environment-looking errors
95
- - AND NOT fast mode
96
-
97
- Skip silently on subsequent runs. User can force with `/rune env-check`.
98
-
99
- ## Phase 1: UNDERSTAND
100
-
101
- **Goal**: Know what exists before changing anything.
102
-
103
- **REQUIRED SUB-SKILLS**: Use `rune:scout`. For non-trivial tasks, use `rune:ba`.
104
-
105
- 1. Create TodoWrite with all applicable phases for this task
106
- 2. Mark Phase 1 as `in_progress`
107
- 3. **BA gate** determine if Business Analyst elicitation is needed:
108
- - If task is a Feature Request, Integration, or Greenfield → invoke `rune:ba` for requirement elicitation
109
- - If task description is > 50 words or contains business terms (users, revenue, workflow, integration) → invoke `rune:ba`
110
- - If Bug Fix or simple Refactor → skip BA, proceed with scout
111
- - BA produces a Requirements Document at `.rune/features/<name>/requirements.md` that feeds into Phase 2 (PLAN)
112
- 4. **Decision enforcement** load prior decisions:
113
- - Use `Glob` to check for `.rune/decisions.md`
114
- - If exists, use `Read` to load it
115
- - Extract decisions relevant to the current task domain (match by keywords: module names, tech choices, patterns)
116
- - These become **constraints for Phase 2 (PLAN)** — the plan MUST NOT contradict active decisions without explicit user override
117
- - If no `.rune/decisions.md` exists, skip silently
118
- ### Phase 1 Step 3.5 Clarification Gate (Lightweight Socratic Check)
119
-
120
- Before planning, ask the user at minimum **2 clarifying questions**:
121
-
122
- 1. **"What does success look like?"** — defines acceptance criteria (how we know we're done)
123
- 2. **"What should NOT change?"** defines blast radius constraints (what's off-limits)
124
-
125
- **Skip conditions** (ALL must be true to skip):
126
- - Bug fix with clear reproduction steps already provided by user
127
- - User explicitly said "just do it", "no questions", or "skip questions"
128
- - Fast mode active AND estimated change < 10 LOC
129
- - Hotfix chain active (production emergency)
130
-
131
- This is NOT the full BA elicitation (5 questions). It's a lightweight 2-question gate that prevents the most common failure: implementing the wrong thing. If the answers reveal complexity → escalate to `rune:ba` for deep requirement analysis.
132
-
133
- **Question format**: Use brainstorm's dynamic questioning format when possible (Priority level, Decision Point, Why This Matters, Options table, Default).
134
-
135
- 4. Invoke scout to scan the codebase:
136
- - Use `Glob` to find files matching the feature domain (e.g., `**/*auth*`, `**/*user*`)
137
- - Use `Grep` to search for related patterns, imports, existing implementations
138
- - Use `Read` to examine key files identified
139
- 5. Summarize findings:
140
- - What exists already
141
- - What patterns/conventions the project uses
142
- - What files will likely need to change
143
- - **Active decisions that constrain this task** (from step 3)
144
- 6. **Python async detection**: If Python project detected (`pyproject.toml` or `setup.py`), use `Grep` for async indicators:
145
- - Search for: `async def`, `await`, `aiosqlite`, `aiohttp`, `httpx.AsyncClient`, `asyncio.run`, `trio`
146
- - If ≥3 matches across source files flag project as **"async-first Python"**
147
- - Note for later phases: new code should default to `async def`, avoid blocking calls (`requests.get`, `time.sleep`, `open()`)
148
- 7. Mark Phase 1 as `completed`
149
-
150
- **Gate**: If scout finds the feature already exists STOP and inform user.
151
-
152
- ## Phase 1.5: DOMAIN CONTEXT (L4 Pack Detection)
153
-
154
- **Goal**: Detect if domain-specific L4 extension packs apply to this task.
155
-
156
- After scout completes (Phase 1), check if the detected tech stack or task description matches any L4 extension pack. If a match is found, load the relevant domain-specific patterns, constraints, and sharp edges into the current workflow.
157
-
158
- **Split pack protocol** (context-efficient):
159
- - `Read` the matching PACK.md index (~60-80 lines) — this contains triggers, skill table, connections, and workflows
160
- - Match the task to the specific skill name in the index's Skills Included table
161
- - `Read` only the matching skill file(s) from `skills/` subdirectory (e.g., `extensions/backend/skills/auth.md`)
162
- - Load max 2-3 skill files per invocation — not all skills in the pack
163
- - Pack-level constraints (from index's Connections and Sharp Edges sections) always apply
164
-
165
- **Monolith pack protocol** (legacy): If no `format: split` in PACK.md frontmatter, read the full PACK.md and extract the matching `### skill-name` section as before.
166
-
167
- 1. Check the project's detected stack against the L4 pack mapping:
168
-
169
- | Signal in Codebase or Task | Pack | File |
170
- |---|---|---|
171
- | `*.tsx`, `*.svelte`, `*.vue`, Tailwind, CSS modules | `@rune/ui` | `extensions/ui/PACK.md` |
172
- | Express/Fastify/NestJS routes, API endpoints | `@rune/backend` | `extensions/backend/PACK.md` |
173
- | Dockerfile, `.github/workflows/`, Terraform | `@rune/devops` | `extensions/devops/PACK.md` |
174
- | `react-native`, `expo`, `flutter`, `ios/`, `android/` | `@rune/mobile` | `extensions/mobile/PACK.md` |
175
- | Auth, OWASP, secrets, PCI/HIPAA markers | `@rune/security` | `extensions/security/PACK.md` |
176
- | Trading, charts, market data, `decimal.js` | `@rune/trading` | `extensions/trading/PACK.md` |
177
- | Multi-tenant, billing, `stripe`, subscription | `@rune/saas` | `extensions/saas/PACK.md` |
178
- | Cart, checkout, inventory, Shopify | `@rune/ecommerce` | `extensions/ecommerce/PACK.md` |
179
- | `openai`, `anthropic`, embeddings, RAG, LLM | `@rune/ai-ml` | `extensions/ai-ml/PACK.md` |
180
- | `three`, `pixi`, `phaser`, `*.glsl`, game loop | `@rune/gamedev` | `extensions/gamedev/PACK.md` |
181
- | CMS, blog, MDX, `i18next`, SEO | `@rune/content` | `extensions/content/PACK.md` |
182
- | Analytics, tracking, A/B test, funnel | `@rune/analytics` | `extensions/analytics/PACK.md` |
183
- | Chrome extension, `manifest.json`, service worker, content script | `@rune/chrome-ext` | `extensions/chrome-ext/PACK.md` |
184
- | PRD, roadmap, KPI, release notes, `.rune/business/` | `@rune-pro/product` | `extensions/pro-product/PACK.md` |
185
- | Sales outreach, pipeline, call prep, competitive intel | `@rune-pro/sales` | `extensions/pro-sales/PACK.md` |
186
- | Data science, SQL, dashboard, statistical testing, ETL | `@rune-pro/data-science` | `extensions/pro-data-science/PACK.md` |
187
- | Support ticket, KB article, escalation, SLA, FAQ | `@rune-pro/support` | `extensions/pro-support/PACK.md` |
188
- | Budget, expense, revenue forecast, P&L, cash flow, runway | `@rune-pro/finance` | `extensions/pro-finance/PACK.md` |
189
- | Contract, NDA, compliance, GDPR, IP, legal incident | `@rune-pro/legal` | `extensions/pro-legal/PACK.md` |
190
-
191
- 2. If 1 pack matches:
192
- - Use `Read` to load the matching PACK.md (index if split, full if monolith)
193
- - For split packs: identify the relevant skill from the index table, then `Read` only that skill file from `skills/` subdirectory
194
- - For monolith packs: extract the relevant `### skill-name` section from the PACK.md body
195
- - Apply pack constraints alongside cook's own constraints for the rest of the workflow
196
- - Announce: "Loaded @rune/[pack] → [skill-name] (split)" or "Loaded @rune/[pack] → [skill-name] (full)"
197
-
198
- 3. If 0 packs match: skip silently, proceed to Phase 2
199
-
200
- This phase is lightweight — a Read + pattern match, not a full scan. It does NOT replace Phase 1 (scout) or Phase 2 (plan). It augments them with domain expertise.
201
-
202
- ## Phase 0: RESUME CHECK (Before Phase 1)
203
-
204
- **Goal**: Detect if a master plan already exists for this task. If so, skip Phase 1-2 and resume from the current phase.
205
-
206
- **Step 0.5 Cross-Project Recall**: Call `neural-memory` (Recall Mode) with 3-5 topics relevant to the current task. Load applicable patterns, past decisions, and error history from neural memory. Always prefix queries with the project name to avoid cross-project noise (e.g., `"ProjectName auth pattern"` not just `"auth pattern"`). This activates neurons from past sessions and surfaces context that may not be in the local `.rune/` files.
207
-
208
- 1. Use `Glob` to check for `.rune/plan-*.md` files
209
- 2. If a master plan exists that matches the current task:
210
- - Read the master plan file
211
- - Find the first phase with status `⬚ Pending` or `🔄 Active`
212
- - Read ONLY that phase's file (e.g., `.rune/plan-<feature>-phase<N>.md`)
213
- - Announce: "Resuming from Phase N: <name>. Loading phase file."
214
- - Skip to Phase 4 (IMPLEMENT) with the phase file as context
215
- - Mark the phase as `🔄 Active` in the master plan
216
- 3. If no master plan exists proceed to Phase 1 as normal
217
-
218
- **This enables multi-session workflows**: Opus plans once → each session picks up the next phase.
219
-
220
- ## Phase 2: PLAN
221
-
222
- **Goal**: Break the task into concrete implementation steps before writing code.
223
-
224
- **REQUIRED SUB-SKILL**: Use `rune:plan`
225
-
226
- 1. Mark Phase 2 as `in_progress`
227
- 2. **Feature workspace** (opt-in) — for non-trivial features (3+ phases), suggest creating a feature workspace:
228
- ```
229
- .rune/features/<feature-name>/
230
- ├── spec.md — what we're building and why (user's original request + context)
231
- ├── plan.md implementation plan (output of plan skill)
232
- ├── decisions.md — feature-specific decisions (subset of .rune/decisions.md)
233
- └── status.md — progress tracking (completed/pending phases)
234
- ```
235
- - Ask user: "Create feature workspace for `<feature-name>`?" — if yes, create the directory + spec.md with the user's request
236
- - plan.md is written after Step 4 (plan approval)
237
- - Skip for simple bug fixes, small refactors, or fast mode
238
- - Session-bridge (Phase 8) auto-updates status.md if workspace exists
239
- 3. Based on scout findings, create an implementation plan:
240
- - List exact files to create/modify
241
- - Define the order of changes
242
- - Identify dependencies between steps
243
- - **Include active decisions from Phase 1 step 3 as constraints** — plan must respect prior decisions or explicitly flag overrides
244
- 4. If multiple valid approaches exist invoke `rune:brainstorm` for trade-off analysis
245
- 5. Present plan to user for approval
246
- 6. If feature workspace was created (step 2), write approved plan to `.rune/features/<name>/plan.md`
247
- 7. Mark Phase 2 as `completed`
248
-
249
- **Gate**: User MUST approve the plan before proceeding. Do NOT skip this.
250
-
251
- ### Phase 2.5: RFC GATE (Breaking Changes Only)
252
-
253
- **Goal**: Formal change management for breaking changes. Prevents unreviewed breaking changes from reaching production.
254
-
255
- **Auto-trigger conditions** (ANY triggers this gate):
256
- - Plan includes `BREAKING CHANGE` annotation
257
- - Plan modifies a public API signature (added/removed/changed parameters)
258
- - Plan alters database schema (migration required)
259
- - Plan removes or renames an exported function/type used by other modules
260
- - Plan changes authentication/authorization flow
261
-
262
- **Skip conditions**: Non-breaking changes, internal refactors, new features with no API surface change.
263
-
264
- **RFC Artifact** (`.rune/rfc/RFC-<NNN>-<slug>.md`):
265
-
266
- ```markdown
267
- # RFC-<NNN>: <Title>
268
-
269
- **Date**: [YYYY-MM-DD]
270
- **Author**: [agent or user]
271
- **Status**: Proposed | Approved | Rejected
272
- **Impact**: [list affected consumers modules, services, users]
273
-
274
- ## What Changes
275
- [Specific breaking change old behavior new behavior]
276
-
277
- ## Why
278
- [Business/technical justification — why breaking is necessary]
279
-
280
- ## Migration Path
281
- [Step-by-step guide for consumers to adapt]
282
- [Include code examples: before → after]
283
-
284
- ## Rollback Plan
285
- [How to revert if the change causes issues]
286
-
287
- ## Affected Systems
288
- | System | Impact | Migration Effort |
289
- |--------|--------|-----------------|
290
- | [module/service] | [description] | [low/medium/high] |
291
- ```
292
-
293
- **Gate**: RFC MUST be written and presented to user for approval. User responds: "approved" → proceed. "rejected" → revise plan. "deferred" → skip breaking change, implement non-breaking alternative.
294
-
295
- <HARD-GATE>
296
- Breaking change without RFC = BLOCKED. No exceptions.
297
- "It's just a small change" is the #1 excuse for production incidents from unreviewed breaking changes.
298
- </HARD-GATE>
299
-
300
- ## Phase 2.5: ADVERSARY (Red-Team Challenge)
301
-
302
- **Goal**: Stress-test the approved plan BEFORE writing code — catch flaws at plan time, not implementation time.
303
-
304
- **REQUIRED SUB-SKILL**: Use `rune:adversary`
305
-
306
- 1. **Skip conditions** (do NOT run adversary for):
307
- - Bug fixes or hotfixes (plan is "fix the bug", nothing to challenge)
308
- - Simple refactors (< 3 files, no new logic)
309
- - Fast mode (user explicitly opted for speed)
310
- 2. **Run adversary** on the approved plan:
311
- - Full Red-Team mode for new features, architectural changes, security-sensitive plans
312
- - Quick Challenge mode for smaller plans (< 3 files, no auth/payment)
313
- 3. **Handle verdict**:
314
- - **REVISE** return to Phase 2 (PLAN) with adversary findings as constraints. User must re-approve.
315
- - **HARDEN** present remediations to user, update plan inline, then proceed to Phase 3
316
- - **PROCEED** pass findings as implementation notes to Phase 3
317
- 4. **Max 1 REVISE loop** per cook session — if the revised plan also gets REVISE, ask user to decide
318
-
319
- ### Phase-Aware Execution (Master Plan + Phase Files)
320
-
321
- When `rune:plan` produces a **master plan + phase files** (non-trivial tasks):
322
-
323
- 1. **After plan approval**: Read the master plan to identify Phase 1
324
- 2. **Load ONLY Phase 1's file** do NOT load all phase files into context
325
- 3. **Execute Phase 1** through cook Phase 3-6 (test → implement → quality → verify)
326
- 4. **After Phase 1 complete**:
327
- - Mark tasks done in the phase file
328
- - Update master plan: Phase 1 status `⬚ → ✅`
329
- - Announce: "Phase 1 complete. Phase 2 ready for next session."
330
- 5. **Next session**: Phase 0 (RESUME CHECK) detects the master plan loads Phase 2 executes
331
- 6. **Repeat** until all phases are ✅
332
-
333
- <HARD-GATE>
334
- NEVER load multiple phase files at once. One phase per session = small context = better code.
335
- If the coder model needs info from other phases, it's in the Cross-Phase Context section of the current phase file.
336
- </HARD-GATE>
337
-
338
- **Why one phase per session?**
339
- - Big context = even Opus misses details and makes mistakes
340
- - Small context = Sonnet handles correctly, Opus has zero mistakes
341
- - Phase files are self-contained via Amateur-Proof Template no other context needed
342
-
343
- ## Phase 3: TEST (TDD Red)
344
-
345
- **Goal**: Define expected behavior with failing tests BEFORE writing implementation.
346
-
347
- **REQUIRED SUB-SKILL**: Use `rune:test`
348
-
349
- 1. Mark Phase 3 as `in_progress`
350
- 2. Write test files based on the plan:
351
- - Use `Write` to create test files
352
- - Cover the primary use case + edge cases
353
- - Tests MUST be runnable
354
- 3. **Python async pre-check** (if async-first Python flagged in Phase 1):
355
- - Verify `pytest-asyncio` is in project dependencies (`pyproject.toml` or `requirements*.txt`)
356
- - Check `pyproject.toml` for `[tool.pytest.ini_options]` → `asyncio_mode = "auto"` if missing, warn user and suggest adding it before writing async tests
357
- - If pytest-asyncio not installed: warn that async tests will silently pass without executing async code
358
- 4. Run the tests to verify they FAIL:
359
- - Use `Bash` to execute the test command (e.g., `pytest`, `npm test`, `cargo test`)
360
- - Expected: tests FAIL (red) because implementation doesn't exist yet
361
- 4. Mark Phase 3 as `completed`
362
-
363
- **Gate**: Tests MUST exist and MUST fail. If tests pass without implementation → tests are wrong, rewrite them.
364
-
365
- ## Phase 4: IMPLEMENT (TDD Green)
366
-
367
- **Goal**: Write the minimum code to make tests pass.
368
-
369
- **REQUIRED SUB-SKILL**: Use `rune:fix`
370
-
371
- 1. Mark Phase 4 as `in_progress`
372
- 2. **Phase-file execution** — if working from a master plan + phase file:
373
- - Execute tasks listed in the phase file (the `## Tasks` section)
374
- - **Wave-based execution**: if tasks are organized into waves (see `plan` skill), execute wave-by-wave:
375
- - Wave 1 tasks first (no dependencies — can run in parallel if inside `team`)
376
- - Wave 2 tasks only after ALL Wave 1 tasks complete
377
- - Within a wave: `team` dispatches as parallel subagents; solo cook runs sequentially
378
- - If a task in Wave N fails → do NOT start Wave N+1. Fix or DECOMPOSE the failed task first
379
- - Follow code contracts from `## Code Contracts` section
380
- - Respect rejection criteria from `## Rejection Criteria` section
381
- - Handle failure scenarios from `## Failure Scenarios` section
382
- - Use `## Cross-Phase Context` for imports/exports from other phases
383
- - Mark each task `[x]` in the phase file as completed
384
- 3. Implement the feature following the plan:
385
- - Use `Write` for new files
386
- - Use `Edit` for modifying existing files
387
- - Follow project conventions found in Phase 1
388
- 3. Run tests after each significant change:
389
- - Use `Bash` to run tests
390
- - If tests pass → continue to next step in plan
391
- - If tests faildebug and fix
392
- - **Python async checklist** (if async-first Python flagged in Phase 1):
393
- - No blocking calls in async functions: `time.sleep()` → `asyncio.sleep()`, `open()` `aiofiles.open()`, `requests.get()` → `httpx.AsyncClient.get()`
394
- - Use `async with` for async context managers (DB connections, HTTP sessions)
395
- - Prefer `asyncio.gather()` for parallel I/O operations
396
- - Use `asyncio.TaskGroup` (Python 3.11+) for structured concurrency
397
- 4. If stuck on unexpected errors invoke `rune:debug` (max 3 debug↔fix loops)
398
- - Debug will scope-lock to the affected directory (Step 1.5) — fix recommendations stay within boundary
399
- - If debug recommends changes outside plan scope → treat as R4 deviation (ASK user first)
400
- 5. **Re-plan check** — before proceeding to Phase 5, evaluate:
401
- - Did debug-fix loops hit max (3) for any area?trigger re-plan
402
- - Were files modified outside the approved plan scope? → trigger re-plan
403
- - Was a new dependency added that changes the approach?trigger re-plan
404
- - Did the user request a scope change during implementation? → trigger re-plan
405
- - If any trigger fires: invoke `rune:plan` with delta context:
406
- ```
407
- Delta: { original_plan: "Phase 2 plan or .rune/features/<name>/plan.md",
408
- trigger: "max_debug | scope_expansion | new_dependency | user_scope_change",
409
- failed_area: "description of what went wrong",
410
- discovered: "new facts found during implementation" }
411
- ```
412
- Plan outputs revised phases. Get user approval before resuming.
413
- 6. **Approach Pivot Gate** — if re-plan ALSO fails (implementation still blocked after revised plan):
414
-
415
- <HARD-GATE>
416
- Do NOT surrender. Do NOT tell user "no solution exists."
417
- Do NOT try a 4th variant of the same approach.
418
- MUST invoke brainstorm(mode="rescue") before giving up.
419
- </HARD-GATE>
420
-
421
- **Trigger conditions** (ANY of these):
422
- - Re-plan produced a revised plan, but implementation hits the SAME category of blocker
423
- - 3 debug-fix loops exhausted AND re-plan exhausted (total 6+ failed attempts in same approach)
424
- - Agent catches itself about to say "this approach doesn't seem feasible" or "no solution found"
425
-
426
- **Action**:
427
- ```
428
- Invoke rune:brainstorm with:
429
- mode: "rescue"
430
- failed_approach: "[name of approach from Phase 2]"
431
- failure_evidence: ["blocker 1", "blocker 2", "blocker 3"]
432
- original_goal: "[what we're still trying to achieve]"
433
- ```
434
-
435
- brainstorm(rescue) returns 3-5 category-diverse alternatives → present to user → user picks → **restart from Phase 2** with the new approach. Previous work is sunk cost — do not try to salvage.
436
-
437
- 7. All tests MUST pass before proceeding
438
- 8. Mark Phase 4 as `completed`
439
-
440
- **Gate**: ALL tests from Phase 3 MUST pass. Do NOT proceed with failing tests.
441
-
442
- ## Phase 5: QUALITY (Parallel)
443
-
444
- **Goal**: Catch issues before they reach production.
445
-
446
- Run quality checks **in parallel** for speed. Any CRITICAL finding blocks the commit.
447
-
448
- ```
449
- PARALLEL EXECUTION:
450
- Launch 5a + 5b + 5c simultaneously as independent Task agents.
451
- Wait for ALL to complete before proceeding.
452
- If any returns BLOCK fix findings, re-run the blocking check only.
453
- ```
454
-
455
- ### 5a. Preflight (Spec Compliance + Logic)
456
- **REQUIRED SUB-SKILL**: Use `rune:preflight`
457
- - **Spec compliance**: Compare approved plan (Phase 2) vs actual diff did we build what we planned?
458
- - Logic review: Are there obvious bugs?
459
- - Error handling: Are errors caught properly?
460
- - Completeness: Does it cover edge cases?
461
-
462
- ### 5b. Security
463
- **REQUIRED SUB-SKILL**: Use `rune:sentinel`
464
- - Secret scan: No hardcoded keys/tokens
465
- - OWASP check: No injection, XSS, CSRF vulnerabilities
466
- - Dependency audit: No known vulnerable packages
467
-
468
- ### 5c. Code Review
469
- **REQUIRED SUB-SKILL**: Use `rune:review`
470
- - Pattern compliance: Follows project conventions
471
- - Code quality: Clean, readable, maintainable
472
- - Performance: No obvious bottlenecks
473
-
474
- ### 5d. Completion Gate
475
- **REQUIRED SUB-SKILL**: Use `rune:completion-gate`
476
- - Validate that agent claims match evidence trail
477
- - Check: tests actually ran (stdout captured), files actually changed (git diff), build actually passed
478
- - Check: no truncated code files (`// ...`, `// rest of code`, bare ellipsis) — agent MUST complete all output
479
- - Any UNCONFIRMED claim → BLOCK with specific gap identified
480
-
481
- **Gate**: If sentinel finds CRITICAL security issue → STOP, fix it, re-run. Non-negotiable.
482
- **Gate**: If completion-gate finds UNCONFIRMED claim → STOP, re-verify. Non-negotiable.
483
-
484
- ## Checkpoint Protocol (Opt-In)
485
-
486
- For long-running cook sessions, save intermediate state at phase boundaries:
487
-
488
- ```
489
- After Phase 2 (PLAN approved): session-bridge saves plan + decisions
490
- After Phase 4 (IMPLEMENT done): session-bridge saves progress + modified files
491
- After Phase 5 (QUALITY passed): session-bridge saves quality results
492
-
493
- Trigger: Invoke rune:session-bridge at each boundary.
494
- This is OPT-IN — only activate if:
495
- - Task spans 3+ phases
496
- - Context-watch has triggered a warning
497
- - User explicitly requests checkpoints
498
- ```
499
-
500
- ## Phase Transition Protocol (MANDATORY)
501
-
502
- Before entering ANY Phase N+1, assert ALL of the following:
503
-
504
- ```
505
- ASSERT Phase N status == completed (in TodoWrite)
506
- ASSERT Phase N gate condition met (see Mesh Gates table below)
507
- ASSERT No BLOCK status from any sub-skill in Phase N
508
- ASSERT No unresolved CRITICAL findings from quality checks
509
-
510
- IF any assertion fails:
511
- STOP. Do NOT proceed to Phase N+1.
512
- → Log: "BLOCKED at Phase N→N+1 transition: [specific assertion that failed]"
513
- Fix the blocking issue, then re-check assertions.
514
- ```
515
-
516
- **Key transitions to enforce:**
517
- | Transition | Gate | Common Violation |
518
- |---|---|---|
519
- | Phase 1 → 2 | Scout Gate (codebase scanned) | Skipping scout "to save time" |
520
- | Phase 2 → 3 | Plan Gate (user approved plan) | Starting code without approval |
521
- | Phase 3 → 4 | Test-First Gate (failing tests exist) | Writing code before tests |
522
- | Phase 4 5 | All tests pass | Moving to quality with failing tests |
523
- | Phase 5 → 6 | Quality gate (no CRITICAL findings) | Ignoring sentinel CRITICAL |
524
- | Phase 6 → 7 | Verification green (lint + types + build) | Committing broken build |
525
-
526
- ## Phase 6: VERIFY
527
-
528
- **Goal**: Final automated verification before commit.
529
-
530
- **REQUIRED SUB-SKILL**: Use `rune:verification`
531
-
532
- 1. Mark Phase 6 as `in_progress`
533
- 2. Run full verification suite:
534
- - Lint check (e.g., `eslint`, `ruff`, `clippy`)
535
- - Type check (e.g., `tsc --noEmit`, `mypy`, `cargo check`)
536
- - Full test suite (not just new tests)
537
- - Build (e.g., `npm run build`, `cargo build`)
538
- 3. Use `rune:hallucination-guard` to verify:
539
- - All imports reference real modules
540
- - API calls use correct signatures
541
- - No phantom dependencies
542
- 4. Mark Phase 6 as `completed`
543
-
544
- **Gate**: ALL checks MUST pass. If any fail → fix and re-run. Do NOT commit broken code.
545
-
546
- ## Phase 7: COMMIT
547
-
548
- **Goal**: Create a clean, semantic commit.
549
-
550
- **RECOMMENDED SUB-SKILL**: Use `rune:git` for semantic commit generation.
551
-
552
- 1. Mark Phase 7 as `in_progress`
553
- 2. Stage changed files:
554
- - Use `Bash` to run `git add <specific files>` (NOT `git add .`)
555
- - Verify staged files with `git status`
556
- 3. Invoke `rune:git commit` to generate semantic commit message from staged diff:
557
- - Analyzes diff to classify change type (feat/fix/refactor/test/docs/chore)
558
- - Extracts scope from file paths
559
- - Detects breaking changes
560
- - Formats as conventional commit: `<type>(<scope>): <description>`
561
- - Fallback: if git skill unavailable, use format `<type>: <description>` manually
562
- 4. **Master plan update** if working from a master plan + phase files:
563
- - Update the master plan file: current phase status `🔄 ✅`
564
- - If next phase exists: announce "Phase N complete. Phase N+1 ready for next session."
565
- - If all phases ✅: announce "All phases complete. Feature done."
566
- 5. Mark Phase 7 as `completed`
567
-
568
- ## Phase 8: BRIDGE
569
-
570
- **Goal**: Save context for future sessions and record metrics for mesh analytics.
571
-
572
- **REQUIRED SUB-SKILL**: Use `rune:session-bridge`
573
-
574
- 1. Mark Phase 8 as `in_progress`
575
- 2. Save decisions to `.rune/decisions.md`:
576
- - What approach was chosen and why
577
- - Any trade-offs made
578
- 3. Update `.rune/progress.md` with completed task
579
- 4. Update `.rune/conventions.md` if new patterns were established
580
- 5. **Write skill-sourced metrics** to `.rune/metrics/skills.json`:
581
- - Read the existing file (or create `{ "version": 1, "updated": "<now>", "skills": {} }`)
582
- - Under the `cook` key, update:
583
- - `phases`: increment `run` or `skip` count for each phase that was run/skipped this session
584
- - `quality_gate_results`: increment `preflight_pass`/`preflight_fail`, `sentinel_pass`/`sentinel_block`, `review_pass`/`review_issues` based on Phase 5 outcomes
585
- - `debug_loops`: increment `total` by number of debug-fix loops in Phase 4, update `max_per_session` if this session exceeded it
586
- - Write the updated file back
587
- 6. **Adaptive error recovery** (H3 Intelligence):
588
- - If Phase 4 had 3 debug-fix loops (max) for a specific error pattern, write a routing override to `.rune/metrics/routing-overrides.json`:
589
- - Format: `{ "id": "r-<timestamp>", "condition": "<error pattern>", "action": "route to problem-solver before debug", "source": "auto", "active": true }`
590
- - Max 10 active rules — if exceeded, remove oldest inactive rule
591
- 7. **Step 8.5 — Capture Learnings**: Call `neural-memory` (Capture Mode). Save 2-5 memories covering: architecture decisions made this session, patterns introduced or validated, errors encountered and their root-cause fixes, and any trade-offs chosen. Use rich cognitive language (causal, decisional, comparative — not flat facts). Tag each memory with `[project-name, technology, topic]`. Priority: 5 for routine patterns, 7-8 for key decisions, 9-10 for critical errors. Do NOT batch — save each memory immediately. Do NOT wait for the user to ask.
592
- 8. Mark Phase 8 as `completed`
593
-
594
- ## Autonomous Loop Patterns
595
-
596
- When cook runs inside `team` (L1) or autonomous workflows, these patterns apply:
597
-
598
- ### De-Sloppify Pass
599
-
600
- After Phase 4 (IMPLEMENT), if the implementation touched 5+ files, run a focused cleanup pass:
601
- 1. Re-read all modified files
602
- 2. Check for: leftover debug statements, inconsistent naming, duplicated logic, missing error handling
603
- 3. Fix issues found (this is still Phase 4 — not a new phase)
604
- 4. This pass catches "almost right" code that slips through when focused on making tests pass
605
-
606
- ### Continuous PR Loop (team orchestration only)
607
-
608
- When `team` runs multiple cook instances in parallel:
609
- ```
610
- cook instance commit push create PR wait CI
611
- IF CI passes mark workstream complete
612
- IF CI fails read CI output fix push wait CI (max 3 retries)
613
- IF 3 retries fail → escalate to user with CI logs
614
- ```
615
-
616
- ### Formal Pause/Resume (`.continue-here.md`)
617
-
618
- When cook must pause mid-phase (context limit, user break, session end before phase completes):
619
-
620
- 1. Create `.rune/.continue-here.md` with structured handoff:
621
- ```markdown
622
- ## Continue Here
623
- - **Phase**: [current phase number and name]
624
- - **Task**: [current task within phase — e.g., "Task 3 of 5"]
625
- - **Completed**: [list of tasks done this session]
626
- - **Remaining**: [list of tasks not yet started]
627
- - **Decisions**: [any decisions made this session]
628
- - **Blockers**: [if any what's stuck and why]
629
- - **WIP Files**: [files modified but not yet committed]
630
- ```
631
- 2. Create a WIP commit: `wip: cook phase N paused at task M`
632
- 3. Phase 0 (RESUME CHECK) detects `.continue-here.md` → resumes from exact task position
633
- 4. After successful resume and phase completion → delete `.continue-here.md`
634
-
635
- This is more granular than Phase 0's plan-level resume — it resumes within a phase, not just between phases.
636
-
637
- ### Mid-Run Signal Detection (Two-Stage Intent Classification)
638
-
639
- When user sends a message DURING cook execution (mid-phase), classify intent before acting:
640
-
641
- **Stage 1 — Keyword Fast-Path** (no LLM reasoning needed, <60 chars):
642
-
643
- | Pattern | Intent | Action |
644
- |---------|--------|--------|
645
- | "stop", "cancel", "dừng", "abort" | `Cancel` | Save progress emit Cook Report with status BLOCKED → stop |
646
- | "status", "tiến độ", "progress", "where are you" | `StatusQuery` | Reply with current phase + task + % estimate → resume |
647
- | "wait", "pause", "đợi" | `Pause` | Create `.rune/.continue-here.md` → WIP commit → stop |
648
- | "skip this", "bỏ qua", "next" | `Steer` | Skip current task → proceed to next task/phase |
649
-
650
- **Stage 2 — Context Classification** (if no keyword match AND message >60 chars):
651
-
652
- | Intent | Signal | Action |
653
- |--------|--------|--------|
654
- | `Steer` | Modifies scope but keeps goal ("actually use Redis instead of Memcached") | Update plan inline, note deviation in Cook Report |
655
- | `NewTask` | Unrelated to current work ("also fix the login page") | Log to `.rune/backlog.md`, continue current task. Announce: "Noted for later — staying on current task." |
656
- | `Clarification` | Answers a question cook asked, or provides missing context | Absorb into current phase context, resume |
657
-
658
- > Source: goclaw (832★) — two-stage intent classification prevents expensive LLM calls for simple signals like "stop" or "status".
659
-
660
- <HARD-GATE>
661
- NEVER treat a Cancel/Pause signal as a Steer or NewTask. User safety signals take absolute priority.
662
- If ambiguous between Cancel and Steer → ask user: "Did you mean stop, or change approach?"
663
- </HARD-GATE>
664
-
665
- ### Exit Conditions (Mandatory for Autonomous Runs)
666
-
667
- Every cook invocation inside `team` or autonomous workflows MUST have exit conditions:
668
-
669
- ```
670
- MAX_DEBUG_LOOPS: 3 per error area (already enforced)
671
- MAX_QUALITY_LOOPS: 2 re-runs of Phase 5 (fix→recheck cycle)
672
- MAX_REPLAN: 1 re-plan per cook session (Phase 4 re-plan check)
673
- MAX_PIVOT: 1 approach pivot per cook session (Approach Pivot Gate)
674
- MAX_FIXES: 30 per session (hard cap — fix's WTF-likelihood self-regulation)
675
- WTF_THRESHOLD: 20% quality decay risk → STOP fixing, commit progress, re-assess
676
- TIMEOUT_SIGNAL: If context-watch reports ORANGE, wrap up current phase and checkpoint
677
- ```
678
-
679
- **Escalation chain**: debug-fix (3x) → re-plan (1x) → **approach pivot via brainstorm rescue (1x)** → THEN escalate to user. Never surrender before exhausting the pivot.
680
-
681
- If any exit condition triggers without resolution → cook emits `BLOCKED` status with details and stops. Never spin indefinitely.
682
-
683
- ### Subagent Status Protocol
684
-
685
- When cook completes (whether standalone or invoked by `team`), it MUST return one of four statuses. Sub-skills invoked by cook (fix, test, review, sentinel, etc.) MUST also return one of these statuses so cook can route accordingly.
686
-
687
- | Status | Meaning | Cook Action |
688
- |--------|---------|-------------|
689
- | `DONE` | Task complete, no issues | Proceed to next phase |
690
- | `DONE_WITH_CONCERNS` | Task complete but issues noted (e.g., "tests pass but a performance regression observed") | Proceed, but append concern to `.rune/progress.md` and surface in Cook Report; address in Phase 5 (QUALITY) or next review cycle |
691
- | `NEEDS_CONTEXT` | Cannot proceed without more information (missing requirement, ambiguous spec, unknown environment) | Pause execution. Ask user the specific question(s) blocking progress. Resume from the same phase after answer received. |
692
- | `BLOCKED` | Hard blocker — cannot continue regardless of context (broken dependency, fundamental incompatibility, exhausted escalation chain) | Trigger escalation chain: debug-fix (3x) → re-plan (1x) → brainstorm rescue (1x) → then escalate to user with full details |
693
-
694
- **DONE_WITH_CONCERNS logging format** (append to `.rune/progress.md`):
695
- ```
696
- [CONCERN][phase][timestamp] <sub-skill>: <concern description>
697
- ```
698
-
699
- **NEEDS_CONTEXT format**: State exactly what is unknown, why it blocks progress, and what the two most likely answers are (to help the user respond quickly).
700
-
701
- **BLOCKED format**: Include the phase, the sub-skill that emitted BLOCKED, the specific blocker, and what was already attempted.
702
-
703
- ## Deviation Rules
704
-
705
- When implementation diverges from plan:
706
-
707
- | Rule | Scope | Action | Example |
708
- |------|-------|--------|---------|
709
- | R1: Bug fix | Code doesn't work as planned | Auto-fix, continue | Test fails due to typo, missing import |
710
- | R2: Security fix | Vulnerability discovered | Auto-fix, continue | SQL injection, XSS, hardcoded secret |
711
- | R3: Blocking fix | Can't proceed without change | Auto-fix, continue | Missing dependency, wrong API signature |
712
- | R4: Architectural change | Different approach than planned | **ASK user first** | New database table, changed API contract, different library |
713
-
714
- R1-R3: security primitives and correctness fixes are NOT features — fix silently.
715
- R4: if you catch yourself thinking "this is a better way" — STOP and ask. The plan was approved for a reason.
716
-
717
- ## Error Recovery
718
-
719
- | Phase | If this fails... | Do this... |
720
- |-------|-----------------|------------|
721
- | 1 UNDERSTAND | scout finds nothing relevant | Proceed with plan, note limited context |
722
- | 2 PLAN | Task too complex | Break into smaller tasks, consider `rune:team` |
723
- | 3 TEST | Can't write tests (no test framework) | Skip TDD, write tests after implementation |
724
- | 4 IMPLEMENT | Fix hits repeated bugs | `rune:debug` (max 3 loops) → re-plan → if still blocked → **Approach Pivot Gate** → `rune:brainstorm(rescue)` |
725
- | 5a PREFLIGHT | Logic issues found | Fix → re-run preflight |
726
- | 5b SENTINEL | Security CRITICAL found | Fix immediately → re-run (mandatory) |
727
- | 5c REVIEW | Code quality issues | Fix CRITICAL/HIGH → re-review (max 2 loops) |
728
- | 6 VERIFY | Build/lint/type fails | Fix → re-run verification |
729
-
730
- ### Repair Operators (before escalation)
731
-
732
- When a task fails during Phase 4 (IMPLEMENT):
733
-
734
- | Operator | When | Action |
735
- |----------|------|--------|
736
- | **RETRY** | Transient failure (network, timeout, flaky test) | Re-run same approach, max 2 attempts |
737
- | **DECOMPOSE** | Task too complex, partial progress | Split into 2-3 smaller tasks, continue |
738
- | **PRUNE** | Approach fundamentally wrong | Remove failed code, try different approach from plan |
739
-
740
- **Budget**: 2 repair attempts per task. After 2 failures → escalate:
741
- - Same error both times → `debug` for root cause
742
- - Different errors → `plan` to redesign the task
743
- - All approaches exhausted → `brainstorm(rescue)` for alternative category
744
-
745
- Do NOT ask user until repair budget is spent.
746
-
747
- ## Called By (inbound)
748
-
749
- - User: `/rune cook` direct invocation — primary entry point
750
- - `team` (L1): parallel workstream execution (meta-orchestration)
751
-
752
- ## Calls (outbound)
753
-
754
- - `neural-memory` (external): Phase 0 (resume) + Phase 8 (complete) — Recall project context at start, capture learnings at end
755
- - `sentinel-env` (L3): Phase 0.5 — environment pre-flight (first run only)
756
- - `scout` (L2): Phase 1 — scan codebase before planning
757
- - `onboard` (L2): Phase 1 — if no CLAUDE.md exists, initialize project context first
758
- - `plan` (L2): Phase 2 — create implementation plan
759
- - `brainstorm` (L2): Phase 2 — trade-off analysis when multiple approaches exist
760
- - `design` (L2): Phase 2 — UI/design phase when building frontend features
761
- - `adversary` (L2): Phase 2.5 — red-team challenge on approved plan before implementation
762
- - `test` (L2): Phase 3 — write failing tests (RED phase)
763
- - `fix` (L2): Phase 4 — implement code changes (GREEN phase)
764
- - `debug` (L2): Phase 4 — when implementation hits unexpected errors (max 3 loops)
765
- - `db` (L2): Phase 4 — when schema changes are detected in the diff
766
- - `preflight` (L2): Phase 5a — logic and completeness review
767
- - `sentinel` (L2): Phase 5b — security scan
768
- - `review` (L2): Phase 5c — code quality review
769
- - `perf` (L2): Phase 5 — performance regression check before PR (optional)
770
- - `completion-gate` (L3): Phase 5d — validate agent claims against evidence trail
771
- - `constraint-check` (L3): Phase 5 — audit HARD-GATE compliance across workflow
772
- - `verification` (L3): Phase 6 — automated checks (lint, types, tests, build)
773
- - `hallucination-guard` (L3): Phase 6 — verify imports and API calls are real
774
- - `journal` (L3): Phase 7 — record architectural decisions made during feature
775
- - `session-bridge` (L3): Phase 8 — save context for future sessions
776
- - `audit` (L2): Phase 5 — project health audit when scope warrants it
777
- - `review-intake` (L2): Phase 5 — structured review intake for complex PRs
778
- - `sast` (L3): Phase 5 — static analysis security testing
779
- - `skill-forge` (L2): when new skill creation detected during cook flow
780
- - `worktree` (L3): Phase 4 — worktree isolation for parallel implementation
781
- - L4 extension packs: Phase 1.5 — domain-specific patterns when stack matches (see Phase 1.5 mapping table)
782
-
783
- ## Data Flow
784
-
785
- ### Feeds Into →
786
-
787
- - `journal` (L3): architectural decisions made during cook → ADR entries for future sessions
788
- - `session-bridge` (L3): cook's context (plan, decisions, progress) → .rune/ state files for next session
789
- - `neural-memory` (external): learnings from this cook run → persistent cross-session memory
790
-
791
- ### Fed By ←
792
-
793
- - `ba` (L2): Requirements Document → cook's Phase 1 UNDERSTAND input
794
- - `plan` (L2): master plan + phase files → cook's Phase 2-4 execution roadmap
795
- - `session-bridge` (L3): .rune/.continue-here.md → cook's Phase 0 resume context
796
- - `neural-memory` (external): past project decisions → cook's Phase 0 context recall
797
-
798
- ### Feedback Loops ↻
799
-
800
- - `cook` ↔ `debug`: cook encounters bug during Phase 4 → debug diagnoses → cook resumes with fix. Debug may discover the plan is wrong → cook triggers Approach Pivot
801
- - `cook` ↔ `test`: cook writes tests in Phase 3 (RED), implements in Phase 4 (GREEN), runs tests again → failures loop back to Phase 4 fix
802
-
803
- ## Analysis Paralysis Guard
804
-
805
- <HARD-GATE>
806
- 5+ consecutive read-only tool calls (Read, Grep, Glob) without a single write action (Edit, Write, Bash) = STUCK.
807
-
808
- You MUST either:
809
- 1. **Act** — write code, run a command, create a file
810
- 2. **Report BLOCKED** — state the specific missing piece: "Cannot proceed because [X]"
811
-
812
- Stuck patterns (all banned):
813
- - Reading 10+ files to "fully understand" before acting
814
- - Grepping every variation of a string across the entire repo
815
- - Reading the same file twice in one investigation
816
- - "Let me check one more thing" — repeated after 5 reads
817
-
818
- A wrong first attempt that produces feedback beats perfect understanding that never ships.
819
- </HARD-GATE>
820
-
821
- ### Hash-Based Tool Loop Detection (Content-Aware)
822
-
823
- The 5-read counter above catches obvious paralysis. This catches **same-input-same-output loops** — where the agent keeps calling the same tool with the same arguments and getting the same result, making zero progress.
824
-
825
- **Detection logic** (conceptual — tracked mentally, not via actual SHA256):
826
-
827
- ```
828
- For each tool call, track:
829
- argsHash = fingerprint(tool_name + arguments)
830
- resultHash = fingerprint(result content)
831
-
832
- IF same argsHash AND same resultHash seen before:
833
- consecutive_identical += 1
834
- ELSE:
835
- consecutive_identical = 0
836
-
837
- Thresholds:
838
- 3 identical calls → WARN: "Loop detected — same tool, same args, same result 3x. Change approach."
839
- 5 identical calls → FORCE STOP: "True stuck loop. Must try different tool or different arguments."
840
- ```
841
-
842
- **Key distinction**: retry-with-different-result is NOT a loop (e.g., re-running tests after a fix). Only same-input-AND-same-output counts.
843
-
844
- > Source: goclaw (832★) — SHA256-based loop detection distinguishes true stuck loops from productive retries.
845
-
846
- **Common loop patterns to catch**:
847
- | Pattern | Looks Like | Actually |
848
- |---------|-----------|----------|
849
- | Re-reading same file after failed edit | `Read(file.ts)` → same content 3x | Agent forgot what it read — act on existing knowledge |
850
- | Re-running same failing test without code change | `Bash(npm test)` → same failure 3x | No code was changed between runs — fix first, then test |
851
- | Grepping same pattern across different paths | `Grep("pattern", src/)` → `Grep("pattern", lib/)` → same 0 results | Pattern doesn't exist — change search terms |
852
-
853
- ## Constraints
854
-
855
- 1. MUST run scout before planning — no plan based on assumptions alone
856
- 2. MUST present plan to user and get approval before writing code
857
- 3. MUST write failing tests before implementation (TDD) unless explicitly skipped by user
858
- 4. MUST NOT commit with failing tests — fix or revert first
859
- 5. MUST NOT modify files outside the approved plan scope without user confirmation
860
- 6. MUST run verification (lint + type-check + tests + build) before commit — not optional
861
- 7. MUST NOT say "all tests pass" without showing the actual test output
862
- 8. MUST NOT contradict active decisions from `.rune/decisions.md` without explicit user override — if the plan conflicts with a prior decision, flag it and ask user before proceeding
863
-
864
- ## Mesh Gates
865
-
866
- | Gate | Requires | If Missing |
867
- |------|----------|------------|
868
- | Resume Gate | Phase 0 checks for existing master plan before starting | Proceed to Phase 1 if no plan exists |
869
- | Scout Gate | scout output (files examined, patterns found) before Phase 2 | Invoke rune:scout first |
870
- | Plan Gate | User-approved plan with file paths before Phase 3 | Cannot proceed to TEST |
871
- | Adversary Gate | adversary verdict (PROCEED/HARDEN) before Phase 3 for features | Skip for bugfix/hotfix/refactor/fast-mode |
872
- | Phase File Gate | Current phase file loaded (not full plan) for multi-session | Load only the active phase file |
873
- | Test-First Gate | Failing tests exist before Phase 4 IMPLEMENT | Write tests first or get explicit skip from user |
874
- | Quality Gate | preflight + sentinel + review passed before Phase 7 COMMIT | Fix findings, re-run |
875
- | Verification Gate | lint + types + tests + build all green before commit | Fix failures, re-run |
876
-
877
- ## Output Format
878
-
879
- ```
880
- ## Cook Report: [Task Name]
881
- - **Status**: DONE | DONE_WITH_CONCERNS | NEEDS_CONTEXT | BLOCKED
882
- - **Phases**: [list of completed phases]
883
- - **Files Changed**: [count] ([list])
884
- - **Tests**: [passed]/[total] ([coverage]%)
885
- - **Quality**: preflight [PASS/WARN] | sentinel [PASS/WARN] | review [PASS/WARN]
886
- - **Commit**: [hash] — [message]
887
-
888
- ### Deliverables (NEXUS response — when invoked by team)
889
- | # | Deliverable | Status | Evidence |
890
- |---|-------------|--------|----------|
891
- | 1 | [from handoff] | DELIVERED | [file path or test output quote] |
892
- | 2 | [from handoff] | DELIVERED | [file path or test output quote] |
893
- | 3 | [from handoff] | PARTIAL | [what's missing and why] |
894
-
895
- ### Concerns (if DONE_WITH_CONCERNS)
896
- - [concern]: [impact assessment] — [suggested remediation]
897
-
898
- ### Decisions Made
899
- - [decision]: [rationale]
900
-
901
- ### Session State
902
- - Saved to .rune/decisions.md
903
- - Saved to .rune/progress.md
904
- ```
905
-
906
- > When cook is invoked standalone (not by team), the Deliverables table is optional. When invoked by team with a NEXUS Handoff, the Deliverables table is MANDATORY — team uses it to track acceptance criteria across streams.
907
-
908
- ## Sharp Edges
909
-
910
- Known failure modes for this skill. Check these before declaring done.
911
-
912
- | Failure Mode | Severity | Mitigation |
913
- |---|---|---|
914
- | Skipping scout to "save time" on a simple task | CRITICAL | Scout Gate blocks this — Phase 1 is mandatory regardless of perceived simplicity |
915
- | Writing code without user-approved plan | HIGH | Plan Gate: do NOT proceed to Phase 3 without explicit approval ("go", "proceed", "yes") |
916
- | Claiming "all tests pass" without showing output | HIGH | Constraint 7 blocks this — show actual test runner output via completion-gate |
917
- | Entering debug↔fix loop more than 3 times without escalating | MEDIUM | After 3 loops → re-plan → if still blocked → Approach Pivot Gate → brainstorm(rescue) |
918
- | Surrendering "no solution" without triggering Approach Pivot Gate | CRITICAL | MUST invoke brainstorm(rescue) before telling user "can't be done" — pivot to different category first |
919
- | Re-planning with the same approach category after it fundamentally failed | HIGH | Re-plan = revise steps within same approach. If CATEGORY is wrong → Approach Pivot Gate, not re-plan |
920
- | Not escalating to sentinel:opus on security-sensitive tasks | MEDIUM | Auth, crypto, payment code → sentinel must run at opus, not sonnet |
921
- | Running Phase 5 checks sequentially instead of parallel | MEDIUM | Launch preflight+sentinel+review as parallel Task agents for speed |
922
- | Saying "done" without evidence trail | CRITICAL | completion-gate validates claims — UNCONFIRMED = BLOCK |
923
- | Analysis paralysis — 5+ reads without writing | HIGH | Analysis Paralysis Guard: act on incomplete info or report BLOCKED with specific missing piece |
924
- | Fast mode on security-relevant code | HIGH | Fast mode auto-excludes auth/crypto/payments — never fast-track security code |
925
- | Loading all phase files at once into context | HIGH | Phase File Gate: load ONLY the active phase file — one phase per session |
926
- | Resuming without checking master plan | MEDIUM | Phase 0 (RESUME CHECK) runs before Phase 1 — detects existing plans |
927
- | Treating user "stop"/"cancel" as scope change | CRITICAL | Mid-Run Signal Detection: Cancel/Pause are safety signals with absolute priority — never reinterpret as Steer or NewTask |
928
- | Same tool+args+result called 3+ times without progress | HIGH | Hash-Based Loop Detection: 3x warn, 5x force stop. Only same-input-AND-same-output counts — retries with different results are fine |
929
- | Ignoring mid-run user messages during autonomous execution | HIGH | Two-stage intent classification: keyword fast-path for simple signals, context classification for longer messages. Never queue user messages — process immediately |
930
- | Breaking change shipped without RFC review | CRITICAL | Phase 2.5 RFC Gate: any breaking change MUST have RFC artifact + user approval before implementation |
931
- | Runaway fix loop — fix introduces more bugs than it resolves | HIGH | fix v0.5.0 WTF-likelihood self-regulation: >20% decay = STOP. Hard cap 30 fixes/session via MAX_FIXES exit condition. Regressions +15%, blast radius +5%/file |
932
-
933
- ## Self-Validation
934
-
935
- ```
936
- SELF-VALIDATION (run before emitting Cook Report):
937
- - [ ] Every phase in Phase Skip Rules was either executed or explicitly skipped with reason
938
- - [ ] Plan approval gate was not bypassed — user said "go" (check conversation history)
939
- - [ ] No Phase 4 code was written before Phase 3 tests (TDD order preserved)
940
- - [ ] All Phase 5 quality gates (preflight, sentinel, review) ran — not just claimed
941
- - [ ] Cook Report contains actual commit hash, not placeholder
942
- ```
943
-
944
- ## Done When
945
-
946
- - All applicable phases complete per Phase Skip Rules (determined before starting)
947
- - User has approved the plan (Phase 2 gate — explicit "go" received)
948
- - All tests PASS — actual test runner output shown
949
- - preflight + sentinel + review all PASS or findings addressed
950
- - verification (lint + types + build) green
951
- - Commit created with semantic message
952
- - Cook Report emitted with commit hash and phase list
953
- - Session state saved to .rune/ via session-bridge
954
- - Self-Validation: all checks passed
955
-
956
- ## Cost Profile
957
-
958
- ~$0.05-0.15 per feature. Haiku for scanning (Phase 1), sonnet for coding (Phase 3-4), opus for complex planning (Phase 2 when needed).
1
+ ---
2
+ name: cook
3
+ description: "Feature implementation orchestrator. ALWAYS use this skill for ANY code change — implement, build, add feature, create, fix bug, or any task that modifies source code. This is the default route for 70% of all requests. Runs full TDD cycle: understand → plan → test → implement → quality → verify → commit."
4
+ context: fork
5
+ agent: general-purpose
6
+ metadata:
7
+ author: runedev
8
+ version: "1.7.0"
9
+ layer: L1
10
+ model: sonnet
11
+ group: orchestrator
12
+ tools: "Read, Write, Edit, Bash, Glob, Grep"
13
+ ---
14
+
15
+ # cook
16
+
17
+ ## Purpose
18
+
19
+ The primary orchestrator for feature implementation. Coordinates the entire L2 mesh in a phased TDD workflow. Handles 70% of all user requests — any task that modifies source code routes through cook.
20
+
21
+ <HARD-GATE>
22
+ Before starting ANY implementation:
23
+ 1. You MUST understand the codebase first (Phase 1)
24
+ 2. You MUST have a plan before writing code (Phase 2)
25
+ 3. You MUST write failing tests before implementation (Phase 3) — unless explicitly skipped
26
+ This applies to EVERY feature regardless of perceived simplicity.
27
+ </HARD-GATE>
28
+
29
+ ## Workflow Chains (Predefined)
30
+
31
+ Cook supports predefined workflow chains for common task types. Use these as shortcuts instead of manually determining phases:
32
+
33
+ ```
34
+ /rune cook feature → Full TDD pipeline (all phases)
35
+ /rune cook bugfix → Diagnose → fix → verify (Phase 1 → 4 → 6 → 7)
36
+ /rune cook refactor → Understand → plan → implement → quality (Phase 1 → 2 → 4 → 5 → 6 → 7)
37
+ /rune cook security → Full pipeline + sentinel@opus + sast (all phases, security-escalated)
38
+ /rune cook hotfix → Minimal: fix → verify → commit (Phase 4 → 6 → 7, skip scout if user provides context)
39
+ /rune cook nano → Trivial: do → verify → done (no phases, ≤3 steps)
40
+ ```
41
+
42
+ **Chain selection**: If user invokes `/rune cook` without a chain type, auto-detect from the task description:
43
+ - Contains "bug", "fix", "broken", "error" → `bugfix`
44
+ - Contains "refactor", "clean", "restructure" → `refactor`
45
+ - Contains "security", "auth", "vulnerability", "CVE" → `security`
46
+ - Contains "urgent", "hotfix", "production" → `hotfix`
47
+ - Contains "quick", "just", "chỉ cần", "copy", "move", "rename", "bump" → `nano`
48
+ - Default `feature`
49
+
50
+ ## Phase Skip Rules
51
+
52
+ Not every task needs every phase:
53
+
54
+ ```
55
+ Nano task: DOVERIFYDONE (no phases, auto-detected)
56
+ Simple bug fix: Phase 1 4 6 → 7
57
+ Small refactor: Phase 1 4 5 → 6 → 7
58
+ New feature: Phase 1 → 1.5 → 2 → 3 → 4 → 5 → 6 → 7 8
59
+ Complex feature: All phases + brainstorm in Phase 2
60
+ Security-sensitive: All phases + sentinel escalated to opus
61
+ Fast mode: Phase 1 → 4 → 6 → 7 (auto-detected, see below)
62
+ Multi-session: Phase 0 (resume) 3 4 5 → 6 → 7 (one plan phase per session)
63
+ ```
64
+
65
+ Determine complexity BEFORE starting using the Rigor Assessment below. Create TodoWrite with applicable phases.
66
+
67
+ ### Rigor Assessment (Progressive Scaling)
68
+
69
+ Before selecting a workflow chain or phase set, compute the task's **rigor level** from risk signals. This prevents over-engineering trivial changes while ensuring full ceremony for critical ones.
70
+
71
+ | Risk Signal | Weight | Detection |
72
+ |-------------|--------|-----------|
73
+ | Files affected: 1 | 0 | Estimate from task description + scout |
74
+ | Files affected: 2-3 | +1 | |
75
+ | Files affected: 4+ | +3 | |
76
+ | Cross-module impact (changes span 2+ directories) | +2 | scout identifies touch points across boundaries |
77
+ | Security-sensitive code (auth, crypto, payments, secrets) | +3 | Keyword match in file paths or task description |
78
+ | Public API change (exports, routes, schema) | +2 | Task modifies interfaces consumed by external code |
79
+ | Database schema change | +2 | Task mentions migration, schema, ALTER, column |
80
+ | New dependency added | +1 | Task requires `npm install` or equivalent |
81
+ | Code will be imported by other modules | +1 | New exports or modifications to shared utilities |
82
+
83
+ **Rigor level mapping:**
84
+
85
+ | Score | Level | Maps To | Phases |
86
+ |-------|-------|---------|--------|
87
+ | 0 | Nano | `nano` chain | DO → VERIFY → DONE |
88
+ | 1-2 | Fast | `fast` mode | Phase 1 4 6 → 7 |
89
+ | 3-5 | Standard | `bugfix` / `refactor` | Phase 1 → 2 → 4 → 5 → 6 → 7 |
90
+ | 6-8 | Full | `feature` | Phase 1 → 1.5 → 2 → 3 → 4 → 5 → 6 → 7 → 8 |
91
+ | 9+ | Critical | `security` / full + adversary | All phases + sentinel@opus + adversary |
92
+
93
+ **Rules:**
94
+ - Security signal (+3) automatically floors rigor at Standard NEVER nano/fast for security code
95
+ - User can override: "full pipeline" forces Full, "just do it" forces Nano
96
+ - If rigor upgrades mid-task (e.g., scout reveals cross-module impact not obvious from description), announce: "Rigor upgrade: [signal detected] — upgrading from Fast to Standard."
97
+ - Announce chosen level: "Rigor: Fast (score 2 single file, no security)"
98
+
99
+ > Source: Fission-AI/OpenSpec (32.8k★) — progressive ceremony scaling by risk factors.
100
+
101
+ ## Nano Mode (Auto-Detect)
102
+
103
+ For trivial tasks that don't need any pipeline at all:
104
+
105
+ ```
106
+ IF all of these are true:
107
+ - Task is ≤3 discrete steps (e.g., run command, edit 1 file, commit)
108
+ - Task description < 60 chars OR user prefixes with "quick:", "just", "chỉ cần"
109
+ - No code logic changes (copy files, config edits, version bumps, git ops, run scripts)
110
+ - No new functions/classes/components created
111
+ THEN: Nano Mode activated
112
+ - Execute directly: DO VERIFY → DONE
113
+ - No phases. No plan. No test. No review.
114
+ - Still verify output (check exit codes, confirm file exists, etc.)
115
+ - Still use semantic commit message if committing
116
+ ```
117
+
118
+ **Announce**: "Nano mode: trivial task, executing directly."
119
+ **Override**: User can say "full pipeline" or "cook feature" to force phases.
120
+ **Escape hatch**: If during execution the task turns out more complex than expected → announce upgrade: "Upgrading to Fast/Full mode — task is more complex than detected." Resume from Phase 1.
121
+
122
+ <HARD-GATE>
123
+ Nano mode MUST NOT be used for:
124
+ - Any code that will be imported/called by other code
125
+ - Security-relevant files (auth, crypto, payments, .env, secrets)
126
+ - Database schema changes
127
+ - Public API changes
128
+ If any of these are detected mid-task, STOP and upgrade to Fast/Full mode.
129
+ </HARD-GATE>
130
+
131
+ ## Fast Mode (Auto-Detect)
132
+
133
+ Cook auto-detects small changes and streamlines the pipeline:
134
+
135
+ ```
136
+ IF all of these are true:
137
+ - Total estimated change < 30 LOC
138
+ - Single file affected
139
+ - No security-relevant code (auth, crypto, payments, .env)
140
+ - No public API changes
141
+ - No database schema changes
142
+ THEN: Fast Mode activated
143
+ - Skip Phase 2 (PLAN) change is too small for a formal plan
144
+ - Skip Phase 3 (TEST) unless existing tests cover the area
145
+ - Skip Phase 5b (SENTINEL) non-security code
146
+ - Skip Phase 8 (BRIDGE) not worth persisting
147
+ - KEEP Phase 5a (PREFLIGHT) and Phase 6 (VERIFY) always run quality checks
148
+ ```
149
+
150
+ **Announce fast mode**: "Fast mode: small change detected (<30 LOC, single file, non-security). Streamlined pipeline."
151
+ **Override**: User can say "full pipeline" to force all phases even on small changes.
152
+
153
+ ## Phase 0.5: ENVIRONMENT CHECK (First Run Only)
154
+
155
+ **SUB-SKILL**: Use `rune:sentinel-env` — verify the environment can run the project before planning.
156
+
157
+ Auto-trigger: no `.rune/` dir (first run) OR build just failed with env-looking errors AND NOT fast mode. Skip silently on subsequent runs. Force with `/rune env-check`.
158
+
159
+ ## Phase 1: UNDERSTAND
160
+
161
+ **Goal**: Know what exists before changing anything.
162
+
163
+ **REQUIRED SUB-SKILLS**: Use `rune:scout`. For non-trivial tasks, use `rune:ba`.
164
+
165
+ 1. Create TodoWrite with all applicable phases for this task
166
+ 2. Mark Phase 1 as `in_progress`
167
+ 3. **BA gate**: Feature Request / Integration / Greenfield invoke `rune:ba`. Task > 50 words or business terms (users, revenue, workflow) → invoke `rune:ba`. Bug Fix / simple Refactor → skip. BA produces `.rune/features/<name>/requirements.md` for Phase 2.
168
+ 4. **Decision enforcement**: `Glob` for `.rune/decisions.md`; if exists, `Read` + extract constraints for Phase 2. Plan MUST NOT contradict active decisions without explicit user override.
169
+
170
+ ### Phase 1 Step 3.5 — Clarification Gate
171
+
172
+ Ask **2 questions** before planning: (1) "What does success look like?" (2) "What should NOT change?"
173
+
174
+ Skip if: bug fix with clear repro steps | user said "just do it" | fast mode + <10 LOC | hotfix chain active. Complexity revealed → escalate to `rune:ba`.
175
+
176
+ 5. Invoke scout to scan the codebase (Glob + Grep + Read on relevant files)
177
+ 6. Summarize: what exists, project conventions, files likely to change, active decision constraints
178
+ 7. **Python async detection**: if Python project detected, `Grep` for async indicators (`async def`, `await`, `aiosqlite`, `aiohttp`, `asyncio.run`). If ≥3 matches → flag as **"async-first Python"** — new code defaults to `async def`
179
+ 8. Mark Phase 1 as `completed`
180
+
181
+ **Gate**: If scout finds the feature already exists STOP and inform user.
182
+
183
+ ## Phase 1.5: DOMAIN CONTEXT (L4 Pack Detection)
184
+
185
+ **Goal**: Detect if domain-specific L4 extension packs apply to this task.
186
+
187
+ <MUST-READ path="references/pack-detection.md" trigger="Phase 1.5 before checking L4 pack mapping"/>
188
+
189
+ After scout completes, check if the detected tech stack or task description matches any L4 extension pack. This phase is lightweight — a Read + pattern match. It does NOT replace Phase 1 (scout) or Phase 2 (plan). If 0 packs match: skip silently.
190
+
191
+ ## Phase 1.7: WORKFLOW ORCHESTRATION (Multi-Skill Sequences)
192
+
193
+ **Goal**: If Phase 1.5 detected a pack AND the task maps to a named workflow, orchestrate the multi-skill sequence.
194
+
195
+ **Trigger**: Only runs if Phase 1.5 found a pack match AND the pack's Workflows table has a matching command.
196
+
197
+ <MUST-READ path="references/pack-detection.md" trigger="Phase 1.7 — workflow command detection section"/>
198
+
199
+ 1. Read the matched PACK.md's Workflows section
200
+ 2. Identify the workflow name and skill sequence
201
+ 3. For each skill in sequence:
202
+ a. Load the skill file from the pack's `skills/` directory
203
+ b. Execute the skill's workflow steps
204
+ c. Write output artifact to `.rune/<domain>/` (e.g., `.rune/hr/jd-[role]-[date].md`)
205
+ d. The next skill reads the previous artifact as input context
206
+ 4. After all skills complete: summarize the workflow results to the user
207
+
208
+ **Threading state**: Each skill in the sequence produces an artifact file. The next skill's Step 1 reads existing artifacts from `.rune/<domain>/`. This is already built into each skill — no new plumbing needed.
209
+
210
+ **Skip if**: No workflow match found in Phase 1.5. Single-skill tasks proceed directly to Phase 2 (PLAN) as normal.
211
+
212
+ ## Phase 0: RESUME CHECK (Before Phase 1)
213
+
214
+ **Goal**: Detect if a master plan already exists for this task. If so, skip Phase 1-2 and resume from the current phase.
215
+
216
+ **Step 0.5 Cross-Project Recall**: Call `neural-memory` (Recall Mode) with 3-5 topics relevant to the current task. Always prefix queries with the project name (e.g., `"ProjectName auth pattern"` not `"auth pattern"`).
217
+
218
+ 1. Use `Glob` to check for `.rune/plan-*.md` files
219
+ 2. If a master plan exists matching the current task: Read it → find first `⬚ Pending` or `🔄 Active` phase → load ONLY that phase file → announce "Resuming from Phase N" → skip to Phase 4
220
+ 3. If no master plan exists → proceed to Phase 1 as normal
221
+
222
+ **This enables multi-session workflows**: Opus plans once each session picks up the next phase.
223
+
224
+ ## Phase 2: PLAN
225
+
226
+ **Goal**: Break the task into concrete implementation steps before writing code.
227
+
228
+ **REQUIRED SUB-SKILL**: Use `rune:plan`
229
+
230
+ 1. Mark Phase 2 as `in_progress`
231
+ 2. **Feature workspace** (opt-in) for non-trivial features (3+ phases), suggest creating `.rune/features/<feature-name>/` with `spec.md`, `plan.md`, `decisions.md`, `status.md`. Skip for simple bug fixes, fast mode.
232
+ 3. Create implementation plan: exact files to create/modify, change order, dependencies, active decision constraints
233
+ 4. If multiple valid approaches exist → invoke `rune:brainstorm` for trade-off analysis
234
+ 5. Present plan to user for approval
235
+ 6. If feature workspace was created, write approved plan to `.rune/features/<name>/plan.md`
236
+ 7. Mark Phase 2 as `completed`
237
+
238
+ **Gate**: User MUST approve the plan before proceeding. Do NOT skip this.
239
+
240
+ ### Phase 2.5: RFC GATE (Breaking Changes Only)
241
+
242
+ **Goal**: Formal change management for breaking changes. Prevents unreviewed breaking changes from reaching production.
243
+
244
+ <MUST-READ path="references/rfc-template.md" trigger="Phase 2.5 any time a breaking change is detected in the plan"/>
245
+
246
+ <HARD-GATE>
247
+ Breaking change without RFC = BLOCKED. No exceptions.
248
+ "It's just a small change" is the #1 excuse for production incidents from unreviewed breaking changes.
249
+ </HARD-GATE>
250
+
251
+ ### Phase 2.5: ADVERSARY (Red-Team Challenge)
252
+
253
+ **Goal**: Stress-test the approved plan BEFORE writing code catch flaws at plan time, not implementation time.
254
+
255
+ **REQUIRED SUB-SKILL**: Use `rune:adversary`
256
+
257
+ 1. **Skip conditions**: bug fixes, hotfixes, simple refactors (< 3 files, no new logic), fast mode
258
+ 2. **Run adversary** — Full Red-Team mode for new features/architectural changes; Quick Challenge mode for smaller plans
259
+ 3. **Handle verdict**:
260
+ - **REVISE** return to Phase 2 with adversary findings as constraints; user must re-approve
261
+ - **HARDEN** → present remediations, update plan inline, then proceed to Phase 3
262
+ - **PROCEED** pass findings as implementation notes to Phase 3
263
+ 4. **Max 1 REVISE loop** per cook session — if revised plan also gets REVISE, ask user to decide
264
+
265
+ ### Phase-Aware Execution (Master Plan + Phase Files)
266
+
267
+ When `rune:plan` produces a **master plan + phase files** (non-trivial tasks):
268
+
269
+ 1. After plan approval: load ONLY Phase 1's file — do NOT load all phase files
270
+ 2. Execute through cook Phase 3-6 (test → implement → quality → verify)
271
+ 3. After phase complete: mark tasks done, update master plan status `⬚ → ✅`, announce "Phase N complete. Phase N+1 ready for next session."
272
+ 4. Next session: Phase 0 detects master plan → loads next phase → executes
273
+
274
+ <HARD-GATE>
275
+ NEVER load multiple phase files at once. One phase per session = small context = better code.
276
+ If the coder model needs info from other phases, it's in the Cross-Phase Context section of the current phase file.
277
+ </HARD-GATE>
278
+
279
+ ## Phase 3: TEST (TDD Red)
280
+
281
+ **Goal**: Define expected behavior with failing tests BEFORE writing implementation.
282
+
283
+ **REQUIRED SUB-SKILL**: Use `rune:test`
284
+
285
+ 1. Mark Phase 3 as `in_progress`
286
+ 2. **Eval definitions** (Full/Critical rigor only): Before writing tests, define capability evals (pass@k) and regression evals (pass^k) in `.rune/evals/<feature>.md`. Capability evals test "can the system do this new thing?" — regression evals test "did we break existing behavior?" Skip for Fast/Standard rigor levels.
287
+ 3. Write test files based on the plan — cover primary use case + edge cases; tests MUST be runnable
288
+ 4. **Python async pre-check** (if async-first Python flagged in Phase 1): verify `pytest-asyncio` is installed and `asyncio_mode = "auto"` is in `pyproject.toml` — if missing, warn user before writing async tests
289
+ 5. Run tests to verify they FAIL — expected: RED because implementation doesn't exist yet
290
+ 6. Mark Phase 3 as `completed`
291
+
292
+ **Gate**: Tests MUST exist and MUST fail. If tests pass without implementation → tests are wrong, rewrite them.
293
+
294
+ ## Phase 4: IMPLEMENT (TDD Green)
295
+
296
+ **Goal**: Write the minimum code to make tests pass.
297
+
298
+ **REQUIRED SUB-SKILL**: Use `rune:fix`
299
+
300
+ 1. Mark Phase 4 as `in_progress`
301
+ 2. **Phase-file execution** — if working from a master plan + phase file:
302
+ - Execute tasks from `## Tasks` section wave-by-wave
303
+ - Wave N only starts after ALL Wave N-1 tasks complete
304
+ - Follow Code Contracts, Rejection Criteria, Failure Scenarios from the phase file
305
+ - Mark each task `[x]` as completed
306
+ 3. Implement the feature following the plan (Write for new files, Edit for existing)
307
+ 4. Run tests after each significant change if fail debug and fix
308
+ - **Python async** (if async-first flagged): no blocking calls in async functions — `time.sleep` → `asyncio.sleep`, `requests` → `httpx.AsyncClient`, use `asyncio.gather()` for parallel I/O
309
+ 5. If stuck → invoke `rune:debug` (max 3 debug↔fix loops). Fixes outside plan scope require user approval (R4).
310
+ 6. **Re-plan check** evaluate before Phase 5: max debug loops hit? out-of-scope files changed? new dep changes approach? user scope change? If any fire → invoke `rune:plan` with delta context, get user approval before resuming.
311
+ 7. **Approach Pivot Gate** if re-plan ALSO fails:
312
+
313
+ <HARD-GATE>
314
+ Do NOT surrender. Do NOT tell user "no solution exists."
315
+ Do NOT try a 4th variant of the same approach.
316
+ MUST invoke brainstorm(mode="rescue") before giving up.
317
+ </HARD-GATE>
318
+
319
+ Invoke `rune:brainstorm(mode="rescue")` with `failed_approach`, `failure_evidence[]`, `original_goal`. Returns 3-5 alternatives user picks → **restart from Phase 2**.
320
+
321
+ 8. All tests MUST pass before proceeding
322
+ 9. Mark Phase 4 as `completed`
323
+
324
+ **Gate**: ALL tests from Phase 3 MUST pass. Do NOT proceed with failing tests.
325
+
326
+ ## Phase 5: QUALITY (Staged)
327
+
328
+ **Goal**: Catch issues before they reach production.
329
+
330
+ Quality checks run in **two stages** spec compliance gates code review. Reviewing code quality before verifying it matches the spec wastes effort on code that may need rewriting.
331
+
332
+ ```
333
+ STAGE 1 (parallel):
334
+ Launch 5a (preflight) + 5b (sentinel) simultaneously.
335
+ Wait for BOTH to complete.
336
+ If 5a returns BLOCK → fix spec gaps, re-run 5a. Code review CANNOT start on non-compliant code.
337
+ If 5b returns BLOCK → fix security issue, re-run 5b.
338
+
339
+ STAGE 2 (after Stage 1 passes):
340
+ Launch 5c (review) + 5d (completion-gate) simultaneously.
341
+ If any returns BLOCK fix findings, re-run the blocking check only.
342
+ ```
343
+
344
+ > Source: obra/superpowers v5.0.2 (84k★) — spec compliance MUST pass before code quality review dispatched.
345
+
346
+ ### 5a. Preflight (Spec Compliance + Logic) — STAGE 1
347
+ **REQUIRED SUB-SKILL**: Use `rune:preflight`
348
+ - Spec compliance: compare approved plan vs actual diff
349
+ - Logic review, error handling, completeness
350
+ - **Must pass before 5c (review) can start** — no point reviewing code quality if it doesn't match the spec
351
+
352
+ ### 5b. Security STAGE 1
353
+ **REQUIRED SUB-SKILL**: Use `rune:sentinel`
354
+ - Secret scan, OWASP check (no injection/XSS/CSRF), dependency audit
355
+
356
+ ### 5c. Code ReviewSTAGE 2
357
+ **REQUIRED SUB-SKILL**: Use `rune:review`
358
+ - Pattern compliance, code quality, performance bottlenecks
359
+ - Reviewer reads code independently does NOT rely on implementer's claims
360
+ - **Reviewer isolation** (when invoked via `team`): The review agent MUST be a separate context window from the implementing agent. Author reasoning contaminates review — the reviewer should never have seen the implementation's reasoning chain. Sonnet implements, a fresh Sonnet reviews.
361
+
362
+ ### 5d. Completion Gate — STAGE 2
363
+ **REQUIRED SUB-SKILL**: Use `rune:completion-gate`
364
+ - Validate agent claims match evidence trail (tests ran, files changed, build passed)
365
+ - No truncated code files (`// ...`, `// rest of code`, bare ellipsis) — agent MUST complete all output
366
+ - Any UNCONFIRMED claim → BLOCK
367
+
368
+ **Gate**: If sentinel finds CRITICAL security issue → STOP, fix it, re-run. Non-negotiable.
369
+ **Gate**: If completion-gate finds UNCONFIRMED claim → STOP, re-verify. Non-negotiable.
370
+
371
+ ## Per-Phase Rules (Project-Specific)
372
+
373
+ Projects can define phase-specific rules in `.rune/phase-rules.md` that apply ONLY during specific cook phases. These are additive — they enhance skill guidance, not replace it.
374
+
375
+ ```markdown
376
+ # .rune/phase-rules.md (example)
377
+
378
+ ## Phase 2: PLAN
379
+ - All API endpoints must follow REST naming convention /api/v1/<resource>
380
+ - Database changes require a rollback migration
381
+
382
+ ## Phase 3: TEST
383
+ - Enforce TDD format: describe it arrange act → assert
384
+ - Minimum 3 edge cases per public function
385
+
386
+ ## Phase 5: QUALITY
387
+ - Review must check for N+1 queries on any ORM code
388
+ - Sentinel must verify CORS configuration on new routes
389
+ ```
390
+
391
+ **Loading**: Cook reads `.rune/phase-rules.md` during Phase 0 (resume check). Rules for each phase are injected into the sub-skill's context when that phase starts. If file doesn't exist skip silently.
392
+
393
+ > Source: Fission-AI/OpenSpec (32.8k★) fine-grained per-phase quality control.
394
+
395
+ ## Checkpoint Protocol (Opt-In)
396
+
397
+ Invoke `rune:session-bridge` after Phase 2, 4, and 5 to save intermediate state. OPT-IN activate only if task spans 3+ phases, context-watch is ORANGE, or user explicitly requests checkpoints.
398
+
399
+ ## Phase Transition Protocol (MANDATORY)
400
+
401
+ Before entering ANY Phase N+1, assert: Phase N `completed` in TodoWrite | gate condition met | no BLOCK from sub-skills | no unresolved CRITICAL findings. If any failsSTOP, log "BLOCKED at Phase N→N+1: [assertion]", fix, re-check.
402
+
403
+ **Key transitions:** 1→2: scout done | 2→3: plan approved | 34: failing tests exist | 4→5: all tests pass | 5→6: no CRITICAL findings | 6→7: lint+types+build green.
404
+
405
+ ## Phase 6: VERIFY
406
+
407
+ **REQUIRED SUB-SKILL**: Use `rune:verification` run lint, type check, full test suite, build. Then `rune:hallucination-guard` to verify imports and API signatures. ALL checks MUST pass before commit.
408
+
409
+ ## Phase 7: COMMIT
410
+
411
+ **RECOMMENDED SUB-SKILL**: Use `rune:git` — stage specific files (`git add <files>`, NOT `git add .`), generate semantic commit message from diff. If working from master plan: update phase status `🔄 → ✅`, announce next phase or "All phases complete."
412
+
413
+ ## Phase 8: BRIDGE
414
+
415
+ **Goal**: Save context for future sessions and record metrics for mesh analytics.
416
+
417
+ **REQUIRED SUB-SKILL**: Use `rune:session-bridge`
418
+
419
+ 1. Mark Phase 8 as `in_progress`
420
+ 2. Save to `.rune/decisions.md` (approach + trade-offs), `.rune/progress.md` (task complete), `.rune/conventions.md` (new patterns)
421
+ 3. **Skill metrics** `.rune/metrics/skills.json`: increment phase run/skip counts, quality gate results, debug loop counts under `cook` key
422
+ 4. **Routing overrides** (H3): if Phase 4 hit max loops for an error pattern → write rule to `.rune/metrics/routing-overrides.json`. Max 10 active rules.
423
+ 5. **Step 8.5 — Capture Learnings**: `neural-memory` (Capture Mode) — 2-5 memories: architecture decisions, patterns, error root-causes, trade-offs. Cognitive language (causal/decisional/comparative). Tags: `[project, tech, topic]`. Priority 5 routine / 7-8 decisions / 9-10 critical errors.
424
+ 6. Mark Phase 8 as `completed`
425
+
426
+ ## Autonomous Loop Patterns
427
+
428
+ When cook runs inside `team` (L1) or autonomous workflows, these patterns apply.
429
+
430
+ ### De-Sloppify Pass
431
+
432
+ After Phase 4 completes (all tests green), run a **separate focused cleanup pass** on all modified files. Two focused passes outperform one constrained pass — let the implementer write freely in Phase 4, then clean up here.
433
+
434
+ **Trigger**: Implementation touched 3+ files OR 100+ LOC changed. Skip for nano/fast rigor.
435
+
436
+ **Slop targets** (check every modified file):
437
+
438
+ | Slop Type | Detection | Fix |
439
+ |-----------|-----------|-----|
440
+ | Leftover debug | `console.log`, `print()`, `debugger`, `TODO: remove` | Delete |
441
+ | Over-defensive checks | Null checks on values guaranteed non-null by TypeScript/framework | Remove redundant guard |
442
+ | Type-test slop | `typeof x === 'string'` when x is already typed as string | Remove — trust the type system |
443
+ | Duplicated logic | Same 3+ lines appear in multiple places | Extract utility |
444
+ | Framework-behavior tests | Tests asserting that React renders, that Express routes exist, that mocks work | Delete — test YOUR code, not the framework |
445
+ | Inconsistent naming | Mixed `camelCase`/`snake_case` in same file | Normalize to project convention |
446
+ | Dead imports | Imports no longer used after edits | Remove |
447
+
448
+ **Important**: This is NOT a quality gate — it's a cleanup pass. Don't block the pipeline for cosmetic issues. Fix what you find, move on.
449
+
450
+ > Source: affaan-m/everything-claude-code (91.9k★) separate de-sloppify agent pass after implementation.
451
+
452
+ ### Continuous PR Loop (team orchestration only)
453
+
454
+ ```
455
+ cook instance commit push → create PR → wait CI
456
+ IF CI passes → mark workstream complete
457
+ IF CI fails read CI output fix push wait CI (max 3 retries)
458
+ IF 3 retries fail escalate to user with CI logs
459
+ ```
460
+
461
+ ### Formal Pause/Resume (`.continue-here.md`)
462
+
463
+ <MUST-READ path="references/pause-resume-template.md" trigger="when cook must pause mid-phase (context limit, user break, session end)"/>
464
+
465
+ When cook must pause mid-phase, create `.rune/.continue-here.md` with structured handoff, then WIP commit. Phase 0 detects it on resume. More granular than plan-level resume — resumes within a phase.
466
+
467
+ ### Mid-Run Signal Detection
468
+
469
+ <MUST-READ path="references/mid-run-signals.md" trigger="when user sends a message DURING cook execution"/>
470
+
471
+ Two-stage intent classification: keyword fast-path for short messages (<60 chars), context classification for longer ones. Never queue user messages — process immediately.
472
+
473
+ <HARD-GATE>
474
+ NEVER treat a Cancel/Pause signal as a Steer or NewTask. User safety signals take absolute priority.
475
+ If ambiguous between Cancel and Steer → ask user: "Did you mean stop, or change approach?"
476
+ </HARD-GATE>
477
+
478
+ ### Exit Conditions (Mandatory for Autonomous Runs)
479
+
480
+ <MUST-READ path="references/exit-conditions.md" trigger="cook running inside team or any autonomous workflow"/>
481
+
482
+ Hard caps: MAX_DEBUG_LOOPS=3, MAX_QUALITY_LOOPS=2, MAX_REPLAN=1, MAX_PIVOT=1, MAX_FIXES=30, WTF_THRESHOLD=20%.
483
+ Escalation chain: debug-fix (3x) → re-plan (1x) → brainstorm rescue (1x) → THEN escalate to user.
484
+
485
+ ### Subagent Status Protocol
486
+
487
+ <MUST-READ path="references/subagent-status.md" trigger="when cook or any sub-skill needs to return a status"/>
488
+
489
+ Cook and all sub-skills return: `DONE` | `DONE_WITH_CONCERNS` | `NEEDS_CONTEXT` | `BLOCKED`.
490
+
491
+ ### Subagent Context Isolation
492
+
493
+ When invoking sub-skills (fix, debug, test, review, etc.), **craft exactly the context they need** — never pass the full orchestrator session context.
494
+
495
+ | Pass To Sub-Skill | DO NOT Pass |
496
+ |-------------------|-------------|
497
+ | Task description + specific goal | Full conversation history |
498
+ | Relevant file paths from scout | Unrelated files from other phases |
499
+ | Project conventions (naming, test framework) | Other sub-skill outputs |
500
+ | Plan excerpt for THIS phase only | Full master plan |
501
+ | Error/stack trace (for debug/fix) | Previous debug attempts from other bugs |
502
+
503
+ **Why**: Sub-skills that inherit orchestrator context get polluted — they chase false connections, reference stale data, and consume tokens on irrelevant context. A focused sub-skill with 500 tokens of curated context outperforms one with 5000 tokens of inherited noise.
504
+
505
+ > Source: obra/superpowers v5.0.2 (84k★) first-class context isolation principle.
506
+
507
+ ## Deviation Rules
508
+
509
+ <MUST-READ path="references/deviation-rules.md" trigger="when implementation diverges from the approved plan"/>
510
+
511
+ R1-R3 (bug/security/blocking fix): auto-fix, continue. R4 (architectural change): ASK user first.
512
+
513
+ ## Error Recovery
514
+
515
+ <MUST-READ path="references/error-recovery.md" trigger="when any phase fails or a task hits repeated errors"/>
516
+
517
+ Includes phase-by-phase failure handling and repair operators (RETRY → DECOMPOSE → PRUNE) with a 2-attempt budget before escalation.
518
+
519
+ ## Analysis Paralysis Guard
520
+
521
+ <HARD-GATE>
522
+ 5+ consecutive read-only tool calls (Read, Grep, Glob) without a single write action (Edit, Write, Bash) = STUCK.
523
+
524
+ You MUST either:
525
+ 1. **Act** — write code, run a command, create a file
526
+ 2. **Report BLOCKED** — state the specific missing piece: "Cannot proceed because [X]"
527
+
528
+ Stuck patterns (all banned):
529
+ - Reading 10+ files to "fully understand" before acting
530
+ - Grepping every variation of a string across the entire repo
531
+ - Reading the same file twice in one investigation
532
+ - "Let me check one more thing" — repeated after 5 reads
533
+
534
+ A wrong first attempt that produces feedback beats perfect understanding that never ships.
535
+ </HARD-GATE>
536
+
537
+ ### Hash-Based Tool Loop Detection
538
+
539
+ <MUST-READ path="references/loop-detection.md" trigger="when same tool+args+result appears to be repeating"/>
540
+
541
+ Mentally track tool call fingerprints. 3 identical calls → WARN. 5 identical calls → FORCE STOP. Only same-input-AND-same-output counts as a loop.
542
+
543
+ ## Called By (inbound)
544
+
545
+ - User: `/rune cook` direct invocation — primary entry point
546
+ - `team` (L1): parallel workstream execution (meta-orchestration)
547
+
548
+ ## Calls (outbound)
549
+
550
+ | Phase | Sub-skill | Layer | Purpose |
551
+ |-------|-----------|-------|---------|
552
+ | 0 / 8 | `neural-memory` | ext | Recall context at start; capture learnings at end |
553
+ | 0.5 | `sentinel-env` | L3 | Environment pre-flight (first run only) |
554
+ | 1 | `scout` | L2 | Scan codebase before planning |
555
+ | 1 | `onboard` | L2 | Initialize project context if no CLAUDE.md |
556
+ | 1 | `ba` | L2 | Requirement elicitation for features |
557
+ | 2 | `plan` | L2 | Create implementation plan |
558
+ | 2 | `brainstorm` | L2 | Trade-off analysis / rescue mode |
559
+ | 2 | `design` | L2 | UI/design phase for frontend features |
560
+ | 2.5 | `adversary` | L2 | Red-team challenge on approved plan |
561
+ | 3 | `test` | L2 | Write failing tests (RED phase) |
562
+ | 4 | `fix` | L2 | Implement code changes (GREEN phase) |
563
+ | 4 | `debug` | L2 | Unexpected errors (max 3 loops) |
564
+ | 4 | `db` | L2 | Schema changes detected in diff |
565
+ | 4 | `worktree` | L3 | Worktree isolation for parallel implementation |
566
+ | 5a | `preflight` | L2 | Spec compliance + logic review |
567
+ | 5b | `sentinel` | L2 | Security scan |
568
+ | 5c | `review` | L2 | Code quality review |
569
+ | 5 | `perf` | L2 | Performance regression check (optional) |
570
+ | 5 | `audit` | L2 | Project health audit when scope warrants |
571
+ | 5 | `review-intake` | L2 | Structured review intake for complex PRs |
572
+ | 5 | `sast` | L3 | Static analysis security testing |
573
+ | 5d | `completion-gate` | L3 | Validate agent claims against evidence trail |
574
+ | 5 | `constraint-check` | L3 | Audit HARD-GATE compliance across workflow |
575
+ | 6 | `verification` | L3 | Lint + types + tests + build |
576
+ | 6 | `hallucination-guard` | L3 | Verify imports and API calls are real |
577
+ | 7 | `journal` | L3 | Record architectural decisions |
578
+ | 8 | `session-bridge` | L3 | Save context for future sessions |
579
+ | any | `skill-forge` | L2 | When new skill creation detected during cook |
580
+ | 1.5 | L4 extension packs | L4 | Domain-specific patterns when stack matches |
581
+
582
+ ## Data Flow
583
+
584
+ **Feeds Into →** `journal` (decisions → ADRs) | `session-bridge` (context .rune/ state) | `neural-memory` (learnings → cross-session)
585
+
586
+ **Fed By ←** `ba` (requirements → Phase 1) | `plan` (master plan → Phase 2-4) | `session-bridge` (.continue-here.md Phase 0 resume) | `neural-memory` (past decisions → Phase 0 recall)
587
+
588
+ **Feedback Loops ↻** cook↔debug (Phase 4 bug debugfix resume; if plan wrong Approach Pivot) | cook↔test (RED GREEN → failures loop back)
589
+
590
+ ## Constraints
591
+
592
+ 1. MUST run scout before planning
593
+ 2. MUST get user plan approval before writing code
594
+ 3. MUST write failing tests before implementation (TDD) unless explicitly skipped
595
+ 4. MUST NOT commit with failing tests
596
+ 5. MUST NOT modify files outside approved plan scope without user confirmation
597
+ 6. MUST run verification (lint + type-check + tests + build) before commit
598
+ 7. MUST NOT say "all tests pass" without showing actual test output
599
+ 8. MUST NOT contradict `.rune/decisions.md` without explicit user override
600
+
601
+ ## Mesh Gates
602
+
603
+ | Gate | Requires | If Missing |
604
+ |------|----------|------------|
605
+ | Resume Gate | Phase 0 checks for master plan before starting | Proceed to Phase 1 |
606
+ | Scout Gate | scout output before Phase 2 | Invoke rune:scout first |
607
+ | Plan Gate | User-approved plan before Phase 3 | Cannot proceed |
608
+ | Adversary Gate | adversary verdict before Phase 3 for features | Skip for bugfix/hotfix/refactor |
609
+ | Phase File Gate | Active phase file only (multi-session) | Load only active phase |
610
+ | Test-First Gate | Failing tests before Phase 4 | Write tests or get explicit skip |
611
+ | Quality Gate | preflight + sentinel + review before Phase 7 | Fix findings, re-run |
612
+ | Verification Gate | lint + types + tests + build green before commit | Fix, re-run |
613
+
614
+ ## Output Format
615
+
616
+ <MUST-READ path="references/output-format.md" trigger="before emitting the Cook Report at end of any session"/>
617
+
618
+ Emit a Cook Report with: Status, Phases, Files Changed, Tests, Quality results, Commit hash.
619
+ When invoked by `team` with a NEXUS Handoff, include the Deliverables table — MANDATORY.
620
+
621
+ ## Returns
622
+
623
+ | Artifact | Format | Location |
624
+ |----------|--------|----------|
625
+ | Plan files (master + phase) | Markdown | `.rune/plan-<feature>.md`, `.rune/plan-<feature>-phase<N>.md` |
626
+ | Implementation code | Source files | Per plan file paths |
627
+ | Test files | Source files | Co-located or `__tests__/` per project convention |
628
+ | Verification results | Inline stdout | Shown in Cook Report |
629
+ | Cook Report | Markdown (inline) | Emitted at end of session |
630
+ | Session state | Markdown | `.rune/decisions.md`, `.rune/progress.md`, `.rune/conventions.md` |
631
+
632
+ ## Sharp Edges
633
+
634
+ <MUST-READ path="references/sharp-edges.md" trigger="before declaring done — review all 18 failure modes"/>
635
+
636
+ **CRITICAL failures** (always check): skipping scout | writing code without plan approval | "done" without evidence trail | surrendering without Approach Pivot Gate | breaking change without RFC | treating Cancel/Pause as scope change.
637
+
638
+ ## Self-Validation
639
+
640
+ ```
641
+ SELF-VALIDATION (run before emitting Cook Report):
642
+ - [ ] Every phase in Phase Skip Rules was either executed or explicitly skipped with reason
643
+ - [ ] Plan approval gate was not bypassed — user said "go" (check conversation history)
644
+ - [ ] No Phase 4 code was written before Phase 3 tests (TDD order preserved)
645
+ - [ ] All Phase 5 quality gates (preflight, sentinel, review) ran not just claimed
646
+ - [ ] Cook Report contains actual commit hash, not placeholder
647
+ ```
648
+
649
+ ## Done When
650
+
651
+ All applicable phases complete + Self-Validation passed:
652
+ - User approved plan | All tests PASS (output shown) | preflight+sentinel+review PASS | build green
653
+ - Cook Report emitted with commit hash | Session state saved to .rune/ via session-bridge
654
+
655
+ ## Cost Profile
656
+
657
+ ~$0.05-0.15 per feature. Haiku for scanning (Phase 1), sonnet for coding (Phase 3-4), opus for complex planning (Phase 2 when needed).