/stack — Generate a Swarm Stack File
Input examples
/stack .NET API + Angular + Postgres --replicas 3
/stack worker service --replicas 2 --with-db
/stack fullstack --with-proxy (adds a Traefik front, see traefik-proxy-stack.yml)
Process
- Detect the services and their dependency order.
- For each service: base image (reuse
docker-kit/docker-conventions.mdfor the Dockerfile side),deploy:stanza perswarm-conventions.md, healthcheck. - Sensitive values → reference an
external: truesecret, never an inline env var — see/secret. - Attach all services to a stack-scoped overlay network.
- L1 approval → Write.
Mandatory rules
deploy.replicasexplicit for every service — never rely on the Swarm default of 1resources.limits+.reservationsboth setupdate_config+rollback_configboth set — a rollout with no rollback plan is incomplete- Secrets via
docker secret— never plain env vars for passwords/keys/tokens - Stateful services (db, anything with local volume) get
placement.constraints - No inline Ingress — routing by hostname needs a proxy front (
--with-proxy), Swarm has no Ingress resource
Output
docker-stack.yml
.env.example (placeholders only — real secrets are never written to a file the agent generates)
References
- @.claude/rules/swarm-conventions.md
- @../../docker-kit/.claude/rules/docker-conventions.md