claude-code-kit 0.7.0__py3-none-any.whl

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 (209) hide show
  1. claude_code_kit-0.7.0.dist-info/METADATA +384 -0
  2. claude_code_kit-0.7.0.dist-info/RECORD +209 -0
  3. claude_code_kit-0.7.0.dist-info/WHEEL +4 -0
  4. claude_code_kit-0.7.0.dist-info/entry_points.txt +4 -0
  5. claude_code_kit-0.7.0.dist-info/licenses/LICENSE +21 -0
  6. claude_kit/__init__.py +10 -0
  7. claude_kit/__main__.py +8 -0
  8. claude_kit/_payload/agents/acceptance-reviewer.md +60 -0
  9. claude_kit/_payload/agents/auditor.md +76 -0
  10. claude_kit/_payload/agents/dependency-scanner.md +84 -0
  11. claude_kit/_payload/agents/developer.md +187 -0
  12. claude_kit/_payload/agents/devils-advocate.md +62 -0
  13. claude_kit/_payload/agents/devops-engineer.md +134 -0
  14. claude_kit/_payload/agents/e2e-tester.md +152 -0
  15. claude_kit/_payload/agents/em-reviewer.md +105 -0
  16. claude_kit/_payload/agents/incident-responder.md +64 -0
  17. claude_kit/_payload/agents/merge-reviewer.md +194 -0
  18. claude_kit/_payload/agents/observability-engineer.md +94 -0
  19. claude_kit/_payload/agents/orchestrator.md +551 -0
  20. claude_kit/_payload/agents/owasp-reviewer.md +76 -0
  21. claude_kit/_payload/agents/policy-validator.md +63 -0
  22. claude_kit/_payload/agents/pr-raiser.md +138 -0
  23. claude_kit/_payload/agents/risk-classifier.md +50 -0
  24. claude_kit/_payload/agents/sdlc-code-reviewer.md +196 -0
  25. claude_kit/_payload/agents/secret-scanner.md +70 -0
  26. claude_kit/_payload/agents/security-reviewer.md +80 -0
  27. claude_kit/_payload/agents/senior-backend-dev.md +199 -0
  28. claude_kit/_payload/agents/senior-frontend-dev.md +181 -0
  29. claude_kit/_payload/agents/senior-tester.md +206 -0
  30. claude_kit/_payload/agents/spec-doc-writer.md +331 -0
  31. claude_kit/_payload/agents/story-planner.md +56 -0
  32. claude_kit/_payload/agents/technical-architect.md +139 -0
  33. claude_kit/_payload/agents/tester.md +193 -0
  34. claude_kit/_payload/agents/ui-designer.md +73 -0
  35. claude_kit/_payload/agents/unit-tester.md +119 -0
  36. claude_kit/_payload/catalog/mcp.yaml +54 -0
  37. claude_kit/_payload/catalog/org.yaml +145 -0
  38. claude_kit/_payload/catalog/profiles.yaml +96 -0
  39. claude_kit/_payload/catalog/stacks.yaml +96 -0
  40. claude_kit/_payload/commands/init.md +36 -0
  41. claude_kit/_payload/commands/sdlc.md +18 -0
  42. claude_kit/_payload/commands/status.md +20 -0
  43. claude_kit/_payload/hooks/hooks.json +58 -0
  44. claude_kit/_payload/hooks/scripts/audit-log.sh +18 -0
  45. claude_kit/_payload/hooks/scripts/guard-secrets.sh +26 -0
  46. claude_kit/_payload/hooks/scripts/lint-fix.sh +38 -0
  47. claude_kit/_payload/hooks/scripts/load-continuity.sh +32 -0
  48. claude_kit/_payload/hooks/scripts/load-learnings.sh +40 -0
  49. claude_kit/_payload/hooks/scripts/type-check.sh +23 -0
  50. claude_kit/_payload/hooks/scripts/validate-frontmatter.sh +34 -0
  51. claude_kit/_payload/hooks/scripts/validate-settings.sh +21 -0
  52. claude_kit/_payload/hooks/scripts/warn-large-edits.sh +24 -0
  53. claude_kit/_payload/hooks/scripts/warn-missing-tests.sh +24 -0
  54. claude_kit/_payload/hooks/scripts/warn-sensitive-files.sh +30 -0
  55. claude_kit/_payload/hooks/scripts/warn-shared-modules.sh +33 -0
  56. claude_kit/_payload/rules/agent-guardrails.md +83 -0
  57. claude_kit/_payload/rules/agent-memory.md +106 -0
  58. claude_kit/_payload/rules/agent-resilience.md +61 -0
  59. claude_kit/_payload/rules/autonomy-levels.md +30 -0
  60. claude_kit/_payload/rules/code-organization.md +312 -0
  61. claude_kit/_payload/rules/continuity.md +84 -0
  62. claude_kit/_payload/rules/design-patterns.md +422 -0
  63. claude_kit/_payload/rules/devops-observability.md +57 -0
  64. claude_kit/_payload/rules/documentation.md +326 -0
  65. claude_kit/_payload/rules/evals.md +62 -0
  66. claude_kit/_payload/rules/frontend-best-practices.md +157 -0
  67. claude_kit/_payload/rules/goal-setting-and-monitoring.md +72 -0
  68. claude_kit/_payload/rules/human-in-the-loop.md +64 -0
  69. claude_kit/_payload/rules/linting-and-formatting.md +220 -0
  70. claude_kit/_payload/rules/mandatory-workflow.md +309 -0
  71. claude_kit/_payload/rules/model-tiers.md +34 -0
  72. claude_kit/_payload/rules/quality-gates.md +107 -0
  73. claude_kit/_payload/rules/rarv-cycle.md +31 -0
  74. claude_kit/_payload/rules/reasoning-techniques.md +62 -0
  75. claude_kit/_payload/rules/responsive-and-accessibility.md +353 -0
  76. claude_kit/_payload/rules/risk-classification.md +36 -0
  77. claude_kit/_payload/rules/testing.md +417 -0
  78. claude_kit/_payload/rules/tool-design.md +66 -0
  79. claude_kit/_payload/skills/_references/accessibility-checklist.md +160 -0
  80. claude_kit/_payload/skills/_references/orchestration-patterns.md +405 -0
  81. claude_kit/_payload/skills/_references/performance-checklist.md +153 -0
  82. claude_kit/_payload/skills/_references/security-checklist.md +134 -0
  83. claude_kit/_payload/skills/_references/testing-patterns.md +236 -0
  84. claude_kit/_payload/skills/accessibility-review/SKILL.md +56 -0
  85. claude_kit/_payload/skills/api-and-interface-design/SKILL.md +294 -0
  86. claude_kit/_payload/skills/api-integration/SKILL.md +348 -0
  87. claude_kit/_payload/skills/archive-sprint/SKILL.md +31 -0
  88. claude_kit/_payload/skills/backlog/SKILL.md +41 -0
  89. claude_kit/_payload/skills/backlog/item-template.md +20 -0
  90. claude_kit/_payload/skills/browser-testing-with-devtools/SKILL.md +302 -0
  91. claude_kit/_payload/skills/ci-cd-and-automation/SKILL.md +402 -0
  92. claude_kit/_payload/skills/code-review-and-quality/SKILL.md +347 -0
  93. claude_kit/_payload/skills/code-simplification/SKILL.md +331 -0
  94. claude_kit/_payload/skills/component-design/SKILL.md +171 -0
  95. claude_kit/_payload/skills/consolidate-learnings/SKILL.md +55 -0
  96. claude_kit/_payload/skills/context-engineering/SKILL.md +321 -0
  97. claude_kit/_payload/skills/debugging-and-error-recovery/SKILL.md +300 -0
  98. claude_kit/_payload/skills/decision/SKILL.md +46 -0
  99. claude_kit/_payload/skills/decision/adr-template.md +36 -0
  100. claude_kit/_payload/skills/deprecation-and-migration/SKILL.md +207 -0
  101. claude_kit/_payload/skills/documentation-and-adrs/SKILL.md +299 -0
  102. claude_kit/_payload/skills/doubt-driven-development/SKILL.md +243 -0
  103. claude_kit/_payload/skills/execute/SKILL.md +27 -0
  104. claude_kit/_payload/skills/frontend-ui-engineering/SKILL.md +328 -0
  105. claude_kit/_payload/skills/git-workflow-and-versioning/SKILL.md +300 -0
  106. claude_kit/_payload/skills/idea-refine/SKILL.md +178 -0
  107. claude_kit/_payload/skills/idea-refine/examples.md +238 -0
  108. claude_kit/_payload/skills/idea-refine/frameworks.md +99 -0
  109. claude_kit/_payload/skills/idea-refine/refinement-criteria.md +113 -0
  110. claude_kit/_payload/skills/idea-refine/scripts/idea-refine.sh +15 -0
  111. claude_kit/_payload/skills/incident-postmortem/SKILL.md +74 -0
  112. claude_kit/_payload/skills/incremental-implementation/SKILL.md +245 -0
  113. claude_kit/_payload/skills/interview-me/SKILL.md +221 -0
  114. claude_kit/_payload/skills/load-testing/SKILL.md +83 -0
  115. claude_kit/_payload/skills/manual-test/SKILL.md +516 -0
  116. claude_kit/_payload/skills/performance-optimization/SKILL.md +277 -0
  117. claude_kit/_payload/skills/planning-and-task-breakdown/SKILL.md +223 -0
  118. claude_kit/_payload/skills/playwright-verification/SKILL.md +205 -0
  119. claude_kit/_payload/skills/refresh-docs/SKILL.md +63 -0
  120. claude_kit/_payload/skills/remember/SKILL.md +96 -0
  121. claude_kit/_payload/skills/scope/SKILL.md +52 -0
  122. claude_kit/_payload/skills/scope/scope-template.md +82 -0
  123. claude_kit/_payload/skills/sdlc/SKILL.md +83 -0
  124. claude_kit/_payload/skills/security-and-hardening/SKILL.md +368 -0
  125. claude_kit/_payload/skills/security-verification/SKILL.md +209 -0
  126. claude_kit/_payload/skills/shipping-and-launch/SKILL.md +309 -0
  127. claude_kit/_payload/skills/smoke-test/SKILL.md +78 -0
  128. claude_kit/_payload/skills/source-driven-development/SKILL.md +195 -0
  129. claude_kit/_payload/skills/spec-driven-development/SKILL.md +200 -0
  130. claude_kit/_payload/skills/sprint/SKILL.md +67 -0
  131. claude_kit/_payload/skills/sprint/sprint-template.md +90 -0
  132. claude_kit/_payload/skills/test-driven-development/SKILL.md +383 -0
  133. claude_kit/_payload/skills/threat-model/SKILL.md +60 -0
  134. claude_kit/_payload/skills/triage/SKILL.md +87 -0
  135. claude_kit/_payload/skills/ui-ux-design/SKILL.md +71 -0
  136. claude_kit/_payload/skills/unit-test/SKILL.md +237 -0
  137. claude_kit/_payload/skills/using-agent-skills/SKILL.md +180 -0
  138. claude_kit/_payload/templates/CLAUDE.md +238 -0
  139. claude_kit/_payload/templates/CLAUDE.stack.md.tmpl +53 -0
  140. claude_kit/_payload/templates/CONTINUITY.template.md +35 -0
  141. claude_kit/_payload/templates/README.claude-sdlc.md.tmpl +219 -0
  142. claude_kit/_payload/templates/agent-memory/MEMORY.md +30 -0
  143. claude_kit/_payload/templates/agent-memory/api/.gitkeep +0 -0
  144. claude_kit/_payload/templates/agent-memory/architecture/.gitkeep +0 -0
  145. claude_kit/_payload/templates/agent-memory/debugging/.gitkeep +0 -0
  146. claude_kit/_payload/templates/agent-memory/gotchas/.gitkeep +0 -0
  147. claude_kit/_payload/templates/agent-memory/patterns/.gitkeep +0 -0
  148. claude_kit/_payload/templates/agent-memory/performance/.gitkeep +0 -0
  149. claude_kit/_payload/templates/artifacts/adr.md +18 -0
  150. claude_kit/_payload/templates/artifacts/feature-spec.md +29 -0
  151. claude_kit/_payload/templates/artifacts/release-plan.md +23 -0
  152. claude_kit/_payload/templates/artifacts/runbook.md +24 -0
  153. claude_kit/_payload/templates/artifacts/security-review.md +23 -0
  154. claude_kit/_payload/templates/artifacts/test-plan.md +22 -0
  155. claude_kit/_payload/templates/org/README.md +53 -0
  156. claude_kit/_payload/templates/org/agents/data-workflow-agent.md +59 -0
  157. claude_kit/_payload/templates/org/agents/founder-prototype-agent.md +61 -0
  158. claude_kit/_payload/templates/org/agents/internal-tools-builder.md +63 -0
  159. claude_kit/_payload/templates/org/agents/pm-copilot.md +60 -0
  160. claude_kit/_payload/templates/org/agents/support-ticket-engineer.md +63 -0
  161. claude_kit/_payload/templates/org/packs/devops-and-release/README.md +46 -0
  162. claude_kit/_payload/templates/org/packs/devops-and-release/pack.yaml +32 -0
  163. claude_kit/_payload/templates/org/packs/engineering-core/README.md +46 -0
  164. claude_kit/_payload/templates/org/packs/engineering-core/pack.yaml +44 -0
  165. claude_kit/_payload/templates/org/packs/non-engineer-builder/README.md +53 -0
  166. claude_kit/_payload/templates/org/packs/non-engineer-builder/pack.yaml +39 -0
  167. claude_kit/_payload/templates/org/packs/onboarding-and-docs/README.md +49 -0
  168. claude_kit/_payload/templates/org/packs/onboarding-and-docs/pack.yaml +26 -0
  169. claude_kit/_payload/templates/org/packs/product-to-code/README.md +50 -0
  170. claude_kit/_payload/templates/org/packs/product-to-code/pack.yaml +34 -0
  171. claude_kit/_payload/templates/org/packs/quality-and-review/README.md +53 -0
  172. claude_kit/_payload/templates/org/packs/quality-and-review/pack.yaml +40 -0
  173. claude_kit/_payload/templates/org/packs/security-and-compliance/README.md +50 -0
  174. claude_kit/_payload/templates/org/packs/security-and-compliance/pack.yaml +36 -0
  175. claude_kit/_payload/templates/org/rules/ai-working-agreement.md +45 -0
  176. claude_kit/_payload/templates/org/rules/ambiguity-resolution.md +36 -0
  177. claude_kit/_payload/templates/org/rules/branch-and-pr-policy.md +41 -0
  178. claude_kit/_payload/templates/org/rules/compliance-policy.md +50 -0
  179. claude_kit/_payload/templates/org/rules/non-engineer-safe-coding.md +37 -0
  180. claude_kit/_payload/templates/org/rules/pii-policy.md +46 -0
  181. claude_kit/_payload/templates/org/rules/production-data-policy.md +35 -0
  182. claude_kit/_payload/templates/org/rules/prompt-to-task-conversion.md +30 -0
  183. claude_kit/_payload/templates/org/rules/prototype-boundaries.md +40 -0
  184. claude_kit/_payload/templates/org/rules/secrets-policy.md +34 -0
  185. claude_kit/_payload/templates/org/skills/customer-issue-to-fix/SKILL.md +61 -0
  186. claude_kit/_payload/templates/org/skills/feature-from-idea/SKILL.md +56 -0
  187. claude_kit/_payload/templates/org/skills/prompt-to-safe-task/SKILL.md +59 -0
  188. claude_kit/_payload/templates/org/skills/prototype-to-production/SKILL.md +61 -0
  189. claude_kit/_payload/templates/org/skills/repo-onboarding/SKILL.md +60 -0
  190. claude_kit/_payload/templates/settings.json +53 -0
  191. claude_kit/_payload/templates/stacks/backend/python/fastapi/rules/fastapi-patterns.md +64 -0
  192. claude_kit/_payload/templates/stacks/db/mongodb/agents/migration-specialist.md +61 -0
  193. claude_kit/_payload/templates/stacks/db/mongodb/agents/mongodb-specialist.md +59 -0
  194. claude_kit/_payload/templates/stacks/db/mongodb/rules/mongodb-patterns.md +39 -0
  195. claude_kit/_payload/templates/stacks/db/postgres/agents/db-performance-reviewer.md +66 -0
  196. claude_kit/_payload/templates/stacks/db/postgres/agents/migration-specialist.md +56 -0
  197. claude_kit/_payload/templates/stacks/db/postgres/agents/postgres-specialist.md +58 -0
  198. claude_kit/_payload/templates/stacks/db/postgres/rules/database-performance.md +64 -0
  199. claude_kit/_payload/templates/stacks/db/postgres/rules/postgres-patterns.md +43 -0
  200. claude_kit/_payload/templates/stacks/frontend/react/rules/react-patterns.md +63 -0
  201. claude_kit/catalog.py +476 -0
  202. claude_kit/cli.py +327 -0
  203. claude_kit/hooks.py +246 -0
  204. claude_kit/models.py +205 -0
  205. claude_kit/prompts.py +209 -0
  206. claude_kit/render.py +146 -0
  207. claude_kit/scaffold.py +492 -0
  208. claude_kit/upgrader.py +294 -0
  209. claude_kit/validator.py +197 -0
@@ -0,0 +1,402 @@
1
+ ---
2
+ name: ci-cd-and-automation
3
+ description: Automates CI/CD pipeline setup. Use when setting up or modifying build and deployment pipelines. Use when you need to automate quality gates, configure test runners in CI, or establish deployment strategies.
4
+ ---
5
+
6
+ # CI/CD and Automation
7
+
8
+ ## Overview
9
+
10
+ Automate quality gates so that no change reaches production without passing tests, lint, type checking, and build. CI/CD is the enforcement mechanism for every other skill — it catches what humans and agents miss, and it does so consistently on every single change.
11
+
12
+ **Shift Left:** Catch problems as early in the pipeline as possible. A bug caught in linting costs minutes; the same bug caught in production costs hours. Move checks upstream — static analysis before tests, tests before staging, staging before production.
13
+
14
+ **Faster is Safer:** Smaller batches and more frequent releases reduce risk, not increase it. A deployment with 3 changes is easier to debug than one with 30. Frequent releases build confidence in the release process itself.
15
+
16
+ ## When to Use
17
+
18
+ - Setting up a new project's CI pipeline
19
+ - Adding or modifying automated checks
20
+ - Configuring deployment pipelines
21
+ - When a change should trigger automated verification
22
+ - Debugging CI failures
23
+
24
+ ## The Quality Gate Pipeline
25
+
26
+ Every change goes through these gates before merge:
27
+
28
+ ```
29
+ Pull Request Opened
30
+
31
+
32
+ ┌─────────────────┐
33
+ │ LINT CHECK │ Project's linter
34
+ │ ↓ pass │
35
+ │ TYPE CHECK │ Project's type checker
36
+ │ ↓ pass │
37
+ │ UNIT TESTS │ Project's test runner
38
+ │ ↓ pass │
39
+ │ BUILD │ Project's build
40
+ │ ↓ pass │
41
+ │ INTEGRATION │ API/DB tests
42
+ │ ↓ pass │
43
+ │ E2E (optional) │ Project's E2E framework
44
+ │ ↓ pass │
45
+ │ SECURITY AUDIT │ Dependency audit
46
+ │ ↓ pass │
47
+ │ BUNDLE SIZE │ Bundle size check (if applicable)
48
+ └─────────────────┘
49
+
50
+
51
+ Ready for review
52
+ ```
53
+
54
+ **No gate can be skipped.** If lint fails, fix lint — don't disable the rule. If a test fails, fix the code — don't skip the test.
55
+
56
+ ## GitHub Actions Configuration
57
+
58
+ ### Basic CI Pipeline
59
+
60
+ ```yaml
61
+ # .github/workflows/ci.yml
62
+ name: CI
63
+
64
+ on:
65
+ pull_request:
66
+ branches: [main]
67
+ push:
68
+ branches: [main]
69
+
70
+ jobs:
71
+ quality:
72
+ runs-on: ubuntu-latest
73
+ steps:
74
+ - uses: actions/checkout@v4
75
+
76
+ # Example for Node.js projects
77
+ - uses: actions/setup-node@v4
78
+ with:
79
+ node-version: '22'
80
+ cache: 'npm'
81
+
82
+ - name: Install dependencies
83
+ run: npm ci
84
+
85
+ - name: Lint
86
+ run: npm run lint
87
+
88
+ - name: Type check
89
+ run: npm run typecheck # e.g., tsc --noEmit or equivalent
90
+
91
+ - name: Test
92
+ run: npm test -- --coverage
93
+
94
+ - name: Build
95
+ run: npm run build
96
+
97
+ - name: Security audit
98
+ run: npm audit --audit-level=high
99
+ ```
100
+
101
+ **For other stacks:**
102
+ - Python: Replace `setup-node` with `setup-python`, use `pip install -r requirements.txt`, run the project's linter/type checker/test runner
103
+ - Go: Use `setup-go`, run `go vet`, `go test`, `go build`
104
+ - Java: Use `setup-java`, run `mvn verify` or `gradle build`
105
+ - Rust: Use `rust-toolchain`, run `cargo clippy`, `cargo test`, `cargo build`
106
+
107
+ ### With Database Integration Tests
108
+
109
+ ```yaml
110
+ integration:
111
+ runs-on: ubuntu-latest
112
+ services:
113
+ # Example with PostgreSQL - adjust for your database
114
+ postgres:
115
+ image: postgres:16
116
+ env:
117
+ POSTGRES_DB: testdb
118
+ POSTGRES_USER: ci_user
119
+ POSTGRES_PASSWORD: ${{ secrets.CI_DB_PASSWORD }}
120
+ ports:
121
+ - 5432:5432
122
+ options: >-
123
+ --health-cmd pg_isready
124
+ --health-interval 10s
125
+ --health-timeout 5s
126
+ --health-retries 5
127
+
128
+ steps:
129
+ - uses: actions/checkout@v4
130
+ - uses: actions/setup-node@v4 # or setup-python, setup-go, etc.
131
+ with:
132
+ node-version: '22'
133
+ cache: 'npm'
134
+ - run: npm ci
135
+ - name: Run migrations
136
+ run: npm run migrate # e.g., Prisma, Drizzle, Alembic, Flyway, etc.
137
+ env:
138
+ DATABASE_URL: postgresql://ci_user:${{ secrets.CI_DB_PASSWORD }}@localhost:5432/testdb
139
+ - name: Integration tests
140
+ run: npm run test:integration
141
+ env:
142
+ DATABASE_URL: postgresql://ci_user:${{ secrets.CI_DB_PASSWORD }}@localhost:5432/testdb
143
+ ```
144
+
145
+ > **Note:** Even for CI-only test databases, use GitHub Secrets for credentials rather than hardcoding values. This builds good habits and prevents accidental reuse of test credentials in other contexts.
146
+
147
+ ### E2E Tests
148
+
149
+ ```yaml
150
+ e2e:
151
+ runs-on: ubuntu-latest
152
+ steps:
153
+ - uses: actions/checkout@v4
154
+ - uses: actions/setup-node@v4
155
+ with:
156
+ node-version: '22'
157
+ cache: 'npm'
158
+ - run: npm ci
159
+ - name: Install E2E framework dependencies
160
+ run: npx playwright install --with-deps chromium # or Cypress, Selenium, etc.
161
+ - name: Build
162
+ run: npm run build
163
+ - name: Run E2E tests
164
+ run: npm run test:e2e # e.g., playwright test, cypress run
165
+ - uses: actions/upload-artifact@v4
166
+ if: failure()
167
+ with:
168
+ name: e2e-test-report
169
+ path: test-results/ # adjust to your framework's output dir
170
+ ```
171
+
172
+ ## Feeding CI Failures Back to Agents
173
+
174
+ The power of CI with AI agents is the feedback loop. When CI fails:
175
+
176
+ ```
177
+ CI fails
178
+
179
+
180
+ Copy the failure output
181
+
182
+
183
+ Feed it to the agent:
184
+ "The CI pipeline failed with this error:
185
+ [paste specific error]
186
+ Fix the issue and verify locally before pushing again."
187
+
188
+
189
+ Agent fixes → pushes → CI runs again
190
+ ```
191
+
192
+ **Key patterns:**
193
+
194
+ ```
195
+ Lint failure → Agent runs the project's linter with auto-fix and commits
196
+ Type error → Agent reads the error location and fixes the type
197
+ Test failure → Agent follows debugging-and-error-recovery skill
198
+ Build error → Agent checks config and dependencies
199
+ ```
200
+
201
+ ## Deployment Strategies
202
+
203
+ ### Preview Deployments
204
+
205
+ Every PR gets a preview deployment for manual testing:
206
+
207
+ ```yaml
208
+ # Deploy preview on PR (Vercel/Netlify/CloudFlare/etc.)
209
+ deploy-preview:
210
+ runs-on: ubuntu-latest
211
+ if: github.event_name == 'pull_request'
212
+ steps:
213
+ - uses: actions/checkout@v4
214
+ - name: Deploy preview
215
+ run: npx vercel --token=${{ secrets.VERCEL_TOKEN }}
216
+ # Or: netlify deploy --build --context deploy-preview
217
+ # Or: your platform's deployment CLI
218
+ ```
219
+
220
+ ### Feature Flags
221
+
222
+ Feature flags decouple deployment from release. Deploy incomplete or risky features behind flags so you can:
223
+
224
+ - **Ship code without enabling it.** Merge to main early, enable when ready.
225
+ - **Roll back without redeploying.** Disable the flag instead of reverting code.
226
+ - **Canary new features.** Enable for 1% of users, then 10%, then 100%.
227
+ - **Run A/B tests.** Compare behavior with and without the feature.
228
+
229
+ ```typescript
230
+ // Simple feature flag pattern (example - adapt to your language/framework)
231
+ if (featureFlags.isEnabled('new-checkout-flow', { userId })) {
232
+ return renderNewCheckout();
233
+ }
234
+ return renderLegacyCheckout();
235
+ ```
236
+
237
+ **Flag lifecycle:** Create → Enable for testing → Canary → Full rollout → Remove the flag and dead code. Flags that live forever become technical debt — set a cleanup date when you create them.
238
+
239
+ ### Staged Rollouts
240
+
241
+ ```
242
+ PR merged to main
243
+
244
+
245
+ Staging deployment (auto)
246
+ │ Manual verification
247
+
248
+ Production deployment (manual trigger or auto after staging)
249
+
250
+
251
+ Monitor for errors (15-minute window)
252
+
253
+ ├── Errors detected → Rollback
254
+ └── Clean → Done
255
+ ```
256
+
257
+ ### Rollback Plan
258
+
259
+ Every deployment should be reversible:
260
+
261
+ ```yaml
262
+ # Manual rollback workflow
263
+ name: Rollback
264
+ on:
265
+ workflow_dispatch:
266
+ inputs:
267
+ version:
268
+ description: 'Version to rollback to'
269
+ required: true
270
+
271
+ jobs:
272
+ rollback:
273
+ runs-on: ubuntu-latest
274
+ steps:
275
+ - name: Rollback deployment
276
+ run: |
277
+ # Deploy the specified previous version
278
+ # Example for Vercel:
279
+ npx vercel rollback ${{ inputs.version }}
280
+ # Adjust for your deployment platform
281
+ ```
282
+
283
+ ## Environment Management
284
+
285
+ ```
286
+ .env.example → Committed (template for developers)
287
+ .env → NOT committed (local development)
288
+ .env.test → Committed (test environment, no real secrets)
289
+ CI secrets → Stored in GitHub Secrets / vault
290
+ Production secrets → Stored in deployment platform / vault
291
+ ```
292
+
293
+ CI should never have production secrets. Use separate secrets for CI testing.
294
+
295
+ ## Automation Beyond CI
296
+
297
+ ### Dependabot / Renovate
298
+
299
+ ```yaml
300
+ # .github/dependabot.yml
301
+ version: 2
302
+ updates:
303
+ - package-ecosystem: npm # or pip, cargo, gomod, etc.
304
+ directory: /
305
+ schedule:
306
+ interval: weekly
307
+ open-pull-requests-limit: 5
308
+ ```
309
+
310
+ ### Build Cop Role
311
+
312
+ Designate someone responsible for keeping CI green. When the build breaks, the Build Cop's job is to fix or revert — not the person whose change caused the break. This prevents broken builds from accumulating while everyone assumes someone else will fix it.
313
+
314
+ ### PR Checks
315
+
316
+ - **Required reviews:** At least 1 approval before merge
317
+ - **Required status checks:** CI must pass before merge
318
+ - **Branch protection:** No force-pushes to main
319
+ - **Auto-merge:** If all checks pass and approved, merge automatically
320
+
321
+ ## CI Optimization
322
+
323
+ When the pipeline exceeds 10 minutes, apply these strategies in order of impact:
324
+
325
+ ```
326
+ Slow CI pipeline?
327
+ ├── Cache dependencies
328
+ │ └── Use actions/cache or language-specific cache options
329
+ ├── Run jobs in parallel
330
+ │ └── Split lint, typecheck, test, build into separate parallel jobs
331
+ ├── Only run what changed
332
+ │ └── Use path filters to skip unrelated jobs (e.g., skip e2e for docs-only PRs)
333
+ ├── Use matrix builds
334
+ │ └── Shard test suites across multiple runners
335
+ ├── Optimize the test suite
336
+ │ └── Remove slow tests from the critical path, run them on a schedule instead
337
+ └── Use larger runners
338
+ └── GitHub-hosted larger runners or self-hosted for CPU-heavy builds
339
+ ```
340
+
341
+ **Example: caching and parallelism (Node.js)**
342
+ ```yaml
343
+ jobs:
344
+ lint:
345
+ runs-on: ubuntu-latest
346
+ steps:
347
+ - uses: actions/checkout@v4
348
+ - uses: actions/setup-node@v4
349
+ with: { node-version: '22', cache: 'npm' }
350
+ - run: npm ci
351
+ - run: npm run lint
352
+
353
+ typecheck:
354
+ runs-on: ubuntu-latest
355
+ steps:
356
+ - uses: actions/checkout@v4
357
+ - uses: actions/setup-node@v4
358
+ with: { node-version: '22', cache: 'npm' }
359
+ - run: npm ci
360
+ - run: npm run typecheck
361
+
362
+ test:
363
+ runs-on: ubuntu-latest
364
+ steps:
365
+ - uses: actions/checkout@v4
366
+ - uses: actions/setup-node@v4
367
+ with: { node-version: '22', cache: 'npm' }
368
+ - run: npm ci
369
+ - run: npm test -- --coverage
370
+ ```
371
+
372
+ ## Common Rationalizations
373
+
374
+ | Rationalization | Reality |
375
+ |---|---|
376
+ | "CI is too slow" | Optimize the pipeline (see CI Optimization below), don't skip it. A 5-minute pipeline prevents hours of debugging. |
377
+ | "This change is trivial, skip CI" | Trivial changes break builds. CI is fast for trivial changes anyway. |
378
+ | "The test is flaky, just re-run" | Flaky tests mask real bugs and waste everyone's time. Fix the flakiness. |
379
+ | "We'll add CI later" | Projects without CI accumulate broken states. Set it up on day one. |
380
+ | "Manual testing is enough" | Manual testing doesn't scale and isn't repeatable. Automate what you can. |
381
+
382
+ ## Red Flags
383
+
384
+ - No CI pipeline in the project
385
+ - CI failures ignored or silenced
386
+ - Tests disabled in CI to make the pipeline pass
387
+ - Production deploys without staging verification
388
+ - No rollback mechanism
389
+ - Secrets stored in code or CI config files (not secrets manager)
390
+ - Long CI times with no optimization effort
391
+
392
+ ## Verification
393
+
394
+ After setting up or modifying CI:
395
+
396
+ - [ ] All quality gates are present (lint, types, tests, build, audit)
397
+ - [ ] Pipeline runs on every PR and push to main
398
+ - [ ] Failures block merge (branch protection configured)
399
+ - [ ] CI results feed back into the development loop
400
+ - [ ] Secrets are stored in the secrets manager, not in code
401
+ - [ ] Deployment has a rollback mechanism
402
+ - [ ] Pipeline runs in under 10 minutes for the test suite