Cook

From Rune-kit/rune · View interactive version

Cook is an AI agent skill from the GitHub repository Rune-kit/rune. Feature implementation orchestrator — runs the TDD cycle understand → plan → test → implement → quality → verify → commit. Use when the user wants working code built or changed across more than a line or two: a new feature, a bug fix with an unknown blast radius, a refactor. Not for questions, revie

How to use this skill

Skill file

cook

Purpose

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.

<HARD-GATE>

Before starting ANY implementation:

  1. You MUST understand the codebase first (Phase 1)
  2. You MUST have a plan before writing code (Phase 2)
  3. You MUST write failing tests before implementation (Phase 3) — unless explicitly skipped

This applies to EVERY feature regardless of perceived simplicity.

</HARD-GATE>

Workflow Chains (Predefined)

Full detail moved to CODE0 (progressive disclosure). Read that file before executing this section. Mesh links used there: rune:deploy, rune:fix, rune:graft, rune:incident, rune:journal, rune:neural-memory, rune:sentinel, rune:verification, rune:watchdog.

Phase Skip Rules

Not every task needs every phase:

Nano task:           DO → VERIFY → DONE (no phases, auto-detected)
Simple bug fix:      Phase 1 → 4 → 6 → 7
Small refactor:      Phase 1 → 4 → 5 → 6 → 7
New feature:         Phase 1 → 1.5 → 2 → 3 → 4 → 5 → 6 → 6.5 → 7 → 8  (6.5: conditional — requires requirements.md)
Complex feature:     All phases (incl. 6.5) + brainstorm in Phase 2
Security-sensitive:  All phases + sentinel escalated to opus
Fast mode:           Phase 1 → 4 → 6 → 7 (auto-detected, see below)
Multi-session:       Phase 0 (resume) → 3 → 4 → 5 → 6 → 7 (one plan phase per session)

Determine complexity BEFORE starting using the Rigor Assessment below. Create TodoWrite with applicable phases.

Rigor Assessment (Progressive Scaling)

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.

| Risk Signal | Weight | Detection |

|-------------|--------|-----------|

| Files affected: 1 | 0 | Estimate from task description + scout |

| Files affected: 2-3 | +1 | |

| Files affected: 4+ | +3 | |

| Cross-module impact (changes span 2+ directories) | +2 | scout identifies touch points across boundaries |

| Security-sensitive code (auth, crypto, payments, secrets) | +3 | Keyword match in file paths or task description |

| Public API change (exports, routes, schema) | +2 | Task modifies interfaces consumed by external code |

| Database schema change | +2 | Task mentions migration, schema, ALTER, column |

| New dependency added | +1 | Task requires npm install or equivalent |

| Code will be imported by other modules | +1 | New exports or modifications to shared utilities |

Rigor level mapping:

| Score | Level | Maps To | Phases |

|-------|-------|---------|--------|

| 0 | Nano | nano chain | DO → VERIFY → DONE |

| 1-2 | Fast | fast mode | Phase 1 → 4 → 6 → 7 |

| 3-5 | Standard | bugfix / refactor | Phase 1 → 2 → 4 → 5 → 6 → 7 |

| 6-8 | Full | feature | Phase 1 → 1.5 → 2 → 3 → 4 → 5 → 6 → 7 → 8 |

| 9+ | Critical | security / full + adversary | All phases + sentinel@opus + adversary |

Rules:

Nano Mode (Auto-Detect)

Full detail moved to CODE0 (progressive disclosure). Read that file before executing this section.

<HARD-GATE>

Nano mode MUST NOT be used for:

If any of these are detected mid-task, STOP and upgrade to Fast/Full mode.

</HARD-GATE>

Fast Mode (Auto-Detect)

Full detail moved to CODE0 (progressive disclosure). Read that file before executing this section.

Phase 0.5: ENVIRONMENT CHECK (First Run Only)

SUB-SKILL: Use rune:sentinel-env — verify the environment can run the project before planning.

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.

Phase 1: UNDERSTAND

Goal: Know what exists before changing anything.

REQUIRED SUB-SKILLS: Use rune:scout. For non-trivial tasks, use rune:ba.

  1. Create TodoWrite with all applicable phases for this task
  2. Mark Phase 1 as in_progress
  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. Synthesis-mode auto-trigger: if user pasted a spec > 200 words, conversation has > 1000 words on this feature, .rune/features/<name>/requirements.md already exists (continuation), or user said "synthesize"/"just write the spec" → BA Step 1.4 activates Synthesis Mode (extract + cite sources + confirm), skipping the 5-question elicitation. Cook does NOT need to choose mode — BA detects automatically.
  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.

4b. Contract enforcement: If .rune/contract.md was loaded in Phase 0.6, list applicable contract sections for this task (e.g., contract.security for auth work, contract.data for database changes). These rules constrain Phase 2 planning and Phase 4 implementation.

Phase 1 Step 3.5 — Clarification Gate

Ask 2 questions before planning: (1) "What does success look like?" (2) "What should NOT change?"

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.

  1. Invoke scout to scan the codebase (Glob + Grep + Read on relevant files)
  2. Summarize: what exists, project conventions, files likely to change, active decision constraints
  3. 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
  4. Explore-Before-Commit: If scout reveals multiple viable approaches (e.g., 2+ libraries, 2+ architectural patterns), do NOT commit to an approach yet. Instead:
  1. Mark Phase 1 as completed

Gate: If scout finds the feature already exists → STOP and inform user.

Phase 1.5: DOMAIN CONTEXT (L4 Pack Detection)

Full detail moved to CODE0 (progressive disclosure). Read that file before executing this section.

Phase 1.7: WORKFLOW ORCHESTRATION (Multi-Skill Sequences)

Full detail moved to CODE0 (progressive disclosure). Read that file before executing this section.

Phase 0: RESUME CHECK (Before Phase 1)

Goal: Detect if a master plan already exists for this task, or if a --template was specified. If so, skip Phase 1-2 and resume/load the workflow.

Step 0.4 — Template Detection: If user passed --template <name>:

  1. Search installed pack templates for the name: Glob for extensions/*/templates/<name>.md and extensions/pro-*/templates/<name>.md
  2. If found: Read the template file → parse phases, signals, connections, acceptance criteria
  3. Generate a master plan from the template: each template phase becomes a plan phase
  4. Write plan files to .rune/plan-<template-name>.md + .rune/plan-<template-name>-phaseN.md
  5. Announce "Loading template: <name> (<pack>)" → skip Phase 1, 1.5, 1.7, 2 → proceed to Phase 4 with Phase 1 of the template
  6. If template not found: warn user and fall through to normal workflow

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").

  1. Use Glob to check for .rune/plan-*.md files
  2. If a master plan exists matching the current task:

1. Invoke rune:ba to backfill requirements (5-question elicitation, or Synthesis Mode if the plan + conversation already carry enough context) → produces .rune/features/<name>/requirements.md.

2. Re-invoke rune:plan to reconcile the existing plan against the new spec — if the plan contradicts a locked Decision or misses a requirement, revise the affected phase files and get user re-approval (Re-Planning protocol).

3. THEN resume. For Bug Fix / Refactor / trivial tasks, skip this gate — no spec is expected.

  1. If no master plan exists → proceed to Phase 1 as normal

Step 0.6 — Contract Load: Use Glob to check for .rune/contract.md. If it exists:

  1. Read the contract file and parse each ## section as a named rule set
  2. Hold contract rules in context — they apply as hard gates throughout all phases
  3. Any code change that violates a contract rule → STOP and inform user before proceeding
  4. If no contract exists → proceed normally (contract is optional)

<HARD-GATE>

Contract violations are NON-NEGOTIABLE. If .rune/contract.md exists and a planned or implemented change violates any rule, cook MUST stop and report the violation. The user must explicitly override ("ignore contract rule X") to proceed.

</HARD-GATE>

This enables multi-session workflows: Opus plans once → each session picks up the next phase.

Phase 2: PLAN

Goal: Break the task into concrete implementation steps before writing code.

REQUIRED SUB-SKILL: Use rune:plan

  1. Mark Phase 2 as in_progress
  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.
  3. Create implementation plan: exact files to create/modify, change order, dependencies, active decision constraints
  4. If multiple valid approaches exist → invoke rune:brainstorm for trade-off analysis
  5. Frontend detection — if task touches .tsx/.jsx/.vue/.svelte/.css, component files, or mentions "UI/page/screen/design/layout/landing": invoke rune:design BEFORE plan approval. Pass hint mode: "tweaks-default" — design proposes ONE opinionated default per .rune/design-system.md (Step 2.7), not a 5-option menu. User replies with tweaks ("more professional", "darker") rather than picking from a list. If .rune/design-system.md is missing, design creates it first.
  6. Present plan to user for approval
  7. If feature workspace was created, write approved plan to .rune/features/<name>/plan.md
  8. Mark Phase 2 as completed

Gate: User MUST approve the plan before proceeding. Do NOT skip this.

Phase 2.5: RFC GATE (Breaking Changes Only)

Full detail moved to CODE0 (progressive disclosure). Read that file before executing this section.

<HARD-GATE>

Breaking change without RFC = BLOCKED. No exceptions.

"It's just a small change" is the #1 excuse for production incidents from unreviewed breaking changes.

</HARD-GATE>

Phase 2.5: ADVERSARY (Red-Team Challenge)

Full detail moved to CODE0 (progressive disclosure). Read that file before executing this section. Mesh links used there: rune:adversary.

Phase-Aware Execution (Master Plan + Phase Files)

Full detail moved to CODE0 (progressive disclosure). Read that file before executing this section. Mesh links used there: rune:plan.

<HARD-GATE>

NEVER load multiple phase files at once. One phase per session = small context = better code.

If the coder model needs info from other phases, it's in the Cross-Phase Context section of the current phase file.

</HARD-GATE>

Phase 3: TEST (TDD Red)

Goal: Define expected behavior with failing tests BEFORE writing implementation.

REQUIRED SUB-SKILL: Use rune:test

  1. Mark Phase 3 as in_progress
  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.
  3. Write ONE test for the next behavior — vertical slicing required, see rune:test references/vertical-tdd.md. Bulk-writing tests = horizontal violation, blocks Phase 4
  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
  5. Run the test to verify it FAILS — expected: RED because implementation doesn't exist yet
  6. Mark Phase 3 as completed (one cycle); Phase 4 implements that one cycle, then loop returns here for the next test

Gate: Test MUST exist and MUST fail. If test passes without implementation → test is wrong, rewrite. If 2+ tests staged before any GREEN → tdd.horizontal.violation signal, unwind to one test.

Phase 4: IMPLEMENT (TDD Green)

Goal: Write the minimum code to make tests pass.

REQUIRED SUB-SKILL: Use rune:fix

Reuse Ladder (climb before you write)

Full detail moved to CODE0 (progressive disclosure). Read that file before executing this section. Mesh links used there: rune:brainstorm, rune:debug, rune:plan.

<HARD-GATE>

Do NOT surrender. Do NOT tell user "no solution exists."

Do NOT try a 4th variant of the same approach.

MUST invoke brainstorm(mode="rescue") before giving up.

</HARD-GATE>

Phase 5: QUALITY (Staged)

Goal: Catch issues before they reach production.

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.

Signal dispatch ordering: When fix emits code.changed, 4 listeners react (preflight, sentinel, test, review). Cook coordinates dispatch order — do NOT let all 4 fire simultaneously:

STAGE 1 (parallel):
  Launch 5a (preflight) + 5b (sentinel) simultaneously.
  Wait for BOTH to complete.
  If 5a returns BLOCK → fix spec gaps, re-run 5a. Code review CANNOT start on non-compliant code.
  If 5b returns BLOCK → fix security issue, re-run 5b.

STAGE 2 (after Stage 1 passes):
  Launch 5c (review) + 5d (completion-gate) simultaneously.
  If any returns BLOCK → fix findings, re-run the blocking check only.

Remediation Cycle Counter

Full detail moved to CODE0 (progressive disclosure). Read that file before executing this section.

Upstream Inconsistency Protocol

Full detail moved to CODE0 (progressive disclosure). Read that file before executing this section. Mesh links used there: rune:ba, rune:plan.

5a. Preflight (Spec Compliance + Logic) — STAGE 1

REQUIRED SUB-SKILL: Use rune:preflight

5b. Security — STAGE 1

REQUIRED SUB-SKILL: Use rune:sentinel

5c. Code Review — STAGE 2

REQUIRED SUB-SKILL: Use rune:review

5d. Completion Gate — STAGE 2

REQUIRED SUB-SKILL: Use rune:completion-gate

Gate: If sentinel finds CRITICAL security issue → STOP, fix it, re-run. Non-negotiable.

Gate: If completion-gate finds UNCONFIRMED claim → STOP, re-verify. Non-negotiable.

Per-Phase Rules (Project-Specific)

Full detail moved to CODE0 (progressive disclosure). Read that file before executing this section.

Checkpoint Protocol (Opt-In)

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. Before spawning subagents, invoke rune:context-pack to create structured handoff briefings.

Phase Transition Protocol (MANDATORY)

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 fails → STOP, log "BLOCKED at Phase N→N+1: [assertion]", fix, re-check.

Key transitions: 1→2: scout done | 2→3: plan approved | 3→4: failing tests exist | 4→5: all tests pass | 5→6: no CRITICAL findings | 6→6.5: lint+types+build green | 6.5→7: convergence.clean or documented escalation (features with requirements.md; others pass through).

Phase 6: VERIFY

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.

Quickstart execution: if .rune/features/<name>/quickstart.md exists (plan Step 3.7 boundary artifact), execute its validation blocks — run each command, compare against its Expect line. Any mismatch = verification FAIL (treat like a failing test). If the environment cannot run a block (no browser, no DB), SKIP it with the reason named in the Cook Report — a skipped quickstart is visible debt, never silent.

Phase 6.5: CONVERGE (Spec↔Code Gap Scan)

Full detail moved to CODE0 (progressive disclosure). Read that file before executing this section. Mesh links used there: rune:converge.

<HARD-GATE>

A P1 story with a CRITICAL convergence gap (missing/contradicts) MUST NOT be committed as "done."

Either remediate within the round cap, or escalate with the gap documented — never claim completion over a known dead path.

</HARD-GATE>

Phase 7: COMMIT

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."

Phase 8: BRIDGE

Full detail moved to CODE0 (progressive disclosure). Read that file before executing this section. Mesh links used there: rune:session-bridge.

Autonomous Loop Patterns

Full detail moved to CODE0 (progressive disclosure). Read that file before executing this section.

<HARD-GATE>

NEVER treat a Cancel/Pause signal as a Steer or NewTask. User safety signals take absolute priority.

If ambiguous between Cancel and Steer → ask user: "Did you mean stop, or change approach?"

</HARD-GATE>

<HARD-GATE>

"Bad work is worse than no work." Cook MUST produce this report rather than attempting a 4th variant of a failing approach. Escalating is not failure — shipping broken code is.

</HARD-GATE>

Deviation Rules

Full detail moved to CODE0 (progressive disclosure). Read that file before executing this section.

Error Recovery

Full detail moved to CODE0 (progressive disclosure). Read that file before executing this section.

Analysis Paralysis Guard

Full detail moved to CODE0 (progressive disclosure). Read that file before executing this section.

<HARD-GATE>

5+ consecutive read-only tool calls (Read, Grep, Glob) without a single write action (Edit, Write, Bash) = STUCK.

You MUST either:

  1. Act — write code, run a command, create a file
  2. Report BLOCKED — state the specific missing piece: "Cannot proceed because [X]"

Stuck patterns (all banned):

A wrong first attempt that produces feedback beats perfect understanding that never ships.

</HARD-GATE>

Called By (inbound)

Calls (outbound)

| Phase | Sub-skill | Layer | Purpose |

|-------|-----------|-------|---------|

| 0 / 8 | neural-memory | ext | Recall context at start; capture learnings at end |

| 0.5 | sentinel-env | L3 | Environment pre-flight (first run only) |

| 1 | scout | L2 | Scan codebase before planning |

| 1 | onboard | L2 | Initialize project context if no CLAUDE.md |

| 1 | ba | L2 | Requirement elicitation for features |

| 1 | logic-guardian | L2 | Conditional: when .rune/logic-manifest.json exists — protect complex business logic before any edits |

| 2 | plan | L2 | Create implementation plan |

| 2 | brainstorm | L2 | Trade-off analysis / rescue mode |

| 2 | design | L2 | UI/design phase for frontend features — invoke with mode: "tweaks-default" (one opinionated default + accept natural-language tweaks, not a 5-option menu) |

| 2.5 | adversary | L2 | Red-team challenge on approved plan |

| 3 | test | L2 | Write failing tests (RED phase) |

| 4 | fix | L2 | Implement code changes (GREEN phase) |

| 4 | debug | L2 | Unexpected errors (max 3 loops) |

| 4 | db | L2 | Schema changes detected in diff |

| 4 | worktree | L3 | Worktree isolation for parallel implementation |

| 5a | preflight | L2 | Spec compliance + logic review |

| 5b | sentinel | L2 | Security scan |

| 5c | review | L2 | Code quality review |

| 5 | scope-guard | L3 | Verify changed files match approved plan scope (flag out-of-scope files before commit) |

| 5 | perf | L2 | Performance regression check (optional) |

| 5 | audit | L2 | Project health audit when scope warrants |

| 5 | review-intake | L2 | Structured review intake for complex PRs OR Issue Triage Mode for issue tracker items (state machine: needs-triage / needs-info / ready-for-agent / ready-for-human / wontfix). When external feedback source is an issue (not PR comment), review-intake auto-detects and runs Issue Triage Mode — emits triage.classified + agent.brief.ready (for AFK pickup) |

| 5 | sast | L3 | Static analysis security testing |

| 5d | completion-gate | L3 | Validate agent claims against evidence trail |

| 5 | constraint-check | L3 | Audit HARD-GATE compliance across workflow |

| 6 | verification | L3 | Lint + types + tests + build |

| 6 | hallucination-guard | L3 | Verify imports and API calls are real |

| 6.5 | converge | L3 | Spec↔code gap scan for features with requirements.md — dead buttons, missing backends, contradicted decisions |

| 7 | journal | L3 | Record architectural decisions |

| 8 | session-bridge | L3 | Save context for future sessions |

| any | context-pack | L3 | create structured handoff briefings before spawning subagents |

| any | skill-forge | L2 | When new skill creation detected during cook |

| 1.5 | L4 extension packs | L4 | Domain-specific patterns when stack matches |

Data Flow

Full detail moved to CODE0 (progressive disclosure). Read that file before executing this section.

Constraints

  1. MUST run scout before planning
  2. MUST get user plan approval before writing code
  3. MUST write failing tests before implementation (TDD) unless explicitly skipped
  4. MUST NOT commit with failing tests
  5. MUST NOT modify files outside approved plan scope without user confirmation
  6. MUST run verification (lint + type-check + tests + build) before commit
  7. MUST NOT say "all tests pass" without showing actual test output
  8. MUST NOT contradict .rune/decisions.md without explicit user override

Mesh Gates

Full detail moved to CODE0 (progressive disclosure). Read that file before executing this section. Mesh links used there: rune:ba, rune:scout.

Structured Output Contract (Prompt-as-API Pattern)

Full detail moved to CODE0 (progressive disclosure). Read that file before executing this section.

Output Format

Full detail moved to CODE0 (progressive disclosure). Read that file before executing this section.

Returns

Full detail moved to CODE0 (progressive disclosure). Read that file before executing this section.

Document Ownership

Full detail moved to CODE0 (progressive disclosure). Read that file before executing this section.

Anti-Patterns

Full detail moved to CODE0 (progressive disclosure). Read that file before executing this section.

Sharp Edges

<MUST-READ path="references/sharp-edges.md" trigger="before declaring done — review all 18 failure modes"/>

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.

Self-Validation

Full detail moved to CODE0 (progressive disclosure). Read that file before executing this section.

Done When

All applicable phases complete + Self-Validation passed:

Cost Profile

~$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).

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.