build-local
Build and validate locally for projects without remote deployment (prototypes, experiments, local-only dev)
mkdir -p ~/.claude/commands && curl -fsSL https://raw.githubusercontent.com/marcusgoll/Spec-Flow/HEAD/.claude/commands/build/build-local.md -o ~/.claude/commands/build-local.mdbuild-local.md
> **⚠️ INTERNAL COMMAND**: This command is automatically called by `/ship` when deployment model is `local-only`.
> Most users should use `/ship` instead of calling this directly.
# /build-local — Local Build & Validation
<context>
**Current Feature Directory**: !`find specs/ -maxdepth 1 -type d -name "[0-9]*" | sort -n | tail -1 2>$null || echo "none"`
**Workflow State**: @specs/*/workflow-state.yaml
**Git Status**: !`git status --short 2>$null || echo "clean"`
**Git Remote**: !`git remote get-url origin 2>$null || echo "no-remote"`
**Previous Phases**:
- Pre-flight: !`yq eval '.quality_gates.pre_flight.passed' specs/*/workflow-state.yaml 2>$null || echo "unknown"`
- Optimize: !`yq eval '.phases.optimize.status' specs/*/workflow-state.yaml 2>$null || echo "unknown"`
- Preview: !`yq eval '.workflow.manual_gates.preview.status' specs/*/workflow-state.yaml 2>$null || echo "unknown"`
**Project Type Detection**:
- Node.js: !`test -f package.json && echo "yes" || echo "no"`
- Makefile: !`test -f Makefile && echo "yes" || echo "no"`
- Rust: !`test -f Cargo.toml && echo "yes" || echo "no"`
- Go: !`test -f go.mod && echo "yes" || echo "no"`
- Python: !`test -f setup.py && echo "yes" || test -f pyproject.toml && echo "yes" || echo "no"`
**Package Manager**: !`command -v pnpm >/dev/null 2>&1 && echo "pnpm" || (command -v yarn >/dev/null 2>&1 && echo "yarn" || (command -v npm >/dev/null 2>&1 && echo "npm" || echo "unknown"))`
**Build Tools Available**: !`command -v make >/dev/null 2>&1 && echo "make" || echo "none"`
</context>
<objective>
Build and validate the project locally for projects without remote deployment (local-only deployment model).
**Purpose**: For projects without git remote or deployment infrastructure (prototypes, experiments, desktop apps, learning projects).
**Risk Level**: 🟢 LOW - No production deployment, all operations local
**When Used**: Automatically called by `/ship` when:
- No git remote configured
- Deployment model detected as `local-only`
- Project is development/learning focused (not production-bound)
**Build Phases** (executed in order):
1. **Initialize**: Verify prerequisites, load workflow state
2. **Production Build**: Run build commands based on project type
3. **Run Tests**: Execute test suite (if available)
4. **Analyze Build Artifacts**: Check bundle sizes, dependencies
5. **Security Scan** (optional): Run security audit, generate SBOM
6. **Local Build Report**: Generate comprehensive build summary
**Prerequisites** (verified before execution):
- `/implement` phase complete
- `/optimize` phase complete
- `/preview` manual gate approved
- Pre-flight validation passed
**Timing**: 2-5 minutes (depends on project size and test suite)
</objective>
## Anti-Hallucination Rules
**CRITICAL**: Follow these rules to prevent false build success claims.
1. **Never claim build succeeded without actual exit code 0**
- Check actual bash exit code from build commands
- Exit code 0 = build succeeded
- Exit code != 0 = build failed
- Don't claim success if build was interrupted or errored
2. **Quote actual build errors from command output**
- Report actual compiler errors, test failures, lint violations
- Include file:line references from actual output
- Don't invent or summarize errors - quote them exactly
3. **Verify build artifacts actually exist**
- Check for actual build output (dist/, build/, target/, bin/)
- Don't assume artifacts exist without verification
- Report "Build artifacts not found" if missing
4. **Quote actual test results from test output**
- Report actual test counts (passed/failed/skipped)
- Include test names that failed
- Don't claim "all tests passed" without actual test runner output
5. **Read actual build report content**
- Read generated local-build-report.md file
- Quote actual metrics (bundle size, dependency count, test coverage)
- Don't fabricate report content
**Why this matters**: False build success claims waste time debugging later. Accurate reporting of actual build status prevents confusion and ensures code quality.
---
<process>
### Step 1: Verify Prerequisites
**Check workflow state exists**:
```bash
FEATURE_DIR=$(find specs/ -maxdepth 1 -type d -name "[0-9]*" | sort -n | tail -1)
test -f "$FEATURE_DIR/workflow-state.yaml"
```
If workflow state doesn't exist:
```
❌ No workflow state found
Expected: specs/{feature-slug}/workflow-state.yaml
Cannot proceed with build without workflow state.
Run /feature to create feature context first.
```
EXIT immediately
**Verify prerequisite phases completed**:
```bash
# Check pre-flight validation
yq eval '.quality_gates.pre_flight.passed == true' "$FEATURE_DIR/workflow-state.yaml"
```
If not passed: Display "❌ Pre-flight validation not passed" and EXIT
```bash
# Check optimize phase
yq eval '.phases.optimize.status == "completed"' "$FEATURE_DIR/workflow-state.yaml"
```
If not completed: Display "❌ Optimization phase not complete" and EXIT
```bash
# Check preview gate
yq eval '.workflow.manual_gates.preview.status' "$FEATURE_DIR/workflow-state.yaml"
```
If not "approved": Display "❌ Preview gate not approved" and EXIT
If all checks pass:
```
✅ All pre-build checks passed
```
### Step 2: Execute Local Build
**Update workflow phase to in_progress**:
```bash
yq eval -i '.phases.ship:build-local.status = "in_progress"' "$FEATURE_DIR/workflow-state.yaml"
yq eval -i '.phases.ship:build-local.started_at = "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"' "$FEATURE_DIR/workflow-state.yaml"
```
**Display build banner**:
```
🏠 Local Build & Validation
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Feature: {feature-slug}
Build Type: Local (no deployment)
Starting build phases...
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```
**Detect project type and run appropriate build commands**:
**For Node.js projects** (package.json exists):
```bash
# Detect package manager
if command -v pnpm >/dev/null 2>&1; then
PKG_MGR="pnpm"
elif command -Execute multiple sprints in parallel based on dependency graph from sprint-plan.md
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
Display Vercel and Railway deployment quota usage with 24h rolling window analysis, quota reset predictions, and deployment strategy recommendations