From factory
Use when the user wants to "deploy", "ship it", "push to production", "go live", "release", "deploy to alpha", "deploy to staging", or when the product is ready to be shipped to an environment. Handles three environments (alpha, staging, prod) with a promotion model and per-environment gates.
How this skill is triggered — by the user, by Claude, or both
Slash command
/factory:deployThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Deploy source code to one of three environments: alpha, staging, or
Deploy source code to one of three environments: alpha, staging, or production. Follows a promotion model where code moves through environments as it clears successive gates. Verifies prerequisites, executes the deployment, confirms health, and produces a receipt.
Parameter: target environment — alpha, staging, or prod
(default: prod).
| Environment | App Name | Deploy Command | Gates Required |
|---|---|---|---|
| Alpha | {app}-alpha | manifest deploy_command (alpha) | None |
| Staging | {app}-staging | manifest deploy_command (staging) | QA pass |
| Prod | {app} | manifest deploy_command (prod) | QA pass + security clear |
/qa passes. Smoke tests run here./security
clearance and explicit user confirmation. Full health checks and automatic
rollback enforced.Read and execute ALL [MANDATORY] sections in GLOBAL-REFERENCE.md:
{PHASE_NAME} = deploy{OUTPUT_FILES} = ["DEPLOY-RECEIPT.md"]Also read and follow the Gate Verification section in GLOBAL-REFERENCE.md.
Additional state fields for this skill:
On start, also include:
"target_environment": "<alpha|staging|prod>"On failure, also include:
"outputs": ["DEPLOY-RECEIPT.md"] (receipt is always produced)Check that all prerequisites are met for the target environment.
Alpha — no gates required. Skip this step entirely.
Staging:
QA-REPORT.md and parse the ## Summary section. Extract the
Overall status field directly from the file content. Verify it is
PASS or PASS WITH WARNINGS. If missing or not passing, halt — do
not deploy. Do NOT trust .factory/state.json for gate status — always
read the actual report file.Tested commit field in QA-REPORT.md matches the current
git rev-parse HEAD. If it does not match, the report is stale — halt
and inform the user that QA must be re-run.gh run list or equivalent.Prod:
QA-REPORT.md and parse the ## Summary section. Extract the
Overall status field directly from the file content. Verify it is
PASS or PASS WITH WARNINGS. If missing or not passing, halt — do
not deploy. Do NOT trust .factory/state.json for gate status.SECURITY.md and parse the ## Summary section. Extract the
Overall status field directly from the file content. Verify it is
CLEAR or WARNINGS (not BLOCKED). If missing or BLOCKED, halt
— do not deploy. Do NOT trust .factory/state.json for gate status.Tested commit field in both QA-REPORT.md and
SECURITY.md matches the current git rev-parse HEAD. If either
does not match, the report is stale — halt and inform the user.gh run list or equivalent.If any hard gate fails (security BLOCKED, QA not passing, CI failing),
stop immediately. Write DEPLOY-RECEIPT.md with status: FAILED and the
reason, then exit.
Read the deployment manifest and verify the environment is ready.
Read .factory/deploy-config.json. This file is the source of truth for
deployment configuration — it tells you the platform, app names, deploy
commands, health check paths, and URLs for each environment.
If the file does not exist, halt with an actionable error:
No deployment manifest found at .factory/deploy-config.json.
Run /setup to generate the deployment configuration, or create
the file manually with the required fields (see SPEC-deploy.md).
Extract from the manifest for the target environment:
app_name — the Fly.io app name (or equivalent for other platforms)deploy_command — the exact command to runurl — the base URL for health checks and smoke testsregion — for the deployment receipthealth_check_path — the endpoint to verify after deployrollback_command — the command to roll back if neededUse these values throughout Steps 3-5 instead of hardcoded assumptions.
secrets_command from the manifest — never log or echo
secret values).Execute the deployment using values from the deployment manifest:
deploy_command from the manifest for the target environment.url and health_check_path from the manifest for
post-deploy verification (Step 4).Verification depends on the target environment.
Alpha — no verification required. Deploy is complete once the deploy command succeeds.
Staging:
Prod:
If any verification step fails on prod, proceed to automatic rollback. If verification fails on staging, record the failure and notify the user.
Write DEPLOY-RECEIPT.md with the full deployment record. If a previous
DEPLOY-RECEIPT.md exists, rename it to DEPLOY-RECEIPT-[timestamp].md
before writing the new one. See the Output Template section below.
/qa completes with status PASS or PASS WITH WARNINGS.target: staging./security completes with status CLEAR or WARNINGS.target: prod.The promotion chain ensures code reaching production has been validated in alpha, tested by QA in staging, and cleared by security.
If any post-deploy health check or smoke test fails on prod:
rollback_command from the
deployment manifest for the target environment. Do not wait for
manual intervention.DEPLOY-RECEIPT.md status to ROLLED BACK
with the failure reason, the version rolled back to, and diagnostic
output..factory/state.json deploy phase to failed
with failure_reason explaining what went wrong and that rollback was
performed.A broken production deployment must never stay live. If the rollback itself fails, document that in the receipt and escalate to the user with clear next steps.
If post-deploy verification fails on staging:
DEPLOY-RECEIPT.md with status: FAILED and
diagnostic details.rollback_command for the staging environment).Alpha deployments have no rollback mechanism. If a deploy to alpha fails
or the app is unhealthy, the next /build cycle will deploy a new version.
Record the failure in the receipt but take no rollback action.
# Deployment Receipt — [Date]
## Deployment
- **Status**: SUCCESS / FAILED / ROLLED BACK
- **Version**: [git commit SHA]
- **Previous version**: [git commit SHA]
- **Environment**: alpha / staging / prod
- **App name**: [app name used in deploy command]
- **Platform**: Fly.io
- **Region**: [region]
- **Deployed at**: [ISO 8601 timestamp]
## Gate Checks
| Gate | Required | Status | Notes |
|------|----------|--------|-------|
| QA Report | YES/NO | PASS / WARN / MISSING / SKIPPED | [details] |
| Security Report | YES/NO | CLEAR / WARN / MISSING / SKIPPED | [details] |
| CI Checks | YES/NO | PASS / FAIL / SKIPPED | [details] |
| User Confirmation | YES/NO | CONFIRMED / SKIPPED | [details] |
## Health Checks
| Endpoint | Status | Response Time | Expected |
|----------|--------|---------------|----------|
| /health | 200 | 45ms | 200 |
_(Skipped for alpha deployments.)_
## Smoke Tests
| Test | Status | Notes |
|------|--------|-------|
| [test name] | PASS / FAIL | [details] |
_(Skipped for alpha deployments.)_
## Telemetry
- **Traces flowing**: YES / NO / SKIPPED
- **Error rate**: [percentage] (baseline: [percentage])
## Rollback Info
- **Previous version**: [commit SHA]
- **Rollback command**: `fly releases rollback --app {app-name}`
- **Rollback behavior**: AUTOMATIC (prod) / MANUAL (staging) / N/A (alpha)
- **Rollback performed**: YES / NO / N/A
- **Rollback reason**: [if applicable]
## Diagnostics
[If status is FAILED or ROLLED BACK, include relevant logs, error
messages, and the exact step where failure occurred.]
settings:
- name: auto_archive_receipts
type: boolean
default: true
description: >
Automatically rename existing DEPLOY-RECEIPT.md to
DEPLOY-RECEIPT-{timestamp}.md before writing a new receipt.
When false, overwrite the existing receipt without archiving.
BLOCKED
status from SECURITY.md. Critical issues must be fixed first.secrets_command (names only), never
display secret values.DEPLOY-RECEIPT.md, even on
failure. The receipt is the audit trail.DEPLOY-RECEIPT.md exists, rename it to
DEPLOY-RECEIPT-[timestamp].md before writing the new one.Creates, edits, and optimizes skills for Claude Code, including drafting, evaluating with test prompts, iterating on performance, and improving skill descriptions for better triggering accuracy.
npx claudepluginhub whalbawi/factory --plugin factory