Skip to content

Infrastructure

The /speckit.infra command creates a comprehensive infrastructure specification covering development, production, CI/CD, observability, and disaster recovery.

Overview

The infra spec is the source of truth for all deployment decisions. Actual infrastructure files (docker-compose.yml, Helm charts, .gitlab-ci.yml) should be derived from this spec.

How It Works

Phase 1: Gather Context

The command scans your project for existing infrastructure artifacts:

  • docker-compose.yml / docker-compose.*.yml — services, ports, volumes
  • Dockerfile / Dockerfile.* — build stages, base images
  • charts/ or helm/ — Helm charts, values files
  • .gitlab-ci.yml / .gitlab/ci/ — pipeline stages and jobs
  • Makefile — available targets
  • .env.template / .env.example — environment variables
  • deploy.sh / scripts/ — deployment automation
  • kubernetes-manifests/ — raw K8s manifests
  • providers/ — cloud provider configurations

It also reads the constitution and architecture spec for infrastructure-related principles.

Phase 2: Interactive Definition

Walks you through each section, pre-filling with discovered data:

bash
/speckit.infra Docker Compose for dev with PostgreSQL and Redis, Kubernetes for production on AWS

Phase 3: Generate Outputs

Creates the spec and optionally scaffolds missing files (always asks before creating).

What the Spec Covers

Development Environment (Docker Compose)

SectionDetails
ServicesImage, ports, volumes, health checks, dependencies
Environment VariablesKey vars for local dev, maps to .env.template
Feature FlagsENABLE_* pattern for optional components
VolumesMount paths, persistence settings
NetworkingIngress, DNS (*.localhost), TLS (mkcert)
ConvenienceMakefile targets (dev, test, lint, build)

Production Environment (Kubernetes/Helm)

Deployment follows a 5-phase approach:

PhasePurposeExamples
Phase 1: InfrastructureFoundation servicesIngress controller, cert-manager
Phase 2: Data LayerDatabases and storagePostgreSQL, Redis, MinIO
Phase 3: ObservabilityMonitoring stackPrometheus, Grafana, Loki, Tempo
Phase 4: PlatformPlatform servicesAuth, API gateway
Phase 5: ApplicationYour app servicesFrontend, backend, workers

For each service: namespace, replicas, resource requests/limits, auto-scaling rules, pod security.

Data Layer

  • Databases — Engine, version, purpose, dev mode (container) vs. prod mode (managed)
  • Message Brokers — RabbitMQ, Kafka, etc.
  • Caching — Redis, Memcached with eviction policies
  • Object Storage — MinIO (dev) → S3/Blob/Spaces (prod)
  • Extensions — PostGIS, TimescaleDB, etc.
  • Backup Strategy — Tool, schedule, retention, storage target

CI/CD Pipeline (GitLab)

yaml
stages:
  - test        # Unit tests, linting, type checking
  - lint        # YAML lint, Helm lint, ShellCheck
  - security    # Image scanning, secret detection, SAST
  - build       # Docker build + push to GitLab Container Registry
  - release     # Tag release, publish packages
  - deploy      # Helm upgrade --install to target cluster

Includes: container registry config, deployment strategy (staging: auto, production: manual), rollback procedures.

Observability

AreaDetails
LoggingFormat (JSON structured), aggregation (Loki), retention, correlation IDs
MetricsCollection (Prometheus), dashboards (Grafana), key alerts
TracingProtocol (OpenTelemetry), backend (Tempo), sampling rate
AlertingConditions, severity levels, notification channels

Networking & Security

  • Network Policies — Default deny + explicit allow rules
  • Secrets Management — Source, rotation schedule, consumers
  • TLS Certificates — Self-signed (dev), Let's Encrypt staging/production

Disaster Recovery

  • RPO/RTO Targets — Per component (database, object storage, full cluster)
  • Recovery Procedures — Documented steps for each failure scenario
  • Testing Schedule — When recovery is tested and last test date

Cloud Provider Matrix

Settings that vary per provider:

SettingLocalAWSAzureGCPDigitalOcean
Storage Classhostpathgp3managed-premiumpd-ssddo-block-storage
Load BalancerKind LBNLBAzure LBGCP LBDO LB
Managed DBDockerRDSAzure DBCloud SQLManaged DB

Scaffolding

After generating the spec, the command offers to create files that don't exist yet:

FilePurpose
docker-compose.ymlLocal dev services
.env.templateEnvironment variable template
MakefileConvenience targets (dev, test, lint, build, deploy)
charts/{project}/Helm chart structure
.gitlab-ci.ymlCI/CD pipeline skeleton
deploy.shPhased deployment script

Each file is generated from the infra spec. The command asks before creating each one and never overwrites existing files without confirmation.

Acceptance Scenarios

The infra spec includes built-in acceptance scenarios:

  • First-time setup: make dev starts all services within 3 minutes
  • Restart without data loss: Services restart with persisted data
  • Idempotent deployment: Re-running deploy.sh produces no changes
  • End-to-end tracing: Distributed traces span all services
  • Disaster recovery: Recovery meets defined RPO/RTO targets

Drift Detection

When the infra spec changes, re-run /speckit.infra to detect drift between the spec and actual files. The command compares the current spec against discovered artifacts and flags discrepancies.

Released under the MIT License.