@luanpdd/kit-mcp 1.10.0 → 1.12.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 (63) hide show
  1. package/gates/ai-prompt-stability.md +120 -0
  2. package/gates/legacy-refactor-safety.md +178 -0
  3. package/gates/observability-coverage.md +151 -0
  4. package/gates/release-pipeline-policy.md +132 -0
  5. package/kit/COMANDOS.md +15 -0
  6. package/kit/agents/ai-mutation-tester.md +298 -0
  7. package/kit/agents/cascading-failures-auditor.md +306 -0
  8. package/kit/agents/executor.md +13 -0
  9. package/kit/agents/legacy-characterizer.md +378 -0
  10. package/kit/agents/load-shedding-instrumenter.md +297 -0
  11. package/kit/agents/observability-coverage-auditor.md +325 -0
  12. package/kit/agents/omm-auditor.md +47 -0
  13. package/kit/agents/payload-capture-instrumenter.md +283 -0
  14. package/kit/agents/planner.md +29 -0
  15. package/kit/agents/prr-conductor.md +8 -0
  16. package/kit/agents/refactor-safety-auditor.md +414 -0
  17. package/kit/agents/release-pipeline-auditor.md +360 -0
  18. package/kit/agents/seam-finder.md +367 -0
  19. package/kit/agents/shotgun-surgery-detector.md +359 -0
  20. package/kit/agents/storytelling-analyst.md +309 -0
  21. package/kit/agents/supabase-edge-fn-writer.md +12 -0
  22. package/kit/agents/verifier.md +30 -0
  23. package/kit/commands/auditar-cascading.md +111 -0
  24. package/kit/commands/auditar-marco.md +44 -1
  25. package/kit/commands/auditar-observabilidade-cobertura.md +183 -0
  26. package/kit/commands/auditar-refactor.md +219 -0
  27. package/kit/commands/auditar-release.md +109 -0
  28. package/kit/commands/capturar-payloads.md +193 -0
  29. package/kit/commands/caracterizar-prompt.md +195 -0
  30. package/kit/commands/caracterizar.md +212 -0
  31. package/kit/commands/concluir-marco.md +41 -1
  32. package/kit/commands/detectar-duplicacao.md +197 -0
  33. package/kit/commands/discutir-fase.md +41 -0
  34. package/kit/commands/encontrar-seams.md +136 -0
  35. package/kit/commands/forense.md +40 -1
  36. package/kit/commands/legacy.md +263 -0
  37. package/kit/commands/load-shedding.md +117 -0
  38. package/kit/commands/observabilidade.md +2 -0
  39. package/kit/commands/refactor-seguro.md +321 -0
  40. package/kit/commands/sre.md +3 -0
  41. package/kit/commands/storytelling.md +179 -0
  42. package/kit/skills/_shared-legacy/glossary.md +389 -0
  43. package/kit/skills/_shared-sre/glossary.md +139 -0
  44. package/kit/skills/ai-prompt-characterization/SKILL.md +335 -0
  45. package/kit/skills/cascading-failures/SKILL.md +307 -0
  46. package/kit/skills/four-golden-signals/SKILL.md +17 -0
  47. package/kit/skills/hermetic-builds/SKILL.md +323 -0
  48. package/kit/skills/legacy-api-only-applications/SKILL.md +358 -0
  49. package/kit/skills/legacy-characterization-tests/SKILL.md +330 -0
  50. package/kit/skills/legacy-effect-analysis/SKILL.md +331 -0
  51. package/kit/skills/legacy-extract-class/SKILL.md +203 -0
  52. package/kit/skills/legacy-monster-methods/SKILL.md +444 -0
  53. package/kit/skills/legacy-programming-by-difference/SKILL.md +252 -0
  54. package/kit/skills/legacy-seams-and-test-harness/SKILL.md +460 -0
  55. package/kit/skills/legacy-shotgun-surgery/SKILL.md +286 -0
  56. package/kit/skills/legacy-sprout-wrap-techniques/SKILL.md +434 -0
  57. package/kit/skills/legacy-storytelling-naked-crc/SKILL.md +270 -0
  58. package/kit/skills/llm-as-dependency/SKILL.md +436 -0
  59. package/kit/skills/load-shedding-graceful-degradation/SKILL.md +396 -0
  60. package/kit/skills/pre-refactor-characterization/SKILL.md +421 -0
  61. package/kit/skills/release-engineering/SKILL.md +367 -0
  62. package/kit/skills/retry-strategies/SKILL.md +372 -0
  63. package/package.json +2 -2
@@ -0,0 +1,109 @@
1
+ ---
2
+ name: auditar-release
3
+ description: Invoca release-pipeline-auditor — audita CI/CD para hermeticidade (lockfile + frozen-install + image SHA + sem network), reprodutibilidade (versions pinned), policy enforcement (branch protection, signed commits, CODEOWNERS). Cap 8 livro Google SRE.
4
+ argument-hint: "[--dimensions hermeticidade,reprodutibilidade,policy-enforcement] [--gh-repo OWNER/REPO]"
5
+ allowed-tools:
6
+ - Read
7
+ - Bash
8
+ - Grep
9
+ - Glob
10
+ - Task
11
+ - Write
12
+ ---
13
+
14
+ <objective>
15
+ Auditar **release pipeline** (CI/CD + Dockerfile + branch protection) em 3 dimensões: hermeticidade, reprodutibilidade, policy enforcement. Invoca o agente [`release-pipeline-auditor`](../agents/release-pipeline-auditor.md) que aplica skills [`hermetic-builds`](../skills/hermetic-builds/SKILL.md) + [`release-engineering`](../skills/release-engineering/SKILL.md).
16
+
17
+ **Cria/Atualiza:**
18
+ - `.planning/RELEASE-AUDIT.md` — relatório scored 30 pontos com top 5 fixes priorizados
19
+
20
+ **Após:** o user vê fragility quantificada (não opinião). Resultado feeds PRR Axe 5 (Change Management) v1.10 e gate `release-pipeline-policy` opt-in.
21
+ </objective>
22
+
23
+ <context>
24
+ **Argumentos:**
25
+ - `--dimensions <list>` — subset de `[hermeticidade, reprodutibilidade, policy-enforcement]` (default: todas)
26
+ - `--gh-repo OWNER/REPO` — override de repo detection (default: `gh repo view`)
27
+ - `--output PATH` — caminho do output (default: `.planning/RELEASE-AUDIT.md`)
28
+
29
+ **Exemplos:**
30
+ ```
31
+ /auditar-release # full audit (3 dims)
32
+ /auditar-release --dimensions hermeticidade # só hermeticidade
33
+ /auditar-release --gh-repo myorg/myrepo # override repo
34
+ ```
35
+
36
+ **Pré-requisitos opcionais:**
37
+ - `gh` CLI autenticado (`gh auth status`) — para checks de branch protection via API
38
+ - Sem `gh`: agent skip dimension policy-enforcement parcialmente (filesystem only)
39
+ </context>
40
+
41
+ <process>
42
+
43
+ ## 1. Parsear argumentos
44
+
45
+ ```bash
46
+ DIMENSIONS=$(echo "$ARGUMENTS" | grep -oE -- '--dimensions [^ ]+' | awk '{print $2}')
47
+ GH_REPO=$(echo "$ARGUMENTS" | grep -oE -- '--gh-repo [^ ]+' | awk '{print $2}')
48
+ OUTPUT_PATH=$(echo "$ARGUMENTS" | grep -oE -- '--output [^ ]+' | awk '{print $2}')
49
+
50
+ [ -z "$OUTPUT_PATH" ] && OUTPUT_PATH=".planning/RELEASE-AUDIT.md"
51
+ mkdir -p "$(dirname "$OUTPUT_PATH")"
52
+ ```
53
+
54
+ ## 2. Dispatch para `release-pipeline-auditor`
55
+
56
+ ```text
57
+ Task(
58
+ subagent_type="release-pipeline-auditor",
59
+ prompt="
60
+ project_root: .
61
+ output_path: ${OUTPUT_PATH}
62
+ ${DIMENSIONS:+dimensions: ${DIMENSIONS}}
63
+ ${GH_REPO:+gh_repo: ${GH_REPO}}
64
+
65
+ Aplicar skills hermetic-builds + release-engineering. Etapas:
66
+ 1. Detectar lockfile, CI files, Dockerfile
67
+ 2. Auditar Hermeticidade (10pts): lockfile commitado, frozen-install, image SHA, sem network, SLSA provenance
68
+ 3. Auditar Reprodutibilidade (10pts): actions pinned, node version pinned, package manager pinned, sem timestamps, build cache
69
+ 4. Auditar Policy Enforcement (10pts): branch protection, required PR + reviewers + status checks, CODEOWNERS, signed commits, workflow permissions, release via tag
70
+ 5. Score agregado (0-30) com veredito ROBUST/ADEQUATE/FRAGILE/BROKEN
71
+ 6. Top 5 fixes priorizados com esforço estimado
72
+ "
73
+ )
74
+ ```
75
+
76
+ ## 3. Pós-output
77
+
78
+ ```
79
+ ═══════════════════════════════════════════════════════════
80
+ framework ► AUDITAR-RELEASE ▸ ${OUTPUT_PATH}
81
+ ═══════════════════════════════════════════════════════════
82
+
83
+ [output do agent]
84
+
85
+ ## Próximos passos
86
+
87
+ 1. **Aplicar top 5 fixes** do RELEASE-AUDIT.md (esforço total ~1-2h)
88
+ 2. **/prr <service>** (v1.10) — Axe 5 (Change Management) consume este audit
89
+ 3. **Re-audit em 30d** — verificar progresso
90
+ 4. **/concluir-marco** (framework + patch v1.11) — opt-in gate `release-pipeline-policy`
91
+
92
+ ## Cross-suite
93
+
94
+ - v1.10 SRE — PRR Axe 5 (Change Management)
95
+ - v1.11 SRE Resilience — esse audit
96
+ - v1.12 Legacy — overrides de refactor têm audit trail aqui
97
+ - Framework flow — /concluir-marco gate opt-in
98
+ ```
99
+
100
+ </process>
101
+
102
+ <success_criteria>
103
+ - [ ] $ARGUMENTS parseados (todos opcionais)
104
+ - [ ] `release-pipeline-auditor` invocado via Task
105
+ - [ ] RELEASE-AUDIT.md scored 30 pts criado
106
+ - [ ] Veredito ROBUST/ADEQUATE/FRAGILE/BROKEN
107
+ - [ ] Top 5 fixes priorizados com esforço
108
+ - [ ] Cross-references com /prr e /concluir-marco
109
+ </success_criteria>
@@ -0,0 +1,193 @@
1
+ ---
2
+ name: capturar-payloads
3
+ description: Invoca payload-capture-instrumenter — instrumenta Edge Function Supabase para captura via mcp__supabase__get_logs por N dias, sanitiza PII, gera fixtures para legacy-characterizer. Modernização 2026.
4
+ argument-hint: "<edge_function_path> [--days N] [--max-payloads N] [--mode instrument|drain|full] [--sanitize-keys k1,k2,...]"
5
+ allowed-tools:
6
+ - Read
7
+ - Write
8
+ - Edit
9
+ - Bash
10
+ - Grep
11
+ - Glob
12
+ - Task
13
+ - mcp__supabase__execute_sql
14
+ - mcp__supabase__get_logs
15
+ ---
16
+
17
+ <objective>
18
+ Instrumentar Edge Function Supabase para capturar **payloads reais** de produção, drenar logs após janela de captura via `mcp__supabase__get_logs`, sanitizar PII deterministicamente, e gerar fixtures prontos para alimentar `/caracterizar`. Invoca o agente [`payload-capture-instrumenter`](../agents/payload-capture-instrumenter.md) que aplica a skill [`legacy-characterization-tests`](../skills/legacy-characterization-tests/SKILL.md) Pattern 7.
19
+
20
+ **Cria/Atualiza:**
21
+ - Patch na Edge Function adicionando log dedicado controlado por env `CAPTURE_PAYLOADS=true`
22
+ - `supabase/functions/_shared/payload-capture.ts` — sanitização canônica
23
+ - `tests/characterization/<edge-fn>/fixtures/payload-NN.json` — fixtures sanitizados após drenagem
24
+
25
+ **Após:** o user tem fixtures BASEADOS EM DISTRIBUIÇÃO REAL de produção, não em sintéticos. Cobertura comportamental cresce significativamente.
26
+ </objective>
27
+
28
+ <context>
29
+ **Argumentos:**
30
+ - `<edge_function_path>` — path da Edge Function (e.g., `supabase/functions/process-orders/index.ts`) — OBRIGATÓRIO
31
+ - `--days N` — janela de captura em dias (default: 7)
32
+ - `--max-payloads N` — máximo de fixtures a salvar (default: 100)
33
+ - `--mode instrument|drain|full` — fase do workflow:
34
+ - `instrument` — só aplica patch (você faz deploy + aguarda)
35
+ - `drain` — só drena logs (após capture já rodou em prod)
36
+ - `full` — patch + aguarda + drena (default — orquestra tudo)
37
+ - `--sanitize-keys k1,k2,k3` — keys adicionais a redact
38
+
39
+ **Workflow esperado:**
40
+
41
+ ```
42
+ Dia 0: /capturar-payloads <fn> --mode=instrument
43
+ Dia 0: Você faz deploy + setar CAPTURE_PAYLOADS=true em env
44
+ Dia 1-7: produção captura naturalmente
45
+ Dia 7: /capturar-payloads <fn> --mode=drain
46
+ Dia 7: Fixtures criados em tests/characterization/<fn>/fixtures/
47
+ Dia 7: /caracterizar <fn> --fixtures-dir tests/characterization/<fn>/fixtures
48
+ ```
49
+
50
+ **Exemplos:**
51
+ ```
52
+ /capturar-payloads supabase/functions/webhook-stripe/index.ts # full mode 7 dias
53
+ /capturar-payloads supabase/functions/process-orders/index.ts --days 14 # janela maior
54
+ /capturar-payloads supabase/functions/process-orders/index.ts --mode=instrument # só patch
55
+ /capturar-payloads supabase/functions/process-orders/index.ts --mode=drain # só drenagem
56
+ ```
57
+
58
+ **Pré-requisitos:**
59
+ - Edge Function deployada em Supabase (modo drain depende de logs em prod)
60
+ - MCP Supabase conectado para drenagem automatizada (alternativa: `supabase functions logs` CLI)
61
+ - Tier full em IDEs com MCP; tier partial degrada para instrumentação only
62
+
63
+ **Quando preferir este comando vs `/caracterizar` direto:**
64
+ - Edge Function tem alto traffic (≥ 100 req/dia) — distribuição real cobre edge cases que sintético não pega
65
+ - Edge Function tem contrato externo crítico (webhook de Stripe/GitHub) — fidelidade absoluta requer payloads reais
66
+ - Equipe quer baseline empírico antes de refactor — payloads reais > inputs sintéticos
67
+ </context>
68
+
69
+ <process>
70
+
71
+ ## 1. Parsear argumentos
72
+
73
+ ```bash
74
+ EDGE_FN_PATH=$(echo "$ARGUMENTS" | awk '{print $1}')
75
+ CAPTURE_DAYS=$(echo "$ARGUMENTS" | grep -oE -- '--days [0-9]+' | awk '{print $2}')
76
+ MAX_PAYLOADS=$(echo "$ARGUMENTS" | grep -oE -- '--max-payloads [0-9]+' | awk '{print $2}')
77
+ MODE=$(echo "$ARGUMENTS" | grep -oE -- '--mode[= ][^ ]+' | sed 's/--mode[= ]//')
78
+ SANITIZE_KEYS=$(echo "$ARGUMENTS" | grep -oE -- '--sanitize-keys [^ ]+' | awk '{print $2}')
79
+
80
+ [ -z "$CAPTURE_DAYS" ] && CAPTURE_DAYS=7
81
+ [ -z "$MAX_PAYLOADS" ] && MAX_PAYLOADS=100
82
+ [ -z "$MODE" ] && MODE="full"
83
+
84
+ if [ -z "$EDGE_FN_PATH" ]; then
85
+ echo "ERROR: edge_function_path obrigatório"
86
+ echo "Uso: /capturar-payloads <path> [opções]"
87
+ exit 1
88
+ fi
89
+
90
+ if [ ! -f "$EDGE_FN_PATH" ]; then
91
+ echo "ERROR: arquivo não encontrado: $EDGE_FN_PATH"
92
+ exit 1
93
+ fi
94
+ ```
95
+
96
+ ## 2. Validar pré-requisitos
97
+
98
+ ```bash
99
+ # verificar Edge Function (Deno + Deno.serve)
100
+ if ! grep -q "Deno.serve" "$EDGE_FN_PATH"; then
101
+ echo "ERROR: $EDGE_FN_PATH não parece Edge Function (sem Deno.serve)"
102
+ exit 1
103
+ fi
104
+
105
+ # detectar projeto Supabase
106
+ PROJECT_ID=""
107
+ if [ -f "supabase/config.toml" ]; then
108
+ PROJECT_ID=$(grep -E '^project_id\s*=' supabase/config.toml | sed 's/.*= *"\(.*\)".*/\1/' | head -1)
109
+ fi
110
+
111
+ if [ -z "$PROJECT_ID" ] && [ "$MODE" != "instrument" ]; then
112
+ echo "WARN: PROJECT_ID não detectado em supabase/config.toml — drenagem pode falhar"
113
+ fi
114
+ ```
115
+
116
+ ## 3. Dispatch para `payload-capture-instrumenter`
117
+
118
+ ```text
119
+ Task(
120
+ subagent_type="payload-capture-instrumenter",
121
+ prompt="
122
+ edge_function_path: ${EDGE_FN_PATH}
123
+ capture_days: ${CAPTURE_DAYS}
124
+ max_payloads: ${MAX_PAYLOADS}
125
+ mode: ${MODE}
126
+ ${SANITIZE_KEYS:+sanitize_keys: ${SANITIZE_KEYS}}
127
+ ${PROJECT_ID:+project_id: ${PROJECT_ID}}
128
+
129
+ Aplicar skill legacy-characterization-tests Pattern 7. Etapas:
130
+ 1. Preflight: validar Edge Function, detectar project_id
131
+ 2. (mode=instrument|full) Patch Edge Function adicionando log dedicado
132
+ 3. (mode=instrument) Output mensagem para fazer deploy + setar CAPTURE_PAYLOADS=true
133
+ 4. (mode=drain|full após delay) Drenar logs via mcp__supabase__get_logs
134
+ 5. Para cada log entry com kind=payload-capture:
135
+ - Parse payload sanitized
136
+ - Salvar em tests/characterization/<fn>/fixtures/payload-NN.json
137
+ 6. Pós-processamento: validar nenhum unredacted, sanitização adicional
138
+ 7. Output curto + recomendações (review fixtures, /caracterizar, remove flag)
139
+ "
140
+ )
141
+ ```
142
+
143
+ ## 4. Pós-output
144
+
145
+ ```
146
+ ═══════════════════════════════════════════════════════════
147
+ framework ► CAPTURAR-PAYLOADS ▸ ${EDGE_FN_PATH}
148
+ ═══════════════════════════════════════════════════════════
149
+
150
+ [output do payload-capture-instrumenter]
151
+
152
+ ## Próximos passos por mode
153
+
154
+ ### Após mode=instrument
155
+ 1. Deploy: `supabase functions deploy <name>`
156
+ 2. Setar env var: `supabase secrets set CAPTURE_PAYLOADS=true`
157
+ 3. Aguardar ${CAPTURE_DAYS} dias
158
+ 4. Rodar: `/capturar-payloads ${EDGE_FN_PATH} --mode=drain`
159
+
160
+ ### Após mode=drain ou full
161
+ 1. **REVISAR fixtures** manualmente — sample 5-10 arquivos
162
+ 2. **VALIDAR no PII vaza:**
163
+ ```bash
164
+ grep -E "([0-9]{3}\.[0-9]{3}\.[0-9]{3}-?[0-9]{2}|@.*\..*\.com)" tests/characterization/*/fixtures/*.json
165
+ ```
166
+ 3. **Alimentar legacy-characterizer:**
167
+ ```bash
168
+ /caracterizar ${EDGE_FN_PATH} --fixtures-dir tests/characterization/$(basename $(dirname ${EDGE_FN_PATH}))/fixtures
169
+ ```
170
+ 4. **Após characterization gerada:** REMOVE flag CAPTURE_PAYLOADS:
171
+ ```bash
172
+ supabase secrets unset CAPTURE_PAYLOADS
173
+ git revert <commit-instrument>
174
+ ```
175
+
176
+ ## Cross-suite
177
+
178
+ - **/caracterizar** (v1.12) — consome fixtures gerados aqui
179
+ - **/instrumentar-fase** (v1.9) — captura é instrumentação shift-left aplicada
180
+ - **/golden-signals** (v1.10) — captura E golden signals podem coexistir mesma Edge Function
181
+ ```
182
+
183
+ </process>
184
+
185
+ <success_criteria>
186
+ - [ ] $ARGUMENTS parseados (edge_function_path obrigatório, 4 flags opcionais)
187
+ - [ ] Pré-requisitos validados (Deno.serve presente; supabase/config.toml para project_id)
188
+ - [ ] `payload-capture-instrumenter` invocado via Task com mode resolvido
189
+ - [ ] Tier degradation correto (Full = MCP drain; Partial = instrument-only)
190
+ - [ ] Output forwarded transparentemente
191
+ - [ ] Próximos passos específicos por mode (instrument vs drain vs full)
192
+ - [ ] Cross-references com /caracterizar, /instrumentar-fase, /golden-signals
193
+ </success_criteria>
@@ -0,0 +1,195 @@
1
+ ---
2
+ name: caracterizar-prompt
3
+ description: Characterization de prompts/tools LLM em produção — temperature=0 + seed fixo + sanitização específica. Trata prompts como código legacy. Modernização 2026 sem precedente em 2004.
4
+ argument-hint: "<prompt_file> [--inputs-dir PATH] [--provider openai|anthropic] [--seed N] [--max-tokens N] [--num-intents N]"
5
+ allowed-tools:
6
+ - Read
7
+ - Write
8
+ - Edit
9
+ - Bash
10
+ - Grep
11
+ - Glob
12
+ - Task
13
+ ---
14
+
15
+ <objective>
16
+ Caracterizar **prompt LLM ou tool definition** capturando outputs determinísticos como golden snapshots. Aplica skill [`ai-prompt-characterization`](../skills/ai-prompt-characterization/SKILL.md) — `temperature=0`, `seed` fixo, sanitização de timestamps/UUIDs/datas relativas, 5+ intents distintas. Trata prompt como **código legacy também** — versionado, testado, code-reviewed.
17
+
18
+ **Cria/Atualiza:**
19
+ - `tests/characterization/prompts/<prompt-stem>.test.ts` (ou `.py`/`.go` conforme runtime)
20
+ - `tests/characterization/prompts/__snapshots__/<prompt-stem>.test.ts.snap`
21
+ - `tests/characterization/prompts/<prompt-stem>/inputs/<intent>.json` — inputs canônicos por intent
22
+
23
+ **Após:** mudança em prompt deve manter snapshot diff = 0 (ou mudança documentada). Detecta drift de model upstream automaticamente.
24
+ </objective>
25
+
26
+ <context>
27
+ **Argumentos:**
28
+ - `<prompt_file>` — arquivo do prompt (e.g., `prompts/generate-summary.md`) — OBRIGATÓRIO
29
+ - `--inputs-dir <path>` — diretório com inputs canônicos por intent (default: agent gera 5 sintéticos cobrindo concise/detailed/code/edge/adversarial)
30
+ - `--provider openai|anthropic` — provider de LLM (default: detecta via deps)
31
+ - `--seed N` — seed para determinismo (default: 42)
32
+ - `--max-tokens N` — limite output (default: 500)
33
+ - `--num-intents N` — número de intents a cobrir (default: 5; mínimo: 5)
34
+ - `--system-prompt <text>` — system prompt se aplicável
35
+
36
+ **Exemplos:**
37
+ ```
38
+ /caracterizar-prompt prompts/generate-summary.md
39
+ /caracterizar-prompt prompts/code-reviewer.md --num-intents 7 --max-tokens 1000
40
+ /caracterizar-prompt prompts/intent-classifier.md --inputs-dir test-data/classifier-intents
41
+ /caracterizar-prompt prompts/customer-support.md --provider anthropic --seed 123
42
+ ```
43
+
44
+ **Pré-requisitos:**
45
+ - ANTHROPIC_API_KEY ou OPENAI_API_KEY em env
46
+ - Test framework (Vitest, Jest, pytest, ...)
47
+ - Provider escolhido suporta `temperature=0` + `seed`
48
+
49
+ **Quando este comando é o caminho:**
50
+ - Prompt em produção > 50 linhas
51
+ - Mudanças em prompt quebraram silenciosamente no passado
52
+ - Equipe quer baseline antes de refactor de prompt
53
+ - CI deve detectar drift de model upstream (Claude 4.7 → 4.8)
54
+ </context>
55
+
56
+ <process>
57
+
58
+ ## 1. Parsear argumentos
59
+
60
+ ```bash
61
+ PROMPT_FILE=$(echo "$ARGUMENTS" | awk '{print $1}')
62
+ INPUTS_DIR=$(echo "$ARGUMENTS" | grep -oE -- '--inputs-dir [^ ]+' | awk '{print $2}')
63
+ PROVIDER=$(echo "$ARGUMENTS" | grep -oE -- '--provider [^ ]+' | awk '{print $2}')
64
+ SEED=$(echo "$ARGUMENTS" | grep -oE -- '--seed [0-9]+' | awk '{print $2}')
65
+ MAX_TOKENS=$(echo "$ARGUMENTS" | grep -oE -- '--max-tokens [0-9]+' | awk '{print $2}')
66
+ NUM_INTENTS=$(echo "$ARGUMENTS" | grep -oE -- '--num-intents [0-9]+' | awk '{print $2}')
67
+
68
+ [ -z "$SEED" ] && SEED=42
69
+ [ -z "$MAX_TOKENS" ] && MAX_TOKENS=500
70
+ [ -z "$NUM_INTENTS" ] && NUM_INTENTS=5
71
+
72
+ if [ -z "$PROMPT_FILE" ]; then
73
+ echo "ERROR: prompt_file obrigatório"
74
+ exit 1
75
+ fi
76
+
77
+ if [ ! -f "$PROMPT_FILE" ]; then
78
+ echo "ERROR: arquivo não encontrado: $PROMPT_FILE"
79
+ exit 1
80
+ fi
81
+ ```
82
+
83
+ ## 2. Detectar provider + framework
84
+
85
+ ```bash
86
+ # auto-detect provider
87
+ if [ -z "$PROVIDER" ]; then
88
+ if [ -n "$ANTHROPIC_API_KEY" ]; then
89
+ PROVIDER="anthropic"
90
+ elif [ -n "$OPENAI_API_KEY" ]; then
91
+ PROVIDER="openai"
92
+ else
93
+ echo "ERROR: nenhum provider detectado. Setar ANTHROPIC_API_KEY ou OPENAI_API_KEY"
94
+ exit 1
95
+ fi
96
+ fi
97
+
98
+ # detectar test framework
99
+ FRAMEWORK=""
100
+ if [ -f "package.json" ]; then
101
+ if jq -re '.devDependencies.vitest' package.json >/dev/null 2>&1; then FRAMEWORK="vitest"
102
+ elif jq -re '.devDependencies.jest' package.json >/dev/null 2>&1; then FRAMEWORK="jest"
103
+ fi
104
+ elif [ -f "pyproject.toml" ]; then
105
+ FRAMEWORK="pytest"
106
+ fi
107
+
108
+ [ -z "$FRAMEWORK" ] && FRAMEWORK="vitest" # default sane
109
+ ```
110
+
111
+ ## 3. Dispatch para `legacy-characterizer` (modo prompt)
112
+
113
+ ```text
114
+ Task(
115
+ subagent_type="legacy-characterizer",
116
+ prompt="
117
+ target_file: ${PROMPT_FILE}
118
+ target_kind: prompt
119
+ provider: ${PROVIDER}
120
+ seed: ${SEED}
121
+ max_tokens: ${MAX_TOKENS}
122
+ num_intents: ${NUM_INTENTS}
123
+ ${INPUTS_DIR:+inputs_dir: ${INPUTS_DIR}}
124
+ framework: ${FRAMEWORK}
125
+
126
+ Aplicar skill ai-prompt-characterization. Etapas:
127
+ 1. Ler prompt + identificar inputs esperados (system prompt? user message format? tools?)
128
+ 2. Gerar (ou ler de inputs-dir) ${NUM_INTENTS}+ inputs cobrindo intents distintas:
129
+ - concise: pedido curto, output esperado curto
130
+ - detailed: pedido elaborado, output esperado longo
131
+ - code-heavy: input/output com código
132
+ - edge case: input ambíguo
133
+ - adversarial: prompt injection attempt
134
+ 3. Para cada intent: rodar LLM com temperature=0 + seed=${SEED}
135
+ 4. Capturar text + finishReason + toolCalls (se function calling) + inputTokens + outputTokens + modelVersion
136
+ 5. Sanitizar: timestamps, UUIDs, datas relativas, valores monetários, versões
137
+ 6. Salvar como snapshot tests usando ${FRAMEWORK}
138
+ 7. Cobertura behavioral = % intents cobertas (não % linhas)
139
+ "
140
+ )
141
+ ```
142
+
143
+ ## 4. Pós-output
144
+
145
+ ```
146
+ ═══════════════════════════════════════════════════════════
147
+ framework ► CARACTERIZAR-PROMPT ▸ tests/characterization/prompts/...
148
+ ═══════════════════════════════════════════════════════════
149
+
150
+ [output do legacy-characterizer em modo prompt]
151
+
152
+ ## ⚠ REVISÃO MANUAL OBRIGATÓRIA
153
+
154
+ Snapshots gerados — leia cada um antes de commit:
155
+ 1. Verificar nenhum PII/secret persiste pós-sanitização
156
+ 2. Verificar nenhum timestamp/UUID/data relativa unredacted
157
+ 3. Confirmar finishReason esperado (stop vs length vs tool_use)
158
+ 4. Para tool_uses: confirmar tool name + input shape
159
+
160
+ ## Próximos passos
161
+
162
+ 1. **Revisar snapshots** manualmente
163
+ 2. **Rodar suite local:**
164
+ - JS/TS: `npm test -- tests/characterization/prompts`
165
+ - Python: `pytest tests/characterization/prompts`
166
+ 3. **Commit** como `chore: characterize <prompt-name>`
167
+ 4. **Configurar CI:**
168
+ - `tests/characterization/prompts/**` rodam em PR que toca `prompts/**`
169
+ - Diff vermelho = mudança comportamental detectada → review humano
170
+ 5. **Configurar nightly** para detectar drift de model upstream:
171
+ - Anthropic publica Claude 4.8 → re-run characterization → snapshot diff
172
+ 6. **Custo:** ~${NUM_INTENTS} × ($0.015/1k input tokens × 2k = $0.03 + output) ≈ $0.10-0.50/run
173
+
174
+ ## Cross-suite
175
+
176
+ - **/caracterizar** (v1.12) — characterization de código (não prompt) — análogo
177
+ - **`llm-as-dependency`** skill — fakear LLM em business logic tests (não esses tests)
178
+ - **`legacy-api-only-applications`** skill — LLM provider é caso especial de API external
179
+ - **/instrumentar-fase** (v1.9) — instrumenta consumer de prompt (latency, tokens)
180
+ ```
181
+
182
+ </process>
183
+
184
+ <success_criteria>
185
+ - [ ] $ARGUMENTS parseados
186
+ - [ ] Provider detectado automaticamente OU especificado
187
+ - [ ] Framework de teste detectado
188
+ - [ ] `legacy-characterizer` invocado em modo prompt
189
+ - [ ] ≥ 5 intents cobrindo grupos canônicos (concise/detailed/code/edge/adversarial)
190
+ - [ ] temperature=0 + seed=fixo aplicado
191
+ - [ ] Sanitização específica para outputs LLM aplicada
192
+ - [ ] Tests rodam contra LLM real apenas em characterization (não em business logic tests)
193
+ - [ ] Próximos passos: review, commit, CI config, nightly drift detection
194
+ - [ ] Cross-suite com llm-as-dependency e legacy-api-only-applications
195
+ </success_criteria>