Deployment Skill
When to use this skill
Use when setting up CI/CD pipelines, containerizing applications, configuring infrastructure, or managing releases.
Deployment Principles
1. Automate everything
- If you deploy manually more than once, automate it
- Manual steps = human error risk
2. Deploy small and often
- Small deployments are easier to debug, roll back, and understand
- Ship multiple times per day, not once per sprint
3. Rollback is always the first response
- If something breaks, revert first, investigate second
- Every deployment must be reversible within minutes
CI/CD Pipeline
Standard pipeline stages
Code Push → Lint → Typecheck → Unit Test → Build → Integration Test → Deploy → Smoke Test
| Stage |
Purpose |
Fail behavior |
| Lint |
Code style & rules |
Block merge |
| Typecheck |
Type safety |
Block merge |
| Unit test |
Logic correctness |
Block merge |
| Build |
Artifact creation |
Block deploy |
| Integration test |
Component interactions |
Block deploy |
| Deploy |
Release to environment |
Auto-rollback on failure |
| Smoke test |
Critical paths work post-deploy |
Alert + auto-rollback |
Branch strategy
| Branch |
Purpose |
Deploys to |
main |
Production-ready code |
Production |
staging |
Pre-production testing |
Staging environment |
| Feature branches |
Work in progress |
Preview environment (optional) |
Containerization
Dockerfile best practices
# 1. Use specific version tags (not :latest)
FROM node:20-alpine AS base
# 2. Copy dependency files first (cache layer)
COPY package.json package-lock.json ./
RUN npm ci --production
# 3. Copy source code (changes more often)
COPY src/ ./src/
# 4. Use multi-stage builds (smaller final image)
FROM base AS production
# ... production-only setup
# 5. Run as non-root user
USER nobody
# 6. Use health check
HEALTHCHECK CMD curl -f http://localhost:3000/health || exit 1
Container rules
- Pin base image versions —
node:20.11-alpine, not node:latest
- Multi-stage builds — separate build dependencies from runtime
- Non-root user — never run as root in production
.dockerignore — exclude node_modules, .git, tests, docs
- Health checks — containers should report their own health
- One process per container — don't bundle multiple services
Environment Management
Environment hierarchy
local → dev → staging → production
Rules
- Environment parity — staging should mirror production as closely as possible
- Environment-specific config via env vars — never hardcode URLs, credentials, or flags
- Configuration hierarchy:
- Environment variables (highest priority)
- Environment-specific config file
- Default config file (lowest priority)
Required env vars (document these)
# App
APP_PORT=3000
APP_ENV=production
LOG_LEVEL=info
# Database
DATABASE_URL=postgres://...
DATABASE_POOL_SIZE=10
# Auth
JWT_SECRET=...
SESSION_TTL_SECONDS=3600
# External services
API_KEY_SERVICE_X=...
Release Management
Versioning
Use semantic versioning (SemVer): MAJOR.MINOR.PATCH
- MAJOR — breaking changes
- MINOR — new features, backward compatible
- PATCH — bug fixes, backward compatible
Release checklist
Rollback procedure
- Detect — monitoring alerts or user reports
- Decide — rollback if fix isn't obvious within 15 minutes
- Revert — deploy previous known-good version
- Communicate — notify stakeholders
- Investigate — root-cause analysis after rollback
- Fix forward — fix the issue, deploy again
Monitoring Post-Deploy
After every deployment, watch for 30 minutes:
- Error rate (should stay flat or decrease)
- Response latency (should stay flat or decrease)
- Resource usage (CPU, memory)
- Key business metrics (conversions, signups)
Infrastructure as Code
- Define infrastructure in code — Terraform, Pulumi, CloudFormation
- Version control infra configs — same repo or dedicated infra repo
- Review infra changes like code — PR process for infrastructure
- Test in staging first — never apply untested infra changes to production
PR Checklist for Deployment Changes
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: deployment-123description: Guidelines for CI/CD, containerization, infrastructure, and release management Use when this capability is needed.4---56# Deployment Skill78## When to use this skill910Use when setting up CI/CD pipelines, containerizing applications, configuring infrastructure, or managing releases.1112---1314## Deployment Principles1516### 1. Automate everything17- If you deploy manually more than once, automate it18- Manual steps = human error risk1920### 2. Deploy small and often21- Small deployments are easier to debug, roll back, and understand22- Ship multiple times per day, not once per sprint2324### 3. Rollback is always the first response25- If something breaks, revert first, investigate second26- Every deployment must be reversible within minutes2728---2930## CI/CD Pipeline3132### Standard pipeline stages33```34Code Push → Lint → Typecheck → Unit Test → Build → Integration Test → Deploy → Smoke Test35```3637| Stage | Purpose | Fail behavior |38|-------|---------|---------------|39| **Lint** | Code style & rules | Block merge |40| **Typecheck** | Type safety | Block merge |41| **Unit test** | Logic correctness | Block merge |42| **Build** | Artifact creation | Block deploy |43| **Integration test** | Component interactions | Block deploy |44| **Deploy** | Release to environment | Auto-rollback on failure |45| **Smoke test** | Critical paths work post-deploy | Alert + auto-rollback |4647### Branch strategy48| Branch | Purpose | Deploys to |49|--------|---------|-----------|50| `main` | Production-ready code | Production |51| `staging` | Pre-production testing | Staging environment |52| Feature branches | Work in progress | Preview environment (optional) |5354---5556## Containerization5758### Dockerfile best practices59```dockerfile60# 1. Use specific version tags (not :latest)61FROM node:20-alpine AS base6263# 2. Copy dependency files first (cache layer)64COPY package.json package-lock.json ./65RUN npm ci --production6667# 3. Copy source code (changes more often)68COPY src/ ./src/6970# 4. Use multi-stage builds (smaller final image)71FROM base AS production72# ... production-only setup7374# 5. Run as non-root user75USER nobody7677# 6. Use health check78HEALTHCHECK CMD curl -f http://localhost:3000/health || exit 179```8081### Container rules82- **Pin base image versions** — `node:20.11-alpine`, not `node:latest`83- **Multi-stage builds** — separate build dependencies from runtime84- **Non-root user** — never run as root in production85- **`.dockerignore`** — exclude `node_modules`, `.git`, tests, docs86- **Health checks** — containers should report their own health87- **One process per container** — don't bundle multiple services8889---9091## Environment Management9293### Environment hierarchy94```95local → dev → staging → production96```9798### Rules99- **Environment parity** — staging should mirror production as closely as possible100- **Environment-specific config via env vars** — never hardcode URLs, credentials, or flags101- **Configuration hierarchy:**102 1. Environment variables (highest priority)103 2. Environment-specific config file104 3. Default config file (lowest priority)105106### Required env vars (document these)107```108# App109APP_PORT=3000110APP_ENV=production111LOG_LEVEL=info112113# Database114DATABASE_URL=postgres://...115DATABASE_POOL_SIZE=10116117# Auth118JWT_SECRET=...119SESSION_TTL_SECONDS=3600120121# External services122API_KEY_SERVICE_X=...123```124125---126127## Release Management128129### Versioning130Use **semantic versioning** (SemVer): `MAJOR.MINOR.PATCH`131- **MAJOR** — breaking changes132- **MINOR** — new features, backward compatible133- **PATCH** — bug fixes, backward compatible134135### Release checklist136- [ ] All CI checks pass on release branch137- [ ] Changelog updated with user-facing changes138- [ ] Database migrations tested on staging139- [ ] Feature flags set correctly for gradual rollout140- [ ] Rollback plan documented and tested141- [ ] Monitoring dashboards ready142- [ ] On-call team notified143144### Rollback procedure1451. **Detect** — monitoring alerts or user reports1462. **Decide** — rollback if fix isn't obvious within 15 minutes1473. **Revert** — deploy previous known-good version1484. **Communicate** — notify stakeholders1495. **Investigate** — root-cause analysis after rollback1506. **Fix forward** — fix the issue, deploy again151152---153154## Monitoring Post-Deploy155156After every deployment, watch for 30 minutes:157- Error rate (should stay flat or decrease)158- Response latency (should stay flat or decrease)159- Resource usage (CPU, memory)160- Key business metrics (conversions, signups)161162---163164## Infrastructure as Code165166- **Define infrastructure in code** — Terraform, Pulumi, CloudFormation167- **Version control infra configs** — same repo or dedicated infra repo168- **Review infra changes like code** — PR process for infrastructure169- **Test in staging first** — never apply untested infra changes to production170171---172173## PR Checklist for Deployment Changes174175- [ ] Pipeline tested with a dry run176- [ ] Dockerfile follows best practices (pinned versions, non-root, multi-stage)177- [ ] Environment variables documented178- [ ] Rollback procedure documented and tested179- [ ] Health checks configured180- [ ] Monitoring/alerting updated181- [ ] Staging deployment verified before production182183---184> Converted and distributed by [TomeVault](https://tomevault.io/claim/xmenq) — claim your Tome and manage your conversions.185<!-- tomevault:4.0:skill_md:2026-04-14 -->