This document contains the complete specification for @build.
For quick reference, see SKILL.md.
The build command executes a single workstream following TDD.
- Workstream file exists in
docs/workstreams/backlog/ - WS has Goal and Acceptance Criteria
- Dependencies are satisfied
- Scope is SMALL or MEDIUM
Run automatically or manually:
hooks/pre-build.sh {WS-ID}Checks:
- WS file exists
- Goal section present
- AC defined
- Dependencies complete
The guard system ensures you only edit files within the workstream scope:
sdp guard activate {WS-ID}This:
- Reads
scope_filesfrom WS frontmatter - Creates
.sdp/active_ws.jsonwith allowed files - Enables pre-edit validation
For each Acceptance Criterion:
Red Phase:
- Write a failing test that validates the AC
- Run test to confirm it fails
- Commit the failing test
Green Phase:
- Write minimal code to make test pass
- Run test to confirm it passes
- Commit the passing code
Refactor Phase:
- Improve code quality without changing behavior
- Run all tests to confirm still passing
- Commit the refactored code
Run after all ACs complete:
# Test coverage
pytest --cov=src --cov-report=term-missing --cov-fail-under=80
# Type checking
mypy src/ --strict
# Linting
ruff check src/
# File size check
find src/ -name "*.py" -exec wc -l {} \; | awk '$1 > 200 {print}'After all quality gates pass:
# Complete WS
sdp guard complete {WS-ID}
# Move to completed
mv docs/workstreams/backlog/{WS-ID}-*.md docs/workstreams/completed/
# Commit
git add .
git commit -m "feat({scope}): {WS-ID} - {title}"Report progress after each step:
✅ Step 1/5: Create module skeleton
✅ Step 2/5: Implement core class
✅ Step 3/5: Add error handling
...Generate and append execution report to the workstream file:
from sdp.report.generator import ReportGenerator
generator = ReportGenerator(ws_id="WS-XXX-YY")
generator.start_timer()
# ... execute workstream ...
generator.stop_timer()
# Collect statistics
stats = generator.collect_stats(
files_changed=[("src/module.py", "modified", 100)],
coverage_pct=85.0,
tests_passed=12,
tests_failed=0,
deviations=["Added extra validation for edge case"]
)
# Get current commit
import subprocess
commit_hash = subprocess.run(
["git", "rev-parse", "HEAD"],
capture_output=True,
text=True
).stdout.strip()
# Append report
generator.append_report(
stats,
executed_by="developer-name",
commit_hash=commit_hash
)Error: Pre-build validation fails with dependency error
Fix: Complete dependent workstreams first
Error: Guard rejects file edit
Fix: Update scope_files in WS frontmatter or use correct file
Error: Coverage check fails below 80%
Fix: Add more test cases to cover branches
Error: mypy reports type errors
Fix: Add type hints or fix type mismatches
See docs/examples/build/ for:
- TDD cycle examples
- Execution report samples
- Common patterns