From codebrain
Deployment orchestration and environment management. Handles deploy commands, env vars, CI/CD pipelines, promote/rollback procedures. Platform-agnostic: supports Vercel, Docker, Fly.io, Railway, and custom CI/CD. Use when deploying, setting up pipelines, or managing environments.
npx claudepluginhub chrsmay/codebrain-plugin --plugin codebrainThis skill uses the workspace's default tool permissions.
Deployment orchestration and environment management. Platform-agnostic.
Creates isolated Git worktrees for feature branches with prioritized directory selection, gitignore safety checks, auto project setup for Node/Python/Rust/Go, and baseline verification.
Executes implementation plans in current session by dispatching fresh subagents per independent task, with two-stage reviews: spec compliance then code quality.
Dispatches parallel agents to independently tackle 2+ tasks like separate test failures or subsystems without shared state or dependencies.
Deployment orchestration and environment management. Platform-agnostic.
/codebrain:deploy [target]
Before any deployment, verify:
Build passes locally
npm run build 2>&1 | tail -5
# Should exit 0 with no errors
Tests pass
npm test 2>&1 | tail -10
Environment variables are set
.env.example or .env.sample for required vars.env.local or files containing secretsNo uncommitted changes
git status --porcelain
# Should be empty
Branch is up to date
git pull --rebase origin main
Auto-detect deployment platform from project files:
| File | Platform |
|---|---|
vercel.json or .vercel/ | Vercel |
Dockerfile | Docker (+ any orchestrator) |
fly.toml | Fly.io |
railway.json | Railway |
netlify.toml | Netlify |
.github/workflows/deploy* | GitHub Actions (custom) |
Procfile | Heroku-compatible |
# Preview deployment
vercel
# Production deployment
vercel --prod
# Promote a preview to production (no rebuild)
vercel promote <deployment-url>
# Rollback to previous production
vercel rollback
# Pull environment variables
vercel env pull .env.local
# View deployment logs
vercel logs <deployment-url>
# Inspect deployment details
vercel inspect <deployment-url>
# Build image
docker build -t myapp:latest .
# Test locally
docker run -p 3000:3000 --env-file .env.local myapp:latest
# Push to registry
docker push registry.example.com/myapp:latest
# Deploy
fly deploy
# View logs
fly logs
# Scale
fly scale count 2
# Rollback
fly releases list
fly deploy --image registry.fly.io/myapp:v<N>
# .github/workflows/deploy.yml
name: Deploy
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm ci
- run: npm test
- run: npm run build
# Platform-specific deploy step here
.env — base defaults (committed, no secrets).env.local — local overrides (gitignored, has secrets).env.production — production-specific (committed, no secrets).env.production.local — production secrets (gitignored)Check for required variables before deploy:
# Extract required vars from code
grep -rh "process.env\.\w\+" --include="*.ts" --include="*.js" | \
grep -oP 'process\.env\.(\w+)' | sort -u
Compare against what's set in the target environment.
Identify the last working deployment
vercel ls --limit 5 # or equivalent
Rollback immediately (don't debug in production)
vercel rollback # or equivalent
Verify rollback succeeded
Investigate the failure separately
/codebrain:observe or /codebrain:investigateAfter every deployment:
# Deployment Report
**Target:** [staging | production]
**Platform:** [Vercel | Docker | Fly.io | ...]
**Date:** [ISO date]
**Commit:** [short SHA + message]
**URL:** [deployment URL]
## Pre-Deploy Checks
| Check | Status |
|-------|--------|
| Build | PASS |
| Tests | PASS |
| Env Vars | PASS |
| Clean working tree | PASS |
## Deployment
- Command: `vercel --prod`
- Duration: [time]
- Status: SUCCESS | FAILED
## Post-Deploy Verification
| Check | Status | Notes |
|-------|--------|-------|
| Health endpoint | PASS | 200 OK in 120ms |
| Smoke tests | PASS | All critical flows work |
| Error monitoring | PASS | No new errors |
| Performance | PASS | p95 latency < 500ms |