@onion-ai/cli 1.0.0-beta.1

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 (220) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +529 -0
  3. package/bin/onion.js +6 -0
  4. package/framework/CLAUDE.md +45 -0
  5. package/framework/VERSION +1 -0
  6. package/framework/agents/compliance/iso-22301-specialist.md +985 -0
  7. package/framework/agents/compliance/iso-27001-specialist.md +713 -0
  8. package/framework/agents/compliance/pmbok-specialist.md +739 -0
  9. package/framework/agents/compliance/security-information-master.md +907 -0
  10. package/framework/agents/compliance/soc2-specialist.md +889 -0
  11. package/framework/agents/deployment/docker-specialist.md +1192 -0
  12. package/framework/agents/development/c4-architecture-specialist.md +745 -0
  13. package/framework/agents/development/c4-documentation-specialist.md +695 -0
  14. package/framework/agents/development/clickup-specialist.md +396 -0
  15. package/framework/agents/development/cursor-specialist.md +277 -0
  16. package/framework/agents/development/docs-reverse-engineer.md +417 -0
  17. package/framework/agents/development/gamma-api-specialist.md +1168 -0
  18. package/framework/agents/development/gitflow-specialist.md +1206 -0
  19. package/framework/agents/development/linux-security-specialist.md +675 -0
  20. package/framework/agents/development/mermaid-specialist.md +515 -0
  21. package/framework/agents/development/nodejs-specialist.md +672 -0
  22. package/framework/agents/development/nx-migration-specialist.md +866 -0
  23. package/framework/agents/development/nx-monorepo-specialist.md +618 -0
  24. package/framework/agents/development/postgres-specialist.md +1123 -0
  25. package/framework/agents/development/react-developer.md +131 -0
  26. package/framework/agents/development/runflow-specialist.md +277 -0
  27. package/framework/agents/development/system-documentation-orchestrator.md +1387 -0
  28. package/framework/agents/development/task-specialist.md +677 -0
  29. package/framework/agents/git/branch-code-reviewer.md +225 -0
  30. package/framework/agents/git/branch-documentation-writer.md +161 -0
  31. package/framework/agents/git/branch-metaspec-checker.md +67 -0
  32. package/framework/agents/git/branch-test-planner.md +176 -0
  33. package/framework/agents/meta/agent-creator-specialist.md +1266 -0
  34. package/framework/agents/meta/command-creator-specialist.md +1676 -0
  35. package/framework/agents/meta/metaspec-gate-keeper.md +240 -0
  36. package/framework/agents/meta/onion.md +824 -0
  37. package/framework/agents/product/branding-positioning-specialist.md +1029 -0
  38. package/framework/agents/product/extract-meeting-specialist.md +394 -0
  39. package/framework/agents/product/meeting-consolidator.md +482 -0
  40. package/framework/agents/product/pain-price-specialist.md +508 -0
  41. package/framework/agents/product/presentation-orchestrator.md +1190 -0
  42. package/framework/agents/product/product-agent.md +201 -0
  43. package/framework/agents/product/story-points-framework-specialist.md +538 -0
  44. package/framework/agents/product/storytelling-business-specialist.md +890 -0
  45. package/framework/agents/research/research-agent.md +292 -0
  46. package/framework/agents/review/code-reviewer.md +154 -0
  47. package/framework/agents/review/corporate-compliance-specialist.md +370 -0
  48. package/framework/agents/testing/test-agent.md +424 -0
  49. package/framework/agents/testing/test-engineer.md +294 -0
  50. package/framework/agents/testing/test-planner.md +117 -0
  51. package/framework/commands/common/prompts/README.md +208 -0
  52. package/framework/commands/common/prompts/clickup-patterns.md +144 -0
  53. package/framework/commands/common/prompts/code-review-checklist.md +168 -0
  54. package/framework/commands/common/prompts/git-workflow-patterns.md +235 -0
  55. package/framework/commands/common/prompts/output-formats.md +240 -0
  56. package/framework/commands/common/prompts/technical.md +194 -0
  57. package/framework/commands/common/templates/abstraction-template.md +399 -0
  58. package/framework/commands/common/templates/agent-template.md +353 -0
  59. package/framework/commands/common/templates/business_context_template.md +748 -0
  60. package/framework/commands/common/templates/command-template.md +273 -0
  61. package/framework/commands/common/templates/technical_context_template.md +526 -0
  62. package/framework/commands/design/screen-spec.md +505 -0
  63. package/framework/commands/development/runflow-dev.md +465 -0
  64. package/framework/commands/docs/build-business-docs.md +299 -0
  65. package/framework/commands/docs/build-compliance-docs.md +143 -0
  66. package/framework/commands/docs/build-index.md +119 -0
  67. package/framework/commands/docs/build-tech-docs.md +221 -0
  68. package/framework/commands/docs/docs-health.md +141 -0
  69. package/framework/commands/docs/help.md +278 -0
  70. package/framework/commands/docs/refine-vision.md +25 -0
  71. package/framework/commands/docs/reverse-consolidate.md +158 -0
  72. package/framework/commands/docs/sync-sessions.md +354 -0
  73. package/framework/commands/docs/validate-docs.md +157 -0
  74. package/framework/commands/engineer/bump.md +29 -0
  75. package/framework/commands/engineer/docs.md +11 -0
  76. package/framework/commands/engineer/hotfix.md +183 -0
  77. package/framework/commands/engineer/plan.md +85 -0
  78. package/framework/commands/engineer/pr-update.md +219 -0
  79. package/framework/commands/engineer/pr.md +117 -0
  80. package/framework/commands/engineer/pre-pr.md +81 -0
  81. package/framework/commands/engineer/start.md +254 -0
  82. package/framework/commands/engineer/validate-phase-sync.md +134 -0
  83. package/framework/commands/engineer/warm-up.md +20 -0
  84. package/framework/commands/engineer/work.md +155 -0
  85. package/framework/commands/f/company-context-extractor.md +93 -0
  86. package/framework/commands/f/process-meetings.md +103 -0
  87. package/framework/commands/git/README.md +682 -0
  88. package/framework/commands/git/code-review.md +213 -0
  89. package/framework/commands/git/fast-commit.md +43 -0
  90. package/framework/commands/git/feature/finish.md +88 -0
  91. package/framework/commands/git/feature/publish.md +89 -0
  92. package/framework/commands/git/feature/start.md +172 -0
  93. package/framework/commands/git/help.md +100 -0
  94. package/framework/commands/git/hotfix/finish.md +96 -0
  95. package/framework/commands/git/hotfix/start.md +92 -0
  96. package/framework/commands/git/init.md +111 -0
  97. package/framework/commands/git/release/finish.md +96 -0
  98. package/framework/commands/git/release/start.md +93 -0
  99. package/framework/commands/git/sync.md +199 -0
  100. package/framework/commands/meta/all-tools.md +58 -0
  101. package/framework/commands/meta/analyze-complex-problem.md +186 -0
  102. package/framework/commands/meta/create-abstraction.md +882 -0
  103. package/framework/commands/meta/create-agent-express.md +98 -0
  104. package/framework/commands/meta/create-agent.md +210 -0
  105. package/framework/commands/meta/create-command.md +203 -0
  106. package/framework/commands/meta/create-knowledge-base.md +143 -0
  107. package/framework/commands/meta/create-task-structure.md +150 -0
  108. package/framework/commands/meta/setup-integration.md +274 -0
  109. package/framework/commands/onion.md +169 -0
  110. package/framework/commands/product/README.md +249 -0
  111. package/framework/commands/product/analyze-pain-price.md +694 -0
  112. package/framework/commands/product/branding.md +458 -0
  113. package/framework/commands/product/check.md +46 -0
  114. package/framework/commands/product/checklist-sync.md +239 -0
  115. package/framework/commands/product/collect.md +95 -0
  116. package/framework/commands/product/consolidate-meetings.md +291 -0
  117. package/framework/commands/product/estimate.md +511 -0
  118. package/framework/commands/product/extract-meeting.md +226 -0
  119. package/framework/commands/product/feature.md +416 -0
  120. package/framework/commands/product/light-arch.md +82 -0
  121. package/framework/commands/product/presentation.md +174 -0
  122. package/framework/commands/product/refine.md +161 -0
  123. package/framework/commands/product/spec.md +79 -0
  124. package/framework/commands/product/task-check.md +378 -0
  125. package/framework/commands/product/task.md +603 -0
  126. package/framework/commands/product/validate-task.md +325 -0
  127. package/framework/commands/product/warm-up.md +24 -0
  128. package/framework/commands/quick/analisys.md +17 -0
  129. package/framework/commands/test/e2e.md +377 -0
  130. package/framework/commands/test/integration.md +508 -0
  131. package/framework/commands/test/unit.md +381 -0
  132. package/framework/commands/validate/collab/pair-testing.md +657 -0
  133. package/framework/commands/validate/collab/three-amigos.md +534 -0
  134. package/framework/commands/validate/qa-points/estimate.md +660 -0
  135. package/framework/commands/validate/test-strategy/analyze.md +1201 -0
  136. package/framework/commands/validate/test-strategy/create.md +411 -0
  137. package/framework/commands/validate/workflow.md +370 -0
  138. package/framework/commands/warm-up.md +20 -0
  139. package/framework/docs/architecture/acoplamento-clickup-problema-analise.md +468 -0
  140. package/framework/docs/architecture/desacoplamento-roadmap.md +364 -0
  141. package/framework/docs/architecture/validacao-fase-1.md +235 -0
  142. package/framework/docs/c4/c4-detection-rules.md +395 -0
  143. package/framework/docs/c4/c4-documentation-templates.md +579 -0
  144. package/framework/docs/c4/c4-mermaid-patterns.md +331 -0
  145. package/framework/docs/c4/c4-templates.md +256 -0
  146. package/framework/docs/clickup/clickup-acceptance-criteria-strategy.md +329 -0
  147. package/framework/docs/clickup/clickup-auto-update-strategy.md +340 -0
  148. package/framework/docs/clickup/clickup-comment-formatter.md +239 -0
  149. package/framework/docs/clickup/clickup-description-fix.md +384 -0
  150. package/framework/docs/clickup/clickup-dual-comment-strategy.md +528 -0
  151. package/framework/docs/clickup/clickup-formatting.md +302 -0
  152. package/framework/docs/clickup/separador-tamanho-otimizado.md +258 -0
  153. package/framework/docs/engineer/pre-pr-acceptance-validation.md +256 -0
  154. package/framework/docs/onion/ESPERANTO.md +293 -0
  155. package/framework/docs/onion/agents-reference.md +832 -0
  156. package/framework/docs/onion/clickup-integration.md +780 -0
  157. package/framework/docs/onion/commands-guide.md +924 -0
  158. package/framework/docs/onion/engineering-flows.md +900 -0
  159. package/framework/docs/onion/getting-started.md +803 -0
  160. package/framework/docs/onion/maintenance-checklist.md +421 -0
  161. package/framework/docs/onion/naming-conventions.md +286 -0
  162. package/framework/docs/onion/practical-examples.md +854 -0
  163. package/framework/docs/product/story-points-integration.md +269 -0
  164. package/framework/docs/product/story-points-validation.md +237 -0
  165. package/framework/docs/reviews/task-manager-docs-review-2025-11-24.md +184 -0
  166. package/framework/docs/strategies/clickup-comment-patterns.md +766 -0
  167. package/framework/docs/strategies/clickup-integration-tests.md +602 -0
  168. package/framework/docs/strategies/clickup-mcp-wrappers-tests.md +888 -0
  169. package/framework/docs/strategies/clickup-regression-tests.md +587 -0
  170. package/framework/docs/strategies/visual-patterns.md +315 -0
  171. package/framework/docs/templates/README.md +649 -0
  172. package/framework/docs/templates/adr-template.md +226 -0
  173. package/framework/docs/templates/analysis-template.md +280 -0
  174. package/framework/docs/templates/execution-plan-template.md +430 -0
  175. package/framework/docs/templates/guide-template.md +367 -0
  176. package/framework/docs/templates/phase-execution-prompt-template.md +504 -0
  177. package/framework/docs/templates/reference-template.md +522 -0
  178. package/framework/docs/templates/solution-template.md +390 -0
  179. package/framework/docs/tools/README.md +356 -0
  180. package/framework/docs/tools/agents.md +365 -0
  181. package/framework/docs/tools/commands.md +669 -0
  182. package/framework/docs/tools/cursor.md +539 -0
  183. package/framework/docs/tools/mcps.md +937 -0
  184. package/framework/docs/tools/rules.md +461 -0
  185. package/framework/rules/language-and-documentation.mdc +371 -0
  186. package/framework/rules/nestjs-controllers.md +83 -0
  187. package/framework/rules/nestjs-dtos.md +255 -0
  188. package/framework/rules/nestjs-modules.md +141 -0
  189. package/framework/rules/nestjs-services.md +230 -0
  190. package/framework/rules/nx-rules.mdc +41 -0
  191. package/framework/rules/onion-patterns.mdc +197 -0
  192. package/framework/skills/codebase-visualizer/SKILL.md +26 -0
  193. package/framework/skills/codebase-visualizer/scripts/visualize.py +131 -0
  194. package/framework/skills/collect/SKILL.md +84 -0
  195. package/framework/skills/create-rule/SKILL.md +152 -0
  196. package/framework/skills/db-schema-visualizer/SKILL.md +49 -0
  197. package/framework/skills/db-schema-visualizer/scripts/visualize.py +1191 -0
  198. package/framework/skills/sync-meetings/SKILL.md +239 -0
  199. package/framework/utils/clickup-mcp-wrappers.md +744 -0
  200. package/framework/utils/date-time-standards.md +200 -0
  201. package/framework/utils/task-manager/README.md +94 -0
  202. package/framework/utils/task-manager/adapters/asana.md +377 -0
  203. package/framework/utils/task-manager/adapters/clickup.md +467 -0
  204. package/framework/utils/task-manager/adapters/linear.md +421 -0
  205. package/framework/utils/task-manager/detector.md +299 -0
  206. package/framework/utils/task-manager/factory.md +363 -0
  207. package/framework/utils/task-manager/interface.md +248 -0
  208. package/framework/utils/task-manager/types.md +409 -0
  209. package/package.json +41 -0
  210. package/src/cli.js +73 -0
  211. package/src/commands/doctor.js +191 -0
  212. package/src/commands/init.js +287 -0
  213. package/src/commands/install.js +261 -0
  214. package/src/commands/list.js +152 -0
  215. package/src/commands/uninstall.js +90 -0
  216. package/src/commands/update.js +26 -0
  217. package/src/utils/fs.js +89 -0
  218. package/src/utils/log.js +35 -0
  219. package/src/utils/paths.js +32 -0
  220. package/src/utils/prompt.js +76 -0
@@ -0,0 +1,854 @@
1
+ # 💡 Exemplos Práticos - Sistema Onion
2
+
3
+ ## 📋 Índice
4
+
5
+ - [Exemplo 1: Nova Feature do Zero](#-exemplo-1-nova-feature-do-zero)
6
+ - [Exemplo 2: Hotfix Urgente](#-exemplo-2-hotfix-urgente)
7
+ - [Exemplo 3: Release e Deploy](#-exemplo-3-release-e-deploy)
8
+ - [Exemplo 4: Gerar Documentação](#-exemplo-4-gerar-documentação)
9
+ - [Exemplo 5: Integração ClickUp Completa](#-exemplo-5-integração-clickup-completa)
10
+ - [Anti-Patterns](#-anti-patterns-o-que-não-fazer)
11
+ - [Troubleshooting Comum](#-troubleshooting-comum)
12
+
13
+ ---
14
+
15
+ ## 🚀 Exemplo 1: Nova Feature do Zero
16
+
17
+ ### Cenário
18
+
19
+ Você precisa implementar um sistema completo de autenticação JWT com refresh tokens.
20
+
21
+ ### Workflow Completo
22
+
23
+ #### Passo 1: Criar Task Estruturada
24
+
25
+ ```bash
26
+ /product/task "Implementar autenticação JWT com refresh tokens e logout seguro"
27
+ ```
28
+
29
+ **O que acontece:**
30
+
31
+ 1. Sistema analisa README.md e docs/
32
+ 2. Identifica como feature de segurança (complexidade média)
33
+ 3. Apresenta plano para confirmação:
34
+
35
+ ```markdown
36
+ ## 🎯 PLANO DE TASK PROPOSTO
37
+
38
+ ### **📋 Task Principal**
39
+
40
+ **Nome**: 🎯 Implementar Autenticação JWT
41
+ **Tipo**: Feature
42
+ **Complexidade**: Média
43
+ **Estimativa**: 13-17 horas
44
+
45
+ ### **🏗️ Decomposição**
46
+
47
+ 📋 Task Principal
48
+ ├── 🔧 Backend JWT Service (4-6h)
49
+ │ ├── ✅ Implementar geração de JWT
50
+ │ ├── ✅ Implementar validação de tokens
51
+ │ └── ✅ Implementar refresh mechanism
52
+ ├── 🔧 API Integration (3-4h)
53
+ │ ├── ✅ Middleware de autenticação
54
+ │ ├── ✅ Protected routes
55
+ │ └── ✅ Error handling
56
+ ├── 🔧 Frontend Integration (3-4h)
57
+ │ ├── ✅ Login component
58
+ │ ├── ✅ Token storage
59
+ │ └── ✅ Auto-refresh
60
+ └── 🔧 Testing & Security (3-4h)
61
+ ├── ✅ Unit tests
62
+ ├── ✅ Integration tests
63
+ └── ✅ Security audit
64
+
65
+ ❓ **Este plano está correto? Posso proceder?** [Y/n]
66
+ ```
67
+
68
+ 4. Após confirmação (`y`):
69
+ - Cria task no ClickUp (ID: `86xyz123`)
70
+ - Cria 4 subtasks com parent relationship
71
+ - Executa `/git/feature/start jwt-authentication`
72
+ - Cria sessão `.claude/sessions/jwt-authentication/`
73
+ - Gera context files
74
+
75
+ **Saída:**
76
+
77
+ ```
78
+ ✅ TASK CRIADA COM DECOMPOSIÇÃO INTELIGENTE
79
+
80
+ 📋 ClickUp: https://app.clickup.com/t/86xyz123
81
+ 🌿 Branch: feature/jwt-authentication
82
+ 📁 Sessão: .claude/sessions/jwt-authentication/
83
+ ```
84
+
85
+ ---
86
+
87
+ #### Passo 2: Iniciar Desenvolvimento
88
+
89
+ ```bash
90
+ /engineer/start jwt-authentication
91
+ ```
92
+
93
+ **O que acontece:**
94
+
95
+ 1. Valida branch (já criada pelo `/product/task`)
96
+ 2. Lê task do ClickUp com subtasks
97
+ 3. Faz 5-7 questões de clarificação:
98
+
99
+ ```markdown
100
+ ## 🔍 Questões de Clarificação
101
+
102
+ 1. **Algoritmo JWT**: Prefere RS256 (assimétrico) ou HS256 (simétrico)?
103
+ - Sugestão: RS256 para melhor segurança
104
+
105
+ 2. **Storage de Refresh Tokens**: Redis ou PostgreSQL?
106
+ - Sugestão: Redis para performance
107
+
108
+ 3. **Expiração**: Qual TTL para access e refresh tokens?
109
+ - Sugestão: 15min (access), 7 dias (refresh)
110
+
111
+ 4. **Logout**: Blacklist de tokens ou invalidação de refresh?
112
+ - Sugestão: Invalidação de refresh (mais simples)
113
+
114
+ 5. **Rate Limiting**: Implementar em endpoints de auth?
115
+ - Sugestão: Sim, 5 tentativas por minuto
116
+
117
+ ❓ **Concordas com estas sugestões?** [Y/n]
118
+ ```
119
+
120
+ 4. Após confirmação, cria arquitetura:
121
+
122
+ **`architecture.md`:**
123
+
124
+ ```markdown
125
+ # Arquitetura - Autenticação JWT
126
+
127
+ ## Componentes
128
+
129
+ ### JWT Service
130
+
131
+ - Geração de access tokens (RS256)
132
+ - Validação de tokens
133
+ - Refresh mechanism
134
+
135
+ ### Auth Middleware
136
+
137
+ - Validação de tokens em requests
138
+ - Error handling
139
+ - Rate limiting
140
+
141
+ ### Token Storage
142
+
143
+ - Redis para refresh tokens
144
+ - TTL automático
145
+ - Blacklist opcional
146
+
147
+ ## Decisões Técnicas
148
+
149
+ ### RS256 vs HS256
150
+
151
+ **Escolhido**: RS256
152
+ **Razão**: Melhor segurança, permite validação sem secret
153
+
154
+ ### Redis vs PostgreSQL
155
+
156
+ **Escolhido**: Redis
157
+ **Razão**: Performance, TTL nativo, uso temporário
158
+
159
+ ## Trade-offs
160
+
161
+ ### Positivos
162
+
163
+ - ✅ Stateless authentication
164
+ - ✅ Escalabilidade
165
+ - ✅ Performance
166
+
167
+ ### Negativos
168
+
169
+ - ⚠️ Complexidade inicial
170
+ - ⚠️ Dependência de Redis
171
+ ```
172
+
173
+ 5. Gera plano de implementação:
174
+
175
+ **`plan.md`:**
176
+
177
+ ```markdown
178
+ # Plano - Autenticação JWT
179
+
180
+ ## Fase 1: Backend JWT Service (4-6h) ⏳ IN PROGRESS
181
+
182
+ - [ ] Instalar dependências (jsonwebtoken, bcrypt)
183
+ - [ ] Criar JWTService class
184
+ - [ ] Implementar generateToken()
185
+ - [ ] Implementar validateToken()
186
+ - [ ] Implementar refreshToken()
187
+ - [ ] Unit tests
188
+
189
+ ## Fase 2: API Integration (3-4h)
190
+
191
+ - [ ] Criar auth middleware
192
+ - [ ] Proteger routes
193
+ - [ ] Implementar error handling
194
+ - [ ] Rate limiting
195
+ - [ ] Integration tests
196
+
197
+ ## Fase 3: Frontend Integration (3-4h)
198
+
199
+ - [ ] Login component
200
+ - [ ] Token storage (localStorage)
201
+ - [ ] Axios interceptors
202
+ - [ ] Auto-refresh logic
203
+ - [ ] E2E tests
204
+
205
+ ## Fase 4: Testing & Security (3-4h)
206
+
207
+ - [ ] Security audit
208
+ - [ ] Penetration testing
209
+ - [ ] Performance testing
210
+ - [ ] Documentation
211
+ ```
212
+
213
+ 6. Atualiza ClickUp:
214
+ - Status → "In Progress"
215
+ - Comentário de início
216
+ - Cria mapeamento fase→subtask
217
+
218
+ ---
219
+
220
+ #### Passo 3: Implementar Fases
221
+
222
+ ```bash
223
+ /engineer/work jwt-authentication
224
+ ```
225
+
226
+ **Ciclo de Implementação:**
227
+
228
+ **Fase 1: Backend JWT Service**
229
+
230
+ ```typescript
231
+ // Sistema implementa código
232
+ // src/services/jwt.service.ts
233
+ import jwt from 'jsonwebtoken';
234
+ import { readFileSync } from 'fs';
235
+
236
+ export class JWTService {
237
+ private privateKey: string;
238
+ private publicKey: string;
239
+
240
+ constructor() {
241
+ this.privateKey = readFileSync('keys/private.pem', 'utf8');
242
+ this.publicKey = readFileSync('keys/public.pem', 'utf8');
243
+ }
244
+
245
+ generateToken(payload: any): string {
246
+ return jwt.sign(payload, this.privateKey, {
247
+ algorithm: 'RS256',
248
+ expiresIn: '15m',
249
+ });
250
+ }
251
+
252
+ validateToken(token: string): any {
253
+ return jwt.verify(token, this.publicKey, {
254
+ algorithms: ['RS256'],
255
+ });
256
+ }
257
+
258
+ // ... mais código
259
+ }
260
+ ```
261
+
262
+ **Após completar Fase 1:**
263
+
264
+ 1. Sistema pausa e pede validação ao usuário
265
+ 2. Usuário revisa e aprova (`y`)
266
+ 3. Sistema automaticamente:
267
+ - Atualiza subtask "Backend JWT Service" → "done"
268
+ - Adiciona comentário no ClickUp:
269
+
270
+ ```
271
+ 🔧 PROGRESSO DE DESENVOLVIMENTO
272
+
273
+ ━━━━━━━━━━━━━━━━━━━━━━━━
274
+
275
+ 📋 FASE COMPLETADA:
276
+ ▶ Fase 1: Backend JWT Service
277
+ ▶ Arquivos modificados: 8 arquivos
278
+ ▶ Funcionalidades: Token generation, validation, refresh
279
+ ▶ Testes: 15 unit tests ✅
280
+
281
+ ✅ DECISÕES TÉCNICAS:
282
+ ∟ Usamos RS256 (assimétrico)
283
+ ∟ Tokens em Redis com TTL
284
+ ∟ Rate limiting implementado
285
+ ∟ Logging de eventos
286
+
287
+ 🚀 PRÓXIMA FASE:
288
+ ▶ Fase 2: API Integration
289
+ ▶ Estimativa: 3-4 horas
290
+
291
+ 📊 PROGRESSO GERAL: 25% completo (1/4 fases)
292
+
293
+ ━━━━━━━━━━━━━━━━━━━━━━━━
294
+
295
+ ⏰ 2025-01-27 15:45 | 🎯 Próximo: Integrar com API
296
+ ```
297
+
298
+ 4. Atualiza `plan.md`:
299
+
300
+ ```markdown
301
+ ## Fase 1: Backend JWT Service (4-6h) ✅ COMPLETED
302
+
303
+ - [x] Instalar dependências
304
+ - [x] Criar JWTService class
305
+ - [x] Implementar generateToken()
306
+ - [x] Implementar validateToken()
307
+ - [x] Implementar refreshToken()
308
+ - [x] Unit tests (15 tests)
309
+
310
+ **Decisões:**
311
+
312
+ - Usamos RS256 para melhor segurança
313
+ - Redis para storage com TTL automático
314
+ - Rate limiting: 5 req/min
315
+
316
+ **Próxima Fase:** API Integration
317
+ ```
318
+
319
+ **Repete para Fases 2, 3 e 4...**
320
+
321
+ ---
322
+
323
+ #### Passo 4: Criar Pull Request
324
+
325
+ ```bash
326
+ /engineer/pr
327
+ ```
328
+
329
+ **O que acontece:**
330
+
331
+ 1. Valida que todos os testes passam
332
+ 2. Commit e push das mudanças
333
+ 3. Atualiza ClickUp:
334
+ - Status → "in progress"
335
+ - Tag → "under-review"
336
+ - Comentário com PR link
337
+ 4. Abre PR no GitHub/GitLab
338
+ 5. Aguarda code review
339
+ 6. Aplica correções (se necessário)
340
+
341
+ ---
342
+
343
+ #### Passo 5: Pós-Merge
344
+
345
+ ```bash
346
+ # Automático após merge
347
+ /git/sync
348
+ ```
349
+
350
+ **O que acontece:**
351
+
352
+ 1. GitFlow analysis
353
+ 2. Cleanup de branches
354
+ 3. Session archiving
355
+ 4. Atualiza ClickUp → "Done"
356
+ 5. Sincroniza branches locais
357
+
358
+ ---
359
+
360
+ ### Resultado Final
361
+
362
+ - ✅ Feature completa implementada
363
+ - ✅ 4 subtasks concluídas
364
+ - ✅ Documentação gerada
365
+ - ✅ Testes passando
366
+ - ✅ ClickUp sincronizado
367
+ - ✅ Branch merged e limpa
368
+
369
+ ---
370
+
371
+ ## 🔥 Exemplo 2: Hotfix Urgente
372
+
373
+ ### Cenário
374
+
375
+ Bug crítico em produção: timeout na API de pagamentos causando perda de transações.
376
+
377
+ ### Workflow Rápido
378
+
379
+ #### Passo 1: Criar Hotfix
380
+
381
+ ```bash
382
+ /git/hotfix/start "fix-payment-timeout"
383
+ ```
384
+
385
+ **Saída:**
386
+
387
+ ```
388
+ 🔥 HOTFIX BRANCH CRIADA
389
+
390
+ Branch: hotfix/fix-payment-timeout
391
+ Base: main (produção)
392
+ Sessão: .claude/sessions/fix-payment-timeout/
393
+ ```
394
+
395
+ ---
396
+
397
+ #### Passo 2: Análise e Implementação
398
+
399
+ ```bash
400
+ /engineer/hotfix "fix-payment-timeout"
401
+ ```
402
+
403
+ **Análise Rápida:**
404
+
405
+ ```markdown
406
+ ## 🐛 Análise do Bug
407
+
408
+ ### Sintomas
409
+
410
+ - Timeout após 30s em /api/payments
411
+ - 15% das transações falhando
412
+ - Logs mostram query lenta
413
+
414
+ ### Root Cause
415
+
416
+ - Query N+1 em relacionamentos
417
+ - Falta de índice em payments.user_id
418
+ - Connection pool saturado
419
+
420
+ ### Fix
421
+
422
+ 1. Adicionar índice
423
+ 2. Otimizar query (eager loading)
424
+ 3. Aumentar connection pool
425
+ ```
426
+
427
+ **Implementação:**
428
+
429
+ ```sql
430
+ -- migrations/add_payment_index.sql
431
+ CREATE INDEX idx_payments_user_id ON payments(user_id);
432
+ ```
433
+
434
+ ```typescript
435
+ // src/services/payment.service.ts
436
+ // ANTES (N+1 problem)
437
+ const payments = await Payment.findAll();
438
+ for (const payment of payments) {
439
+ const user = await payment.getUser(); // N+1!
440
+ }
441
+
442
+ // DEPOIS (eager loading)
443
+ const payments = await Payment.findAll({
444
+ include: [{ model: User }], // ✅ Single query
445
+ });
446
+ ```
447
+
448
+ ---
449
+
450
+ #### Passo 3: Testes Rápidos
451
+
452
+ ```bash
453
+ # Testes de regressão
454
+ npm test -- payment.service.spec.ts
455
+
456
+ # Performance test
457
+ artillery quick --count 100 --num 10 http://localhost:3000/api/payments
458
+ ```
459
+
460
+ ---
461
+
462
+ #### Passo 4: PR Urgente
463
+
464
+ ```bash
465
+ /engineer/pr
466
+ ```
467
+
468
+ **Code Review Acelerado:**
469
+
470
+ - ✅ Testes passam
471
+ - ✅ Performance melhorou 10x
472
+ - ✅ Sem breaking changes
473
+
474
+ ---
475
+
476
+ #### Passo 5: Merge e Deploy
477
+
478
+ ```bash
479
+ # Após aprovação
480
+ /git/hotfix/finish
481
+ ```
482
+
483
+ **O que acontece:**
484
+
485
+ 1. Merge para `main` (produção)
486
+ 2. Merge para `develop` (desenvolvimento)
487
+ 3. Tag `hotfix/fix-payment-timeout`
488
+ 4. Deploy automático para produção
489
+ 5. Notificação da equipe
490
+
491
+ ---
492
+
493
+ ### Resultado
494
+
495
+ - ⏱️ **Tempo total:** 2 horas (análise + fix + deploy)
496
+ - ✅ **Bug resolvido** em produção
497
+ - ✅ **Zero downtime**
498
+ - ✅ **Documentado** para postmortem
499
+
500
+ ---
501
+
502
+ ## 📦 Exemplo 3: Release e Deploy
503
+
504
+ ### Cenário
505
+
506
+ Preparar release v1.2.0 com 15 features e 8 bugfixes.
507
+
508
+ ### Workflow
509
+
510
+ #### Passo 1: Criar Release Branch
511
+
512
+ ```bash
513
+ /git/release/start "v1.2.0"
514
+ ```
515
+
516
+ ---
517
+
518
+ #### Passo 2: Ajustes Finais
519
+
520
+ ```bash
521
+ # Atualizar CHANGELOG
522
+ # Atualizar versão
523
+ /engineer/bump minor
524
+
525
+ # Testes finais
526
+ npm run test:e2e
527
+ npm run test:integration
528
+ ```
529
+
530
+ ---
531
+
532
+ #### Passo 3: PR e Aprovação
533
+
534
+ ```bash
535
+ /engineer/pr
536
+ ```
537
+
538
+ **Checklist de Release:**
539
+
540
+ - ✅ Todos os testes passam
541
+ - ✅ CHANGELOG atualizado
542
+ - ✅ Versão atualizada
543
+ - ✅ Documentação atualizada
544
+ - ✅ Breaking changes documentadas
545
+
546
+ ---
547
+
548
+ #### Passo 4: Merge e Tag
549
+
550
+ ```bash
551
+ /git/release/finish
552
+ ```
553
+
554
+ **O que acontece:**
555
+
556
+ 1. Merge para `main`
557
+ 2. Merge para `develop`
558
+ 3. Tag `v1.2.0`
559
+ 4. Deploy para produção
560
+ 5. Release notes geradas
561
+
562
+ ---
563
+
564
+ ## 📚 Exemplo 4: Gerar Documentação
565
+
566
+ ### Cenário
567
+
568
+ Projeto novo precisa de documentação completa.
569
+
570
+ ### Workflow
571
+
572
+ #### Passo 1: Documentação de Negócio
573
+
574
+ ```bash
575
+ /docs/build-business-docs
576
+ ```
577
+
578
+ **Saída:**
579
+
580
+ ```
581
+ docs/business-context/
582
+ ├── vision.md # Visão do produto
583
+ ├── stakeholders.md # Stakeholders e papéis
584
+ └── business-model.md # Modelo de negócio
585
+ ```
586
+
587
+ ---
588
+
589
+ #### Passo 2: Documentação Técnica
590
+
591
+ ```bash
592
+ /docs/build-tech-docs
593
+ ```
594
+
595
+ **Saída:**
596
+
597
+ ```
598
+ docs/technical-context/
599
+ ├── architecture.md # Arquitetura do sistema
600
+ ├── technology-stack.md # Stack tecnológico
601
+ └── constraints.md # Restrições técnicas
602
+ ```
603
+
604
+ ---
605
+
606
+ #### Passo 3: Índice Navegável
607
+
608
+ ```bash
609
+ /docs/build-index
610
+ ```
611
+
612
+ **Saída:** `docs/index.md` com links para toda documentação
613
+
614
+ ---
615
+
616
+ #### Passo 4: Validação
617
+
618
+ ```bash
619
+ /docs/validate-docs
620
+ /docs/docs-health
621
+ ```
622
+
623
+ **Validações:**
624
+
625
+ - ✅ Links funcionam
626
+ - ✅ Estrutura completa
627
+ - ✅ Sem seções vazias
628
+ - ✅ Formatação consistente
629
+
630
+ ---
631
+
632
+ ## 🔗 Exemplo 5: Integração ClickUp Completa
633
+
634
+ ### Cenário
635
+
636
+ Usar ClickUp MCP para gerenciar todo o ciclo de vida de uma feature.
637
+
638
+ ### Workflow Detalhado
639
+
640
+ #### Passo 1: Criar Task com Decomposição
641
+
642
+ ```bash
643
+ /product/task "Sistema de notificações push com preferências de usuário"
644
+ ```
645
+
646
+ **ClickUp Structure Criada:**
647
+
648
+ ```
649
+ 📋 Sistema de Notificações Push (86abc789)
650
+ ├── 🔧 Backend Push Service (86abc790)
651
+ │ └── Checklists Nativos:
652
+ │ ✅ Implementar FCM integration
653
+ │ ✅ Criar notification queue
654
+ │ ✅ Implementar retry logic
655
+ ├── 🔧 User Preferences API (86abc791)
656
+ │ └── Checklists Nativos:
657
+ │ ✅ CRUD de preferências
658
+ │ ✅ Validação de regras
659
+ │ ✅ Testes de API
660
+ └── 🔧 Frontend Integration (86abc792)
661
+ └── Checklists Nativos:
662
+ ✅ Settings UI
663
+ ✅ Push permission
664
+ ✅ Notification display
665
+ ```
666
+
667
+ ---
668
+
669
+ #### Passo 2: Monitorar Progresso
670
+
671
+ ```bash
672
+ # Durante desenvolvimento
673
+ /engineer/work notificacoes-push
674
+
675
+ # Sistema automaticamente:
676
+ # - Lê checklists nativos
677
+ # - Calcula progresso (3/9 items = 33%)
678
+ # - Atualiza ClickUp em tempo real
679
+ ```
680
+
681
+ ---
682
+
683
+ #### Passo 3: Sincronização Automática
684
+
685
+ ```javascript
686
+ // Sistema monitora checklists nativos
687
+ const task = await mcp_clickup_get_task({
688
+ task_id: '86abc789',
689
+ subtasks: true,
690
+ });
691
+
692
+ // Calcula progresso
693
+ let totalItems = 0;
694
+ let resolvedItems = 0;
695
+
696
+ task.subtasks.forEach((subtask) => {
697
+ subtask.checklists.forEach((checklist) => {
698
+ totalItems += checklist.unresolved + checklist.resolved;
699
+ resolvedItems += checklist.resolved;
700
+ });
701
+ });
702
+
703
+ const progress = ((resolvedItems / totalItems) * 100).toFixed(1);
704
+ console.log(`Progresso: ${progress}%`); // 33.3%
705
+ ```
706
+
707
+ ---
708
+
709
+ #### Passo 4: Validação de Conclusão
710
+
711
+ ```bash
712
+ /product/task-check 86abc789
713
+ ```
714
+
715
+ **Validações:**
716
+
717
+ - ✅ Todos os checklists resolvidos
718
+ - ✅ Critérios de aceitação atendidos
719
+ - ✅ Testes passando
720
+ - ✅ Documentação completa
721
+
722
+ ---
723
+
724
+ ## ❌ Anti-Patterns: O Que NÃO Fazer
725
+
726
+ ### Anti-Pattern 1: Pular Análise
727
+
728
+ ```bash
729
+ # ❌ ERRADO
730
+ /engineer/work feature-x # Sem /engineer/start antes!
731
+
732
+ # ✅ CORRETO
733
+ /engineer/start feature-x # Análise primeiro
734
+ /engineer/work feature-x # Depois implementação
735
+ ```
736
+
737
+ ---
738
+
739
+ ### Anti-Pattern 2: Não Usar Hierarquia ClickUp
740
+
741
+ ```javascript
742
+ // ❌ ERRADO - Subtasks independentes
743
+ await create_bulk_tasks({
744
+ tasks: [{ name: 'Subtask 1' }, { name: 'Subtask 2' }],
745
+ });
746
+
747
+ // ✅ CORRETO - Hierarquia apropriada
748
+ const main = await create_task({ name: 'Main' });
749
+ await create_task({ name: 'Sub 1', parent: main.id });
750
+ await create_task({ name: 'Sub 2', parent: main.id });
751
+ ```
752
+
753
+ ---
754
+
755
+ ### Anti-Pattern 3: Commits Grandes
756
+
757
+ ```bash
758
+ # ❌ ERRADO
759
+ git add .
760
+ git commit -m "Implementei tudo"
761
+
762
+ # ✅ CORRETO
763
+ git add src/services/jwt.service.ts
764
+ git commit -m "feat: implement JWT generation"
765
+
766
+ git add src/middleware/auth.middleware.ts
767
+ git commit -m "feat: add auth middleware"
768
+ ```
769
+
770
+ ---
771
+
772
+ ### Anti-Pattern 4: Pular Testes
773
+
774
+ ```bash
775
+ # ❌ ERRADO
776
+ /engineer/pr # Sem rodar testes!
777
+
778
+ # ✅ CORRETO
779
+ npm test
780
+ /engineer/pre-pr # Validações
781
+ /engineer/pr # Depois PR
782
+ ```
783
+
784
+ ---
785
+
786
+ ## 🔧 Troubleshooting Comum
787
+
788
+ ### Problema 1: Branch já existe
789
+
790
+ ```bash
791
+ # Sintoma
792
+ Error: Branch feature/x already exists
793
+
794
+ # Solução
795
+ git checkout feature/x # Usar existente
796
+ # OU
797
+ git branch -D feature/x # Deletar e recriar
798
+ /git/feature/start "x"
799
+ ```
800
+
801
+ ---
802
+
803
+ ### Problema 2: ClickUp não atualiza
804
+
805
+ ```bash
806
+ # Diagnóstico
807
+ cat .claude/sessions/<feature-slug>/context.md | grep "Task ID"
808
+
809
+ # Se task-id incorreto, corrigir manualmente
810
+ # Se correto, validar conexão MCP
811
+ ```
812
+
813
+ ---
814
+
815
+ ### Problema 3: Sessão não encontrada
816
+
817
+ ```bash
818
+ # Sintoma
819
+ /engineer/work x
820
+ Error: Session not found
821
+
822
+ # Solução
823
+ /engineer/start x # Criar sessão
824
+ ```
825
+
826
+ ---
827
+
828
+ ### Problema 4: Testes falhando
829
+
830
+ ```bash
831
+ # Diagnóstico
832
+ npm test -- --verbose
833
+
834
+ # Correção
835
+ # 1. Corrigir testes
836
+ # 2. Rodar novamente
837
+ # 3. Só então fazer PR
838
+ ```
839
+
840
+ ---
841
+
842
+ ## 🔗 Documentos Relacionados
843
+
844
+ - [Guia de Comandos](./commands-guide.md) - Todos os comandos
845
+ - [Fluxos de Engenharia](./engineering-flows.md) - Workflows detalhados
846
+ - [Integração ClickUp](./clickup-integration.md) - ClickUp MCP
847
+ - [Referência de Agentes](./agents-reference.md) - Agentes disponíveis
848
+ - [Configuração Inicial](./getting-started.md) - Setup do sistema
849
+
850
+ ---
851
+
852
+ **Última atualização:** 2025-01-27
853
+ **Versão:** 2.0
854
+ **Exemplos:** 5 completos + anti-patterns + troubleshooting