| id | GUIDE-TPL-QUICKSTART-001 | ||||
|---|---|---|---|---|---|
| title | Quick Start Guide | ||||
| doc_type | guide | ||||
| status | published | ||||
| audience | developers | ||||
| tags |
|
||||
| stories |
|
||||
| requirements |
|
||||
| acs |
|
||||
| adrs |
|
||||
| last_updated | 2025-12-22 |
Goal: Get productive in under 15 minutes.
This template is opinionated by design. It's not a generic Rust starter—it encodes specific beliefs about how governed, agent-friendly service development should work.
The template enforces these opinions through contracts in specs/spec_ledger.yaml:
-
Environment: Nix-First (Tier-1)
- Nix with flakes provides the canonical development environment
- Native Windows/macOS are supported as Tier-2 (functional but slower)
- CI uses Nix to guarantee parity between local and remote validation
- Why: Eliminates "works on my machine" by making the environment reproducible
-
CI Gate:
cargo xtask selftestRequired- All PRs must pass an 12-step governance validation
- Includes: code quality, BDD scenarios, policy tests, graph integrity
- Selftest passing means "governed and ready to review"
- Why: Prevents drift between specs, tests, docs, and code
-
Governance Artifacts: First-Class Citizens
- Questions (
QUESTIONS.yaml), friction (FRICTION_LOG.md), and forks (FORKS.yaml) are tracked artifacts - Exposed via HTTP APIs (
/platform/questions,/platform/friction,/platform/forks) - CLI commands with
--jsonoutput for machine consumption - Governance artifacts support
refsfield for REQ-/AC- IDs (AC-TPL-ARTIFACTS-HAVE-REFS) - Why: Governance data is as important as the code—make it queryable
- Questions (
-
BDD Harness: Exit Codes for Automation (AC-TPL-BDD-EXIT-CODES)
- BDD test harness returns exit 0 when all non-@wip scenarios pass
- Skipped scenarios (@skip) don't affect exit code
- Returns non-zero only if at least one non-@wip scenario fails
- Why: CI/CD needs reliable, deterministic test outcomes
-
Fork Visibility: Platform Status Integration (AC-TPL-FORKS-STATUS-SUMMARY)
- Fork registry visible in
/platform/status(governance.forks.total, forks.ids) cargo xtask fork-list --jsonreflects fork registry state- Why: IDPs and agents need to discover known forks without reading raw YAML
- Fork registry visible in
-
Agent Surfaces: APIs, Bundles, JSON CLI
- Platform introspection via
/platform/*endpoints (status, graph, docs, hints) - Context bundles for LLM workflows (
cargo xtask bundle <task>) - Core reporting commands support
--jsonfor programmatic use (version, friction-list, questions-list, fork-list) - Why: Agents and platform tooling need structured, machine-readable interfaces
- Platform introspection via
Don't edit config files randomly. Opinions are encoded as Acceptance Criteria (ACs) in specs/spec_ledger.yaml.
To change an opinion:
- Identify the relevant AC(s) in the spec ledger
- Modify or remove the AC and its associated BDD scenarios
- Update implementation to match your preference
- Run
cargo xtask selftestto verify consistency
For step-by-step guidance, see:
- First fork:
docs/how-to/FIRST_FORK.md– one-page runbook for getting from zero to forked in 20 minutes - Change an opinion:
docs/how-to/change-template-opinion.md– the recommended override path - Just add an endpoint:
docs/how-to/add-http-endpoint.md– the fast path for Axum developers who want to add routes - Axum developers:
docs/explanation/axum-mental-map.md– how standard Axum patterns map to this template - Modify an AC:
docs/how-to/change-acceptance-criterion.md– day-2 contract changes (update, demote, remove ACs) - Choose your opinionation level:
docs/how-to/pre-fork-checklist.md→ Phase 5 – decide what's kernel vs optional before customizing - Add your AC:
docs/how-to/add-acceptance-criterion.md - Fork for your service:
docs/how-to/new-service-from-template.md - Report upstream:
docs/how-to/report-fork-feedback.md - Kernel vs defaults:
docs/KERNEL_SNAPSHOT.md– table of enforced vs optional ACs + philosophy contracts
Example: If you don't want Nix, remove ACs related to REQ-PLT-NIX-DEVSHELL, update CI workflows, and document your alternative environment in a new AC.
Required: Nix with flakes (Tier-1 recommended for exact CI parity) Optional: Docker, WSL2 (if on Windows), VS Code (recommended editor)
For detailed setup by platform, troubleshooting, and Tier-2 guidance, see docs/reference/environment.md.
# Clone
git clone https://github.com/EffortlessMetrics/Rust-Template.git my-service && cd my-service
# Enter Nix devshell (installs all tools, matches CI)
nix develop
# Bootstrap (hooks, checks, tests) - 3-5 minutes first run
cargo xtask dev-upcargo run -p app-http
# → http://localhost:8080/ui (dashboard)
# → http://localhost:8080/platform/status (API)
# Smoke test
curl http://localhost:8080/health
# Expected: {"status":"ok"}Wire-level smoke (no DB, no secrets):
# Terminal 1
nix develop
cargo run -p app-http
# Terminal 2
curl -sS localhost:8080/platform/status | jq .
curl -sS localhost:8080/platform/openapi | head
curl -sS localhost:8080/platform/agent/hints | jq .Local runs do not require Postgres. The default config/local.yaml disables auto-migrate so cargo run -p app-http boots without a database. If you want DB-backed paths locally, set DATABASE_URL and run docker compose up -d.
By default, the service starts in open mode (no authentication required). For production:
# Enable JWT authentication for write endpoints
export PLATFORM_AUTH_MODE=jwt
export PLATFORM_JWT_SECRET=$(openssl rand -base64 32)
cargo run -p app-httpSee how-to/security-configuration.md for auth modes, CORS, and security headers.
During development (fast):
cargo xtask check # fmt + clippy + tests (~30s)
cargo xtask test-changed # Test what you edited (seconds to minutes)
cargo xtask test-ac AC-PLT-001 # Test specific ACBefore PR (full validation):
cargo xtask selftest # 12-step governance validation (10-20 min)Validation ladder: check → test-changed → test-ac → selftest
See SELECTIVE_TESTING.md for details.
VS Code integration is pre-configured in .vscode/:
Recommended extensions (auto-suggested on open):
- rust-analyzer (Rust language support)
- Even Better TOML (TOML syntax)
- crates (Cargo.toml dependency management)
- Docker (container support)
- Code Spell Checker (with repo dictionary)
- YAML (for spec files)
Built-in tasks (Ctrl+Shift+B / Cmd+Shift+B):
kernel: smoke(default build) - Quick validationdev: check- Fast code quality checkdev: test-changed- Test affected codekernel: selftest- Full governance validation
Debug configurations (F5):
Run app-http- Launch the service with debuggerDebug unit tests- Debug all testsDebug current test- Debug selected test
Settings configured:
- Format on save for Rust
- Clippy on save
- Spell checker with repo dictionary
- Search exclusions (target/, .llm/)
Open the command palette (Ctrl+Shift+P / Cmd+Shift+P) and type "Tasks: Run Task" to see all available tasks.
# 1. Find relevant AC
cargo xtask ac-coverage | grep HEALTH
# → ✅ AC-TPL-HEALTH-001: Service responds to /health
# 2. Edit code
# → crates/app-http/src/routes/health.rs
# 3. Test your change
cargo xtask test-changed
# 4. Validate
cargo xtask check
cargo xtask selftest # Before PRcargo xtask doctor # Check setup
cargo xtask status # Governance dashboard
cargo xtask version # Kernel versioncargo xtask check # Fast validation
cargo xtask test-changed # Test affected code
cargo xtask bdd # Run BDD scenarios
cargo xtask selftest # Full governance gatecargo xtask ac-coverage # Show AC test coverage
cargo xtask ac-status # Generate status report
cargo xtask ac-new <ID> "Desc" --requirement <REQ>
cargo xtask tasks-list # Available work itemscargo xtask docs-check # Validate docs
cargo xtask adr-new "Title" # New ADR
cargo xtask spellcheck # Run spellcheckcargo xtask policy-test # Run OPA/Rego policies
cargo xtask graph-export # Export governance graph
cargo xtask audit # Security auditcargo xtask bundle <task> # Generate LLM context
cargo xtask suggest-next --task <id> # Get workflow guidance
cargo xtask help-flows # Available flowsAcceptance Criteria (ACs): Testable behaviors in specs/spec_ledger.yaml, verified by BDD scenarios tagged @AC-XXX.
Spec Ledger: specs/spec_ledger.yaml - Stories → Requirements → ACs → Tests → Docs. Single source of truth.
Selftest: cargo xtask selftest - 12-step validation (code quality + BDD + policies + graph integrity). Must be green before merge.
Platform APIs: http://localhost:8080/platform/* - /status (health), /graph (REQ/AC/Doc graph), /tasks (work items), /agent/hints (prioritized suggestions).
Validation Ladder:
check- Fast feedback (30s)test-changed- Test affected codetest-ac <ID>- Test specific ACselftest- Full gate (10-20 min)
dev-up fails with "conftest not found"
→ Run nix develop first
selftest slow (2+ hours on Windows)
→ Expected on native Windows (Tier-2). Use WSL2 + Nix (Tier-1) for canonical validation.
AC shows ❌ in ac-coverage
→ No BDD tests wired. Run cargo xtask ac-suggest-scenarios <AC-ID>, add to specs/features/*.feature.
Policy tests fail
→ Run cargo xtask policy-test to see which policy failed. Common fixes:
- Add
testsarray to AC in spec_ledger.yaml - Add ACs for
must_have_ac: truerequirements - Fix typo in feature file tag
Humans:
- Architecture: why-this-exists.md
- Workflows: AGENT_GUIDE.md
- Testing: SELECTIVE_TESTING.md
Agents:
- Instructions: CLAUDE.md
- APIs:
/platform/agent/hintsfor prioritized work - Guidance:
cargo xtask suggest-next --task <id>
Common Tasks:
- Add feature: governed-feature-dev skill
- Fix drift: governed-maintenance skill
- Release: governed-release skill
- Integrate with IDP/portal: Integrate with IDP or Agent
In-repo:
cargo xtask help- All commandscargo xtask doctor- Environment checkhttp://localhost:8080/ui- Web dashboard
Docs:
- README.md - Overview
- CLAUDE.md - Agent instructions
- docs/AGENT_GUIDE.md - Detailed workflows
- docs/INDEX.md - Full index
Stuck?
cargo xtask doctorcargo xtask status- MISSING_MANUAL.md
You're ready! Core commands learned. Environment working. Go build.