init-project
The init-project command generates eight standardized project design documents (overview, architecture, tech stack, data model, API specification, capacity planning, deployment strategy, and development workflow) through an interactive questionnaire or configuration file, automatically adapting questions based on whether the project is greenfield or brownfield and which tech stack is detected.
mkdir -p ~/.claude/commands && curl -fsSL https://raw.githubusercontent.com/marcusgoll/Spec-Flow/HEAD/.claude/commands/project/init-project.md -o ~/.claude/commands/init-project.mdinit-project.md
# /init-project — Project Documentation Generator (Hybrid Pattern)
> **v11.0 Architecture**: Uses hybrid pattern - questionnaire in main context (good UX), document generation isolated via Task() (saves ~5-10k tokens).
<context>
**User Input**: $ARGUMENTS
Existing project docs: !`ls -1 docs/project/*.md 2>/dev/null | wc -l` file(s)
Package manager detected: !`test -f package.json && echo "npm/pnpm" || test -f pyproject.toml && echo "python" || test -f Cargo.toml && echo "rust" || test -f go.mod && echo "go" || echo "unknown"`
Brownfield indicators: !`ls package.json requirements.txt Cargo.toml go.mod docker-compose.yml 2>/dev/null | tr '\n' ', ' || echo "greenfield"`
</context>
<architecture>
## Hybrid Pattern (v11.0)
```
User: /init-project "My App"
│
▼
┌──────────────────────────────────────────────────────┐
│ MAIN CONTEXT (questionnaire - good UX) │
│ │
│ 1. Detect brownfield/greenfield │
│ 2. Run 15-48 questions via AskUserQuestion │
│ 3. Save answers to temp config │
│ → .spec-flow/temp/init-answers.yaml │
└──────────────────────────────────────────────────────┘
│
▼
┌──────────────────────────────────────────────────────┐
│ Task(init-project-agent) ← ISOLATED │
│ │
│ 1. Read answers from temp config │
│ 2. Generate 8 project docs │
│ 3. Run quality gates │
│ 4. Create ADR │
│ 5. Return summary │
│ 6. EXIT │
└──────────────────────────────────────────────────────┘
│
▼
┌──────────────────────────────────────────────────────┐
│ MAIN CONTEXT (results - minimal tokens) │
│ │
│ 1. Display success summary │
│ 2. Show generated files │
│ 3. Suggest next steps │
└──────────────────────────────────────────────────────┘
```
**Benefits:**
- Questionnaire has natural interactive UX
- Document generation isolated (saves 5-10k tokens)
- Can re-run generation if session ends mid-way (answers cached)
</architecture>
<objective>
Generate comprehensive project design documentation (8 core files, 4 optional design files) through interactive questionnaire or config file mode.
**Core outputs (always generated):**
1. `docs/project/overview.md` - Vision, users, scope, metrics
2. `docs/project/system-architecture.md` - C4 diagrams, data flows
3. `docs/project/tech-stack.md` - Technology choices with rationale
4. `docs/project/data-architecture.md` - ERD, entity schemas
5. `docs/project/api-strategy.md` - REST/GraphQL patterns, versioning
6. `docs/project/capacity-planning.md` - Scaling model, cost projections
7. `docs/project/deployment-strategy.md` - CI/CD, environments, rollback
8. `docs/project/development-workflow.md` - Git flow, PR process, DoD
9. `docs/adr/0001-project-architecture-baseline.md` - Baseline ADR
**Optional outputs (--with-design flag):**
- 4 design system docs in `docs/design/`
- `design/systems/tokens.css` - WCAG AA compliant design tokens
- `design/systems/tokens.json` - Programmatic token access
**Foundation:**
These docs establish the foundation for `/roadmap` and `/feature` workflows by documenting architectural decisions, tech stack, and development practices.
**Dependencies:**
- Git repository initialized
- Required tools: git, jq, yq (for config file mode)
- Optional: gh (for foundation issue), markdownlint, lychee
**Mode Flags:**
- `--interactive`: Interactive questionnaire mode (15 questions, ~10 min) - default
- `--ci` / `--no-input`: Non-interactive CI/CD mode (reads environment variables)
- `--with-design`: Include design system setup (extended questionnaire with 48 questions)
**Operation Flags:**
- `--update`: Fill `[NEEDS CLARIFICATION]` sections only (preserves existing content)
- `--force`: Overwrite all docs completely (destructive)
- `--write-missing-only`: Only create files that don't exist
- `--config FILE`: Load answers from JSON/YAML config file
**Preference System:**
The command uses 3-tier preferences to determine mode:
1. Config file: `.spec-flow/config/user-preferences.yaml` (default_mode, include_design)
2. Command history: Learns from past usage
3. Command-line flags: Explicit overrides
</objective>
<process>
0. **Load User Preferences (3-Tier System)**:
**Determine initialization mode using 3-tier preference system:**
a. **Load configuration file** (Tier 1 - lowest priority):
```powershell
$preferences = & .spec-flow/scripts/utils/load-preferences.ps1 -Command "init-project"
$configMode = $preferences.commands.'init-project'.default_mode # "interactive" or "ci"
$includeDesign = $preferences.commands.'init-project'.include_design # true or false
```
b. **Load command history** (Tier 2 - medium priority, overrides config):
```powershell
$history = & .spec-flow/scripts/utils/load-command-history.ps1 -Command "init-project"
if ($history.last_used_mode -and $history.total_uses -gt 0) {
$preferredMode = $history.last_used_mode # Use learned preference
} else {
$preferredMode = $configMode # Fall back to config
}
```
c. **Check command-line flags** (Tier 3 - highest priority):
```javascript
const args = "$ARGUMENTS".trim();
const hasInteractiveFlag = args.includes('--interactive');
const hasCIFlag = args.includes('--ci');
const hasNoInput = args.includes('--no-input');
const hasWithDesign = args.includes('--with-design');
let selectedMode;
let designFlag = '';
// Determine mode
if (hExecute multiple sprints in parallel based on dependency graph from sprint-plan.md
Build and validate locally for projects without remote deployment (prototypes, experiments, local-only dev)
Execute multi-sprint epic workflow from interactive scoping through deployment with parallel sprint execution and self-improvement
Execute feature development workflow from specification through production deployment with automated quality gates
Analyze workflow state and provide context-aware guidance with visual progress indicators and recommended next steps
Initialize project documentation, preferences, or design tokens
Implement small bug fixes and features (<100 LOC) without full workflow. Use for single-file changes, bug fixes, refactors, and minor enhancements that can be completed in under 30 minutes.
Enter deep craftsman mode - question everything, plan like Da Vinci, craft insanely great solutions, then materialize to roadmap