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

Commit 7401e85

Browse files
z23ccclaude
andcommitted
feat(pipeline): add Brainstorm phase and /flow-code:go entry point (v0.1.33)
- Add Brainstorm as first phase in pipeline state machine (Brainstorm → Plan → PlanReview → Work → ImplReview → Close) - Make /flow-code:go the sole user-facing entry point - Demote /flow-code:run to internal skill - Brainstorm auto-skips for existing flow IDs and spec files - Update all docs, agents, and skills to reference new pipeline Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 84ac389 commit 7401e85

16 files changed

Lines changed: 217 additions & 307 deletions

File tree

.claude-plugin/flowctl-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v0.1.29
1+
v0.1.33

.claude-plugin/plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "flow-code",
3-
"version": "0.1.31",
3+
"version": "0.1.33",
44
"description": "Zero-dependency planning + execution with .flow/ task tracking and Ralph autonomous mode (multi-model review gates). Worker subagent per task with git worktree isolation for parallel execution. Three-layer quality system (guard + RP plan-review + Codex adversarial). Full-auto by default — AI decides from context, zero questions. Teams-default with file locking, DAG mutation, Codex-driven conflict resolution, auto draft-PR. Auto-detected stack profiles with one-command guard (test/lint/typecheck). Enhanced agent definitions with permissionMode/maxTurns/effort. Lifecycle hooks with state preservation (PreCompact injects .flow state into compaction, TaskCompleted auto-unlocks files, SubagentStart context injection). Memory v2 with atomic entries, dedup, and progressive disclosure. TDD enforcement mode. Multi-epic queue with dependency visualization. Includes 20 subagents, 25+ commands, 23 skills.",
55
"author": {
66
"name": "z23cc",

CLAUDE.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ 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 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.
7+
Flow-Code is a Claude Code plugin for structured, plan-first development. The primary entry point is `/flow-code:go` (full autopilot: brainstorm → 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

@@ -31,9 +31,7 @@ $FLOWCTL <command>
3131

3232
## Primary Workflow
3333

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.
34+
`/flow-code:go "idea"` — full autopilot from raw idea to PR. Runs brainstorm (AI self-interview) → plan → plan-review → work → impl-review → close via `flowctl phase next/done`. Zero human input. For existing epics or spec files, brainstorm is auto-skipped.
3735

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

@@ -133,17 +131,17 @@ Rust: clippy for linting, cargo test for tests. No TypeScript, no npm. Skills an
133131
- **Task duration**: `flowctl done` auto-tracks `duration_seconds` from start to completion, rendered in evidence
134132
- **File ownership**: `flowctl task create --files <paths>` declares owned files; `flowctl files <id>` shows ownership map + conflict detection
135133
- **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
136-
- **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
134+
- **Agent Teams mode**: `/flow-code:go` (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
137135
- **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
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.
136+
- **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:go` 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.
139137
- **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
140138
- **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
141139
- **Auto-improve analysis-driven**: generates custom program.md from codebase analysis (hotspots, lint, coverage, memory) with Action Catalog ranked by impact — not static templates
142140
- **Auto-improve quantitative**: captures before/after metrics per experiment, commit messages include delta `[lint:23→21]`
143141
- **Worker self-review**: Phase 6 runs guard + structured diff review (correctness, quality, performance, testing) before commit
144-
- **Plan auto-execute**: `/flow-code:run` (or legacy `/flow-code:plan`) defaults to auto-execute work after planning (Teams mode handles any task count); `--plan-only` to opt out
142+
- **Plan auto-execute**: `/flow-code:go` (or legacy `/flow-code:plan`) defaults to auto-execute work after planning (Teams mode handles any task count); `--plan-only` to opt out
145143
- **Goal-backward verification**: worker Phase 10 re-reads acceptance criteria and verifies each is actually satisfied before completing
146-
- **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)
144+
- **Full-auto by default**: `/flow-code:go` 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)
147145
- **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)
148146
- **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
149147
- **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

agents/worker.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
name: worker
3-
description: Task implementation worker. Spawned by flow-code-run during the work phase. Do not invoke directly - use /flow-code:run instead.
3+
description: Task implementation worker. Spawned by flow-code-run during the work phase. Do not invoke directly - use /flow-code:go instead.
44
model: inherit
55
disallowedTools: Task
66
color: "#3B82F6"
@@ -45,7 +45,7 @@ Do NOT skip phases. Do NOT execute phases out of order. The gate enforces sequen
4545
The project has two phase models that operate at different levels:
4646

4747
**Epic-level phases** (managed by `flowctl phase next/done`):
48-
Plan → PlanReview → Work → ImplReview → Close
48+
Brainstorm → Plan → PlanReview → Work → ImplReview → Close
4949

5050
**Worker-level phases** (managed by `flowctl worker-phase next/done`):
5151
Phases 1-12 execute WITHIN the epic "Work" phase. Each worker processes one task through all 12 phases while the epic remains in "Work" phase.

commands/flow-code/go.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
---
22
name: flow-code:go
3-
description: "Full autopilot: brainstormplanworkreviewclose. Zero human input."
3+
description: "Full autopilot: brainstorm, plan, work, review, close. Zero human input from idea to PR."
44
argument-hint: "<idea or problem description>"
55
---
66

7-
# IMPORTANT: This command MUST invoke the skill `flow-code-go`
7+
# IMPORTANT: This command MUST invoke the skill flow-code-run
88

9-
The ONLY purpose of this command is to call the `flow-code-go` skill. You MUST use that skill now.
9+
The ONLY purpose of this command is to call the flow-code-run skill. You MUST use that skill now.
1010

1111
**User request:** $ARGUMENTS
1212

13-
Pass the user request to the skill. The skill handles the full autonomous pipeline.
13+
Pass the user request to the skill with GO_MODE=true. The skill handles all pipeline logic including the brainstorm phase.

commands/flow-code/run.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
---
2-
name: run
3-
description: Unified pipeline entry point for plan-first development
2+
name: flow-code:run
3+
description: "Internal pipeline entry point. Use /flow-code:go instead."
44
---
55

6-
# IMPORTANT: This command MUST invoke the skill flow-code-run
6+
# This command redirects to /flow-code:go
77

8-
The ONLY purpose of this command is to call the flow-code-run skill. You MUST use that skill now.
8+
`/flow-code:run` is now internal. The user-facing entry point is `/flow-code:go`.
9+
10+
Tell the user: "Use `/flow-code:go` instead. It runs the full pipeline: brainstorm, plan, work, review, close."
11+
12+
If the user provided arguments, invoke the flow-code-run skill directly:
913

1014
**User request:** $ARGUMENTS
1115

docs/CODEBASE_MAP.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,8 @@ sequenceDiagram
241241
User->>Interview: /flow-code:interview
242242
Interview->>flowctl: epic set-plan (refined spec)
243243
244-
Note over User,flowctl: Preferred: /flow-code:run fn-N (unified pipeline)
245-
User->>Run: /flow-code:run "description"
244+
Note over User,flowctl: Preferred: /flow-code:go fn-N (unified pipeline)
245+
User->>Run: /flow-code:go "description"
246246
loop flowctl phase next/done
247247
Run->>flowctl: phase next --epic fn-N --json
248248
flowctl-->>Run: {phase, prompt, all_done}
@@ -272,13 +272,13 @@ sequenceDiagram
272272
273273
alt status = plan
274274
ralph.sh->>Claude: prompt_plan.md (new process)
275-
Claude->>Claude: /flow-code:run (plan phase)
275+
Claude->>Claude: /flow-code:go (plan phase)
276276
else status = work
277277
ralph.sh->>Claude: prompt_work.md (new process)
278-
Claude->>Claude: /flow-code:run (work phase)
278+
Claude->>Claude: /flow-code:go (work phase)
279279
else status = completion_review
280280
ralph.sh->>Claude: prompt_completion.md (new process)
281-
Claude->>Claude: /flow-code:run (close phase)
281+
Claude->>Claude: /flow-code:go (close phase)
282282
end
283283
284284
Claude-->>ralph.sh: exit (verdict in log)

docs/skills.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ These skills form the primary workflow. They ship with the plugin.
88

99
| Skill | Command | Purpose | Location |
1010
|-------|---------|---------|----------|
11-
| `flow-code-go` | `/flow-code:go` | **Full autopilot** — brainstorm → plan → work → review → close → PR | `skills/` |
12-
| `flow-code-run` | `/flow-code:run` | Unified phase loop (plan → review → work → close) | `skills/` |
11+
| `flow-code-go` | `/flow-code:go` | **Full autopilot** — brainstorm → plan → work → review → close → PR (sole user-facing entry point) | `skills/` |
12+
| `flow-code-run` | Internal | Internal pipeline engine, invoked by `/flow-code:go` | `skills/` |
1313
| `flow-code-plan` | `/flow-code:plan` | Research codebase and create epic with tasks | `codex/skills/` |
1414
| `flow-code-work` | `/flow-code:work` | Execute tasks with re-anchoring, reviews, wave checkpoints | `codex/skills/` |
1515
| `flow-code` | `/flow-code` | Task/epic management entry point (list, create, status) | `skills/` |
@@ -82,7 +82,7 @@ Or for more control:
8282
2. `/flow-code:plan .flow/specs/<slug>-requirements.md` — research + create tasks
8383
3. `/flow-code:work fn-N` — execute tasks
8484

85-
`/flow-code:run` handles plan → work → close (skips brainstorm).
85+
`/flow-code:go fn-N` resumes an existing epic (brainstorm auto-skipped).
8686

8787
## Tier Classification
8888

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
# Design: `/flow-code:go` — Unified Entry Point with Brainstorm Phase
2+
3+
## Problem
4+
5+
Flow-Code's pipeline starts at Plan, but raw ideas need refinement before planning. `/flow-code:go` was documented as the full-autopilot entry point (brainstorm → plan → work → review → close) but never implemented. Meanwhile `/flow-code:run` serves as the primary user-facing command — this creates confusion.
6+
7+
## Solution
8+
9+
1. Add `Brainstorm` as the first phase in flowctl's pipeline state machine
10+
2. Make `/flow-code:go` the sole user-facing entry point
11+
3. Demote `/flow-code:run` to an internal skill
12+
13+
## Architecture
14+
15+
### State Machine (flowctl-core)
16+
17+
```
18+
Brainstorm → Plan → PlanReview → Work → ImplReview → Close
19+
```
20+
21+
All epics initialize at `Brainstorm`. The phase is either executed (new idea) or skipped (existing flow ID / spec file).
22+
23+
### Phase Behavior
24+
25+
| Input Type | Brainstorm Phase |
26+
|------------|-----------------|
27+
| Natural language idea | Execute: auto brainstorm (AI self-interview → requirements doc) |
28+
| Flow ID (`fn-N`) | Skip: `flowctl phase done --phase brainstorm` |
29+
| Spec file path | Skip: `flowctl phase done --phase brainstorm` |
30+
| `--plan-only` | Skip brainstorm, stop after Plan |
31+
32+
### Command & Skill Mapping
33+
34+
| Layer | File | Change |
35+
|-------|------|--------|
36+
| Command (user-facing) | `commands/flow-code/go.md` | New — routes to `flow-code-run` skill |
37+
| Command (removed) | `commands/flow-code/run.md` | Delete or redirect to `go` |
38+
| Skill | `skills/flow-code-run/SKILL.md` | Add brainstorm phase handling, set `user-invocable: false` |
39+
| Skill trigger | skill frontmatter | Update trigger list: `/flow-code:go` replaces `/flow-code:run` |
40+
41+
## Rust Changes
42+
43+
### `flowctl-core/src/pipeline.rs`
44+
45+
```rust
46+
pub enum PipelinePhase {
47+
Brainstorm, // NEW
48+
Plan,
49+
PlanReview,
50+
Work,
51+
ImplReview,
52+
Close,
53+
}
54+
```
55+
56+
- `ALL_PHASES`: 6 elements, `Brainstorm` first
57+
- `Brainstorm.next()``Some(Plan)`
58+
- `Brainstorm.as_str()``"brainstorm"`
59+
- `Brainstorm.prompt_template()``"Explore and pressure-test the idea before planning"`
60+
- `Brainstorm.is_terminal()``false`
61+
- `PipelinePhase::parse("brainstorm")``Some(Brainstorm)`
62+
63+
### `flowctl-cli/src/commands/workflow/pipeline_phase.rs`
64+
65+
- `get_or_init_phase`: default init changes from `Plan` to `Brainstorm`
66+
67+
### Tests
68+
69+
- `test_phase_sequence`: starts from `Brainstorm`, expected array gains `Plan` at front
70+
- `test_all_phases`: `len()` assertion 5 → 6
71+
- `test_serde_roundtrip`: auto-covered
72+
- `test_display`: add `Brainstorm` case
73+
- `test_parse_roundtrip`: auto-covered
74+
- `test_invalid_transition_rejection`: update examples if needed
75+
76+
## Skill Changes
77+
78+
### `skills/flow-code-run/SKILL.md`
79+
80+
Phase loop gains brainstorm handling:
81+
82+
```
83+
when phase == "brainstorm":
84+
if input is natural language (not flow ID, not spec file):
85+
1. Gather codebase context (grep, git log, existing specs)
86+
2. Classify complexity (trivial/medium/large)
87+
3. Self-interview: 6-10 Q&A pairs grounded in code evidence
88+
4. Generate 2-3 approaches, auto-select best
89+
5. Write requirements doc to .flow/specs/<slug>-requirements.md
90+
6. flowctl phase done --phase brainstorm
91+
else:
92+
flowctl phase done --phase brainstorm (skip)
93+
```
94+
95+
The brainstorm logic is inlined from the existing `flow-code-brainstorm` SKILL.md auto mode — not delegated via skill invocation.
96+
97+
### `commands/flow-code/go.md`
98+
99+
```yaml
100+
---
101+
name: go
102+
description: "Full autopilot: brainstorm → plan → work → review → close"
103+
---
104+
# IMPORTANT: This command MUST invoke the skill flow-code-run
105+
Pass $ARGUMENTS to the skill with GO_MODE=true.
106+
```
107+
108+
### Flags (inherited from current `/flow-code:run`)
109+
110+
| Flag | Effect |
111+
|------|--------|
112+
| `--plan-only` | Skip brainstorm, stop after Plan |
113+
| `--no-pr` | Skip PR creation at close |
114+
| `--tdd` | Force test-first in worker |
115+
| `--review=rp\|codex\|none` | Override review backend |
116+
117+
## Documentation Updates
118+
119+
| File | Change |
120+
|------|--------|
121+
| `CLAUDE.md` | Pipeline sequence: add Brainstorm. Entry points: `/flow-code:go` replaces `/flow-code:run` |
122+
| `docs/skills.md` | Core Skills: replace `flow-code-run` with `flow-code-go`. Mark `flow-code-run` internal |
123+
| `docs/flowctl.md` | Phase command docs: add `brainstorm` phase |
124+
| `README.md` | Update pipeline diagram and usage examples |
125+
| `README_CN.md` | Same as README.md |
126+
127+
## Non-Goals
128+
129+
- Interactive brainstorm mode (always auto, zero human input)
130+
- Separate `flow-code-go` skill directory (reuses `flow-code-run`)
131+
- Backward compatibility with old `.flow/` state files

flowctl/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)