# Greenfield Workflow Workflow for new projects built from scratch. Flows linearly: Problem → Research → Plan → UI Design (if applicable) → Decompose → Implement → Run Tests → Security Audit (optional) → Deploy. ## Step Reference Table | Step | Name | Sub-Skill | Internal SubSteps | |------|-----------|------------------------|---------------------------------------| | 0 | Problem | problem/SKILL.md | Phase 1–4 | | 1 | Research | research/SKILL.md | Mode A: Phase 1–4 · Mode B: Step 0–8 | | 2 | Plan | plan/SKILL.md | Step 1–6 + Final | | 2a | UI Design | ui-design/SKILL.md | Phase 0–8 (conditional — UI projects only) | | 3 | Decompose | decompose/SKILL.md | Step 1–4 | | 4 | Implement | implement/SKILL.md | (batch-driven, no fixed sub-steps) | | 5 | Run Tests | (autopilot-managed) | Unit tests → Blackbox tests | | 5b | Security Audit | security/SKILL.md | Phase 1–5 (optional) | | 5c | Performance Test | (autopilot-managed) | Load/stress tests (optional) | | 6 | Deploy | deploy/SKILL.md | Step 1–7 | ## Detection Rules Check rules in order — first match wins. --- **Step 0 — Problem Gathering** Condition: `_docs/00_problem/` does not exist, OR any of these are missing/empty: - `problem.md` - `restrictions.md` - `acceptance_criteria.md` - `input_data/` (must contain at least one file) Action: Read and execute `.cursor/skills/problem/SKILL.md` --- **Step 1 — Research (Initial)** Condition: `_docs/00_problem/` is complete AND `_docs/01_solution/` has no `solution_draft*.md` files Action: Read and execute `.cursor/skills/research/SKILL.md` (will auto-detect Mode A) --- **Step 1b — Research Decision** Condition: `_docs/01_solution/` contains `solution_draft*.md` files AND `_docs/01_solution/solution.md` does not exist AND `_docs/02_document/architecture.md` does not exist Action: Present the current research state to the user: - How many solution drafts exist - Whether tech_stack.md and security_analysis.md exist - One-line summary from the latest draft Then present using the **Choose format**: ``` ══════════════════════════════════════ DECISION REQUIRED: Research complete — next action? ══════════════════════════════════════ A) Run another research round (Mode B assessment) B) Proceed to planning with current draft ══════════════════════════════════════ Recommendation: [A or B] — [reason based on draft quality] ══════════════════════════════════════ ``` - If user picks A → Read and execute `.cursor/skills/research/SKILL.md` (will auto-detect Mode B) - If user picks B → auto-chain to Step 2 (Plan) --- **Step 2 — Plan** Condition: `_docs/01_solution/` has `solution_draft*.md` files AND `_docs/02_document/architecture.md` does not exist Action: 1. The plan skill's Prereq 2 will rename the latest draft to `solution.md` — this is handled by the plan skill itself 2. Read and execute `.cursor/skills/plan/SKILL.md` If `_docs/02_document/` exists but is incomplete (has some artifacts but no `FINAL_report.md`), the plan skill's built-in resumability handles it. --- **Step 2a — UI Design (conditional)** Condition: `_docs/02_document/architecture.md` exists AND the autopilot state does NOT show Step 2a (UI Design) as completed or skipped AND the project is a UI project **UI Project Detection** — the project is a UI project if ANY of the following are true: - `package.json` exists in the workspace root or any subdirectory - `*.html`, `*.jsx`, `*.tsx` files exist in the workspace - `_docs/02_document/components/` contains a component whose `description.md` mentions UI, frontend, page, screen, dashboard, form, or view - `_docs/02_document/architecture.md` mentions frontend, UI layer, SPA, or client-side rendering - `_docs/01_solution/solution.md` mentions frontend, web interface, or user-facing UI If the project is NOT a UI project → mark Step 2a as `skipped` in the state file and auto-chain to Step 3. If the project IS a UI project → present using Choose format: ``` ══════════════════════════════════════ DECISION REQUIRED: UI project detected — generate mockups? ══════════════════════════════════════ A) Generate UI mockups before decomposition (recommended) B) Skip — proceed directly to decompose ══════════════════════════════════════ Recommendation: A — mockups before decomposition produce better task specs for frontend components ══════════════════════════════════════ ``` - If user picks A → Read and execute `.cursor/skills/ui-design/SKILL.md`. After completion, auto-chain to Step 3 (Decompose). - If user picks B → Mark Step 2a as `skipped` in the state file, auto-chain to Step 3 (Decompose). --- **Step 3 — Decompose** Condition: `_docs/02_document/` contains `architecture.md` AND `_docs/02_document/components/` has at least one component AND `_docs/02_tasks/` does not exist or has no task files (excluding `_dependencies_table.md`) Action: Read and execute `.cursor/skills/decompose/SKILL.md` If `_docs/02_tasks/` has some task files already, the decompose skill's resumability handles it. --- **Step 4 — Implement** Condition: `_docs/02_tasks/` contains task files AND `_dependencies_table.md` exists AND `_docs/03_implementation/FINAL_implementation_report.md` does not exist Action: Read and execute `.cursor/skills/implement/SKILL.md` If `_docs/03_implementation/` has batch reports, the implement skill detects completed tasks and continues. --- **Step 5 — Run Tests** Condition: `_docs/03_implementation/FINAL_implementation_report.md` exists AND the autopilot state does NOT show Step 5 (Run Tests) as completed AND (`_docs/04_deploy/` does not exist or is incomplete) Action: Run the full test suite to verify the implementation before deployment. 1. **Unit tests**: detect the project's test runner (e.g., `pytest`, `dotnet test`, `cargo test`, `npm test`) and run all unit tests 2. **Blackbox tests**: if `docker-compose.test.yml` or an equivalent test environment exists, spin it up and run the blackbox test suite 3. **Report results**: present a summary of passed/failed/skipped tests If all tests pass → auto-chain to Step 5b (Security Audit). If tests fail → present using Choose format: ``` ══════════════════════════════════════ TEST RESULTS: [N passed, M failed, K skipped] ══════════════════════════════════════ A) Fix failing tests and re-run B) Proceed to deploy anyway (not recommended) C) Abort — fix manually ══════════════════════════════════════ Recommendation: A — fix failures before deploying ══════════════════════════════════════ ``` --- **Step 5b — Security Audit (optional)** Condition: the autopilot state shows Step 5 (Run Tests) is completed AND the autopilot state does NOT show Step 5b (Security Audit) as completed or skipped AND (`_docs/04_deploy/` does not exist or is incomplete) Action: Present using Choose format: ``` ══════════════════════════════════════ DECISION REQUIRED: Run security audit before deploy? ══════════════════════════════════════ A) Run security audit (recommended for production deployments) B) Skip — proceed directly to deploy ══════════════════════════════════════ Recommendation: A — catches vulnerabilities before production ══════════════════════════════════════ ``` - If user picks A → Read and execute `.cursor/skills/security/SKILL.md`. After completion, auto-chain to Step 6 (Deploy). - If user picks B → Mark Step 5b as `skipped` in the state file, auto-chain to Step 6 (Deploy). --- **Step 5c — Performance Test (optional)** Condition: the autopilot state shows Step 5b (Security Audit) is completed or skipped AND the autopilot state does NOT show Step 5c (Performance Test) as completed or skipped AND (`_docs/04_deploy/` does not exist or is incomplete) Action: Present using Choose format: ``` ══════════════════════════════════════ DECISION REQUIRED: Run performance/load tests before deploy? ══════════════════════════════════════ A) Run performance tests (recommended for latency-sensitive or high-load systems) B) Skip — proceed directly to deploy ══════════════════════════════════════ Recommendation: [A or B — base on whether acceptance criteria include latency, throughput, or load requirements] ══════════════════════════════════════ ``` - If user picks A → Run performance tests: 1. Check if `_docs/02_document/tests/performance-tests.md` exists for test scenarios 2. Detect appropriate load testing tool (k6, locust, artillery, wrk, or built-in benchmarks) 3. Execute performance test scenarios against the running system 4. Present results vs acceptance criteria thresholds 5. If thresholds fail → present Choose format: A) Fix and re-run, B) Proceed anyway, C) Abort 6. After completion, auto-chain to Step 6 (Deploy) - If user picks B → Mark Step 5c as `skipped` in the state file, auto-chain to Step 6 (Deploy). --- **Step 6 — Deploy** Condition: the autopilot state shows Step 5 (Run Tests) is completed AND (Step 5b is completed or skipped) AND (Step 5c is completed or skipped) AND (`_docs/04_deploy/` does not exist or is incomplete) Action: Read and execute `.cursor/skills/deploy/SKILL.md` --- **Done** Condition: `_docs/04_deploy/` contains all expected artifacts (containerization.md, ci_cd_pipeline.md, environment_strategy.md, observability.md, deployment_procedures.md) Action: Report project completion with summary. If the user runs autopilot again after greenfield completion, Flow Resolution rule 3 routes to the existing-code flow (re-entry after completion) so they can add new features. ## Auto-Chain Rules | Completed Step | Next Action | |---------------|-------------| | Problem Gathering | Auto-chain → Research (Mode A) | | Research (any round) | Auto-chain → Research Decision (ask user: another round or proceed?) | | Research Decision → proceed | Auto-chain → Plan | | Plan | Auto-chain → UI Design detection (Step 2a) | | UI Design (done or skipped) | Auto-chain → Decompose | | Decompose | **Session boundary** — suggest new conversation before Implement | | Implement | Auto-chain → Run Tests (Step 5) | | Run Tests (all pass) | Auto-chain → Security Audit choice (Step 5b) | | Security Audit (done or skipped) | Auto-chain → Performance Test choice (Step 5c) | | Performance Test (done or skipped) | Auto-chain → Deploy (Step 6) | | Deploy | Report completion |