jarvis-ai-framework 1.0.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 (240) hide show
  1. package/AGENTS.md +416 -0
  2. package/LICENSE +21 -0
  3. package/README.md +190 -0
  4. package/agents/AGENTS.md +234 -0
  5. package/agents/README.md +309 -0
  6. package/agents/engineering/data/eng.data-engineer.agent.md +309 -0
  7. package/agents/engineering/eng.agent.md +303 -0
  8. package/agents/engineering/eng.bug-hunter.md +386 -0
  9. package/agents/engineering/eng.cybersecurity.agent.md +503 -0
  10. package/agents/engineering/eng.dev-code-reviewer.md +148 -0
  11. package/agents/engineering/eng.docs-writer.md +152 -0
  12. package/agents/engineering/eng.frontend.agent.md +117 -0
  13. package/agents/engineering/eng.rpa.agent.md +215 -0
  14. package/agents/engineering/eng.tech-analyst.agent.md +102 -0
  15. package/agents/engineering/eng.ux-designer.agent.md +193 -0
  16. package/agents/engineering/qa/eng.qa.cypress-specialist.md +109 -0
  17. package/agents/engineering/qa/eng.qa.quality-champion-task-agent.md +85 -0
  18. package/agents/engineering/qa/eng.qa.quality-strategist.md +111 -0
  19. package/agents/engineering/qa/eng.qa.test-architect.md +400 -0
  20. package/agents/engineering/qa/eng.qa.test-planner.md +477 -0
  21. package/agents/engineering/qa/eng.qa.testing-engineer.md +339 -0
  22. package/agents/product/prod.pm-checker.md +52 -0
  23. package/bin/commands/docs-publish.js +184 -0
  24. package/bin/commands/docs-sync.js +139 -0
  25. package/bin/commands/info.js +87 -0
  26. package/bin/commands/init.js +237 -0
  27. package/bin/commands/install-rtk.js +90 -0
  28. package/bin/commands/list.js +48 -0
  29. package/bin/commands/qa-signoff.js +112 -0
  30. package/bin/commands/whoami.js +43 -0
  31. package/bin/jarvis.js +159 -0
  32. package/bin/lib/auth/session.js +56 -0
  33. package/bin/lib/config/constants.js +123 -0
  34. package/bin/lib/config/ide-config.js +233 -0
  35. package/bin/lib/core/scanner.js +124 -0
  36. package/bin/lib/core/sync-engine.js +551 -0
  37. package/bin/lib/docs/fetch-file.sh +41 -0
  38. package/bin/lib/docs/publish-file.sh +284 -0
  39. package/bin/lib/docs/validate-frontmatter.js +157 -0
  40. package/bin/lib/env-loader.js +198 -0
  41. package/bin/lib/tasks/comment.js +131 -0
  42. package/bin/lib/utils/git-parser.js +145 -0
  43. package/bin/lib/utils/logger.js +104 -0
  44. package/bin/lib/utils/npmrc-parser.js +106 -0
  45. package/bin/lib/utils/paths.js +55 -0
  46. package/bin/lib/utils/ui.js +59 -0
  47. package/bin/lib/vcs/api.js +312 -0
  48. package/bin/lib/vcs/create-issue.js +43 -0
  49. package/bin/lib/vcs/create-merge.js +43 -0
  50. package/bin/lib/vcs/fetch-raw.js +30 -0
  51. package/bin/postinstall.js +41 -0
  52. package/members.md +25 -0
  53. package/package.json +55 -0
  54. package/rules/AGENTS.md +205 -0
  55. package/rules/engineering/data/data-rules.md +200 -0
  56. package/rules/engineering/eng-rules.md +243 -0
  57. package/rules/engineering/eng-security-rules.md +186 -0
  58. package/rules/engineering/eng.breakdown-subtasks-rules.md +585 -0
  59. package/rules/engineering/eng.bump-rules.md +27 -0
  60. package/rules/engineering/eng.docs-scraping-rules.md +64 -0
  61. package/rules/engineering/eng.downstream-flow-rules.md +297 -0
  62. package/rules/engineering/eng.integrations-rules.md +73 -0
  63. package/rules/engineering/eng.plan-rules.md +333 -0
  64. package/rules/engineering/eng.pr-rules.md +359 -0
  65. package/rules/engineering/eng.pre-pr-rules.md +103 -0
  66. package/rules/engineering/eng.start-rules.md +246 -0
  67. package/rules/engineering/eng.tech-spec-rules.md +968 -0
  68. package/rules/engineering/eng.work-rules.md +312 -0
  69. package/rules/engineering/frontend/eng.frontend-rules.md +147 -0
  70. package/rules/engineering/qa/eng.qa.cypress-standards-rules.md +259 -0
  71. package/rules/engineering/qa/eng.qa.exploratory-session-rules.md +137 -0
  72. package/rules/engineering/qa/eng.qa.quality-gate-scoring-rules.md +181 -0
  73. package/rules/engineering/qa/eng.qa.tech-spec-validation-criteria-rules.md +120 -0
  74. package/rules/engineering/rpa/eng.rpa-rules.md +230 -0
  75. package/rules/product/README.md +24 -0
  76. package/rules/product/prod-rules.md +151 -0
  77. package/rules/rtk-rules.md +68 -0
  78. package/skills/AGENTS.md +290 -0
  79. package/skills/SKILLS-ROADMAP.md +333 -0
  80. package/skills/churn-audit/SKILL.md +385 -0
  81. package/skills/context-detect/SKILL.md +399 -0
  82. package/skills/context-detect/assets/context-profile-template.md +127 -0
  83. package/skills/docs-central/README.md +310 -0
  84. package/skills/docs-central/SKILL.md +423 -0
  85. package/skills/docs-index/SKILL.md +377 -0
  86. package/skills/eng-ai-engineer/SKILL.md +296 -0
  87. package/skills/eng-arch-c4/SKILL.md +358 -0
  88. package/skills/eng-arch-c4/assets/example-code.md +189 -0
  89. package/skills/eng-arch-c4/assets/example-component.md +105 -0
  90. package/skills/eng-arch-c4/assets/example-container.md +104 -0
  91. package/skills/eng-arch-c4/assets/example-context.md +81 -0
  92. package/skills/eng-backend/SKILL.md +776 -0
  93. package/skills/eng-browser-extension-builder/SKILL.md +385 -0
  94. package/skills/eng-cybersecurity/SKILL.md +645 -0
  95. package/skills/eng-data-bi/SKILL.md +199 -0
  96. package/skills/eng-data-debug/SKILL.md +307 -0
  97. package/skills/eng-data-engineer/SKILL.md +256 -0
  98. package/skills/eng-data-onboard/SKILL.md +310 -0
  99. package/skills/eng-data-orchestrator/SKILL.md +426 -0
  100. package/skills/eng-design-system/SKILL.md +619 -0
  101. package/skills/eng-docs-write/SKILL.md +312 -0
  102. package/skills/eng-frontend/SKILL.md +913 -0
  103. package/skills/eng-jira-comment/SKILL.md +17 -0
  104. package/skills/eng-microfrontend/SKILL.md +602 -0
  105. package/skills/eng-ms-trace/SKILL.md +469 -0
  106. package/skills/eng-nestjs/SKILL.md +791 -0
  107. package/skills/eng-performance-engineer/SKILL.md +312 -0
  108. package/skills/eng-pr/SKILL.md +339 -0
  109. package/skills/eng-qa-a11y-audit/SKILL.md +269 -0
  110. package/skills/eng-qa-bug-report/SKILL.md +1088 -0
  111. package/skills/eng-qa-bug-report/TASK_MANAGERS.md +138 -0
  112. package/skills/eng-qa-cypress-e2e/SKILL.md +177 -0
  113. package/skills/eng-qa-dev-guide/SKILL.md +164 -0
  114. package/skills/eng-qa-e2e/SKILL.md +400 -0
  115. package/skills/eng-qa-e2e-spec-writer/SKILL.md +322 -0
  116. package/skills/eng-qa-exploratory/SKILL.md +188 -0
  117. package/skills/eng-qa-gate/SKILL.md +370 -0
  118. package/skills/eng-qa-gate/assets/checklist-validacao.md +291 -0
  119. package/skills/eng-qa-graphql-contract/SKILL.md +256 -0
  120. package/skills/eng-qa-quality-report/SKILL.md +412 -0
  121. package/skills/eng-qa-test-plan/SKILL.md +466 -0
  122. package/skills/eng-qa-test-plan/assets/test-coverage-template.md +92 -0
  123. package/skills/eng-qa-test-plan/assets/test-patterns.md +178 -0
  124. package/skills/eng-qa-testsprite/SKILL.md +325 -0
  125. package/skills/eng-qa-testsprite/references/testsprite-mcp.md +224 -0
  126. package/skills/eng-qa-unit-test/SKILL.md +471 -0
  127. package/skills/eng-rabbitmq/SKILL.md +661 -0
  128. package/skills/eng-scraper/SKILL.md +683 -0
  129. package/skills/eng-scraper-robot-builder/SKILL.md +370 -0
  130. package/skills/eng-security-patch/SKILL.md +378 -0
  131. package/skills/eng-security-triage/SKILL.md +266 -0
  132. package/skills/eng-task-comment/SKILL.md +60 -0
  133. package/skills/eng-tech-analyst/SKILL.md +529 -0
  134. package/skills/eng-threat-model/SKILL.md +161 -0
  135. package/skills/init-jarvis/SKILL.md +1304 -0
  136. package/skills/init-jarvis/assets/mcp-configs.md +389 -0
  137. package/skills/init-jarvis/assets/onboarding-checklist.md +104 -0
  138. package/skills/init-jarvis/assets/setup-guide.md +360 -0
  139. package/skills/lovable-prompt-generator/SKILL.md +304 -0
  140. package/skills/prod-roadmap-report/README.md +303 -0
  141. package/skills/prod-roadmap-report/SKILL.md +198 -0
  142. package/skills/prod-roadmap-report/commands/status.compiled.single.team.md +23 -0
  143. package/skills/prod-roadmap-report/commands/status.list.projects.md +17 -0
  144. package/skills/prod-roadmap-report/commands/status.memory.md +192 -0
  145. package/skills/prod-roadmap-report/commands/status.roadmap.preview.md +94 -0
  146. package/skills/prod-roadmap-report/references/detailed-guide.md +236 -0
  147. package/skills/prod-roadmap-report/rules/detailed-guide.md +237 -0
  148. package/skills/prod-roadmap-report/rules/status-report-rules.md +44 -0
  149. package/skills/prod-roadmap-report/templates/template-multiple-teams-compiled-status.md +53 -0
  150. package/skills/prod-roadmap-report/templates/template-projects-list.md +23 -0
  151. package/skills/prod-roadmap-report/templates/template-single-team-compiled-status.md +60 -0
  152. package/skills/prod-roadmap-report/templates/template-single-team-status.md +49 -0
  153. package/skills/prod-specs/SKILL.md +108 -0
  154. package/skills/prod-specs/references/prod.spec.clarify.md +176 -0
  155. package/skills/prod-specs/references/prod.spec.epic.md +107 -0
  156. package/skills/prod-specs/references/prod.spec.frd.md +135 -0
  157. package/skills/prod-specs/references/prod.spec.issue.md +145 -0
  158. package/skills/prod-specs/references/prod.spec.prd.md +118 -0
  159. package/skills/prod-specs/rules/prod-spec-rules.md +186 -0
  160. package/skills/prod-specs/templates/prod-breakdown-template.md +136 -0
  161. package/skills/prod-specs/templates/prod-epic-template.md +76 -0
  162. package/skills/prod-specs/templates/prod-frd-template.md +172 -0
  163. package/skills/prod-specs/templates/prod-issue-template.md +68 -0
  164. package/skills/prod-specs/templates/prod-prd-full-template.md +159 -0
  165. package/skills/prod-specs/templates/prod-prd-template.md +173 -0
  166. package/skills/prod-specs-update/SKILL.md +272 -0
  167. package/skills/report-issue/SKILL.md +156 -0
  168. package/taxonomy.md +270 -0
  169. package/templates/AGENTS.md +189 -0
  170. package/templates/CDD aplicado a Prompts.md +182 -0
  171. package/templates/ENV-template.md +187 -0
  172. package/templates/engineering/AGENTS-template.md +71 -0
  173. package/templates/engineering/ARD-template.md +193 -0
  174. package/templates/engineering/CONTACTS-template.md +135 -0
  175. package/templates/engineering/PR-template.md +40 -0
  176. package/templates/engineering/RFC-Playbook.md +325 -0
  177. package/templates/engineering/RFC-template.md +199 -0
  178. package/templates/engineering/architecture-template.md +277 -0
  179. package/templates/engineering/breakdown-subtasks-template.md +582 -0
  180. package/templates/engineering/c4-model-template.md +516 -0
  181. package/templates/engineering/data-contract-template.md +135 -0
  182. package/templates/engineering/data-pipeline-template.md +163 -0
  183. package/templates/engineering/plan-template.md +255 -0
  184. package/templates/engineering/qa/eng.qa.quality-gate-examples-template.md +311 -0
  185. package/templates/engineering/qa/eng.qa.quality-gate-report-template.md +249 -0
  186. package/templates/engineering/qa/qa.cypress-test-template.md +172 -0
  187. package/templates/engineering/qa/qa.exploratory-session-template.md +148 -0
  188. package/templates/engineering/qa/qa.quality-report-template.md +130 -0
  189. package/templates/engineering/qa/qa.release-signoff-template.md +54 -0
  190. package/templates/engineering/qa/qa.sprint-plan-template.md +49 -0
  191. package/templates/engineering/swagger-template.md +145 -0
  192. package/templates/engineering/tech-spec-template.md +497 -0
  193. package/templates/engineering/work-progress-template.md +155 -0
  194. package/workflows/AGENTS.md +240 -0
  195. package/workflows/README.md +160 -0
  196. package/workflows/all-tools.md +11 -0
  197. package/workflows/engineering/data/data.contract.md +202 -0
  198. package/workflows/engineering/data/data.new-pipeline.md +234 -0
  199. package/workflows/engineering/eng.breakdown-subtasks.md +420 -0
  200. package/workflows/engineering/eng.bug-audit.md +591 -0
  201. package/workflows/engineering/eng.build-tech-spec.md +1116 -0
  202. package/workflows/engineering/eng.create-ard-from-code.md +259 -0
  203. package/workflows/engineering/eng.create-ard.md +382 -0
  204. package/workflows/engineering/eng.create-rfc.md +245 -0
  205. package/workflows/engineering/eng.debug.md +479 -0
  206. package/workflows/engineering/eng.docs.md +40 -0
  207. package/workflows/engineering/eng.light-arch.md +84 -0
  208. package/workflows/engineering/eng.plan.md +213 -0
  209. package/workflows/engineering/eng.pr.md +466 -0
  210. package/workflows/engineering/eng.pre-pr.md +167 -0
  211. package/workflows/engineering/eng.review.md +185 -0
  212. package/workflows/engineering/eng.rpa.robot.md +342 -0
  213. package/workflows/engineering/eng.security-audit.md +312 -0
  214. package/workflows/engineering/eng.security-incident.md +275 -0
  215. package/workflows/engineering/eng.security-pipeline.md +210 -0
  216. package/workflows/engineering/eng.security-review.md +235 -0
  217. package/workflows/engineering/eng.start.md +494 -0
  218. package/workflows/engineering/eng.work.md +558 -0
  219. package/workflows/engineering/frontend/eng.frontend-component.md +190 -0
  220. package/workflows/engineering/frontend/eng.frontend-perf-audit.md +375 -0
  221. package/workflows/engineering/frontend/eng.frontend-review.md +185 -0
  222. package/workflows/engineering/qa/eng.qa-dev-quality-guide.md +51 -0
  223. package/workflows/engineering/qa/eng.qa-e2e-test-generation.md +51 -0
  224. package/workflows/engineering/qa/eng.qa-exploratory-session.md +60 -0
  225. package/workflows/engineering/qa/eng.qa-quality-gate-validation.md +202 -0
  226. package/workflows/engineering/qa/eng.qa-quality-report.md +83 -0
  227. package/workflows/engineering/qa/eng.qa-refinement-entry.md +83 -0
  228. package/workflows/engineering/qa/eng.qa-release-signoff.md +170 -0
  229. package/workflows/engineering/qa/eng.qa-sprint-planning.md +100 -0
  230. package/workflows/engineering/ta/eng.ta.atendimento.md +93 -0
  231. package/workflows/product/prod.roadmap.preview.md +110 -0
  232. package/workflows/product/prod.spec.breakdown.md +163 -0
  233. package/workflows/product/prod.spec.clarify.md +178 -0
  234. package/workflows/product/prod.spec.epic.md +154 -0
  235. package/workflows/product/prod.spec.frd.md +96 -0
  236. package/workflows/product/prod.spec.issue.md +145 -0
  237. package/workflows/product/prod.spec.md +60 -0
  238. package/workflows/product/prod.spec.prd.md +100 -0
  239. package/workflows/taxonomy.md +92 -0
  240. package/workflows/warm-up.md +574 -0
@@ -0,0 +1,190 @@
1
+ ---
2
+ name: eng.frontend-component
3
+ description: >
4
+ Workflow para criar ou refatorar um componente frontend com qualidade:
5
+ análise de contexto, decisão design system vs local, implementação com
6
+ acessibilidade e testes.
7
+ Aplica-se a componentes React em micro frontends e no design system.
8
+ author: jarvis-team
9
+ version: "1.0"
10
+
11
+ ---
12
+
13
+ # Workflow: Criar ou Refatorar Componente Frontend
14
+
15
+ ## Contexto
16
+
17
+ Use este workflow para garantir que todo componente frontend seja criado com
18
+ qualidade, acessibilidade, testes e no lugar correto (design system vs remote).
19
+
20
+ **Skill de referência**: `eng-frontend`, `eng-design-system`
21
+
22
+ ---
23
+
24
+ ## Fase 1 — Análise
25
+
26
+ ### 1.1 Entender o requisito
27
+
28
+ Antes de qualquer código, responder:
29
+
30
+ ```
31
+ 1. O componente será reutilizado em mais de um remote/app?
32
+ → Sim → pertence ao design system (packages/design-system/)
33
+ → Não → pertence ao remote (apps/{remote}/src/components/)
34
+
35
+ 2. Existe componente similar já criado?
36
+ → Verificar: ls packages/design-system/src/components/
37
+ → Verificar: ls apps/{remote}/src/components/
38
+
39
+ 3. Existe primitivo Radix UI para este componente?
40
+ → Modal, Select, Dropdown, Tooltip, Checkbox → usar Radix como base
41
+
42
+ 4. Quais variantes são necessárias?
43
+ → Levantar com design antes de implementar
44
+
45
+ 5. Qual o contexto React?
46
+ → Server Component (Next.js App Router) ou Client Component?
47
+ → Se usa hooks/eventos → Client Component ('use client')
48
+ ```
49
+
50
+ ### 1.2 Ler o código ao redor
51
+
52
+ ```bash
53
+ # Verificar padrões em uso no projeto
54
+ ls packages/design-system/src/components/ 2>/dev/null || ls src/components/
55
+
56
+ # Ver como um componente similar está implementado
57
+ cat packages/design-system/src/components/{componente-similar}/
58
+
59
+ # Verificar configuração de tokens
60
+ cat packages/design-system/tailwind.config.ts 2>/dev/null
61
+ ```
62
+
63
+ ---
64
+
65
+ ## Fase 2 — Implementação
66
+
67
+ ### 2.1 Criar arquivos
68
+
69
+ Para componente no **design system**:
70
+ ```
71
+ packages/design-system/src/components/{Nome}/
72
+ ├── {Nome}.tsx
73
+ ├── {Nome}.test.tsx
74
+ ├── {Nome}.stories.tsx
75
+ └── index.ts
76
+ ```
77
+
78
+ Para componente em **remote**:
79
+ ```
80
+ apps/{remote}/src/components/{Nome}/
81
+ ├── {Nome}.tsx
82
+ ├── {Nome}.test.tsx
83
+ └── index.ts
84
+ ```
85
+
86
+ ### 2.2 Checklist de implementação
87
+
88
+ #### TypeScript
89
+ - [ ] Props tipadas — sem `any`
90
+ - [ ] Valores default explícitos para props opcionais
91
+ - [ ] `forwardRef` se o componente tem elemento DOM
92
+ - [ ] Exportar o tipo de props para uso externo
93
+
94
+ #### Tokens (design system)
95
+ - [ ] Cores via tokens semânticos — sem hardcode de hex/rgb
96
+ - [ ] Espaçamentos via escala do design system
97
+ - [ ] Variantes com `cva` se o componente tem múltiplos estados visuais
98
+
99
+ #### Acessibilidade
100
+ - [ ] Semântica HTML correta
101
+ - [ ] `aria-label` ou texto visível em elementos interativos sem texto
102
+ - [ ] Estados de focus visíveis (não remover outline)
103
+ - [ ] Navegação por teclado testada manualmente
104
+
105
+ #### Estados visuais
106
+ - [ ] Normal
107
+ - [ ] Hover
108
+ - [ ] Focus
109
+ - [ ] Disabled (se aplicável)
110
+ - [ ] Loading (se aplicável)
111
+ - [ ] Erro (se aplicável)
112
+ - [ ] Vazio (se aplicável, para listas/tabelas)
113
+
114
+ ---
115
+
116
+ ## Fase 3 — Testes
117
+
118
+ ### 3.1 Testes com Testing Library
119
+
120
+ Focar em comportamento, não implementação:
121
+
122
+ ```typescript
123
+ // ✅ Testar o que o usuário vê e faz
124
+ expect(screen.getByRole('button', { name: 'Salvar' })).toBeDisabled()
125
+
126
+ // ❌ Não testar detalhes de implementação
127
+ expect(component.state.isLoading).toBe(true)
128
+ ```
129
+
130
+ ### Cobertura mínima obrigatória
131
+ - [ ] Renderização padrão (smoke test)
132
+ - [ ] Cada variante principal
133
+ - [ ] Estado de loading (se existir)
134
+ - [ ] Estado de erro (se existir)
135
+ - [ ] Interação principal (`click`, `change`, `submit`)
136
+ - [ ] Acessibilidade via `axe` (se addon configurado)
137
+
138
+ ---
139
+
140
+ ## Fase 4 — Story (apenas para design system)
141
+
142
+ ### 4.1 Checklist de story
143
+
144
+ - [ ] `tags: ['autodocs']`
145
+ - [ ] `argTypes` com controles para cada prop variável
146
+ - [ ] Story para cada variante
147
+ - [ ] Story para estados especiais (loading, disabled, erro)
148
+ - [ ] Story `AllVariants` para overview visual
149
+ - [ ] Sem violations na aba `Accessibility` do Storybook
150
+
151
+ ---
152
+
153
+ ## Fase 5 — Integração
154
+
155
+ ### 5.1 Exportar do ponto de entrada correto
156
+
157
+ **Design system:**
158
+ ```typescript
159
+ // packages/design-system/src/index.ts
160
+ export { {Nome}, type {Nome}Props } from './components/{Nome}'
161
+ ```
162
+
163
+ **Remote:**
164
+ ```typescript
165
+ // apps/{remote}/src/components/index.ts (se existir barrel)
166
+ export { {Nome} } from './{Nome}'
167
+ ```
168
+
169
+ ### 5.2 Verificar responsividade
170
+
171
+ ```bash
172
+ # Testar nos breakpoints do projeto
173
+ # mobile: 375px
174
+ # tablet: 768px
175
+ # desktop: 1280px
176
+ ```
177
+
178
+ ---
179
+
180
+ ## Checklist Final
181
+
182
+ - [ ] Componente no lugar correto (design system vs remote)
183
+ - [ ] Props tipadas sem `any`
184
+ - [ ] Tokens do design system usados (sem hardcode)
185
+ - [ ] Estados visuais completos
186
+ - [ ] Acessibilidade: semântica + teclado + ARIA quando necessário
187
+ - [ ] Testes cobrindo comportamentos críticos
188
+ - [ ] Story criada (se design system)
189
+ - [ ] Exportado do index correto
190
+ - [ ] Responsivo nos breakpoints do projeto
@@ -0,0 +1,375 @@
1
+ ---
2
+ name: eng.frontend-perf-audit
3
+ description: >
4
+ Workflow de auditoria de performance frontend: Core Web Vitals, análise de bundle,
5
+ rendering desnecessário e oportunidades de otimização em React e micro frontends.
6
+ author: jarvis-team
7
+ version: "1.0"
8
+
9
+ ---
10
+
11
+ # Workflow: Auditoria de Performance Frontend
12
+
13
+ ## Contexto
14
+
15
+ Use este workflow para investigar problemas de performance, auditar uma feature antes
16
+ do deploy ou planejar otimizações em uma aplicação React / micro frontend.
17
+
18
+ **Skill de referência**: `eng-frontend`
19
+
20
+ ---
21
+
22
+ ## Fase 1 — Coleta de Dados (antes de otimizar)
23
+
24
+ > Nunca otimizar sem medir primeiro. "Premature optimization is the root of all evil."
25
+
26
+ ### 1.1 Medir Core Web Vitals em produção
27
+
28
+ ```bash
29
+ # Lighthouse CLI — auditar URL de produção ou staging
30
+ npx lighthouse {URL} --output=json --output-path=./lighthouse-report.json --chrome-flags="--headless"
31
+
32
+ # Ver resumo rápido
33
+ npx lighthouse {URL} --output=text --only-categories=performance
34
+ ```
35
+
36
+ **Targets:**
37
+
38
+ | Métrica | Meta | Aceitável | Problema |
39
+ |---------|------|-----------|---------|
40
+ | LCP | < 2.5s | 2.5s–4s | > 4s |
41
+ | CLS | < 0.1 | 0.1–0.25 | > 0.25 |
42
+ | INP | < 200ms | 200ms–500ms | > 500ms |
43
+ | FCP | < 1.8s | 1.8s–3s | > 3s |
44
+ | TTFB | < 800ms | 800ms–1.8s | > 1.8s |
45
+
46
+ ### 1.2 Analisar bundle
47
+
48
+ ```bash
49
+ # Next.js — bundle analyzer
50
+ ANALYZE=true npm run build
51
+ # Gera relatório visual em .next/analyze/
52
+
53
+ # Vite — rollup visualizer
54
+ npx vite-bundle-visualizer
55
+ # Ou instalar: npm i -D rollup-plugin-visualizer
56
+
57
+ # Verificar tamanho das chunks geradas
58
+ ls -lh dist/assets/*.js | sort -k5 -rh | head -20
59
+ ```
60
+
61
+ ### 1.3 Identificar re-renders desnecessários (React DevTools)
62
+
63
+ ```
64
+ React DevTools → Profiler → Gravar → Executar ação → Analisar flame graph
65
+
66
+ Perguntas:
67
+ - Quais componentes renderizaram mais vezes?
68
+ - Qual o motivo do re-render (props, state, context)?
69
+ - Há componentes sem mudança visível re-renderizando em cascata?
70
+ ```
71
+
72
+ ---
73
+
74
+ ## Fase 2 — Diagnóstico por Área
75
+
76
+ ### 2.1 LCP alto (página carrega devagar)
77
+
78
+ **Causas comuns:**
79
+
80
+ ```
81
+ 1. Imagem principal sem priority/preload
82
+ 2. Conteúdo principal renderizado no cliente (CSR puro) — usar SSR/SSG
83
+ 3. Web font blocking render (font-display: swap ausente)
84
+ 4. Server response lento (TTFB alto)
85
+ 5. Render-blocking CSS/JS
86
+ ```
87
+
88
+ **Ações de diagnóstico:**
89
+
90
+ ```bash
91
+ # Verificar se imagem do LCP tem preload
92
+ grep -r "priority\|fetchpriority\|preload" src/ | grep -i "img\|image\|hero"
93
+
94
+ # Verificar se o conteúdo principal é SSR ou CSR
95
+ grep -r "'use client'" src/app/ | head -20
96
+ # Componentes 'use client' no app router não fazem SSR
97
+ ```
98
+
99
+ ### 2.2 CLS alto (layout shift)
100
+
101
+ **Causas comuns:**
102
+
103
+ ```
104
+ 1. Imagens sem width/height definidos
105
+ 2. Fontes causando FOUT (Flash of Unstyled Text)
106
+ 3. Conteúdo dinâmico inserido sem espaço reservado
107
+ 4. Ads ou embeds sem dimensões fixas
108
+ 5. Animações que afetam layout (margin, padding, top, left)
109
+ ```
110
+
111
+ **Ações de diagnóstico:**
112
+
113
+ ```bash
114
+ # Verificar imagens sem dimensões
115
+ grep -rn "<img\|<Image" src/ | grep -v "width\|height" | grep -v "fill"
116
+
117
+ # Verificar uso de layout shifts em CSS
118
+ grep -rn "position: absolute\|transform:" src/ | grep -v ".stories."
119
+ ```
120
+
121
+ ### 2.3 INP alto (interface travando)
122
+
123
+ **Causas comuns:**
124
+
125
+ ```
126
+ 1. Event handlers executando trabalho pesado no main thread
127
+ 2. Sem debounce em inputs de busca/filtro
128
+ 3. Listas longas sem virtualização
129
+ 4. useEffect disparando trabalho pesado após interação
130
+ 5. Third-party scripts bloqueando o main thread
131
+ ```
132
+
133
+ **Ações:**
134
+
135
+ ```bash
136
+ # Verificar inputs sem debounce
137
+ grep -n "onChange" src/ -r | grep -v "debounce\|useTransition\|startTransition"
138
+
139
+ # Verificar listas longas sem virtualização
140
+ grep -rn "\.map(" src/components/ | grep -i "list\|table\|grid" | head -20
141
+ ```
142
+
143
+ ### 2.4 Bundle grande
144
+
145
+ **Ações de diagnóstico:**
146
+
147
+ ```bash
148
+ # Verificar dependências pesadas
149
+ cat package.json | grep -E "moment|lodash|date-fns|antd|material-ui|@mui"
150
+
151
+ # Verificar imports de bibliotecas completas (deve ser tree-shakeable)
152
+ grep -rn "import \* as\|import {.*} from 'lodash'" src/
153
+
154
+ # Verificar chunks geradas
155
+ # Chunk > 500KB merece investigação
156
+ # Chunk > 1MB é problema
157
+ ```
158
+
159
+ ---
160
+
161
+ ## Fase 3 — Otimizações por Categoria
162
+
163
+ ### 3.1 Imagens
164
+
165
+ ```tsx
166
+ // ✅ Next.js — sempre usar next/image
167
+ import Image from 'next/image'
168
+
169
+ <Image
170
+ src="/hero.webp"
171
+ alt="Descrição da imagem"
172
+ width={1200}
173
+ height={600}
174
+ priority // obrigatório para imagem LCP (above the fold)
175
+ sizes="(max-width: 768px) 100vw, 1200px"
176
+ />
177
+
178
+ // ✅ Fill mode para imagens em containers flexíveis
179
+ <div className="relative h-64 w-full">
180
+ <Image src="..." alt="..." fill className="object-cover" />
181
+ </div>
182
+ ```
183
+
184
+ ### 3.2 Code Splitting
185
+
186
+ ```tsx
187
+ // ✅ Lazy loading para componentes pesados ou raramente usados
188
+ import { lazy, Suspense } from 'react'
189
+
190
+ const HeavyChart = lazy(() => import('./HeavyChart'))
191
+ const RichEditor = lazy(() => import('./RichEditor'))
192
+ const AdminPanel = lazy(() => import('./AdminPanel'))
193
+
194
+ // ✅ Suspense com fallback adequado (evita CLS)
195
+ <Suspense fallback={<Skeleton className="h-64 w-full" />}>
196
+ <HeavyChart data={data} />
197
+ </Suspense>
198
+ ```
199
+
200
+ ### 3.3 Renderização (Server vs Client)
201
+
202
+ ```tsx
203
+ // ✅ Dado estático/semi-estático → Server Component
204
+ // Sem 'use client' → renderiza no servidor
205
+ export default async function ProductList() {
206
+ const products = await getProducts() // fetch no servidor
207
+ return <ul>{products.map(p => <ProductCard key={p.id} product={p} />)}</ul>
208
+ }
209
+
210
+ // ✅ Interatividade mínima → isolar o Client Component
211
+ 'use client'
212
+ export function AddToCartButton({ productId }: { productId: string }) {
213
+ const [added, setAdded] = useState(false)
214
+ // apenas este componente é Client — o resto da página é Server
215
+ }
216
+ ```
217
+
218
+ ### 3.4 Memoização (quando justificada)
219
+
220
+ ```tsx
221
+ // ✅ memo: componente re-renderizando sem mudança nas props
222
+ // → confirmar no Profiler que o re-render é desnecessário ANTES de adicionar memo
223
+ const DataTable = memo(function DataTable({ rows }: { rows: Row[] }) {
224
+ // renderização custosa
225
+ })
226
+
227
+ // ✅ useMemo: cálculo pesado que não precisa ser repetido
228
+ const filteredData = useMemo(
229
+ () => data.filter(complexFilter).sort(complexSort),
230
+ [data, complexFilter] // recalcula só quando data ou filtro mudam
231
+ )
232
+
233
+ // ✅ useCallback: handler passado para componente memorizado
234
+ const handleSelect = useCallback((id: string) => {
235
+ setSelected(id)
236
+ }, []) // sem dependências que mudam a cada render
237
+
238
+ // ❌ Evitar memo/useMemo/useCallback sem necessidade comprovada
239
+ // → overhead de comparação pode ser maior que o re-render
240
+ ```
241
+
242
+ ### 3.5 Listas longas (virtualização)
243
+
244
+ ```tsx
245
+ // ✅ Para listas > 100 itens — usar TanStack Virtual
246
+ import { useVirtualizer } from '@tanstack/react-virtual'
247
+
248
+ function LongList({ items }: { items: Item[] }) {
249
+ const parentRef = useRef<HTMLDivElement>(null)
250
+ const virtualizer = useVirtualizer({
251
+ count: items.length,
252
+ getScrollElement: () => parentRef.current,
253
+ estimateSize: () => 60, // altura estimada de cada item
254
+ })
255
+
256
+ return (
257
+ <div ref={parentRef} className="h-96 overflow-auto">
258
+ <div style={{ height: virtualizer.getTotalSize() }} className="relative">
259
+ {virtualizer.getVirtualItems().map((virtualItem) => (
260
+ <div
261
+ key={virtualItem.key}
262
+ style={{
263
+ position: 'absolute',
264
+ top: 0,
265
+ transform: `translateY(${virtualItem.start}px)`,
266
+ width: '100%',
267
+ }}
268
+ >
269
+ <ItemRow item={items[virtualItem.index]} />
270
+ </div>
271
+ ))}
272
+ </div>
273
+ </div>
274
+ )
275
+ }
276
+ ```
277
+
278
+ ### 3.6 Debounce em inputs
279
+
280
+ ```tsx
281
+ // ✅ Busca com debounce — não dispara a cada keystroke
282
+ import { useDeferredValue, useTransition } from 'react'
283
+
284
+ // Opção 1: useDeferredValue (React 18+) — mantém UI responsiva
285
+ function SearchResults({ query }: { query: string }) {
286
+ const deferredQuery = useDeferredValue(query)
287
+ const results = useFilteredResults(deferredQuery) // usa o valor atrasado
288
+ return <ResultList items={results} />
289
+ }
290
+
291
+ // Opção 2: useTransition para marcar update como não urgente
292
+ 'use client'
293
+ function SearchInput() {
294
+ const [query, setQuery] = useState('')
295
+ const [isPending, startTransition] = useTransition()
296
+
297
+ return (
298
+ <input
299
+ onChange={(e) => {
300
+ startTransition(() => setQuery(e.target.value))
301
+ }}
302
+ placeholder={isPending ? 'Buscando...' : 'Buscar...'}
303
+ />
304
+ )
305
+ }
306
+ ```
307
+
308
+ ---
309
+
310
+ ## Fase 4 — Micro Frontend: Performance Específica
311
+
312
+ ### 4.1 Shared dependencies duplicadas
313
+
314
+ ```bash
315
+ # Verificar se React está sendo carregado mais de uma vez
316
+ # No Network DevTools: múltiplos react.js ou react-dom.js = problema
317
+
318
+ # Verificar configuração de singleton
319
+ grep -rn "singleton" apps/*/vite.config.ts apps/shell/vite.config.ts
320
+ # Todas as shared deps críticas devem ter singleton: true
321
+ ```
322
+
323
+ ### 4.2 Carregamento de remotes
324
+
325
+ ```tsx
326
+ // ✅ Remotes carregados com lazy loading e Suspense
327
+ // → apenas o shell + remotes da rota atual carregam
328
+
329
+ // ✅ Prefetch de remotes prováveis (hover na nav)
330
+ const prefetchRemote = () => import('{remote}/App')
331
+
332
+ <nav>
333
+ <Link
334
+ to="/modulo"
335
+ onMouseEnter={prefetchRemote} // prefetch ao hover
336
+ >
337
+ Módulo
338
+ </Link>
339
+ </nav>
340
+ ```
341
+
342
+ ---
343
+
344
+ ## Fase 5 — Relatório de Auditoria
345
+
346
+ ```markdown
347
+ ## Auditoria de Performance Frontend — {app/feature}
348
+ **Data:** {data}
349
+ **URL auditada:** {URL}
350
+
351
+ ### Core Web Vitals (antes)
352
+ | Métrica | Valor | Status |
353
+ |---------|-------|--------|
354
+ | LCP | {x}s | {ok/atenção/problema} |
355
+ | CLS | {x} | {ok/atenção/problema} |
356
+ | INP | {x}ms | {ok/atenção/problema} |
357
+
358
+ ### Problemas identificados
359
+ | # | Problema | Impacto | Esforço | Prioridade |
360
+ |---|----------|---------|---------|------------|
361
+ | 1 | {desc} | {alto/médio/baixo} | {horas} | {P1/P2/P3} |
362
+
363
+ ### Ações recomendadas (ordenadas por impacto/esforço)
364
+ 1. {ação concreta — arquivo específico — ganho esperado}
365
+ 2. ...
366
+
367
+ ### Core Web Vitals (esperado após otimizações)
368
+ | Métrica | Antes | Esperado |
369
+ |---------|-------|---------|
370
+ | LCP | {x}s | {y}s |
371
+
372
+ ### Próximos passos
373
+ - [ ] {ação 1} — responsável: {quem}
374
+ - [ ] {ação 2}
375
+ ```