@luanpdd/kit-mcp 1.35.0 → 1.36.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 (117) hide show
  1. package/bin/cli.js +2 -2
  2. package/bin/mcp.js +6 -6
  3. package/bin/ui.js +74 -74
  4. package/gates/ai-prompt-stability.md +120 -120
  5. package/gates/budget-description.md +68 -68
  6. package/gates/confidence.md +29 -29
  7. package/gates/dependency-check.md +33 -33
  8. package/gates/dept-cycle-prevention.md +179 -179
  9. package/gates/golden-signals-coverage.md +133 -133
  10. package/gates/legacy-refactor-safety.md +178 -178
  11. package/gates/multi-tenant-rls-coverage.md +102 -102
  12. package/gates/no-personal-uuid.md +72 -72
  13. package/gates/obs-agents-mcp-supabase.md +86 -86
  14. package/gates/obs-skills-frontmatter.md +76 -76
  15. package/gates/observability-coverage.md +151 -151
  16. package/gates/omm-no-regression.md +83 -83
  17. package/gates/postmortem-template-required.md +127 -127
  18. package/gates/prr-checklist-coverage.md +128 -128
  19. package/gates/regression.md +32 -32
  20. package/gates/release-pipeline-policy.md +132 -132
  21. package/gates/secrets-scan.md +33 -33
  22. package/gates/service-role-not-in-user-facing.md +113 -113
  23. package/gates/skill-must-include.md +71 -71
  24. package/gates/sync-idempotent.md +62 -62
  25. package/gates/verify-phase-goal.md +34 -34
  26. package/kit/agents/designer-ui.md +216 -216
  27. package/kit/agents/workflow-generator.md +537 -167
  28. package/kit/commands/adicionar-backlog.md +1 -1
  29. package/kit/commands/adicionar-fase.md +1 -1
  30. package/kit/commands/adicionar-tarefa.md +1 -1
  31. package/kit/commands/auditar-observabilidade.md +103 -103
  32. package/kit/commands/auditar-toil.md +129 -129
  33. package/kit/commands/caracterizar-prompt.md +195 -195
  34. package/kit/commands/criar-workflow.md +158 -158
  35. package/kit/commands/definir-perfil.md +1 -1
  36. package/kit/commands/definir-slo.md +108 -108
  37. package/kit/commands/fio.md +1 -1
  38. package/kit/commands/golden-signals.md +142 -142
  39. package/kit/commands/instrumentar-fase.md +200 -200
  40. package/kit/commands/investigar-producao.md +162 -162
  41. package/kit/commands/observabilidade.md +118 -118
  42. package/kit/commands/postmortem.md +179 -179
  43. package/kit/commands/prr.md +205 -205
  44. package/kit/commands/publicar-rapido.md +207 -207
  45. package/kit/commands/risk-budget.md +220 -220
  46. package/kit/commands/sre.md +230 -230
  47. package/kit/file-manifest.json +424 -424
  48. package/kit/framework/references/output-style.md +22 -22
  49. package/kit/hooks/post-apply-migration.js +199 -199
  50. package/kit/hooks/sidecar-tool-publisher.js +210 -210
  51. package/kit/skills/_shared-dados-distribuidos/glossary.md +224 -224
  52. package/kit/skills/_shared-legacy/glossary.md +389 -389
  53. package/kit/skills/_shared-multi-tenant/glossary.md +186 -186
  54. package/kit/skills/_shared-observability/glossary.md +396 -396
  55. package/kit/skills/_shared-sre/glossary.md +712 -712
  56. package/kit/skills/_shared-supabase/glossary.md +234 -234
  57. package/kit/skills/blameless-postmortems/SKILL.md +340 -340
  58. package/kit/skills/burn-rate-alerting/SKILL.md +258 -258
  59. package/kit/skills/cascading-failures/SKILL.md +311 -311
  60. package/kit/skills/core-analysis-loop/SKILL.md +352 -352
  61. package/kit/skills/distributed-tracing/SKILL.md +362 -362
  62. package/kit/skills/dynamic-workflow-authoring/SKILL.md +327 -223
  63. package/kit/skills/eliminating-toil/SKILL.md +243 -243
  64. package/kit/skills/event-based-slos/SKILL.md +296 -296
  65. package/kit/skills/four-golden-signals/SKILL.md +314 -314
  66. package/kit/skills/hermetic-builds/SKILL.md +323 -323
  67. package/kit/skills/legacy-monster-methods/SKILL.md +444 -444
  68. package/kit/skills/llm-as-dependency/SKILL.md +436 -436
  69. package/kit/skills/load-shedding-graceful-degradation/SKILL.md +396 -396
  70. package/kit/skills/observability-driven-development/SKILL.md +315 -315
  71. package/kit/skills/observability-maturity-model/SKILL.md +222 -222
  72. package/kit/skills/opentelemetry-standard/SKILL.md +351 -351
  73. package/kit/skills/production-readiness-review/SKILL.md +305 -305
  74. package/kit/skills/release-engineering/SKILL.md +367 -367
  75. package/kit/skills/retry-strategies/SKILL.md +372 -372
  76. package/kit/skills/sre-risk-management/SKILL.md +221 -221
  77. package/kit/skills/structured-events/SKILL.md +265 -265
  78. package/kit/skills/supabase-cron-queues/SKILL.md +275 -275
  79. package/kit/skills/supabase-database-functions/SKILL.md +332 -332
  80. package/kit/skills/supabase-declarative-schema/SKILL.md +183 -183
  81. package/kit/skills/supabase-pgvector-rag/SKILL.md +253 -253
  82. package/kit/skills/supabase-postgres-style/SKILL.md +138 -138
  83. package/kit/skills/supabase-storage/SKILL.md +234 -234
  84. package/kit/skills/telemetry-pipelines/SKILL.md +259 -259
  85. package/kit/skills/telemetry-sampling/SKILL.md +256 -256
  86. package/kit/skills/ui-anti-padroes-ia/SKILL.md +261 -261
  87. package/kit/skills/ui-contexto-produto/SKILL.md +248 -248
  88. package/kit/skills/ui-cor-estrategia/SKILL.md +213 -213
  89. package/kit/skills/ui-critica-auditoria/SKILL.md +260 -260
  90. package/kit/skills/ui-motion-funcional/SKILL.md +264 -264
  91. package/kit/skills/ui-ritmo-espacial/SKILL.md +259 -259
  92. package/kit/skills/ui-tipografia/SKILL.md +211 -211
  93. package/package.json +1 -1
  94. package/src/cli/index.js +1114 -1114
  95. package/src/cli/render.js +194 -194
  96. package/src/cli/upgrade-check.js +135 -135
  97. package/src/core/error-redaction.js +76 -76
  98. package/src/core/failures.js +153 -153
  99. package/src/core/gate-runner.js +205 -205
  100. package/src/core/gates.js +82 -82
  101. package/src/core/logger.js +170 -170
  102. package/src/core/manifest-verify.js +174 -174
  103. package/src/core/metrics.js +268 -268
  104. package/src/core/notify.js +60 -60
  105. package/src/core/path-safety.js +141 -141
  106. package/src/core/replays.js +120 -120
  107. package/src/core/ui.js +185 -185
  108. package/src/mcp-server/install.js +149 -149
  109. package/src/mcp-server/roots.js +124 -124
  110. package/src/ui/auto-spawn.js +113 -113
  111. package/src/ui/browser.js +78 -78
  112. package/src/ui/client.js +130 -130
  113. package/src/ui/events.js +65 -65
  114. package/src/ui/lockfile.js +191 -191
  115. package/src/ui/port.js +67 -67
  116. package/src/ui/server.js +547 -547
  117. package/src/ui/wrapper.js +129 -129
@@ -1,179 +1,179 @@
1
- ---
2
- name: postmortem
3
- description: Invoca postmortem-writer — modo --from-investigation <id> (lê v1.9 trail) ou --incident "<descrição>" standalone; produz postmortem blameless 9 seções.
4
- argument-hint: "(--from-investigation <id> | --incident \"<descrição>\") [--severity SEV1|SEV2|SEV3]"
5
- allowed-tools:
6
- - Read
7
- - Write
8
- - Bash
9
- - Grep
10
- - Glob
11
- - Task
12
- - AskUserQuestion
13
- ---
14
-
15
- <objective>
16
- Gerar **postmortem blameless** de 9 seções (cap 15 do livro Google SRE) — Summary, Impact, Root Causes, Trigger, Resolution, Detection, Action Items, Lessons Learned, Timeline UTC. Invoca o agente [`postmortem-writer`](../agents/postmortem-writer.md) que aplica a skill [`blameless-postmortems`](../skills/blameless-postmortems/SKILL.md) — cultura blameless ("foco em sistema/processo, NÃO em pessoas"), action items SMART, "no postmortem left unreviewed".
17
-
18
- **Cria/Atualiza:**
19
- - `.planning/postmortems/<id>.md` — postmortem blameless completo
20
-
21
- **Após:** o user tem postmortem revisável + action items concretos. Phase 40 INT-FW-V2-01 chained do `/forense` automaticamente após Core Analysis Loop fechar.
22
- </objective>
23
-
24
- <context>
25
- **Argumentos:** `$ARGUMENTS` — comando suporta **2 modos mutuamente exclusivos**.
26
-
27
- **Modo A: `--from-investigation <id>` (preferido — continuação de v1.9)**
28
-
29
- Lê `.planning/investigations/<id>.md` produzido pelo [`incident-investigator`](../agents/incident-investigator.md) (v1.9 — Core Analysis Loop). Extrai automaticamente: trigger, root cause, hipóteses validadas, action items. Campos faltantes (impact quantificado, severity, autores) são perguntados via `AskUserQuestion`.
30
-
31
- **Modo B: `--incident "<descrição>"` (standalone)**
32
-
33
- Para postmortem sem investigation prévia (incident menor, near-miss, lições retrospectivas). Agent gera template e usa `AskUserQuestion` para 9 perguntas guiadas — uma por seção canônica.
34
-
35
- **Flags adicionais:**
36
- - `--severity <SEV1|SEV2|SEV3>` — severity do incident (default: AskUserQuestion)
37
- - `--output <path>` — caminho do postmortem (default: `.planning/postmortems/<id>.md` — id auto-gerado)
38
-
39
- **Exemplos:**
40
- ```
41
- /postmortem --from-investigation incident-2026-05-06-1432-checkout-burn # Modo A
42
- /postmortem --incident "checkout SLO burn às 14:32 — RCA N+1 query orders" --severity SEV2 # Modo B
43
- /postmortem --incident "near-miss: deploy bloqueou 2min antes do PR-1234" # near-miss
44
- ```
45
-
46
- **Pré-requisito (Modo A):** arquivo `.planning/investigations/<id>.md` existe (criado por `/investigar-producao` ou `/forense`).
47
- </context>
48
-
49
- <process>
50
-
51
- ## 1. Parsear argumentos (2 modos)
52
-
53
- ```bash
54
- INV_ID=$(echo "$ARGUMENTS" | grep -oE -- '--from-investigation [^ ]+' | awk '{print $2}')
55
- INCIDENT=$(echo "$ARGUMENTS" | grep -oE -- '--incident "[^"]+"' | sed 's/--incident //; s/^"//; s/"$//')
56
- SEVERITY=$(echo "$ARGUMENTS" | grep -oE -- '--severity [^ ]+' | awk '{print $2}')
57
- OUTPUT_PATH=$(echo "$ARGUMENTS" | grep -oE -- '--output [^ ]+' | awk '{print $2}')
58
-
59
- # PT-BR: validar mutuamente exclusivos
60
- if [ -n "$INV_ID" ] && [ -n "$INCIDENT" ]; then
61
- echo "✗ Erro: --from-investigation e --incident são mutuamente exclusivos. Escolha um."
62
- exit 1
63
- fi
64
-
65
- # PT-BR: se nenhum dos 2 → AskUserQuestion (Modo C — interativo)
66
- if [ -z "$INV_ID" ] && [ -z "$INCIDENT" ]; then
67
- # Listar investigations recentes para sugestão
68
- RECENT_INVS=$(ls -t .planning/investigations/*.md 2>/dev/null | head -5 | while read f; do basename "$f" .md; done | tr '\n' ',')
69
- # AskUserQuestion: "Modo? Continuar de investigation existente OU postmortem standalone?"
70
- # Opções: Continuar de <ID> (uma por investigation recente) | Standalone (texto livre)
71
- echo "ℹ Sem flag explícita. Use --from-investigation <id> ou --incident \"<descrição>\"."
72
- [ -n "$RECENT_INVS" ] && echo " Investigations recentes: $RECENT_INVS"
73
- exit 1
74
- fi
75
- ```
76
-
77
- ## 2. Validar pré-requisitos por modo
78
-
79
- ```bash
80
- mkdir -p .planning/postmortems
81
-
82
- # PT-BR: Modo A — investigation file precisa existir
83
- if [ -n "$INV_ID" ]; then
84
- INV_FILE=".planning/investigations/${INV_ID}.md"
85
- if [ ! -f "$INV_FILE" ]; then
86
- echo "✗ Investigation $INV_ID não existe. Liste com: ls .planning/investigations/"
87
- echo " Para postmortem standalone: /postmortem --incident \"<descrição>\""
88
- exit 1
89
- fi
90
- # PT-BR: derivar postmortem id do investigation_id
91
- POSTMORTEM_ID="$INV_ID"
92
- fi
93
-
94
- # PT-BR: Modo B — gerar postmortem id automaticamente
95
- if [ -n "$INCIDENT" ]; then
96
- DATE=$(date -u +%Y-%m-%d-%H%M)
97
- SLUG=$(echo "$INCIDENT" | tr ' ' '-' | tr -cd 'a-zA-Z0-9-' | head -c 30 | sed 's/-$//')
98
- POSTMORTEM_ID="postmortem-${DATE}-${SLUG}"
99
- fi
100
-
101
- # PT-BR: default output_path (override via --output)
102
- [ -z "$OUTPUT_PATH" ] && OUTPUT_PATH=".planning/postmortems/${POSTMORTEM_ID}.md"
103
-
104
- # PT-BR: idempotência — não sobrescrever postmortem existente sem confirmar
105
- if [ -f "$OUTPUT_PATH" ]; then
106
- echo "⚠ Postmortem $OUTPUT_PATH já existe."
107
- echo " Use --output <novo-path> ou rm $OUTPUT_PATH antes de re-rodar."
108
- exit 1
109
- fi
110
- ```
111
-
112
- ## 3. Listar postmortems recentes (UX)
113
-
114
- ```bash
115
- # PT-BR: contexto — postmortems anteriores para correlacionar lessons learned
116
- ls -t .planning/postmortems/*.md 2>/dev/null | head -3 | while read f; do
117
- ID=$(basename "$f" .md)
118
- DATE=$(grep -m1 '\*\*Date:\*\*' "$f" 2>/dev/null | sed 's/.*Date:\*\* //' || echo "?")
119
- printf " %s — %s\n" "$ID" "$DATE"
120
- done
121
- ```
122
-
123
- ## 4. Dispatch para `postmortem-writer`
124
-
125
- ```text
126
- Task(
127
- subagent_type="postmortem-writer",
128
- prompt="
129
- ${INV_ID:+investigation_id: ${INV_ID}}
130
- ${INCIDENT:+incident_description: ${INCIDENT}}
131
- ${SEVERITY:+severity: ${SEVERITY}}
132
- output_path: ${OUTPUT_PATH}
133
- postmortem_id: ${POSTMORTEM_ID}
134
-
135
- Aplicar skill blameless-postmortems. Modo:
136
- ${INV_ID:+- Modo A: ler .planning/investigations/${INV_ID}.md, extrair trigger/root_cause/hipóteses/action_items automaticamente; perguntar via AskUserQuestion apenas campos faltantes (impact quantificado, severity, autores).}
137
- ${INCIDENT:+- Modo B: gerar template; perguntar via AskUserQuestion 9 questões guiadas — uma por seção canônica (Summary, Impact, Root Causes, Trigger, Resolution, Detection, Action Items, Lessons Learned, Timeline).}
138
-
139
- Padrões obrigatórios:
140
- - Foco em sistema/processo (NUNCA em pessoas) — anti-pattern blame culture
141
- - Action items SMART (Specific, Measurable, Assignable, Realistic, Time-bound)
142
- - Timeline em UTC sempre
143
- - Impact quantificado (# usuários, duração, SLO budget consumido, revenue se aplicável)
144
- - 9 seções canônicas obrigatórias (skip = inválido)
145
- "
146
- )
147
- ```
148
-
149
- ## 5. Pós-output
150
-
151
- ```
152
- ═══════════════════════════════════════════════════════════
153
- framework ► POSTMORTEM ▸ ${POSTMORTEM_ID}
154
- ═══════════════════════════════════════════════════════════
155
-
156
- [output do postmortem-writer — ver Step 6 do agent]
157
-
158
- ## Estado salvo
159
- .planning/postmortems/${POSTMORTEM_ID}.md
160
-
161
- ## Próximos passos
162
- 1. Revisar o postmortem com o time — "no postmortem left unreviewed"
163
- 2. Distribuir para reviewer SRE OU par externo (anti-pattern: auto-review)
164
- 3. Action items entram no roadmap (`/adicionar-tarefa` ou `/adicionar-fase`)
165
- 4. Se PRR for próximo passo de production-readiness: `/prr --service <name>`
166
- 5. Cross-ref OMM: postmortems alimentam Capacidade 5 (Incident Response) — `/observabilidade omm`
167
- ```
168
-
169
- </process>
170
-
171
- <success_criteria>
172
- - [ ] `--from-investigation <id>` E `--incident "<text>"` parseados (mutuamente exclusivos)
173
- - [ ] Modo A: arquivo `.planning/investigations/<id>.md` validado existe antes de dispatch
174
- - [ ] Modo B: postmortem_id auto-gerado a partir de date + slug
175
- - [ ] Idempotência: não sobrescreve postmortem existente sem `--output` explícito
176
- - [ ] `postmortem-writer` invocado via `Task(subagent_type=...)` com prompt completo (modo + 9 seções + padrões)
177
- - [ ] `.planning/postmortems/<id>.md` criado pelo agent
178
- - [ ] Próximos passos sugerem cross-ref para `/prr`, `/observabilidade omm`, `/adicionar-tarefa`
179
- </success_criteria>
1
+ ---
2
+ name: postmortem
3
+ description: Invoca postmortem-writer — modo --from-investigation <id> (lê v1.9 trail) ou --incident "<descrição>" standalone; produz postmortem blameless 9 seções.
4
+ argument-hint: "(--from-investigation <id> | --incident \"<descrição>\") [--severity SEV1|SEV2|SEV3]"
5
+ allowed-tools:
6
+ - Read
7
+ - Write
8
+ - Bash
9
+ - Grep
10
+ - Glob
11
+ - Task
12
+ - AskUserQuestion
13
+ ---
14
+
15
+ <objective>
16
+ Gerar **postmortem blameless** de 9 seções (cap 15 do livro Google SRE) — Summary, Impact, Root Causes, Trigger, Resolution, Detection, Action Items, Lessons Learned, Timeline UTC. Invoca o agente [`postmortem-writer`](../agents/postmortem-writer.md) que aplica a skill [`blameless-postmortems`](../skills/blameless-postmortems/SKILL.md) — cultura blameless ("foco em sistema/processo, NÃO em pessoas"), action items SMART, "no postmortem left unreviewed".
17
+
18
+ **Cria/Atualiza:**
19
+ - `.planning/postmortems/<id>.md` — postmortem blameless completo
20
+
21
+ **Após:** o user tem postmortem revisável + action items concretos. Phase 40 INT-FW-V2-01 chained do `/forense` automaticamente após Core Analysis Loop fechar.
22
+ </objective>
23
+
24
+ <context>
25
+ **Argumentos:** `$ARGUMENTS` — comando suporta **2 modos mutuamente exclusivos**.
26
+
27
+ **Modo A: `--from-investigation <id>` (preferido — continuação de v1.9)**
28
+
29
+ Lê `.planning/investigations/<id>.md` produzido pelo [`incident-investigator`](../agents/incident-investigator.md) (v1.9 — Core Analysis Loop). Extrai automaticamente: trigger, root cause, hipóteses validadas, action items. Campos faltantes (impact quantificado, severity, autores) são perguntados via `AskUserQuestion`.
30
+
31
+ **Modo B: `--incident "<descrição>"` (standalone)**
32
+
33
+ Para postmortem sem investigation prévia (incident menor, near-miss, lições retrospectivas). Agent gera template e usa `AskUserQuestion` para 9 perguntas guiadas — uma por seção canônica.
34
+
35
+ **Flags adicionais:**
36
+ - `--severity <SEV1|SEV2|SEV3>` — severity do incident (default: AskUserQuestion)
37
+ - `--output <path>` — caminho do postmortem (default: `.planning/postmortems/<id>.md` — id auto-gerado)
38
+
39
+ **Exemplos:**
40
+ ```
41
+ /postmortem --from-investigation incident-2026-05-06-1432-checkout-burn # Modo A
42
+ /postmortem --incident "checkout SLO burn às 14:32 — RCA N+1 query orders" --severity SEV2 # Modo B
43
+ /postmortem --incident "near-miss: deploy bloqueou 2min antes do PR-1234" # near-miss
44
+ ```
45
+
46
+ **Pré-requisito (Modo A):** arquivo `.planning/investigations/<id>.md` existe (criado por `/investigar-producao` ou `/forense`).
47
+ </context>
48
+
49
+ <process>
50
+
51
+ ## 1. Parsear argumentos (2 modos)
52
+
53
+ ```bash
54
+ INV_ID=$(echo "$ARGUMENTS" | grep -oE -- '--from-investigation [^ ]+' | awk '{print $2}')
55
+ INCIDENT=$(echo "$ARGUMENTS" | grep -oE -- '--incident "[^"]+"' | sed 's/--incident //; s/^"//; s/"$//')
56
+ SEVERITY=$(echo "$ARGUMENTS" | grep -oE -- '--severity [^ ]+' | awk '{print $2}')
57
+ OUTPUT_PATH=$(echo "$ARGUMENTS" | grep -oE -- '--output [^ ]+' | awk '{print $2}')
58
+
59
+ # PT-BR: validar mutuamente exclusivos
60
+ if [ -n "$INV_ID" ] && [ -n "$INCIDENT" ]; then
61
+ echo "✗ Erro: --from-investigation e --incident são mutuamente exclusivos. Escolha um."
62
+ exit 1
63
+ fi
64
+
65
+ # PT-BR: se nenhum dos 2 → AskUserQuestion (Modo C — interativo)
66
+ if [ -z "$INV_ID" ] && [ -z "$INCIDENT" ]; then
67
+ # Listar investigations recentes para sugestão
68
+ RECENT_INVS=$(ls -t .planning/investigations/*.md 2>/dev/null | head -5 | while read f; do basename "$f" .md; done | tr '\n' ',')
69
+ # AskUserQuestion: "Modo? Continuar de investigation existente OU postmortem standalone?"
70
+ # Opções: Continuar de <ID> (uma por investigation recente) | Standalone (texto livre)
71
+ echo "ℹ Sem flag explícita. Use --from-investigation <id> ou --incident \"<descrição>\"."
72
+ [ -n "$RECENT_INVS" ] && echo " Investigations recentes: $RECENT_INVS"
73
+ exit 1
74
+ fi
75
+ ```
76
+
77
+ ## 2. Validar pré-requisitos por modo
78
+
79
+ ```bash
80
+ mkdir -p .planning/postmortems
81
+
82
+ # PT-BR: Modo A — investigation file precisa existir
83
+ if [ -n "$INV_ID" ]; then
84
+ INV_FILE=".planning/investigations/${INV_ID}.md"
85
+ if [ ! -f "$INV_FILE" ]; then
86
+ echo "✗ Investigation $INV_ID não existe. Liste com: ls .planning/investigations/"
87
+ echo " Para postmortem standalone: /postmortem --incident \"<descrição>\""
88
+ exit 1
89
+ fi
90
+ # PT-BR: derivar postmortem id do investigation_id
91
+ POSTMORTEM_ID="$INV_ID"
92
+ fi
93
+
94
+ # PT-BR: Modo B — gerar postmortem id automaticamente
95
+ if [ -n "$INCIDENT" ]; then
96
+ DATE=$(date -u +%Y-%m-%d-%H%M)
97
+ SLUG=$(echo "$INCIDENT" | tr ' ' '-' | tr -cd 'a-zA-Z0-9-' | head -c 30 | sed 's/-$//')
98
+ POSTMORTEM_ID="postmortem-${DATE}-${SLUG}"
99
+ fi
100
+
101
+ # PT-BR: default output_path (override via --output)
102
+ [ -z "$OUTPUT_PATH" ] && OUTPUT_PATH=".planning/postmortems/${POSTMORTEM_ID}.md"
103
+
104
+ # PT-BR: idempotência — não sobrescrever postmortem existente sem confirmar
105
+ if [ -f "$OUTPUT_PATH" ]; then
106
+ echo "⚠ Postmortem $OUTPUT_PATH já existe."
107
+ echo " Use --output <novo-path> ou rm $OUTPUT_PATH antes de re-rodar."
108
+ exit 1
109
+ fi
110
+ ```
111
+
112
+ ## 3. Listar postmortems recentes (UX)
113
+
114
+ ```bash
115
+ # PT-BR: contexto — postmortems anteriores para correlacionar lessons learned
116
+ ls -t .planning/postmortems/*.md 2>/dev/null | head -3 | while read f; do
117
+ ID=$(basename "$f" .md)
118
+ DATE=$(grep -m1 '\*\*Date:\*\*' "$f" 2>/dev/null | sed 's/.*Date:\*\* //' || echo "?")
119
+ printf " %s — %s\n" "$ID" "$DATE"
120
+ done
121
+ ```
122
+
123
+ ## 4. Dispatch para `postmortem-writer`
124
+
125
+ ```text
126
+ Task(
127
+ subagent_type="postmortem-writer",
128
+ prompt="
129
+ ${INV_ID:+investigation_id: ${INV_ID}}
130
+ ${INCIDENT:+incident_description: ${INCIDENT}}
131
+ ${SEVERITY:+severity: ${SEVERITY}}
132
+ output_path: ${OUTPUT_PATH}
133
+ postmortem_id: ${POSTMORTEM_ID}
134
+
135
+ Aplicar skill blameless-postmortems. Modo:
136
+ ${INV_ID:+- Modo A: ler .planning/investigations/${INV_ID}.md, extrair trigger/root_cause/hipóteses/action_items automaticamente; perguntar via AskUserQuestion apenas campos faltantes (impact quantificado, severity, autores).}
137
+ ${INCIDENT:+- Modo B: gerar template; perguntar via AskUserQuestion 9 questões guiadas — uma por seção canônica (Summary, Impact, Root Causes, Trigger, Resolution, Detection, Action Items, Lessons Learned, Timeline).}
138
+
139
+ Padrões obrigatórios:
140
+ - Foco em sistema/processo (NUNCA em pessoas) — anti-pattern blame culture
141
+ - Action items SMART (Specific, Measurable, Assignable, Realistic, Time-bound)
142
+ - Timeline em UTC sempre
143
+ - Impact quantificado (# usuários, duração, SLO budget consumido, revenue se aplicável)
144
+ - 9 seções canônicas obrigatórias (skip = inválido)
145
+ "
146
+ )
147
+ ```
148
+
149
+ ## 5. Pós-output
150
+
151
+ ```
152
+ ═══════════════════════════════════════════════════════════
153
+ framework ► POSTMORTEM ▸ ${POSTMORTEM_ID}
154
+ ═══════════════════════════════════════════════════════════
155
+
156
+ [output do postmortem-writer — ver Step 6 do agent]
157
+
158
+ ## Estado salvo
159
+ .planning/postmortems/${POSTMORTEM_ID}.md
160
+
161
+ ## Próximos passos
162
+ 1. Revisar o postmortem com o time — "no postmortem left unreviewed"
163
+ 2. Distribuir para reviewer SRE OU par externo (anti-pattern: auto-review)
164
+ 3. Action items entram no roadmap (`/adicionar-tarefa` ou `/adicionar-fase`)
165
+ 4. Se PRR for próximo passo de production-readiness: `/prr --service <name>`
166
+ 5. Cross-ref OMM: postmortems alimentam Capacidade 5 (Incident Response) — `/observabilidade omm`
167
+ ```
168
+
169
+ </process>
170
+
171
+ <success_criteria>
172
+ - [ ] `--from-investigation <id>` E `--incident "<text>"` parseados (mutuamente exclusivos)
173
+ - [ ] Modo A: arquivo `.planning/investigations/<id>.md` validado existe antes de dispatch
174
+ - [ ] Modo B: postmortem_id auto-gerado a partir de date + slug
175
+ - [ ] Idempotência: não sobrescreve postmortem existente sem `--output` explícito
176
+ - [ ] `postmortem-writer` invocado via `Task(subagent_type=...)` com prompt completo (modo + 9 seções + padrões)
177
+ - [ ] `.planning/postmortems/<id>.md` criado pelo agent
178
+ - [ ] Próximos passos sugerem cross-ref para `/prr`, `/observabilidade omm`, `/adicionar-tarefa`
179
+ </success_criteria>