Skip to content
This repository was archived by the owner on Apr 11, 2026. It is now read-only.

Commit 84ac389

Browse files
z23ccclaude
andcommitted
fix(flowctl): comprehensive quality, consistency, and documentation sweep (v0.1.32)
- Replace 54 production unwrap() with expect() for better panic messages - Add fs2 file locking to all read-modify-write operations (pipeline, phases, locks) - Add #![forbid(unsafe_code)] to both crates and unsafe_code=forbid lint - Bump version to 0.1.32 Skill/Agent fixes: - Fix flow-code-go user-invocable: false → true (has command file) - Add tier field to all 24 codex/skills/ SKILL.md files - Add missing user-invocable to 11 skills/ SKILL.md files - Add flow-gap-analyst to plan conditional scout list - Change scout-base JSON output from "required" to "recommended" Documentation sync: - Add Worker/Epic phase mapping table to worker.md - Add Guard execution points table to phases.md - Add Review Backend Resolution priority chain to work SKILL.md - Add Review Circuit Breakers (plan:2, impl:3, epic:2) docs - Add memory injection deduplication note to steps.md - Add worker timeout mechanism (30min default) to phases.md - Add stale lock dual-point recovery to phases.md - Add DAG cycle detection, concurrency safety, worker phase mapping to CLAUDE.md - Add --no-review flag precedence documentation Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 83152ac commit 84ac389

74 files changed

Lines changed: 1390 additions & 170 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CLAUDE.md

Lines changed: 59 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,23 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
44

55
## What Is This
66

7-
Flow-Code is a Claude Code plugin for structured, plan-first development. It provides a unified entry point (`/flow-code:run`) plus individual slash commands, skills, and agents that orchestrate task tracking via a `.flow/` directory. Core engine is a Rust binary (`flowctl`) with file-based JSON storage and MCP server support.
7+
Flow-Code is a Claude Code plugin for structured, plan-first development. It provides two main entry points — `/flow-code:go` (full autopilot: brainstorm → plan → work → review → close) and `/flow-code:run` (plan → work → review → close) — plus individual slash commands, skills, and agents that orchestrate task tracking via a `.flow/` directory. Core engine is a Rust binary (`flowctl`) with file-based JSON storage and MCP server support.
88

99
## Core Architecture
1010

1111
```
1212
commands/flow-code/*.md → Slash command definitions (user-invocable entry points)
13-
skills/*/SKILL.md → Skill implementations (loaded by Skill tool, never Read directly)
13+
skills/*/SKILL.md → Utility & assessment skills (brainstorm, interview, debug, map, etc.)
14+
codex/skills/*/SKILL.md → Core workflow skills (plan, work, plan-review, impl-review, epic-review)
1415
agents/*.md → Subagent definitions (research scouts, worker, plan-sync, etc.)
1516
bin/flowctl → Rust binary (built from flowctl/ workspace)
1617
flowctl/ → Rust Cargo workspace (2 crates: core, cli)
1718
hooks/hooks.json → Ralph workflow guards (active when FLOW_RALPH=1)
1819
docs/ → Architecture docs, CI examples
1920
```
2021

22+
**Skill directories**: Both `skills/` and `codex/skills/` are scanned. Core workflow skills (plan, work, reviews) live in `codex/skills/` for Codex sync compatibility. Both directories are authoritative.
23+
2124
**Skills**: See `docs/skills.md` for the full classification. Core workflow: `flow-code-run` (unified phase loop via `flowctl phase next/done`).
2225

2326
**Key invariant**: The `bin/flowctl` Rust binary is the single source of truth for `.flow/` state. Always invoke as:
@@ -28,10 +31,52 @@ $FLOWCTL <command>
2831

2932
## Primary Workflow
3033

31-
`/flow-code:run "description"` — drives the entire pipeline (plan → plan-review → work → impl-review → close) via `flowctl phase next/done`. One command, zero manual phase transitions.
34+
`/flow-code:go "idea"` — full autopilot from raw idea to PR. Runs auto-brainstorm (AI self-interview) → plan → plan-review → work → impl-review → close. Zero human input.
35+
36+
`/flow-code:run "description"` — drives the pipeline (plan → plan-review → work → impl-review → close) via `flowctl phase next/done`. Skips brainstorm — use when requirements are already clear.
3237

3338
Ralph (`/flow-code:ralph-init`) is the autonomous harness that runs this loop unattended.
3439

40+
## Quality Gates (Three Layers)
41+
42+
Every epic passes through three independent, non-overlapping review gates:
43+
44+
| Layer | Tool | When | What it catches |
45+
|-------|------|------|-----------------|
46+
| **1. Guard** | `flowctl guard` | Worker Phase 6, wave checkpoint, close phase | Lint, type errors, test failures |
47+
| **2. RP Plan-Review** | RP context_builder or Codex | Plan phase | Spec-code misalignment, missing requirements |
48+
| **3. Codex Adversarial** | `flowctl codex adversarial` | Epic completion | Security, concurrency, edge cases (different model family) |
49+
50+
All three must pass (or be skipped via `flowctl config set review.backend none`). Layers are complementary — guard catches syntax, RP catches spec drift, Codex catches blind spots.
51+
52+
## Command Flags
53+
54+
| Flag | Accepted by | Effect |
55+
|------|-------------|--------|
56+
| `--auto` | brainstorm | AI self-interview, zero human input |
57+
| `--plan-only` | go, plan, run | Stop after plan phase |
58+
| `--no-pr` | go, run | Skip draft PR creation at close |
59+
| `--tdd` | work, run | Force test-first development (worker Phase 4) |
60+
| `--interactive` | plan | Opt-in interview before planning |
61+
| `--no-capability-scan` | plan | Skip capability-scout |
62+
| `--research=rp\|grep` | plan | Override research backend |
63+
| `--depth=short\|standard\|deep` | plan | Override plan depth |
64+
| `--review=rp\|codex\|none` | plan, run | Override review backend |
65+
66+
## Worker Protocol (Teams Mode)
67+
68+
Workers communicate with the coordinator via SendMessage with summary prefixes:
69+
70+
| Worker → Coordinator | Coordinator Response |
71+
|---------------------|---------------------|
72+
| `"Task complete: fn-N.M"` | Verify status=done, unlock files, advance wave |
73+
| `"Blocked: fn-N.M"` | Log reason, skip task in current wave |
74+
| `"Spec conflict: fn-N.M"` | Fix spec → `"Spec updated: fn-N.M"` or skip → `"Task skipped: fn-N.M"` |
75+
| `"Need file access: path"` | `"Access granted: path"` or `"Access denied: path"` |
76+
| `"Need mutation: fn-N.M"` | Execute split/skip/dep change, reply with result |
77+
78+
Approval timeouts: file access 120s, spec conflict 120s, mutation 300s. On timeout → worker self-blocks and stops.
79+
3580
## Testing
3681

3782
```bash
@@ -44,6 +89,9 @@ bash scripts/ci_test.sh
4489
# Teams e2e tests (file locking, ownership, protocol)
4590
bash scripts/teams_e2e_test.sh
4691

92+
# Wave checkpoint tests (lock lifecycle, dependency unblock, stale lock recovery)
93+
bash scripts/wave_checkpoint_test.sh
94+
4795
# Ralph e2e tests
4896
bash scripts/ralph_e2e_test.sh
4997
bash scripts/ralph_e2e_rp_test.sh # RepoPrompt backend
@@ -87,8 +135,9 @@ Rust: clippy for linting, cargo test for tests. No TypeScript, no npm. Skills an
87135
- **File locking (Teams)**: `flowctl lock --task <id> --files <paths>` acquires runtime file locks; `flowctl unlock --task <id>` releases on completion; `flowctl lock-check --file <path>` inspects lock state; `flowctl unlock --all` clears all locks between waves
88136
- **Agent Teams mode**: `/flow-code:run` (or legacy `/flow-code:work`) spawns workers as Agent Team teammates with plain-text protocol messages (summary-prefix routing: "Task complete:", "Spec conflict:", "Blocked:", "Need file access:", "New task:", "Access granted/denied:", native `shutdown_request`) and file lock enforcement
89137
- **Adversarial review**: `flowctl codex adversarial --base main [--focus "area"]` runs Codex in adversarial mode — tries to break the code, not validate it. Returns SHIP/NEEDS_WORK with grounded findings
90-
- **Three-layer quality system**: Layer 1: `flowctl guard` (deterministic lint/type/test, every commit). Layer 2: RP plan-review (code-aware spec validation, invoked via `/flow-code:run` plan-review phase — RP sees full codebase via context_builder). Layer 3: `flowctl codex adversarial` (cross-model adversarial, epic completion — different model family catches blind spots). Spec conflicts and blockers forwarded to Codex for autonomous decision-making.
91-
- **Review circuit breaker**: impl-review fix loop capped at `MAX_REVIEW_ITERATIONS` (default 3) — prevents infinite NEEDS_WORK cycles
138+
- **Three-layer quality system**: Layer 1: `flowctl guard` (deterministic lint/type/test — runs at Worker Phase 6, wave checkpoint, and close phase). Layer 2: RP plan-review (code-aware spec validation, invoked via `/flow-code:run` plan-review phase — RP sees full codebase via context_builder). Layer 3: `flowctl codex adversarial` (cross-model adversarial, epic completion — different model family catches blind spots). Spec conflicts and blockers forwarded to Codex for autonomous decision-making.
139+
- **Review circuit breaker**: Plan review max 2 iterations, impl review max 3, epic review max 2 — prevents infinite NEEDS_WORK cycles. After max iterations, pipeline proceeds with warning
140+
- **Review backend resolution**: All review phases use the same priority chain: `--review` flag > `FLOW_REVIEW_BACKEND` env > `.flow/config.json` > default `none`. The `--no-review` flag is equivalent to `--review=none` and always wins
92141
- **Auto-improve analysis-driven**: generates custom program.md from codebase analysis (hotspots, lint, coverage, memory) with Action Catalog ranked by impact — not static templates
93142
- **Auto-improve quantitative**: captures before/after metrics per experiment, commit messages include delta `[lint:23→21]`
94143
- **Worker self-review**: Phase 6 runs guard + structured diff review (correctness, quality, performance, testing) before commit
@@ -97,6 +146,11 @@ Rust: clippy for linting, cargo test for tests. No TypeScript, no npm. Skills an
97146
- **Full-auto by default**: `/flow-code:run` requires zero interactive questions — AI reads git state, `.flow/` config, and request context to make branch, review, and research decisions autonomously. Default mode is Worktree + Teams + Phase-Gate (all three active). Work resumes from `.flow/` state on every startup (not a special "resume mode"). All tasks done → auto push + draft PR (`--no-pr` to skip)
98147
- **Cross-platform**: flowctl is a single Rust binary (macOS/Linux). RP plan-review auto-degrades to Codex on platforms where rp-cli is unavailable. Bash hooks degrade gracefully on Windows (skip, don't block)
99148
- **Session start**: CLAUDE.md instruction (not an enforced hook) — if `.flow/` exists, run `flowctl status --interrupted` to check for unfinished work from a previous session and resume with the suggested `/flow-code:work <id>` command
149+
- **DAG cycle detection**: `flowctl dep add` validates that adding a dependency does not create a cycle in the task dependency graph. If a cycle would be created, the command fails with an error. The DAG is validated using topological sort via the `petgraph` crate
150+
- **Concurrency-safe state**: All read-modify-write operations on shared JSON state files (pipeline, phases, locks) use advisory file locks via `fs2` to prevent lost updates under concurrent access (e.g., Ralph daemon)
151+
- **Worker timeout**: Workers have a 30-minute default timeout per task (configurable via `worker.timeout_minutes`). On timeout: task marked failed, file locks released, wave continues
152+
- **Stale lock recovery**: Runs at wave start AND on worker completion — detects locks held by done/failed/blocked tasks and releases them to prevent deadlocks
153+
- **Worker phase mapping**: Workers execute 12 internal phases (via `flowctl worker-phase next/done`) within the epic "Work" phase. Epic phases and worker phases are independent systems operating at different levels
100154

101155
## Files to Never Commit
102156

README.md

Lines changed: 55 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
**A production-grade harness for Claude Code. Full-auto development from idea to PR.**
1515

16-
**Zero external dependencies. Zero questions asked.**
16+
**Zero Claude Code dependencies. Zero questions asked.**
1717

1818
</div>
1919

@@ -37,7 +37,7 @@ A **harness** wraps around an AI coding agent to handle everything the model can
3737
| Full-auto (zero questions) | ✅ AI decides branch/review/depth ||||
3838
| Context preservation | ✅ PreCompact hook || ✅ embedding + RAG ||
3939
| Auto draft PR |||||
40-
| Zero dependencies | ✅ single Rust binary + Bash skills | ❌ Node.js | ❌ ChromaDB | ❌ Node.js |
40+
| Minimal dependencies | ✅ single Rust binary + git/jq/gh | ❌ Node.js | ❌ ChromaDB | ❌ Node.js |
4141

4242
---
4343

@@ -66,7 +66,8 @@ A **harness** wraps around an AI coding agent to handle everything the model can
6666
Flow-Code is a **harness engineering framework** for Claude Code. One command goes from idea to draft PR — planning, parallel implementation, three-layer quality gates, and cross-model adversarial review, all fully automated.
6767

6868
```
69-
/flow-code:plan "Add OAuth login"
69+
/flow-code:go "Add OAuth login"
70+
→ AI self-interview (auto-brainstorm)
7071
→ AI research (adaptive scouts)
7172
→ RP plan-review (code-aware)
7273
→ Teams parallel workers (file locking)
@@ -113,11 +114,14 @@ Rationale: keeps the system simple, improves re-anchoring, makes automation (Ral
113114
Say one sentence. Flow-Code plans, implements, tests, commits, and opens a draft PR — zero questions asked. AI reads git state and `.flow/` config to make all decisions (branch, review backend, research depth) autonomously.
114115

115116
```bash
116-
# Full auto: plan → implement → test → commit → draft PR
117-
/flow-code:plan "add OAuth support"
117+
# Full autopilot: brainstorm → plan → implement → test → commit → draft PR
118+
/flow-code:go "add OAuth support"
119+
120+
# Skip brainstorm: plan → implement → review → close
121+
/flow-code:run "add OAuth support"
118122

119123
# Resume anytime — reads .flow state and continues from where it left off
120-
/flow-code:work fn-1
124+
/flow-code:run fn-1
121125

122126
# One task at a time for maximum control
123127
/flow-code:work fn-1.1
@@ -165,6 +169,12 @@ Guard is deterministic. RP validates against existing code. Codex (GPT) tries to
165169

166170
## Quick Start
167171

172+
### Prerequisites
173+
174+
Required: `git`, `jq`, `gh` (GitHub CLI), `curl`
175+
176+
Optional: `rp-cli` (for Layer 2 plan-review), `codex` (for Layer 3 adversarial review)
177+
168178
### 1. Install
169179

170180
```bash
@@ -284,6 +294,7 @@ Best for: bug fixes, small features, well-scoped changes that don't need task sp
284294

285295
| Starting point | Recommended sequence |
286296
|----------------|---------------------|
297+
| **Just ship it (zero effort)** | **`/flow-code:go "idea"`** — full autopilot, brainstorm to PR |
287298
| New feature, want solid spec first | Spec → Interview/Plan → Work |
288299
| Vague idea, rough notes | Interview → Plan → Work |
289300
| Detailed spec/PRD | Plan → Interview → Work |
@@ -1271,13 +1282,16 @@ Config lives in `.flow/config.json`, separate from Ralph's `scripts/ralph/config
12711282

12721283
## Commands
12731284

1274-
Ten commands, complete workflow:
1285+
Twenty commands, complete workflow:
12751286

12761287
| Command | What It Does |
12771288
|---------|--------------|
1289+
| `/flow-code:go <idea>` | **Full autopilot**: brainstorm → plan → work → review → close → PR (zero input) |
1290+
| `/flow-code:run <idea\|fn-N>` | Pipeline: plan → work → review → close (skips brainstorm) |
1291+
| `/flow-code:brainstorm <idea>` | Explore and pressure-test ideas before planning (`--auto` for AI self-interview) |
12781292
| `/flow-code:plan <idea>` | Research the codebase, create epic with dependency-ordered tasks |
12791293
| `/flow-code:work <id\|file>` | Execute epic, task, or spec file, re-anchoring before each |
1280-
| `/flow-code:interview <id>` | Deep interview to flesh out a spec before planning |
1294+
| `/flow-code:interview <id>` | Deep interview to flesh out a spec before planning (40+ questions) |
12811295
| `/flow-code:plan-review <id>` | Carmack-level plan review via RepoPrompt |
12821296
| `/flow-code:impl-review` | Carmack-level impl review of current branch |
12831297
| `/flow-code:epic-review <id>` | Epic-completion review: verify implementation matches spec |
@@ -1287,6 +1301,9 @@ Ten commands, complete workflow:
12871301
| `/flow-code:ralph-init` | Scaffold repo-local Ralph harness (`scripts/ralph/`) |
12881302
| `/flow-code:retro` | Post-epic retrospective: what worked, what didn't, lessons → memory |
12891303
| `/flow-code:django` | Django patterns: architecture, DRF, security, testing, verification |
1304+
| `/flow-code:qa` | Visual QA testing with browser automation |
1305+
| `/flow-code:design-review` | Visual design audit with browser automation |
1306+
| `/flow-code:autoplan` | Multi-perspective auto-review (CEO, eng, design, DX) |
12901307
| `/flow-code:skill-create` | TDD-based skill creation: baseline test → write → bulletproof |
12911308
| `/flow-code:setup` | Optional: install flowctl locally + add docs (for power users) |
12921309
| `/flow-code:uninstall` | Remove flow-code from project (keeps tasks if desired) |
@@ -1320,7 +1337,9 @@ Natural language also works:
13201337

13211338
| Command | Available Flags |
13221339
|---------|-----------------|
1323-
| `/flow-code:plan` | `--research=rp\|grep`, `--depth=short\|standard\|deep`, `--review=rp\|codex\|export\|none`, `--plan-only` |
1340+
| `/flow-code:go` | `--plan-only`, `--no-pr` |
1341+
| `/flow-code:brainstorm` | `--auto` (AI self-interview, zero human input) |
1342+
| `/flow-code:plan` | `--research=rp\|grep`, `--depth=short\|standard\|deep`, `--review=rp\|codex\|export\|none`, `--plan-only`, `--interactive` |
13241343
| `/flow-code:work` | `--branch=current\|worktree\|new`, `--review=rp\|codex\|none`, `--no-review`, `--interactive`, `--tdd`, `--no-pr` |
13251344
| `/flow-code:plan-review` | `--review=rp\|codex\|export` |
13261345
| `/flow-code:impl-review` | `--review=rp\|codex\|export` |
@@ -1331,6 +1350,33 @@ Natural language also works:
13311350

13321351
Detailed input documentation for each command.
13331352

1353+
#### `/flow-code:go`
1354+
1355+
```
1356+
/flow-code:go <idea> [--plan-only] [--no-pr]
1357+
```
1358+
1359+
| Input | Description |
1360+
|-------|-------------|
1361+
| `<idea>` | Free-form feature description ("Add OAuth login") |
1362+
| `--plan-only` | Skip brainstorm, plan only, stop after planning |
1363+
| `--no-pr` | Skip draft PR creation at close |
1364+
1365+
Full autopilot: auto-brainstorm (AI self-interview) → plan → plan-review → work → impl-review → close → push + draft PR. Zero human input. Use `/flow-code:run fn-N` to resume an interrupted epic.
1366+
1367+
#### `/flow-code:brainstorm`
1368+
1369+
```
1370+
/flow-code:brainstorm [--auto] <idea>
1371+
```
1372+
1373+
| Input | Description |
1374+
|-------|-------------|
1375+
| `<idea>` | Feature or problem description |
1376+
| `--auto` | AI self-interview mode — no human questions, all answers derived from codebase analysis |
1377+
1378+
Produces `.flow/specs/<slug>-requirements.md`. Next step: `/flow-code:plan .flow/specs/<slug>-requirements.md`.
1379+
13341380
#### `/flow-code:plan`
13351381

13361382
```

0 commit comments

Comments
 (0)