|
| 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 |
0 commit comments