@luanpdd/kit-mcp 1.9.0 → 1.11.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 (84) hide show
  1. package/CHANGELOG.md +86 -0
  2. package/README.md +58 -0
  3. package/gates/ai-prompt-stability.md +120 -0
  4. package/gates/golden-signals-coverage.md +133 -0
  5. package/gates/legacy-refactor-safety.md +178 -0
  6. package/gates/observability-coverage.md +151 -0
  7. package/gates/postmortem-template-required.md +127 -0
  8. package/gates/prr-checklist-coverage.md +128 -0
  9. package/gates/release-pipeline-policy.md +132 -0
  10. package/kit/COMANDOS.md +15 -0
  11. package/kit/agents/ai-mutation-tester.md +298 -0
  12. package/kit/agents/cascading-failures-auditor.md +306 -0
  13. package/kit/agents/executor.md +13 -0
  14. package/kit/agents/golden-signals-instrumenter.md +241 -0
  15. package/kit/agents/legacy-characterizer.md +378 -0
  16. package/kit/agents/load-shedding-instrumenter.md +297 -0
  17. package/kit/agents/observability-coverage-auditor.md +325 -0
  18. package/kit/agents/omm-auditor.md +99 -0
  19. package/kit/agents/payload-capture-instrumenter.md +283 -0
  20. package/kit/agents/planner.md +29 -0
  21. package/kit/agents/postmortem-writer.md +282 -0
  22. package/kit/agents/prr-conductor.md +296 -0
  23. package/kit/agents/refactor-safety-auditor.md +414 -0
  24. package/kit/agents/release-pipeline-auditor.md +360 -0
  25. package/kit/agents/seam-finder.md +367 -0
  26. package/kit/agents/shotgun-surgery-detector.md +359 -0
  27. package/kit/agents/storytelling-analyst.md +309 -0
  28. package/kit/agents/supabase-architect.md +49 -0
  29. package/kit/agents/supabase-edge-fn-writer.md +114 -0
  30. package/kit/agents/supabase-migration-writer.md +80 -0
  31. package/kit/agents/supabase-storage-implementer.md +156 -0
  32. package/kit/agents/toil-auditor.md +277 -0
  33. package/kit/agents/verifier.md +30 -0
  34. package/kit/commands/auditar-cascading.md +111 -0
  35. package/kit/commands/auditar-marco.md +124 -1
  36. package/kit/commands/auditar-observabilidade-cobertura.md +183 -0
  37. package/kit/commands/auditar-refactor.md +219 -0
  38. package/kit/commands/auditar-release.md +109 -0
  39. package/kit/commands/auditar-toil.md +129 -0
  40. package/kit/commands/capturar-payloads.md +193 -0
  41. package/kit/commands/caracterizar-prompt.md +195 -0
  42. package/kit/commands/caracterizar.md +212 -0
  43. package/kit/commands/concluir-marco.md +95 -1
  44. package/kit/commands/detectar-duplicacao.md +197 -0
  45. package/kit/commands/discutir-fase.md +41 -0
  46. package/kit/commands/encontrar-seams.md +136 -0
  47. package/kit/commands/forense.md +103 -1
  48. package/kit/commands/golden-signals.md +142 -0
  49. package/kit/commands/legacy.md +263 -0
  50. package/kit/commands/load-shedding.md +117 -0
  51. package/kit/commands/observabilidade.md +2 -0
  52. package/kit/commands/postmortem.md +179 -0
  53. package/kit/commands/prr.md +205 -0
  54. package/kit/commands/refactor-seguro.md +321 -0
  55. package/kit/commands/risk-budget.md +220 -0
  56. package/kit/commands/sre.md +230 -0
  57. package/kit/commands/storytelling.md +179 -0
  58. package/kit/skills/_shared-legacy/glossary.md +389 -0
  59. package/kit/skills/_shared-sre/glossary.md +712 -0
  60. package/kit/skills/ai-prompt-characterization/SKILL.md +335 -0
  61. package/kit/skills/blameless-postmortems/SKILL.md +340 -0
  62. package/kit/skills/cascading-failures/SKILL.md +307 -0
  63. package/kit/skills/eliminating-toil/SKILL.md +243 -0
  64. package/kit/skills/event-based-slos/SKILL.md +22 -0
  65. package/kit/skills/four-golden-signals/SKILL.md +314 -0
  66. package/kit/skills/hermetic-builds/SKILL.md +323 -0
  67. package/kit/skills/legacy-api-only-applications/SKILL.md +358 -0
  68. package/kit/skills/legacy-characterization-tests/SKILL.md +330 -0
  69. package/kit/skills/legacy-effect-analysis/SKILL.md +331 -0
  70. package/kit/skills/legacy-extract-class/SKILL.md +203 -0
  71. package/kit/skills/legacy-monster-methods/SKILL.md +444 -0
  72. package/kit/skills/legacy-programming-by-difference/SKILL.md +252 -0
  73. package/kit/skills/legacy-seams-and-test-harness/SKILL.md +460 -0
  74. package/kit/skills/legacy-shotgun-surgery/SKILL.md +286 -0
  75. package/kit/skills/legacy-sprout-wrap-techniques/SKILL.md +434 -0
  76. package/kit/skills/legacy-storytelling-naked-crc/SKILL.md +270 -0
  77. package/kit/skills/llm-as-dependency/SKILL.md +436 -0
  78. package/kit/skills/load-shedding-graceful-degradation/SKILL.md +396 -0
  79. package/kit/skills/pre-refactor-characterization/SKILL.md +421 -0
  80. package/kit/skills/production-readiness-review/SKILL.md +305 -0
  81. package/kit/skills/release-engineering/SKILL.md +367 -0
  82. package/kit/skills/retry-strategies/SKILL.md +372 -0
  83. package/kit/skills/sre-risk-management/SKILL.md +221 -0
  84. package/package.json +2 -2
@@ -0,0 +1,305 @@
1
+ ---
2
+ name: production-readiness-review
3
+ description: Use antes de aceitar serviço em produção — PRR checklist 6 axes (System/Instrumentation/Emergency/Capacity/Change/Performance), 3 engagement models, handoff dev→SRE.
4
+ ---
5
+
6
+ # SRE — Production Readiness Review (PRR)
7
+
8
+ ## Quando usar
9
+
10
+ LLM carrega esta skill ao avaliar serviço/feature antes de produção, conduzir handoff dev→SRE, ou definir engagement model. Trigger phrases:
11
+
12
+ - "PRR", "production readiness review"
13
+ - "production-bound", "ready for prod"
14
+ - "handoff dev to SRE"
15
+ - "engagement model", "early engagement"
16
+ - "SRE platform", "frameworks readiness"
17
+ - "Google SRE cap 32"
18
+ - "system architecture / instrumentation / emergency response / capacity / change / performance"
19
+
20
+ ## Regras absolutas
21
+
22
+ - **PRR é GATE, não recomendação** — feature/serviço sem PRR aprovado NÃO entra em produção real (apenas dogfooding/staging). Sem gate, "production-ready" vira slogan; com gate, vira invariante.
23
+ - **6 axes obrigatórios** — System Architecture, Instrumentation/Metrics/Monitoring, Emergency Response, Capacity Planning, Change Management, Performance. Pular um axe = aprovação inválida (lacuna oculta vira incident em 6 meses).
24
+ - **3 engagement models — escolher conforme custo do serviço** — Simple PRR (serviços pequenos/internal), Early Engagement (serviços críticos), Frameworks/SRE Platform (serviços built on top of platform). Modelo errado = ou over-investment (Simple para tier-1) ou under-investment (Early para internal tool).
25
+ - **PRR é ANTES, não DEPOIS** — não "deploy primeiro, fazer PRR depois". PRR conclusão é pré-requisito de aceitar tráfego real (≥ 1% de usuários).
26
+ - **PRR é EVIDENCE-BASED, não opinião** — cada item do checklist tem critério verificável (load test report, runbook URL, dashboard link). "Acreditamos que está pronto" ≠ PRR aprovado.
27
+ - **Action items P0 = blocker; P1 = scheduled** — gaps P0 (sem instrumentação básica, sem rollback, sem on-call) bloqueiam aprovação. Gaps P1 (otimização capacidade, runbook adicional) viram tasks com due date — não bloqueiam, mas são tracked.
28
+ - **Reviewer ≠ time dev** — PRR conduzido por SRE ou par externo ao time dev (eyes-on-code novos, viés reduzido). Auto-PRR pelo time dev = oversight.
29
+ - **PRR é vivo, não one-shot** — após mudança maior (rewrite, novo dependency, RPS 10×), re-run PRR. Statement "passou PRR uma vez em 2024" não é evidence em 2026.
30
+
31
+ ## Patterns canônicos
32
+
33
+ ### Pattern: checklist canônico PRR — 6 axes detalhados
34
+
35
+ ````markdown
36
+ ```markdown
37
+ # PRR Checklist — <serviço/feature> — <data>
38
+
39
+ Reviewer: @<sre-or-external>
40
+ Status: Draft | In Review | Approved | Blocked
41
+
42
+ ---
43
+
44
+ ## Axe 1: System Architecture
45
+
46
+ - [ ] **Redundância**: serviço tolera falha de N instâncias (N=1 mínimo, N=2 ideal). Evidence: deployment manifest (replicas: 2+).
47
+ - [ ] **Single point of failure mapeado**: SPOFs documentados; mitigation plan claro. Evidence: arch diagram + SPOF list.
48
+ - [ ] **Failure modes mapeados**: top 5 modos de falha conhecidos com impact + mitigation. Evidence: failure mode analysis doc.
49
+ - [ ] **Load balancing strategy**: round-robin / least-conn / consistent-hash documentado. Evidence: LB config.
50
+ - [ ] **Graceful degradation**: serviço degrada (não crasha) sob carga ou dependency failure. Evidence: chaos test report ou load test config.
51
+
52
+ ## Axe 2: Instrumentation, Metrics, Monitoring
53
+
54
+ - [ ] **4 golden signals presentes**: Latency (histogram), Traffic (counter), Errors (counter por error.type), Saturation (gauge). Evidence: dashboard URL + queries.
55
+ - [ ] **SLI/SLO definidos**: ao menos 1 SLO por jornada crítica do user (ver [event-based-slos](../event-based-slos/SKILL.md)). Evidence: SLO.md em `.planning/slos/`.
56
+ - [ ] **Alertas SLO burn-rate**: NÃO threshold em CPU/mem/etc. Evidence: alert rules em código + correlação com SLO definido.
57
+ - [ ] **Logs estruturados**: wide events com campos canônicos (`user.id`, `request.id`, `error.type`, `result.success`, `duration_ms`, `build_id`). Evidence: log query exemplo.
58
+ - [ ] **Traces propagados**: W3C TraceContext header em hops cross-service. Evidence: trace exemplo cross-service.
59
+
60
+ ## Axe 3: Emergency Response
61
+
62
+ - [ ] **Runbook existe e foi testado**: passos para incident comuns (5+ scenarios). Evidence: URL do runbook + log do último teste.
63
+ - [ ] **On-call rotation definida**: schedule visível, ≥ 2 pessoas, escalation policy. Evidence: PagerDuty/Opsgenie schedule.
64
+ - [ ] **Page routing**: alertas SLO → on-call específico (não generic). Evidence: alert routing rules.
65
+ - [ ] **Escalation policy**: timeline clara (page → 5 min ack → 15 min escalate to L2 → 30 min L3). Evidence: doc.
66
+ - [ ] **Wheel of Misfortune realizado nos últimos 90d**: time praticou response em incident histórico. Evidence: data + participantes.
67
+
68
+ ## Axe 4: Capacity Planning
69
+
70
+ - [ ] **Load test executado**: pico esperado × 2 testado; report com latency degradation curve. Evidence: load test report.
71
+ - [ ] **RPS limit documentado**: serviço sabe seu max sustainable RPS por instance. Evidence: number + source.
72
+ - [ ] **Auto-scaling testado**: scale-up + scale-down funcionam sem intervenção manual. Evidence: scaling test log.
73
+ - [ ] **Quota/rate-limit por tenant**: tenant abusivo não derruba serviço para outros. Evidence: rate-limit config.
74
+ - [ ] **Headroom ≥ 30%**: capacidade atual / pico esperado ≥ 1.3. Evidence: cálculo + dashboard.
75
+
76
+ ## Axe 5: Change Management
77
+
78
+ - [ ] **Canary release**: deploys vão para 1% → 10% → 100% com hold em cada estágio. Evidence: CI pipeline config.
79
+ - [ ] **Feature flags**: features novas atrás de flag (deploy ≠ release). Evidence: feature flag service.
80
+ - [ ] **Rollback automatizado**: SLO burn rate > N nos primeiros M min após deploy → rollback automático. Evidence: rollback automation config.
81
+ - [ ] **CI/CD gates obrigatórios**: testes + lint + security scan + load test (em paths críticos). Evidence: CI config.
82
+ - [ ] **Deploy frequency mensurado**: time conhece sua deploy cadence (commits/dia ou /semana). Evidence: metric URL.
83
+
84
+ ## Axe 6: Performance
85
+
86
+ - [ ] **Latency baseline (p50/p95/p99/p99.9)**: número conhecido para cada percentil principal. Evidence: dashboard query.
87
+ - [ ] **Error budget definido**: SLO target × window definidos; budget calculado. Evidence: SLO.md.
88
+ - [ ] **Saturation tracked**: CPU / memory / connection pool / queue depth — recurso mais escasso identificado. Evidence: gauge query.
89
+ - [ ] **Long tail (p99.9) monitored**: não só p50; alerta se p99.9 > N×p50 (regression detection). Evidence: query.
90
+ - [ ] **Risk continuum justificado**: target SLO escolhido com base em risk × innovation, não default 99.99%. Evidence: justificativa em SLO.md (ver [sre-risk-management](../sre-risk-management/SKILL.md)).
91
+
92
+ ---
93
+
94
+ ## Action Items
95
+
96
+ | # | Axe | Item | Severity | Owner | Due |
97
+ |---|-----|------|----------|-------|-----|
98
+ | 1 | 2 | Adicionar saturation gauge em /api/v1/orders | P0 | @bob | 2026-05-15 |
99
+ | 2 | 4 | Documentar RPS limit em runbook | P1 | @alice | 2026-05-22 |
100
+
101
+ ## Decisão
102
+
103
+ - [x] **Approved** — service production-ready
104
+ - [ ] **Approved with conditions** — P1s tracked, P0s blockers em release próximo
105
+ - [ ] **Blocked** — P0 gaps; service NÃO aceita tráfego real até resolução
106
+
107
+ ## Reviewer signature
108
+
109
+ Reviewer: @<sre>
110
+ Date: YYYY-MM-DD
111
+ ```
112
+ ````
113
+
114
+ ### Pattern: 3 engagement models — quando usar cada
115
+
116
+ | Modelo | Quando usar | SRE involvement | Custo SRE |
117
+ |---|---|---|---|
118
+ | **Simple PRR** | Serviços pequenos, internal tools, dogfood-only | Reviewer 1 sessão; checklist preenchido por dev | Baixo (4-8h) |
119
+ | **Early Engagement** | Serviços críticos (tier-1), customer-facing, expected RPS > 1k/s | SRE participa do design; junior review em milestones; full PRR pré-launch | Médio (semanas) |
120
+ | **Frameworks / SRE Platform** | Serviços built on top of plataforma SRE-blessed (lib + templates + gates já PRR-ready) | SRE manteve plataforma; dev usa scaffolds; PRR é confirmação que dev seguiu plataforma | Baixo recorrente, alto setup inicial |
121
+
122
+ Modelo escolhido pelo **custo de outage** do serviço:
123
+
124
+ - Outage < $1k/min → Simple PRR (1 sessão, checklist)
125
+ - Outage $1k-100k/min → Early Engagement (SRE no design)
126
+ - Outage > $100k/min OR > 10 microserviços similares → Platform (libs/scaffolds eliminam toil de PRR)
127
+
128
+ ### Pattern: handoff dev → SRE — sequência canônica
129
+
130
+ ```text
131
+ 1. Dev declara intenção: "Esse serviço vai produção em 2026-MM-DD."
132
+ 2. Reviewer SRE aceita engagement model (Simple/Early/Platform).
133
+ 3. Dev preenche PRR checklist (6 axes) com evidence em cada item.
134
+ 4. Reviewer abre PRR-REPORT.md em .planning/prr/<service>.md, score cada axe (Pass/Fail/N-A).
135
+ 5. Reviewer + dev discutem gaps:
136
+ - P0 (blocker): dev resolve antes de production ship
137
+ - P1 (scheduled): owner + due date; tracked em roadmap
138
+ - P2 (optional): documentado mas não obrigatório
139
+ 6. Após P0s resolvidos, reviewer marca Approved e assina.
140
+ 7. Dev ship (canary 1% → 100%).
141
+ 8. Pós-launch: SRE review SLO compliance em 7d, 30d, 90d.
142
+ 9. Re-PRR triggered em mudanças maiores (rewrite, RPS 10×, novo dependency tier-1).
143
+ ```
144
+
145
+ ### Pattern: SRE Platform como amplificador
146
+
147
+ ```text
148
+ Plataforma SRE consiste em:
149
+
150
+ 1. Library/SDK que codifica boas práticas (otel-by-default, structured-logging-by-default,
151
+ 4-golden-signals-by-default, rate-limit-by-default, circuit-breaker-by-default)
152
+ 2. Scaffolds/templates de novo serviço (kit-mcp 's `/sre`, e.g., `/sre new-service <name>`)
153
+ 3. CI gates que verificam adequação à plataforma (gates de Phase 41:
154
+ golden-signals-coverage, postmortem-template-required, prr-checklist-coverage)
155
+ 4. Runbook templates por categoria de serviço (HTTP API, async worker, batch job)
156
+
157
+ Resultado: novo serviço nasce com 80% do PRR já passado por design.
158
+ PRR vira confirmação ("você usou a plataforma?"), não auditoria de zero.
159
+
160
+ Trade-off: setup inicial alto (semanas-meses para escrever plataforma).
161
+ Recomendado para org com 10+ microserviços similares.
162
+ ```
163
+
164
+ ### Pattern: PRR-REPORT.md template canônico
165
+
166
+ ````markdown
167
+ ```markdown
168
+ # PRR-REPORT — <serviço/feature> — <data>
169
+
170
+ **Reviewer:** @<sre-or-external>
171
+ **Engagement model:** Simple PRR | Early Engagement | Frameworks/Platform
172
+ **Status:** Approved | Approved with conditions | Blocked
173
+
174
+ ## Sumário executivo
175
+
176
+ Resultado por axe (1-2 linhas cada):
177
+
178
+ | Axe | Score | Status |
179
+ |-----|-------|--------|
180
+ | 1. System Architecture | 5/5 | Pass |
181
+ | 2. Instrumentation, Metrics, Monitoring | 4/5 | Pass with gaps |
182
+ | 3. Emergency Response | 3/5 | Fail (P0) |
183
+ | 4. Capacity Planning | 4/5 | Pass with gaps |
184
+ | 5. Change Management | 5/5 | Pass |
185
+ | 6. Performance | 4/5 | Pass with gaps |
186
+
187
+ ## Detalhamento por axe
188
+
189
+ [seção por axe com itens checked + evidence + gaps]
190
+
191
+ ## Action Items
192
+
193
+ [tabela com P0/P1/P2 + owner + due]
194
+
195
+ ## Aprovação
196
+
197
+ [Approved / Approved with conditions / Blocked]
198
+ [Assinatura + data]
199
+ ```
200
+ ````
201
+
202
+ ## Anti-patterns
203
+
204
+ ### ANTI: PRR depois do launch
205
+
206
+ ```text
207
+ ANTI: fazer PRR após serviço já em produção.
208
+
209
+ PROBLEMA: gaps P0 já causaram incidents (sem instrumentação significa SEV1 cego);
210
+ valor de gate perdido; PRR vira post-mortem disfarçado.
211
+
212
+ CERTO: PRR ANTES de aceitar tráfego real (≥ 1%); blocker se P0 pendente.
213
+ PRR conclusão é pré-requisito de aceitar tráfego, não follow-up.
214
+ ```
215
+
216
+ ### ANTI: auto-PRR pelo time dev
217
+
218
+ ```text
219
+ ANTI: time dev preenche checklist + auto-aprova.
220
+
221
+ PROBLEMA: confirmation bias (dev acredita que serviço é maduro); itens vagos
222
+ passam ("Sim, temos monitoring"); gaps invisíveis até incident.
223
+
224
+ CERTO: reviewer EXTERNO ao time (SRE ou outro time dev sênior); evidence-based
225
+ em cada item; dev preenche, externo verifica.
226
+ ```
227
+
228
+ ### ANTI: pular axes "menos relevantes"
229
+
230
+ ```text
231
+ ANTI: "Esse serviço é simples, não precisa de capacity planning."
232
+
233
+ PROBLEMA: axe pulado vira lacuna; "simples" é subjetivo; decisão baseada em
234
+ assumption sem evidence.
235
+
236
+ CERTO: TODOS os 6 axes preenchidos. Item N/A é resposta válida (com justificativa)
237
+ — pular silenciosamente NÃO é. Para serviços pequenos, model "Simple PRR"
238
+ cobre os 6 em 4-8h.
239
+ ```
240
+
241
+ ### ANTI: PRR como rubber stamp
242
+
243
+ ```text
244
+ ANTI: reviewer aprova sem ler evidence; meeting 15 min; checklist marcado "looks good".
245
+
246
+ PROBLEMA: first-incident (em 3-6 meses) revela 5+ gaps; reviewer responsabilidade
247
+ compartilhada por incident.
248
+
249
+ CERTO: reviewer aplica time-budget (4-8h Simple, dias Early); evidence verificada
250
+ em cada item; não-OK = blocker, não "todos têm gaps".
251
+ ```
252
+
253
+ ### ANTI: engagement model errado para custo
254
+
255
+ ```text
256
+ ANTI: Simple PRR para tier-1 (outage > $100k/min) OU Early Engagement para internal
257
+ tool com 5 usuários.
258
+
259
+ PROBLEMA: Simple para tier-1 — SRE não engajou no design; problemas estruturais
260
+ inviáveis de fix pós-launch; tier-1 com instabilidade. Early para
261
+ internal tool — over-investment SRE; deslocamento de trabalho importante.
262
+
263
+ CERTO: escolher model conforme custo de outage (regra do glossário: < $1k/min =
264
+ Simple, > $100k/min = Platform).
265
+ ```
266
+
267
+ ### ANTI: PRR one-shot
268
+
269
+ ```text
270
+ ANTI: passou PRR em 2024, foi para prod, nunca re-PRR'd.
271
+
272
+ PROBLEMA: 2 anos depois — dependency new, RPS 10×, código rewrote, time rotated;
273
+ PRR original irrelevante.
274
+
275
+ CERTO: re-PRR triggered em (a) rewrite > 50%, (b) RPS escala > 10×, (c) novo
276
+ dependency tier-1, (d) time-of-record rotation > 50%, (e) anualmente como
277
+ hygiene.
278
+ ```
279
+
280
+ ## Verificação
281
+
282
+ Antes de marcar PRR como `Approved`:
283
+
284
+ 1. **6 axes preenchidos** — System Architecture, Instrumentation/Metrics/Monitoring, Emergency Response, Capacity Planning, Change Management, Performance
285
+ 2. **Cada item tem evidence** — não checkbox vago; evidence concreta (URL/query/doc) em cada
286
+ 3. **Engagement model escolhido apropriadamente** — Simple PRR/Early Engagement/Frameworks-Platform conforme custo de outage
287
+ 4. **Reviewer ≠ time dev** — reviewer externo ou SRE
288
+ 5. **P0s todos resolvidos** — gaps P0 são blockers; nenhum aberto pré-launch
289
+ 6. **P1s tracked com owner + due** — escalonados em roadmap próximo
290
+ 7. **PRR-REPORT.md em `.planning/prr/<service>.md`** — formato canônico
291
+ 8. **Re-PRR trigger documentado** — quando re-PRR é triggered (rewrite, RPS 10×, etc.)
292
+
293
+ ## Ver também
294
+
295
+ - [`_shared-sre/glossary.md`](../_shared-sre/glossary.md) — termos canônicos PRR, 6 axes, 3 engagement models
296
+ - [`four-golden-signals`](../four-golden-signals/SKILL.md) — Axe 2 (Instrumentation) exige os 4 signals
297
+ - [`event-based-slos`](../event-based-slos/SKILL.md) (v1.9) — Axe 6 (Performance) exige SLO definido
298
+ - [`burn-rate-alerting`](../burn-rate-alerting/SKILL.md) (v1.9) — Axe 2 (Instrumentation) exige SLO burn-rate alerts
299
+ - [`sre-risk-management`](../sre-risk-management/SKILL.md) — Axe 6 (Performance) requer risk continuum justificativa
300
+ - [`blameless-postmortems`](../blameless-postmortems/SKILL.md) — Axe 3 (Emergency Response) exige postmortem culture
301
+ - [`eliminating-toil`](../eliminating-toil/SKILL.md) — Axe 5 (Change Management) verifica deploy não é toil
302
+
303
+ ---
304
+
305
+ *Material-fonte: Site Reliability Engineering — Beyer, Jones, Petoff, Murphy (Google/O'Reilly, 2016) — Cap 32: "The Evolving SRE Engagement Model".*
@@ -0,0 +1,367 @@
1
+ ---
2
+ name: release-engineering
3
+ description: Use ao desenhar/auditar pipeline de release — deployment philosophy, self-service, policy enforcement, canary, rollback, branching strategy, release invariants. Cap 8 livro Google SRE.
4
+ ---
5
+
6
+ # SRE — Release Engineering
7
+
8
+ ## Quando usar
9
+
10
+ LLM carrega esta skill ao desenhar pipeline de deploy ou ao investigar release fragility. Trigger phrases:
11
+
12
+ - "release pipeline", "deploy pipeline"
13
+ - "canary release", "rollback"
14
+ - "branching strategy", "trunk-based development"
15
+ - "deployment philosophy"
16
+ - "policy enforcement"
17
+ - "release engineering"
18
+ - "cap 8 Google SRE"
19
+
20
+ ## Regras absolutas
21
+
22
+ - **Release engineering é DISCIPLINA SEPARADA.** Cuida de "código no merge → bits em prod". Não é dev (que produz código), não é SRE clássico (que opera prod). É a ponte.
23
+ - **4 invariantes canônicos (cap 8):**
24
+ 1. **Self-service:** engineers deployam sozinhos via CLI/UI (sem aprovação manual SRE)
25
+ 2. **High velocity:** deploy ≥ 1×/dia (ideal: cada merge)
26
+ 3. **Hermetic builds:** input idêntico → output idêntico
27
+ 4. **Policy enforcement:** policies em ferramenta, não em humano
28
+ - **Trunk-based development > GitFlow.** Main sempre deployable. Feature flags para work in progress. Branches longos = harder rollback + merge hell.
29
+ - **Canary release OBRIGATÓRIO em prod.** 1% → 10% → 50% → 100% com SLO check em cada estágio. Bug detectado em 1% afeta < 1% dos users.
30
+ - **Rollback < 5 min, exercitado.** Schema migrations sempre forward-compatible OR reversible. Artefato N-1 preservado.
31
+ - **Config separada de código (12-factor).** Config versionada, audit-able, GitOps. ConfigMaps, env vars, feature flags. NUNCA hardcoded em image.
32
+ - **Continuous build + test + deploy.** Cada commit dispara pipeline. Deploy contínuo (push tag → prod) preferred a continuous delivery (deploy disponível mas manual).
33
+ - **Release pipeline tem audit trail.** Quem deployou, quando, qual commit, qual artefato. Auto-gerado via CI logs + tags + GitHub Releases.
34
+
35
+ ## Patterns canônicos
36
+
37
+ ### Pattern 1: 4 invariantes canônicos
38
+
39
+ ```text
40
+ 1. SELF-SERVICE
41
+ ============
42
+ ANTI: engineer abre ticket → SRE aprova → SRE deploya
43
+ CERTO: engineer roda `gh workflow run deploy.yml` → workflow valida policies →
44
+ deploy automático
45
+ Implementação: GitHub Actions / GitLab CI / Argo CD com approval rules.
46
+
47
+ 2. HIGH VELOCITY
48
+ ==============
49
+ Métrica DORA: deployment frequency
50
+ Elite: multiple per day
51
+ High: weekly
52
+ Medium: monthly
53
+ Low: < monthly (problem)
54
+ Implementação: trunk-based + feature flags + small commits + CI fast.
55
+
56
+ 3. HERMETIC BUILDS (skill separada)
57
+ =================================
58
+ Mesmo commit + lockfile → mesmo artefato. SLSA Level 3+.
59
+
60
+ 4. POLICY ENFORCEMENT
61
+ ===================
62
+ Policies em ferramenta, não em humanos:
63
+ - branch protection (no direct push to main)
64
+ - required reviewers (≥ 1 ou ≥ 2 dependendo de criticality)
65
+ - required CI checks (build + test + lint + security scan)
66
+ - signed commits (GPG keys)
67
+ - production deploy só de tagged releases
68
+ Implementação: GitHub branch protection + CODEOWNERS + custom Actions.
69
+ ```
70
+
71
+ ### Pattern 2: Trunk-based development workflow
72
+
73
+ ```text
74
+ Trunk-based (Google + Facebook + Netflix):
75
+
76
+ main (deployable)
77
+ ├── feat/A (24-48h) → merge → DELETE branch
78
+ ├── feat/B (24-48h) → merge → DELETE branch
79
+ └── ...
80
+
81
+ Pré-requisitos:
82
+ ✓ Feature flags para work in progress (incomplete features hidden)
83
+ ✓ CI rápido (≤ 10min) — feedback fast
84
+ ✓ Tests forte (> 80% coverage; flaky < 1%)
85
+ ✓ Pair programming OU async PR review
86
+
87
+ vs GitFlow:
88
+ - develop branch (3-7 dias)
89
+ - release branch (1-3 dias)
90
+ - hotfix branch (em incident)
91
+ - main reflete prod
92
+ PROBLEMS: merge hell, slow integration, branch divergence
93
+
94
+ Quando preferir GitFlow (raramente):
95
+ - Long release cycles obrigatórios (regulamentação healthcare/finance)
96
+ - Customers need múltiplas versões em paralelo (LTS branches)
97
+ ```
98
+
99
+ ### Pattern 3: Canary release pipeline canônico
100
+
101
+ ```yaml
102
+ # GitHub Actions deploy.yml — canary release
103
+ name: Deploy
104
+
105
+ on:
106
+ push:
107
+ tags: ['v*']
108
+
109
+ jobs:
110
+ build:
111
+ runs-on: ubuntu-latest
112
+ steps:
113
+ - uses: actions/checkout@v6
114
+ - run: pnpm install --frozen-lockfile
115
+ - run: pnpm build
116
+ - uses: actions/upload-artifact@v4
117
+ with: { name: dist, path: dist/ }
118
+
119
+ canary-1pct:
120
+ needs: build
121
+ runs-on: ubuntu-latest
122
+ steps:
123
+ - uses: actions/download-artifact@v4
124
+ - run: ./scripts/deploy-canary.sh --percent 1
125
+ - run: sleep 600 # observe por 10 min
126
+ - run: ./scripts/check-slo.sh --window 10m --threshold 99.9
127
+ # Se SLO falhar → workflow falha → human intervention
128
+
129
+ canary-10pct:
130
+ needs: canary-1pct
131
+ runs-on: ubuntu-latest
132
+ steps:
133
+ - run: ./scripts/deploy-canary.sh --percent 10
134
+ - run: sleep 600
135
+ - run: ./scripts/check-slo.sh --window 10m --threshold 99.9
136
+
137
+ canary-50pct:
138
+ needs: canary-10pct
139
+ runs-on: ubuntu-latest
140
+ steps:
141
+ - run: ./scripts/deploy-canary.sh --percent 50
142
+ - run: sleep 600
143
+ - run: ./scripts/check-slo.sh --window 10m --threshold 99.9
144
+
145
+ full-rollout:
146
+ needs: canary-50pct
147
+ runs-on: ubuntu-latest
148
+ steps:
149
+ - run: ./scripts/deploy-full.sh
150
+ - run: sleep 1800 # observe por 30 min
151
+ - run: ./scripts/check-slo.sh --window 30m --threshold 99.9
152
+ ```
153
+
154
+ **SLO check em cada stage:** burn rate ≤ baseline × 2 = OK; > 2 = abort + rollback.
155
+
156
+ ### Pattern 4: Rollback canônico
157
+
158
+ ```bash
159
+ # PT-BR: rollback workflow
160
+ # Pré-requisito: artefato N-1 preservado (image registry, S3, etc.)
161
+
162
+ # 1. Detectar problema (manual OR auto via SLO burn alert v1.9)
163
+ # 2. Identificar versão atual + anterior
164
+ CURRENT=$(kubectl get deployment app -o jsonpath='{.spec.template.spec.containers[0].image}')
165
+ PREVIOUS=$(./scripts/get-previous-deploy.sh app)
166
+
167
+ # 3. Rollback (1 comando)
168
+ kubectl set image deployment/app app="$PREVIOUS"
169
+
170
+ # 4. Verificar — SLO burn estabilizou?
171
+ ./scripts/check-slo.sh --window 5m --threshold 99.9
172
+
173
+ # 5. Audit trail — registrar em incident
174
+ echo "Rollback de $CURRENT para $PREVIOUS at $(date)" >> .planning/incidents/<id>.md
175
+
176
+ # Target: rollback < 5 min, da decisão à observabilidade estabilizada
177
+ ```
178
+
179
+ **Schema migration considerations:**
180
+ - ADD column nullable + default → forward-compatible (rollback OK)
181
+ - DROP column → NOT-rollback-able (forward-fix required)
182
+ - ALTER column NOT NULL com default → reversible se default preservado
183
+ - Sempre escrever migration UP + DOWN (mesmo que UP forward-only)
184
+
185
+ ### Pattern 5: Configuration management (12-factor)
186
+
187
+ ```text
188
+ 12-factor app princípios canônicos:
189
+
190
+ I. Codebase — single repo per app
191
+ II. Dependencies — explicit (lockfile)
192
+ III. Config — env vars OR ConfigMap (NÃO hardcoded)
193
+ IV. Backing services — attached resources via env
194
+ V. Build/Release/Run — strict separation
195
+ VI. Processes — stateless
196
+ VII. Port binding — self-contained
197
+ VIII. Concurrency — scale via process model
198
+ IX. Disposability — fast startup + graceful shutdown
199
+ X. Dev/prod parity — same code, same DB type, same OS
200
+ XI. Logs — stdout/stderr (não files)
201
+ XII. Admin processes — one-off scripts em mesmo env
202
+
203
+ Implementação Supabase:
204
+ - Edge Function env vars: Deno.env.get('SUPABASE_URL') etc.
205
+ - Secrets via supabase secrets set
206
+ - Config NÃO commitado (tem .env.example, sem .env)
207
+ - Migrations via supabase/migrations (versionado)
208
+ - Feature flags via env OR Supabase row em config table
209
+ ```
210
+
211
+ ### Pattern 6: Branch protection + CODEOWNERS
212
+
213
+ ```yaml
214
+ # .github/CODEOWNERS
215
+ # PT-BR: define quem revisa cada path
216
+
217
+ # Default — qualquer maintainer
218
+ * @luanpdd
219
+
220
+ # Critical paths — exigir aprovação SRE
221
+ /supabase/migrations/ @luanpdd @sre-team
222
+ /src/auth/ @luanpdd @security-team
223
+ /.github/workflows/ @luanpdd @sre-team
224
+ /gates/ @luanpdd
225
+
226
+ # UI changes — designer review
227
+ /src/components/ @luanpdd @design-team
228
+ ```
229
+
230
+ ```text
231
+ GitHub branch protection rules para `main`:
232
+ ✓ Require pull request before merging
233
+ ✓ Require approvals: 1 (or 2 for critical)
234
+ ✓ Dismiss stale reviews on push
235
+ ✓ Require review from CODEOWNERS
236
+ ✓ Require status checks: build, test, lint
237
+ ✓ Require branches up to date
238
+ ✓ Require signed commits
239
+ ✓ Restrict who can push: empty (force PR)
240
+ ✗ Allow force push: NEVER
241
+ ✗ Allow deletions: NEVER
242
+ ```
243
+
244
+ ### Pattern 7: Audit trail canônico
245
+
246
+ ```text
247
+ Cada release tem audit trail completo:
248
+
249
+ 1. Commit message (what + why)
250
+ 2. PR description (context + breaking changes + migrations)
251
+ 3. PR reviewers (who approved)
252
+ 4. CI logs (build provenance + test results)
253
+ 5. Deploy logs (who triggered, when, which artifact)
254
+ 6. GitHub Release (changelog + tagged commit)
255
+ 7. Monitoring (SLO/golden signals during/after deploy)
256
+
257
+ Tools:
258
+ - GitHub Releases — auto-generated changelog
259
+ - Sentry/Datadog — track release_id em events
260
+ - Slack/PagerDuty — notification em deploy
261
+ - SLSA attestation — provenance signed
262
+ ```
263
+
264
+ ## Anti-patterns
265
+
266
+ ### ANTI: aprovação humana manual em release
267
+
268
+ ```text
269
+ ANTI: cada deploy → SRE checa, aprova, deploya manualmente.
270
+
271
+ PROBLEMA: SRE bottleneck. Deploys raros (1×/semana). Velocity colapsa.
272
+ Toil para SRE.
273
+
274
+ CERTO: policies em ferramenta. Engineer self-deploys. SRE escreve
275
+ guard rails (canary, SLO check), não aprovações ad-hoc.
276
+ ```
277
+
278
+ ### ANTI: deploy de branch local
279
+
280
+ ```text
281
+ ANTI: dev faz `kubectl apply` da máquina dele.
282
+
283
+ PROBLEMA: drift entre git e prod. Sem audit trail. Sem CI check.
284
+ Quando precisa rollback, "qual era a versão?".
285
+
286
+ CERTO: deploy SOMENTE de CI. Local push to prod proibido em
287
+ branch protection. Pipeline valida + deploya + audit.
288
+ ```
289
+
290
+ ### ANTI: rollback "vai dar conta no forward-fix"
291
+
292
+ ```text
293
+ ANTI: cultura "nunca rollback". Sempre forward-fix.
294
+
295
+ PROBLEMA: forward-fix sob pressão = mais bugs. Rollback nunca
296
+ exercitado, quando precisa não funciona.
297
+
298
+ CERTO: rollback < 5min em qualquer release, exercitado mensalmente.
299
+ Forward-fix é exception, não default.
300
+ ```
301
+
302
+ ### ANTI: schema migration NOT NULL sem default
303
+
304
+ ```text
305
+ ANTI: ALTER TABLE orders ADD COLUMN priority INTEGER NOT NULL;
306
+
307
+ PROBLEMA: migration falha em rows existentes. Rollback custoso.
308
+ Code novo + DB velho = error.
309
+
310
+ CERTO: ADD COLUMN priority INTEGER DEFAULT 0 NOT NULL;
311
+ Forward-compatible (old code ignora; new code usa).
312
+ Rollback de code OK porque DB tem default.
313
+ ```
314
+
315
+ ### ANTI: feature flag sem expiration
316
+
317
+ ```text
318
+ ANTI: flags acumulam, nunca removidas. 50 flags em prod, 30 ativas.
319
+
320
+ PROBLEMA: cognitive load. Combinations untested. Flag Y desligado
321
+ há 6 meses ainda no código (dead code).
322
+
323
+ CERTO: flags têm DATA DE EXPIRAÇÃO. Após launch + 30d safe → REMOVE
324
+ flag (e código do branch perdedor). Cleanup é parte da
325
+ feature, não opcional.
326
+ ```
327
+
328
+ ### ANTI: hotfix direct push em main
329
+
330
+ ```text
331
+ ANTI: incident → dev pushar direto em main "pra ser rápido".
332
+
333
+ PROBLEMA: bypass branch protection. Sem review. Sem CI.
334
+ Pode introduzir novo bug.
335
+
336
+ CERTO: hotfix ainda via PR (mesmo se rápido — 5min review). CI
337
+ roda. Branch protection ativa. Audit trail preserved.
338
+ "Rápido" não é desculpa pra atalhar safety.
339
+ ```
340
+
341
+ ## Verificação
342
+
343
+ 1. Self-service deploy ativo (engineers deployam sozinhos)
344
+ 2. Trunk-based OR justified GitFlow exception
345
+ 3. Canary release pipeline (1% → 10% → 50% → 100% com SLO check)
346
+ 4. Rollback testado mensalmente; < 5 min
347
+ 5. Branch protection em main (no direct push, required PR + CI + reviewers)
348
+ 6. CODEOWNERS para paths críticos
349
+ 7. Lockfile commitado + frozen-install em CI
350
+ 8. Build provenance via SLSA
351
+ 9. Config 12-factor (env vars, GitOps)
352
+ 10. Feature flags com expiration policy
353
+ 11. Audit trail completo (commit + PR + CI + deploy + monitoring)
354
+
355
+ ---
356
+
357
+ ## Ver também
358
+
359
+ - [`_shared-sre/glossary.md`](../_shared-sre/glossary.md) — vocabulário (release pipeline, canary, rollback, etc.)
360
+ - [`hermetic-builds`](../hermetic-builds/SKILL.md) (v1.11) — fundação técnica
361
+ - [`production-readiness-review`](../production-readiness-review/SKILL.md) (v1.10) — PRR Axe 5 (Change Management)
362
+ - [`eliminating-toil`](../eliminating-toil/SKILL.md) (v1.10) — manual deployment é toil clássico
363
+ - [`release-pipeline-auditor`](../../agents/release-pipeline-auditor.md) (v1.11) — agent que audita
364
+ - [`/auditar-release`](../../commands/auditar-release.md) (v1.11) — comando
365
+ - [`/concluir-marco`](../../commands/concluir-marco.md) (framework + patch v1.11) — gate `release-pipeline-policy` opt-in
366
+
367
+ *Material-fonte: Site Reliability Engineering — Beyer/Jones/Petoff/Murphy (Google/O'Reilly, 2016) — Cap 8: "Release Engineering". Plus 12-factor app (12factor.net), DORA metrics.*