cmd/sgai/skel/.sgai/skills/deployment/SKILL.md
MANDATORY when GOAL.md mentions deploying, shipping, releasing, or publishing built artifacts to any environment - reads deployment instructions from the .deploy/ directory, enforces pre-deployment verification, artifact integrity checks, deployment execution safety, post-deployment validation, and rollback planning; prevents deploying without tests, skipping rollback plans, or bypassing environment validation. When GOAL.md says deploy, ship, release, publish, or push artifact to production/staging/server.
npx skillsauth add sandgardenhq/sgai deploymentInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Deployment of built artifacts requires mandatory safety gates. This skill reads deployment instructions from the .deploy/ directory and enforces a structured safety process around them.
Three-part model:
| Concern | Location | Role |
|---------|----------|------|
| What to deploy | GOAL.md | Declares deployment intent ("deploy the app to staging") |
| How to deploy | .deploy/ | Contains deployment commands, targets, health checks, rollback procedures |
| Safely deploying | This skill | Enforces safety gates, checklists, and rollback planning |
Core principle: No artifact leaves the build environment without passing every gate. No deployment proceeds without a rollback plan. All deployment instructions come from .deploy/.
Violating the letter of this rule is violating the spirit of this rule.
Announce at start: "I'm using the deployment skill to ensure safe artifact deployment."
This skill is MANDATORY when GOAL.md contains any deployment intent. Scan GOAL.md for:
If ANY of these appear in GOAL.md in the context of deploying a built artifact, this skill must be loaded and followed. No exceptions.
Not applicable when:
Before any gates, read .deploy/ to understand the deployment procedure.
Read the contents of the .deploy/ directory at the repository root. From it, extract:
If .deploy/ contains environment-specific subdirectories, identify which environment GOAL.md is targeting and read the relevant subdirectory.
If .deploy/ does not exist:
.deploy/README.md with deployment instructions based on what you can infer from the project (build system, artifact type, any deployment hints in the codebase).deploy/ contents are correct.The skill never guesses deployment commands at execution time. All deployment commands must be documented in .deploy/ and confirmed by the user before any deployment proceeds.
.deploy/ check:
directory exists: [YES/DRAFTING]
instructions loaded: [YES/NO]
artifact identified: [YES/NO]
target identified: [YES/NO]
deploy command found: [YES/NO]
rollback found: [YES/NO]
health check found: [YES/NO]
ALL must show YES before proceeding to Step 1.
DRAFTING = draft .deploy/README.md, present to user, STOP until confirmed.
No deployment proceeds until ALL gates pass.
completionGateScript, run it and verify it passes.Gate check:
tests: [PASS/FAIL]
build: [PASS/FAIL]
lint: [PASS/FAIL]
completionGate: [PASS/FAIL/N/A]
version: [SET/MISSING]
debug config: [CLEAN/FOUND]
ALL must show PASS/SET/CLEAN before proceeding.
Any FAIL/MISSING/FOUND = STOP. Fix before continuing.
Verify the artifact at the path specified in .deploy/.
.deploy/.Validate the target environment documented in .deploy/. Use the validation commands from .deploy/ if provided.
Environment check:
target reachable: [YES/NO]
services up: [YES/NO]
config validated: [YES/NO]
resources ok: [YES/NO]
no incidents: [YES/NO]
ALL must show YES before proceeding.
MANDATORY. No deployment without a documented rollback.
Use the rollback procedure from .deploy/ as the basis. Verify it is complete and current.
.deploy/ contains step-by-step instructions to revert.If .deploy/ does not include rollback instructions, STOP. Add rollback instructions to .deploy/ and get user confirmation before proceeding.
Execute the deployment command documented in .deploy/.
.deploy/. Do not improvise.Deployment log:
artifact: [name and version]
target: [environment from .deploy/]
command: [command from .deploy/]
started: [timestamp]
completed: [timestamp]
status: [SUCCESS/FAILED]
deployed by: [agent/user]
If deployment fails: Stop. Do NOT retry blindly. Investigate the failure. If the failure is understood and fixable, fix and restart from Step 1.
Run the health checks and verification steps documented in .deploy/.
.deploy/ return healthy..deploy/.Post-deployment verification:
service running: [YES/NO]
health checks: [PASS/FAIL]
smoke tests: [PASS/FAIL]
error rate: [NORMAL/ELEVATED]
performance: [OK/DEGRADED]
ALL must show YES/PASS/NORMAL/OK.
Any NO/FAIL/ELEVATED/DEGRADED = Execute rollback plan from .deploy/.
.deploy/ Directory.deploy/ is a free-form directory at the repository root. It is the single source of truth for how deployment works for this project. The skill makes no assumptions about its internal structure beyond: the contents must be readable and must describe the deployment procedure.
Simple project:
.deploy/
README.md # all deployment instructions in one file
Multi-environment:
.deploy/
README.md # shared instructions, overview
staging/
README.md # staging-specific commands and targets
production/
README.md # production-specific commands and targets
Script-based:
.deploy/
README.md # overview and manual steps
deploy.sh # deployment script
rollback.sh # rollback script
health-check.sh # health check script
Container-based:
.deploy/
README.md # overview
Dockerfile # container build
docker-compose.yml # orchestration
k8s/
deployment.yaml
service.yaml
.deploy/ for a New ProjectWhen .deploy/ does not exist and this skill is activated, draft a .deploy/README.md with the following structure, filled in from project context:
# Deployment Instructions
## Artifact
- Name: [inferred from project]
- Build command: [inferred from build system]
- Output path: [inferred from build output]
## Target
- Host: [ask user if not inferable]
- Method: [scp, docker push, kubectl apply, etc.]
- Deploy command: [the actual command to run]
## Health Check
- URL or command: [health endpoint or verification command]
- Expected result: [HTTP 200, exit code 0, etc.]
## Rollback
- Procedure: [step-by-step rollback commands]
- Time estimate: [duration]
- Trigger: [conditions that require rollback]
## Environment Validation
- Reachability: [command to verify target is accessible]
- Services: [command to verify dependencies are running]
After drafting, present it to the user and STOP until confirmed.
.deploy/ - If .deploy/ does not exist or is empty, draft it and wait for user confirmation. Never deploy without documented instructions.deploy is negligence..deploy/ immediately. Do not "wait and see.".deploy/ says. If .deploy/ is wrong, fix .deploy/ first, then redeploy.| Excuse | Reality |
|--------|---------|
| "Tests passed last time" | Run them NOW. Code may have changed. Dependencies may have changed. |
| "It's just a small change" | Small changes break production. The size of the change does not reduce the risk. |
| "We can fix it in production" | Fix it BEFORE deploying. Production fixes under pressure create more bugs. |
| "Rollback is obvious" | Document it in .deploy/. Under stress, "obvious" becomes "forgotten." |
| "Staging is the same as production" | Validate production separately. Configuration, data, and load differ. |
| "We don't have time for all these checks" | You don't have time for a production outage. Checks take minutes, outages take hours. |
| "It works on my machine" | Your machine is not production. Verify in the target environment. |
| "The team is waiting" | The team prefers a working deployment over a fast broken one. |
| "We'll verify after" | After deployment is too late if it's broken. Verify BEFORE and AFTER. |
| "This deployment is low risk" | All deployments carry risk. Low-risk assessments are often wrong. |
| "CI passed, so it's fine" | CI is necessary but not sufficient. Environment-specific issues exist. |
| "We can always roll back" | Not if you didn't plan and test the rollback. |
| "Skip staging, deploy to prod directly" | Staging exists for a reason. Every environment skip increases risk. |
| "Human partner already validated the environment" | Validate independently. Trust but verify. Someone else's check is not your check. |
| "Automated backups handle rollback" | Automated backups are not a rollback plan. A rollback plan has documented procedure, trigger conditions, and time estimate. Backups are a tool, not a plan. |
| "I checked the environment last deployment" | Stale checks are not checks. Validate fresh every time. State changes between deployments. |
| "This is an emergency, skip the process" | The process IS the emergency response. It's designed to take 10-15 minutes. Skipping it risks turning a 30-minute outage into a multi-hour incident. |
| "I'll just add a quick health check instead of full verification" | A health check is one step of six. Partial compliance is non-compliance. |
| "The previous engineer said just SCP and restart" | Someone else's shortcut is not your deployment process. Follow the skill. |
| "I know how to deploy this, I don't need .deploy/" | Document it in .deploy/ anyway. Knowledge in your head is not a deployment procedure. |
| "I'll just run the command I found in the CI config" | CI config is not .deploy/. If it's correct, put it in .deploy/. |
If you find yourself thinking or saying any of these, STOP and re-read this skill:
.deploy/ first)No special exception. The deployment process is designed to complete in 10-15 minutes total. Skipping steps to save 10 minutes risks hours of extended outage.
Key insight: An unverified fix that makes the outage worse is worse than 10 more minutes of known downtime.
Emergency pressure makes this skill MORE important, not less:
What to do in an emergency:
.deploy/ should already exist. If it does not, this is a planning failure - address it, do not skip it.When a human partner, manager, or senior engineer tells you to skip steps:
You are not being difficult. You are being reliable. The skill exists precisely for moments when someone says "just deploy it."
Loading deployment instructions from .deploy/README.md...
.deploy/ check:
directory exists: YES
instructions loaded: YES
artifact identified: YES (myapp, built via `make build`, output at ./build/myapp)
target identified: YES (prod-server via scp)
deploy command found: YES (scp ./build/myapp prod-server:/opt/myapp && ssh prod-server 'systemctl restart myapp')
rollback found: YES (ssh prod-server 'cp /opt/myapp.bak /opt/myapp && systemctl restart myapp')
health check found: YES (curl -f https://prod-server/health)
Pre-deployment gate:
tests: PASS (147/147)
build: PASS (exit 0)
lint: PASS (0 errors)
completionGate: PASS (make test exit 0)
version: SET (v2.1.0)
debug config: CLEAN
Artifact verification:
path: ./build/myapp (from .deploy/)
sha256: a1b2c3d4e5f6...
size: 14.2MB (expected: 12-16MB)
dev artifacts: NONE
Environment validation:
target reachable: YES (ssh prod-server OK)
services up: YES (postgres, redis healthy)
config validated: YES (env vars match production)
resources ok: YES (disk 60% free, 4GB RAM available)
no incidents: YES
Rollback plan (from .deploy/):
Currently deployed: v2.0.3
Rollback: ssh prod-server 'cp /opt/myapp.bak /opt/myapp && systemctl restart myapp'
Trigger: health check fails or error rate > 1%
Time estimate: 2 minutes
Deployment (executing command from .deploy/):
Command: scp ./build/myapp-v2.1.0 prod-server:/opt/myapp && ssh prod-server 'systemctl restart myapp'
Status: SUCCESS
Time: 14:32:07 UTC
Post-deployment verification (checks from .deploy/):
service running: YES (PID 12345)
health checks: PASS (curl -f https://prod-server/health returns 200)
smoke tests: PASS (login, dashboard, API)
error rate: NORMAL (0.02%)
performance: OK (p99: 180ms)
Deployment complete. v2.1.0 is live.
.deploy/ for a New ProjectGOAL.md says: "Deploy the API server to the staging environment."
Checking for .deploy/ directory... NOT FOUND.
Scanning project structure:
- Go project with Makefile
- Build target: make build → ./bin/api-server
- Dockerfile present
- No existing deployment scripts
Drafting .deploy/README.md:
# Deployment Instructions
## Artifact
- Name: api-server
- Build command: make build
- Output path: ./bin/api-server
## Target
- Host: [NEEDS USER INPUT]
- Method: [NEEDS USER INPUT - scp, docker push, etc.]
- Deploy command: [NEEDS USER INPUT]
## Health Check
- URL or command: [NEEDS USER INPUT]
- Expected result: HTTP 200
## Rollback
- Procedure: [NEEDS USER INPUT]
- Time estimate: [NEEDS USER INPUT]
- Trigger: health check failure or error rate spike
## Environment Validation
- Reachability: [NEEDS USER INPUT]
- Services: [NEEDS USER INPUT]
STOPPED. Presenting draft to user for review and completion.
Deployment will not proceed until .deploy/ is confirmed.
.deploy/WRONG:
"I can see from the Makefile how to deploy, I'll just run it."
→ Document it in .deploy/ first. Undocumented deployment commands are not deployment procedures.
"Tests passed yesterday, deploying now."
→ Tests must be run fresh. Yesterday's results are stale.
"Deploying to production, will check if it works after."
→ Post-deployment verification is mandatory, but so is pre-deployment verification.
"No rollback plan needed, it's a simple update."
→ Every deployment needs a rollback plan in .deploy/. No exceptions.
".deploy/ exists but it's from last month, probably still correct."
→ Verify .deploy/ is current before every deployment. Stale instructions are wrong instructions.
Before marking deployment complete, verify:
.deploy/ loaded: instructions read and understood.deploy/, correct version, integrity checked.deploy/.deploy/, tested/verified, trigger defined.deploy/ ran, monitored, logged.deploy/ pass, no errorsPairs with:
documentation
Start, stop, and steer agentic sessions in sgai workspaces. Use when you need to launch AI agent sessions, halt running sessions, or inject steering instructions to guide the agent mid-execution without stopping it.
development
Monitor sgai workspace status, events, progress, diffs, and workflow diagrams. Use when you need to observe what agents are doing, track progress, get the current state of all workspaces, subscribe to real-time updates via SSE, or inspect code changes.
development
Access agents, skills, and code snippets available in sgai workspaces. Use when you need to discover what agents are defined in a workspace, browse available skills, get skill instructions, find code snippets by language, or retrieve snippet content for a specific task.
data-ai
Handle agent questions and work gates in sgai workspaces. Use when an agent is blocked waiting for human input, when you need to respond to multi-choice questions, approve work gates, or provide free-text answers to agent queries.