@patricio0312rev/skillset 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/LICENSE +21 -0
  3. package/README.md +176 -0
  4. package/bin/cli.js +37 -0
  5. package/package.json +55 -0
  6. package/src/commands/init.js +301 -0
  7. package/src/index.js +168 -0
  8. package/src/lib/config.js +200 -0
  9. package/src/lib/generator.js +166 -0
  10. package/src/utils/display.js +95 -0
  11. package/src/utils/readme.js +196 -0
  12. package/src/utils/tool-specific.js +233 -0
  13. package/templates/ai-engineering/agent-orchestration-planner/ SKILL.md +266 -0
  14. package/templates/ai-engineering/cost-latency-optimizer/ SKILL.md +270 -0
  15. package/templates/ai-engineering/doc-to-vector-dataset-generator/ SKILL.md +239 -0
  16. package/templates/ai-engineering/evaluation-harness/ SKILL.md +219 -0
  17. package/templates/ai-engineering/guardrails-safety-filter-builder/ SKILL.md +226 -0
  18. package/templates/ai-engineering/llm-debugger/ SKILL.md +283 -0
  19. package/templates/ai-engineering/prompt-regression-tester/ SKILL.md +216 -0
  20. package/templates/ai-engineering/prompt-template-builder/ SKILL.md +393 -0
  21. package/templates/ai-engineering/rag-pipeline-builder/ SKILL.md +244 -0
  22. package/templates/ai-engineering/tool-function-schema-designer/ SKILL.md +219 -0
  23. package/templates/architecture/adr-writer/ SKILL.md +250 -0
  24. package/templates/architecture/api-versioning-deprecation-planner/ SKILL.md +331 -0
  25. package/templates/architecture/domain-model-boundaries-mapper/ SKILL.md +300 -0
  26. package/templates/architecture/migration-planner/ SKILL.md +376 -0
  27. package/templates/architecture/performance-budget-setter/ SKILL.md +318 -0
  28. package/templates/architecture/reliability-strategy-builder/ SKILL.md +286 -0
  29. package/templates/architecture/rfc-generator/ SKILL.md +362 -0
  30. package/templates/architecture/scalability-playbook/ SKILL.md +279 -0
  31. package/templates/architecture/system-design-generator/ SKILL.md +339 -0
  32. package/templates/architecture/tech-debt-prioritizer/ SKILL.md +329 -0
  33. package/templates/backend/api-contract-normalizer/ SKILL.md +487 -0
  34. package/templates/backend/api-endpoint-generator/ SKILL.md +415 -0
  35. package/templates/backend/auth-module-builder/ SKILL.md +99 -0
  36. package/templates/backend/background-jobs-designer/ SKILL.md +166 -0
  37. package/templates/backend/caching-strategist/ SKILL.md +190 -0
  38. package/templates/backend/error-handling-standardizer/ SKILL.md +174 -0
  39. package/templates/backend/rate-limiting-abuse-protection/ SKILL.md +147 -0
  40. package/templates/backend/rbac-permissions-builder/ SKILL.md +158 -0
  41. package/templates/backend/service-layer-extractor/ SKILL.md +269 -0
  42. package/templates/backend/webhook-receiver-hardener/ SKILL.md +211 -0
  43. package/templates/ci-cd/artifact-sbom-publisher/ SKILL.md +236 -0
  44. package/templates/ci-cd/caching-strategy-optimizer/ SKILL.md +195 -0
  45. package/templates/ci-cd/deployment-checklist-generator/ SKILL.md +381 -0
  46. package/templates/ci-cd/github-actions-pipeline-creator/ SKILL.md +348 -0
  47. package/templates/ci-cd/monorepo-ci-optimizer/ SKILL.md +298 -0
  48. package/templates/ci-cd/preview-environments-builder/ SKILL.md +187 -0
  49. package/templates/ci-cd/quality-gates-enforcer/ SKILL.md +342 -0
  50. package/templates/ci-cd/release-automation-builder/ SKILL.md +281 -0
  51. package/templates/ci-cd/rollback-workflow-builder/ SKILL.md +372 -0
  52. package/templates/ci-cd/secrets-env-manager/ SKILL.md +242 -0
  53. package/templates/db-management/backup-restore-runbook-generator/ SKILL.md +505 -0
  54. package/templates/db-management/data-integrity-auditor/ SKILL.md +505 -0
  55. package/templates/db-management/data-retention-archiving-planner/ SKILL.md +430 -0
  56. package/templates/db-management/data-seeding-fixtures-builder/ SKILL.md +375 -0
  57. package/templates/db-management/db-performance-watchlist/ SKILL.md +425 -0
  58. package/templates/db-management/etl-sync-job-builder/ SKILL.md +457 -0
  59. package/templates/db-management/multi-tenant-safety-checker/ SKILL.md +398 -0
  60. package/templates/db-management/prisma-migration-assistant/ SKILL.md +379 -0
  61. package/templates/db-management/schema-consistency-checker/ SKILL.md +440 -0
  62. package/templates/db-management/sql-query-optimizer/ SKILL.md +324 -0
  63. package/templates/foundation/changelog-writer/ SKILL.md +431 -0
  64. package/templates/foundation/code-formatter-installer/ SKILL.md +320 -0
  65. package/templates/foundation/codebase-summarizer/ SKILL.md +360 -0
  66. package/templates/foundation/dependency-doctor/ SKILL.md +163 -0
  67. package/templates/foundation/dev-environment-bootstrapper/ SKILL.md +259 -0
  68. package/templates/foundation/dev-onboarding-builder/ SKILL.md +556 -0
  69. package/templates/foundation/docs-starter-kit/ SKILL.md +574 -0
  70. package/templates/foundation/explaining-code/SKILL.md +13 -0
  71. package/templates/foundation/git-hygiene-enforcer/ SKILL.md +455 -0
  72. package/templates/foundation/project-scaffolder/ SKILL.md +65 -0
  73. package/templates/foundation/project-scaffolder/references/templates.md +126 -0
  74. package/templates/foundation/repo-structure-linter/ SKILL.md +0 -0
  75. package/templates/foundation/repo-structure-linter/references/conventions.md +98 -0
  76. package/templates/frontend/animation-micro-interaction-pack/ SKILL.md +41 -0
  77. package/templates/frontend/component-scaffold-generator/ SKILL.md +562 -0
  78. package/templates/frontend/design-to-component-translator/ SKILL.md +547 -0
  79. package/templates/frontend/form-wizard-builder/ SKILL.md +553 -0
  80. package/templates/frontend/frontend-refactor-planner/ SKILL.md +37 -0
  81. package/templates/frontend/i18n-frontend-implementer/ SKILL.md +44 -0
  82. package/templates/frontend/modal-drawer-system/ SKILL.md +377 -0
  83. package/templates/frontend/page-layout-builder/ SKILL.md +630 -0
  84. package/templates/frontend/state-ux-flow-builder/ SKILL.md +23 -0
  85. package/templates/frontend/table-builder/ SKILL.md +350 -0
  86. package/templates/performance/alerting-dashboard-builder/ SKILL.md +162 -0
  87. package/templates/performance/backend-latency-profiler-helper/ SKILL.md +108 -0
  88. package/templates/performance/caching-cdn-strategy-planner/ SKILL.md +150 -0
  89. package/templates/performance/capacity-planning-helper/ SKILL.md +242 -0
  90. package/templates/performance/core-web-vitals-tuner/ SKILL.md +126 -0
  91. package/templates/performance/incident-runbook-generator/ SKILL.md +162 -0
  92. package/templates/performance/load-test-scenario-builder/ SKILL.md +256 -0
  93. package/templates/performance/observability-setup/ SKILL.md +232 -0
  94. package/templates/performance/postmortem-writer/ SKILL.md +203 -0
  95. package/templates/performance/structured-logging-standardizer/ SKILL.md +122 -0
  96. package/templates/security/auth-security-reviewer/ SKILL.md +428 -0
  97. package/templates/security/dependency-vulnerability-triage/ SKILL.md +495 -0
  98. package/templates/security/input-validation-sanitization-auditor/ SKILL.md +76 -0
  99. package/templates/security/pii-redaction-logging-policy-builder/ SKILL.md +65 -0
  100. package/templates/security/rbac-policy-tester/ SKILL.md +80 -0
  101. package/templates/security/secrets-scanner/ SKILL.md +462 -0
  102. package/templates/security/secure-headers-csp-builder/ SKILL.md +404 -0
  103. package/templates/security/security-incident-playbook-generator/ SKILL.md +76 -0
  104. package/templates/security/security-pr-checklist-skill/ SKILL.md +62 -0
  105. package/templates/security/threat-model-generator/ SKILL.md +394 -0
  106. package/templates/testing/contract-testing-builder/ SKILL.md +492 -0
  107. package/templates/testing/coverage-strategist/ SKILL.md +436 -0
  108. package/templates/testing/e2e-test-builder/ SKILL.md +382 -0
  109. package/templates/testing/flaky-test-detective/ SKILL.md +416 -0
  110. package/templates/testing/integration-test-builder/ SKILL.md +525 -0
  111. package/templates/testing/mocking-assistant/ SKILL.md +383 -0
  112. package/templates/testing/snapshot-test-refactorer/ SKILL.md +375 -0
  113. package/templates/testing/test-data-factory-builder/ SKILL.md +449 -0
  114. package/templates/testing/test-reporting-triage-skill/ SKILL.md +469 -0
  115. package/templates/testing/unit-test-generator/ SKILL.md +548 -0
@@ -0,0 +1,281 @@
1
+ ---
2
+ name: release-automation-builder
3
+ description: Automates releases and package publishing with changesets or semantic-release. Handles versioning, changelog generation, git tags, and release notes. Use for "release automation", "semantic versioning", "package publishing", or "changelog generation".
4
+ ---
5
+
6
+ # Release Automation Builder
7
+
8
+ Automate releases with versioning, changelogs, and publishing.
9
+
10
+ ## Using Changesets
11
+
12
+ ### Setup
13
+
14
+ ```bash
15
+ npm install -D @changesets/cli
16
+ npx changeset init
17
+ ```
18
+
19
+ ### Workflow
20
+
21
+ ```yaml
22
+ # .github/workflows/release.yml
23
+ name: Release
24
+
25
+ on:
26
+ push:
27
+ branches:
28
+ - main
29
+
30
+ concurrency: ${{ github.workflow }}-${{ github.ref }}
31
+
32
+ jobs:
33
+ release:
34
+ name: Release
35
+ runs-on: ubuntu-latest
36
+ steps:
37
+ - uses: actions/checkout@v4
38
+ with:
39
+ fetch-depth: 0
40
+
41
+ - uses: actions/setup-node@v4
42
+ with:
43
+ node-version: "20"
44
+ cache: "npm"
45
+
46
+ - run: npm ci
47
+
48
+ - name: Create Release Pull Request or Publish
49
+ uses: changesets/action@v1
50
+ with:
51
+ publish: npm run release
52
+ commit: "chore: release packages"
53
+ title: "chore: release packages"
54
+ env:
55
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
56
+ NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
57
+ ```
58
+
59
+ ### Package Scripts
60
+
61
+ ```json
62
+ {
63
+ "scripts": {
64
+ "changeset": "changeset",
65
+ "version": "changeset version",
66
+ "release": "changeset publish"
67
+ }
68
+ }
69
+ ```
70
+
71
+ ## Using Semantic Release
72
+
73
+ ### Configuration
74
+
75
+ ```javascript
76
+ // .releaserc.js
77
+ module.exports = {
78
+ branches: ["main"],
79
+ plugins: [
80
+ "@semantic-release/commit-analyzer",
81
+ "@semantic-release/release-notes-generator",
82
+ "@semantic-release/changelog",
83
+ "@semantic-release/npm",
84
+ "@semantic-release/github",
85
+ [
86
+ "@semantic-release/git",
87
+ {
88
+ assets: ["CHANGELOG.md", "package.json"],
89
+ message:
90
+ "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}",
91
+ },
92
+ ],
93
+ ],
94
+ };
95
+ ```
96
+
97
+ ### Workflow
98
+
99
+ ```yaml
100
+ # .github/workflows/release.yml
101
+ name: Release
102
+
103
+ on:
104
+ push:
105
+ branches: [main]
106
+
107
+ jobs:
108
+ release:
109
+ runs-on: ubuntu-latest
110
+ steps:
111
+ - uses: actions/checkout@v4
112
+ with:
113
+ persist-credentials: false
114
+
115
+ - uses: actions/setup-node@v4
116
+ with:
117
+ node-version: "20"
118
+
119
+ - run: npm ci
120
+ - run: npm run build
121
+
122
+ - name: Release
123
+ env:
124
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
125
+ NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
126
+ run: npx semantic-release
127
+ ```
128
+
129
+ ## Versioning Strategy
130
+
131
+ ### Semantic Versioning (SemVer)
132
+
133
+ ```
134
+ MAJOR.MINOR.PATCH
135
+
136
+ 1.0.0 → 1.0.1 (patch - bug fix)
137
+ 1.0.1 → 1.1.0 (minor - new feature)
138
+ 1.1.0 → 2.0.0 (major - breaking change)
139
+ ```
140
+
141
+ ### Conventional Commits
142
+
143
+ ```
144
+ feat: add new feature (minor bump)
145
+ fix: fix bug (patch bump)
146
+ perf: performance improvement (patch bump)
147
+ docs: update docs (no bump)
148
+ chore: maintenance (no bump)
149
+
150
+ feat!: breaking change (major bump)
151
+ fix!: breaking bug fix (major bump)
152
+ ```
153
+
154
+ ## Changelog Generation
155
+
156
+ ```markdown
157
+ # Changelog
158
+
159
+ ## [2.1.0] - 2024-01-15
160
+
161
+ ### Added
162
+
163
+ - New dashboard widget (#123)
164
+ - Export to PDF feature (#125)
165
+
166
+ ### Fixed
167
+
168
+ - Memory leak in data processing (#124)
169
+ - Typo in error message (#126)
170
+
171
+ ### Changed
172
+
173
+ - Updated dependencies
174
+
175
+ ## [2.0.0] - 2024-01-01
176
+
177
+ ### Breaking Changes
178
+
179
+ - Removed deprecated API endpoints
180
+ - Changed authentication method
181
+
182
+ ### Migration Guide
183
+
184
+ See MIGRATION.md for upgrade instructions
185
+ ```
186
+
187
+ ## Docker Image Publishing
188
+
189
+ ```yaml
190
+ docker-release:
191
+ runs-on: ubuntu-latest
192
+ needs: test
193
+ if: github.ref == 'refs/heads/main'
194
+ steps:
195
+ - uses: actions/checkout@v4
196
+
197
+ - name: Get version
198
+ id: version
199
+ run: echo "version=$(cat package.json | jq -r '.version')" >> $GITHUB_OUTPUT
200
+
201
+ - name: Login to Docker Hub
202
+ uses: docker/login-action@v3
203
+ with:
204
+ username: ${{ secrets.DOCKER_USERNAME }}
205
+ password: ${{ secrets.DOCKER_PASSWORD }}
206
+
207
+ - name: Build and push
208
+ uses: docker/build-push-action@v5
209
+ with:
210
+ context: .
211
+ push: true
212
+ tags: |
213
+ mycompany/myapp:latest
214
+ mycompany/myapp:${{ steps.version.outputs.version }}
215
+ ```
216
+
217
+ ## NPM Publishing
218
+
219
+ ```yaml
220
+ publish:
221
+ runs-on: ubuntu-latest
222
+ needs: test
223
+ if: github.event_name == 'release'
224
+ steps:
225
+ - uses: actions/checkout@v4
226
+ - uses: actions/setup-node@v4
227
+ with:
228
+ node-version: "20"
229
+ registry-url: "https://registry.npmjs.org"
230
+
231
+ - run: npm ci
232
+ - run: npm run build
233
+
234
+ - name: Publish to npm
235
+ run: npm publish
236
+ env:
237
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
238
+ ```
239
+
240
+ ## GitHub Release Notes
241
+
242
+ ````yaml
243
+ - name: Create GitHub Release
244
+ uses: actions/create-release@v1
245
+ env:
246
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
247
+ with:
248
+ tag_name: v${{ steps.version.outputs.version }}
249
+ release_name: Release ${{ steps.version.outputs.version }}
250
+ body: |
251
+ ## What's Changed
252
+ ${{ steps.changelog.outputs.content }}
253
+
254
+ ## Installation
255
+ ```bash
256
+ npm install mypackage@${{ steps.version.outputs.version }}
257
+ ```
258
+ draft: false
259
+ prerelease: false
260
+ ````
261
+
262
+ ## Best Practices
263
+
264
+ 1. **Conventional commits**: Standardize commit format
265
+ 2. **Protected branches**: Prevent direct pushes to main
266
+ 3. **Automated versioning**: Let tools determine versions
267
+ 4. **Changelogs**: Auto-generate from commits
268
+ 5. **Git tags**: Tag every release
269
+ 6. **Release notes**: Include migration guides
270
+ 7. **Dry run**: Test releases in staging
271
+
272
+ ## Output Checklist
273
+
274
+ - [ ] Changesets or semantic-release configured
275
+ - [ ] Versioning strategy documented
276
+ - [ ] Changelog generation automated
277
+ - [ ] Git tagging automated
278
+ - [ ] Release notes template
279
+ - [ ] NPM publishing (if package)
280
+ - [ ] Docker publishing (if applicable)
281
+ - [ ] Protected branch rules
@@ -0,0 +1,372 @@
1
+ ---
2
+ name: rollback-workflow-builder
3
+ description: Creates safe rollback procedures for deployments with automated workflows, rollback runbooks, version management, and incident response. Use for "rollback automation", "deployment recovery", "incident response", or "production rollback".
4
+ ---
5
+
6
+ # Rollback Workflow Builder
7
+
8
+ Build safe, fast rollback mechanisms for production deployments.
9
+
10
+ ## Manual Rollback Workflow
11
+
12
+ ```yaml
13
+ # .github/workflows/rollback.yml
14
+ name: Rollback
15
+
16
+ on:
17
+ workflow_dispatch:
18
+ inputs:
19
+ version:
20
+ description: "Version to rollback to (e.g., v1.2.3 or previous)"
21
+ required: true
22
+ type: string
23
+ environment:
24
+ description: "Environment to rollback"
25
+ required: true
26
+ type: choice
27
+ options:
28
+ - staging
29
+ - production
30
+ reason:
31
+ description: "Reason for rollback"
32
+ required: true
33
+ type: string
34
+
35
+ jobs:
36
+ rollback:
37
+ runs-on: ubuntu-latest
38
+ environment: ${{ github.event.inputs.environment }}
39
+ steps:
40
+ - uses: actions/checkout@v4
41
+ with:
42
+ ref: ${{ github.event.inputs.version }}
43
+
44
+ - name: Verify version exists
45
+ run: |
46
+ if ! git rev-parse ${{ github.event.inputs.version }} >/dev/null 2>&1; then
47
+ echo "❌ Version ${{ github.event.inputs.version }} not found"
48
+ exit 1
49
+ fi
50
+ echo "✅ Version ${{ github.event.inputs.version }} exists"
51
+
52
+ - name: Get current version
53
+ id: current
54
+ run: |
55
+ CURRENT=$(git describe --tags --abbrev=0)
56
+ echo "version=$CURRENT" >> $GITHUB_OUTPUT
57
+ echo "Current version: $CURRENT"
58
+
59
+ - name: Confirm rollback
60
+ run: |
61
+ echo "🔄 Rolling back from ${{ steps.current.outputs.version }} to ${{ github.event.inputs.version }}"
62
+ echo "Environment: ${{ github.event.inputs.environment }}"
63
+ echo "Reason: ${{ github.event.inputs.reason }}"
64
+
65
+ - uses: actions/setup-node@v4
66
+ with:
67
+ node-version: "20"
68
+
69
+ - run: npm ci
70
+ - run: npm run build
71
+
72
+ - name: Deploy rollback
73
+ run: |
74
+ ./scripts/deploy.sh ${{ github.event.inputs.environment }}
75
+ env:
76
+ DEPLOY_TOKEN: ${{ secrets.DEPLOY_TOKEN }}
77
+
78
+ - name: Verify deployment
79
+ run: |
80
+ ./scripts/health-check.sh ${{ github.event.inputs.environment }}
81
+
82
+ - name: Create incident issue
83
+ uses: actions/github-script@v7
84
+ with:
85
+ script: |
86
+ github.rest.issues.create({
87
+ owner: context.repo.owner,
88
+ repo: context.repo.repo,
89
+ title: `Rollback: ${context.payload.inputs.environment} to ${context.payload.inputs.version}`,
90
+ body: `## Rollback Details
91
+
92
+ **Environment:** ${context.payload.inputs.environment}
93
+ **From:** ${{ steps.current.outputs.version }}
94
+ **To:** ${context.payload.inputs.version}
95
+ **Reason:** ${context.payload.inputs.reason}
96
+ **Triggered by:** @${context.actor}
97
+ **Time:** ${new Date().toISOString()}
98
+
99
+ ## Next Steps
100
+ - [ ] Verify rollback successful
101
+ - [ ] Investigate root cause
102
+ - [ ] Create fix
103
+ - [ ] Update postmortem
104
+ `,
105
+ labels: ['incident', 'rollback']
106
+ })
107
+ ```
108
+
109
+ ## Automated Rollback on Failure
110
+
111
+ ```yaml
112
+ deploy:
113
+ runs-on: ubuntu-latest
114
+ steps:
115
+ - name: Deploy
116
+ id: deploy
117
+ run: ./scripts/deploy.sh production
118
+ continue-on-error: true
119
+
120
+ - name: Verify deployment
121
+ id: verify
122
+ if: steps.deploy.outcome == 'success'
123
+ run: ./scripts/health-check.sh production
124
+ continue-on-error: true
125
+
126
+ - name: Auto-rollback on failure
127
+ if: steps.deploy.outcome == 'failure' || steps.verify.outcome == 'failure'
128
+ run: |
129
+ echo "⚠️ Deployment failed, initiating automatic rollback"
130
+ PREVIOUS_VERSION=$(git describe --tags --abbrev=0 HEAD^)
131
+ ./scripts/deploy.sh production $PREVIOUS_VERSION
132
+
133
+ # Verify rollback
134
+ if ./scripts/health-check.sh production; then
135
+ echo "✅ Rollback successful"
136
+ else
137
+ echo "❌ Rollback failed - manual intervention required"
138
+ exit 1
139
+ fi
140
+ ```
141
+
142
+ ## Kubernetes Rollback
143
+
144
+ ```yaml
145
+ rollback-k8s:
146
+ runs-on: ubuntu-latest
147
+ steps:
148
+ - name: Setup kubectl
149
+ uses: azure/setup-kubectl@v3
150
+
151
+ - name: Configure kubectl
152
+ run: |
153
+ echo "${{ secrets.KUBECONFIG }}" > kubeconfig
154
+ export KUBECONFIG=kubeconfig
155
+
156
+ - name: Rollback deployment
157
+ run: |
158
+ kubectl rollout undo deployment/myapp -n production
159
+ kubectl rollout status deployment/myapp -n production --timeout=5m
160
+
161
+ - name: Get rollback revision
162
+ run: |
163
+ kubectl rollout history deployment/myapp -n production
164
+ ```
165
+
166
+ ## Docker Image Rollback
167
+
168
+ ```yaml
169
+ - name: Rollback to previous image
170
+ run: |
171
+ # Get previous image tag
172
+ PREVIOUS_TAG=$(docker inspect myapp:latest | jq -r '.[0].ContainerConfig.Labels.previous_tag')
173
+
174
+ # Retag previous as latest
175
+ docker pull myapp:$PREVIOUS_TAG
176
+ docker tag myapp:$PREVIOUS_TAG myapp:latest
177
+ docker push myapp:latest
178
+
179
+ # Restart containers
180
+ docker-compose pull
181
+ docker-compose up -d
182
+ ```
183
+
184
+ ## Database Migration Rollback
185
+
186
+ ```yaml
187
+ - name: Rollback database migrations
188
+ run: |
189
+ # Get migration to rollback to
190
+ CURRENT=$(npm run migrate:current)
191
+ TARGET=${{ github.event.inputs.migration }}
192
+
193
+ echo "Rolling back from $CURRENT to $TARGET"
194
+ npm run migrate:down -- --to=$TARGET
195
+
196
+ # Verify rollback
197
+ AFTER=$(npm run migrate:current)
198
+ if [ "$AFTER" != "$TARGET" ]; then
199
+ echo "❌ Migration rollback failed"
200
+ exit 1
201
+ fi
202
+ env:
203
+ DATABASE_URL: ${{ secrets.DATABASE_URL }}
204
+ ```
205
+
206
+ ## Rollback Runbook
207
+
208
+ ````markdown
209
+ # Production Rollback Runbook
210
+
211
+ ## When to Rollback
212
+
213
+ Rollback if:
214
+
215
+ - Critical bugs affecting >10% of users
216
+ - Data integrity issues
217
+ - Security vulnerabilities
218
+ - Performance degradation >50%
219
+ - Error rate >5%
220
+
221
+ ## Before Rollback
222
+
223
+ 1. **Assess impact**: Check monitoring dashboards
224
+ 2. **Identify version**: Determine last known good version
225
+ 3. **Notify team**: Post in #incidents Slack channel
226
+ 4. **Enable maintenance mode** (if possible)
227
+
228
+ ## Rollback Steps
229
+
230
+ ### Automated Rollback (Preferred)
231
+
232
+ 1. Go to Actions → Rollback workflow
233
+ 2. Select environment (staging/production)
234
+ 3. Enter target version (e.g., v1.2.3 or "previous")
235
+ 4. Enter reason for rollback
236
+ 5. Click "Run workflow"
237
+ 6. Monitor progress in Actions tab
238
+
239
+ ### Manual Rollback (Emergency)
240
+
241
+ ```bash
242
+ # 1. SSH to production server
243
+ ssh production
244
+
245
+ # 2. Check current version
246
+ docker ps | grep myapp
247
+
248
+ # 3. Pull previous version
249
+ docker pull myapp:v1.2.3
250
+
251
+ # 4. Update docker-compose
252
+ vim docker-compose.yml
253
+ # Change image: myapp:latest to myapp:v1.2.3
254
+
255
+ # 5. Deploy
256
+ docker-compose up -d
257
+
258
+ # 6. Verify
259
+ curl https://api.myapp.com/health
260
+
261
+ # 7. Check logs
262
+ docker logs myapp -f
263
+ ```
264
+ ````
265
+
266
+ ## After Rollback
267
+
268
+ 1. **Verify**: Run smoke tests
269
+ 2. **Monitor**: Watch error rates for 15 minutes
270
+ 3. **Notify**: Update #incidents with status
271
+ 4. **Disable maintenance mode**
272
+ 5. **Create incident ticket**
273
+ 6. **Schedule postmortem**
274
+
275
+ ## Rollback Verification
276
+
277
+ - [ ] Health check returns 200
278
+ - [ ] Error rate <1%
279
+ - [ ] Response time p95 <500ms
280
+ - [ ] Key features working (login, checkout, etc.)
281
+ - [ ] Database connectivity OK
282
+
283
+ ## Communication Template
284
+
285
+ ```
286
+ 🔄 ROLLBACK IN PROGRESS
287
+
288
+ Environment: Production
289
+ From: v1.3.0
290
+ To: v1.2.3
291
+ Reason: Critical bug in checkout flow
292
+ Status: In progress
293
+ ETA: 5 minutes
294
+
295
+ Updates: #incidents
296
+ ```
297
+
298
+ ## Common Issues
299
+
300
+ ### Issue: Rollback Fails
301
+
302
+ **Symptom:** Deployment doesn't start
303
+ **Fix:** Check logs, verify version exists, ensure secrets are valid
304
+
305
+ ### Issue: Database Incompatibility
306
+
307
+ **Symptom:** App starts but can't read data
308
+ **Fix:** May need to rollback migrations first
309
+
310
+ ### Issue: Traffic Not Routing
311
+
312
+ **Symptom:** Users still see new version
313
+ **Fix:** Clear CDN cache, check load balancer config
314
+
315
+ ````
316
+
317
+ ## Health Check Script
318
+
319
+ ```bash
320
+ #!/bin/bash
321
+ # scripts/health-check.sh
322
+
323
+ ENVIRONMENT=$1
324
+ BASE_URL="https://${ENVIRONMENT}.myapp.com"
325
+
326
+ echo "Running health checks for $ENVIRONMENT..."
327
+
328
+ # API health
329
+ if ! curl -f "$BASE_URL/api/health" > /dev/null 2>&1; then
330
+ echo "❌ API health check failed"
331
+ exit 1
332
+ fi
333
+
334
+ # Database connection
335
+ if ! curl -f "$BASE_URL/api/health/db" > /dev/null 2>&1; then
336
+ echo "❌ Database health check failed"
337
+ exit 1
338
+ fi
339
+
340
+ # Key endpoints
341
+ ENDPOINTS=("/api/users" "/api/products" "/api/orders")
342
+ for endpoint in "${ENDPOINTS[@]}"; do
343
+ if ! curl -f "$BASE_URL$endpoint" > /dev/null 2>&1; then
344
+ echo "❌ Endpoint $endpoint health check failed"
345
+ exit 1
346
+ fi
347
+ done
348
+
349
+ echo "✅ All health checks passed"
350
+ exit 0
351
+ ````
352
+
353
+ ## Best Practices
354
+
355
+ 1. **Fast rollback**: <5 minutes to previous version
356
+ 2. **Automated**: One-click rollback workflow
357
+ 3. **Verified**: Health checks after rollback
358
+ 4. **Documented**: Clear runbook
359
+ 5. **Tested**: Practice rollbacks regularly
360
+ 6. **Monitored**: Alert on failures
361
+ 7. **Communicated**: Notify stakeholders
362
+
363
+ ## Output Checklist
364
+
365
+ - [ ] Manual rollback workflow
366
+ - [ ] Automated rollback on failure
367
+ - [ ] Platform-specific rollback (K8s/Docker)
368
+ - [ ] Database rollback procedure
369
+ - [ ] Rollback runbook documented
370
+ - [ ] Health check scripts
371
+ - [ ] Communication templates
372
+ - [ ] Incident issue automation