@qubiit/lmagent 2.5.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 (155) hide show
  1. package/.editorconfig +18 -0
  2. package/AGENTS.md +169 -0
  3. package/CLAUDE.md +122 -0
  4. package/CONTRIBUTING.md +90 -0
  5. package/LICENSE +21 -0
  6. package/README.md +195 -0
  7. package/config/commands.yaml +194 -0
  8. package/config/levels.yaml +135 -0
  9. package/config/models.yaml +192 -0
  10. package/config/settings.yaml +405 -0
  11. package/config/tools-extended.yaml +534 -0
  12. package/config/tools.yaml +437 -0
  13. package/docs/assets/logo.png +0 -0
  14. package/docs/commands.md +132 -0
  15. package/docs/customization-guide.md +445 -0
  16. package/docs/getting-started.md +154 -0
  17. package/docs/how-to-start.md +242 -0
  18. package/docs/navigation-index.md +227 -0
  19. package/docs/usage-guide.md +113 -0
  20. package/install.js +1044 -0
  21. package/package.json +35 -0
  22. package/pyproject.toml +182 -0
  23. package/rules/_bootstrap.md +138 -0
  24. package/rules/agents-ia.md +607 -0
  25. package/rules/api-design.md +337 -0
  26. package/rules/automations-n8n.md +646 -0
  27. package/rules/code-style.md +570 -0
  28. package/rules/documentation.md +98 -0
  29. package/rules/security.md +316 -0
  30. package/rules/stack.md +395 -0
  31. package/rules/testing.md +326 -0
  32. package/rules/workflow.md +353 -0
  33. package/scripts/create_skill.js +300 -0
  34. package/scripts/validate_skills.js +283 -0
  35. package/skills/ai-agent-engineer/SKILL.md +394 -0
  36. package/skills/ai-agent-engineer/references/agent-patterns.md +149 -0
  37. package/skills/api-designer/SKILL.md +429 -0
  38. package/skills/api-designer/references/api-standards.md +13 -0
  39. package/skills/architect/SKILL.md +285 -0
  40. package/skills/architect/references/c4-model.md +133 -0
  41. package/skills/automation-engineer/SKILL.md +352 -0
  42. package/skills/automation-engineer/references/n8n-patterns.md +127 -0
  43. package/skills/backend-engineer/SKILL.md +261 -0
  44. package/skills/backend-engineer/assets/fastapi-project-structure.yaml +74 -0
  45. package/skills/backend-engineer/references/debugging-guide.md +174 -0
  46. package/skills/backend-engineer/references/design-patterns.md +208 -0
  47. package/skills/backend-engineer/scripts/scaffold_backend.py +313 -0
  48. package/skills/bmad-methodology/SKILL.md +202 -0
  49. package/skills/bmad-methodology/references/scale-adaptive-levels.md +141 -0
  50. package/skills/browser-agent/SKILL.md +502 -0
  51. package/skills/browser-agent/scripts/playwright_setup.ts +16 -0
  52. package/skills/code-reviewer/SKILL.md +306 -0
  53. package/skills/code-reviewer/references/code-review-checklist.md +16 -0
  54. package/skills/data-engineer/SKILL.md +474 -0
  55. package/skills/data-engineer/assets/pg-monitoring-queries.sql +154 -0
  56. package/skills/data-engineer/references/index-strategy.md +128 -0
  57. package/skills/data-engineer/scripts/backup_postgres.py +221 -0
  58. package/skills/devops-engineer/SKILL.md +547 -0
  59. package/skills/devops-engineer/references/ci-cd-patterns.md +265 -0
  60. package/skills/devops-engineer/scripts/docker_healthcheck.py +125 -0
  61. package/skills/document-generator/SKILL.md +746 -0
  62. package/skills/document-generator/references/pdf-generation.md +22 -0
  63. package/skills/frontend-engineer/SKILL.md +532 -0
  64. package/skills/frontend-engineer/references/accessibility-guide.md +146 -0
  65. package/skills/frontend-engineer/scripts/audit_bundle.py +144 -0
  66. package/skills/git-workflow/SKILL.md +374 -0
  67. package/skills/git-workflow/references/git-flow.md +25 -0
  68. package/skills/mcp-builder/SKILL.md +471 -0
  69. package/skills/mcp-builder/references/mcp-server-guide.md +23 -0
  70. package/skills/mobile-engineer/SKILL.md +502 -0
  71. package/skills/mobile-engineer/references/platform-guidelines.md +160 -0
  72. package/skills/orchestrator/SKILL.md +246 -0
  73. package/skills/orchestrator/references/methodology-routing.md +117 -0
  74. package/skills/orchestrator/references/persona-mapping.md +85 -0
  75. package/skills/orchestrator/references/routing-logic.md +110 -0
  76. package/skills/performance-engineer/SKILL.md +549 -0
  77. package/skills/performance-engineer/references/caching-patterns.md +181 -0
  78. package/skills/performance-engineer/scripts/profile_endpoint.py +170 -0
  79. package/skills/product-manager/SKILL.md +488 -0
  80. package/skills/product-manager/references/prioritization-frameworks.md +126 -0
  81. package/skills/prompt-engineer/SKILL.md +433 -0
  82. package/skills/prompt-engineer/references/prompt-patterns.md +158 -0
  83. package/skills/qa-engineer/SKILL.md +441 -0
  84. package/skills/qa-engineer/references/testing-strategy.md +166 -0
  85. package/skills/qa-engineer/scripts/run_coverage.py +147 -0
  86. package/skills/scrum-master/SKILL.md +225 -0
  87. package/skills/scrum-master/references/sprint-ceremonies.md +159 -0
  88. package/skills/security-analyst/SKILL.md +390 -0
  89. package/skills/security-analyst/references/owasp-top10.md +188 -0
  90. package/skills/security-analyst/scripts/audit_security.py +242 -0
  91. package/skills/seo-auditor/SKILL.md +523 -0
  92. package/skills/seo-auditor/references/seo-checklist.md +17 -0
  93. package/skills/spec-driven-dev/SKILL.md +342 -0
  94. package/skills/spec-driven-dev/references/phase-gates.md +107 -0
  95. package/skills/supabase-expert/SKILL.md +602 -0
  96. package/skills/supabase-expert/references/supabase-patterns.md +19 -0
  97. package/skills/swe-agent/SKILL.md +311 -0
  98. package/skills/swe-agent/references/trajectory-format.md +134 -0
  99. package/skills/systematic-debugger/SKILL.md +512 -0
  100. package/skills/systematic-debugger/references/debugging-guide.md +12 -0
  101. package/skills/tech-lead/SKILL.md +409 -0
  102. package/skills/tech-lead/references/code-review-checklist.md +111 -0
  103. package/skills/technical-writer/SKILL.md +631 -0
  104. package/skills/technical-writer/references/doc-templates.md +218 -0
  105. package/skills/testing-strategist/SKILL.md +476 -0
  106. package/skills/testing-strategist/references/testing-pyramid.md +16 -0
  107. package/skills/ux-ui-designer/SKILL.md +419 -0
  108. package/skills/ux-ui-designer/references/design-system-foundation.md +168 -0
  109. package/skills_overview.txt +94 -0
  110. package/templates/PROJECT_KICKOFF.md +284 -0
  111. package/templates/SKILL_TEMPLATE.md +131 -0
  112. package/templates/USAGE.md +95 -0
  113. package/templates/agent-python/README.md +71 -0
  114. package/templates/agent-python/agent.py +272 -0
  115. package/templates/agent-python/config.yaml +76 -0
  116. package/templates/agent-python/prompts/system.md +109 -0
  117. package/templates/agent-python/requirements.txt +7 -0
  118. package/templates/automation-n8n/README.md +14 -0
  119. package/templates/automation-n8n/webhook-handler.json +57 -0
  120. package/templates/backend-node/Dockerfile +12 -0
  121. package/templates/backend-node/README.md +15 -0
  122. package/templates/backend-node/package.json +30 -0
  123. package/templates/backend-node/src/index.ts +19 -0
  124. package/templates/backend-node/src/routes.ts +7 -0
  125. package/templates/backend-node/tsconfig.json +22 -0
  126. package/templates/backend-python/Dockerfile +11 -0
  127. package/templates/backend-python/README.md +78 -0
  128. package/templates/backend-python/app/core/config.py +12 -0
  129. package/templates/backend-python/app/core/database.py +12 -0
  130. package/templates/backend-python/app/main.py +17 -0
  131. package/templates/backend-python/app/routers/__init__.py +1 -0
  132. package/templates/backend-python/app/routers/health.py +7 -0
  133. package/templates/backend-python/requirements-dev.txt +6 -0
  134. package/templates/backend-python/requirements.txt +4 -0
  135. package/templates/backend-python/tests/test_health.py +9 -0
  136. package/templates/checkpoint.yaml +117 -0
  137. package/templates/database/README.md +474 -0
  138. package/templates/frontend-react/README.md +446 -0
  139. package/templates/plan.yaml +320 -0
  140. package/templates/session.yaml +125 -0
  141. package/templates/spec.yaml +229 -0
  142. package/templates/tasks.yaml +330 -0
  143. package/workflows/bugfix-backend.md +380 -0
  144. package/workflows/documentation.md +232 -0
  145. package/workflows/generate-prd.md +320 -0
  146. package/workflows/ideation.md +396 -0
  147. package/workflows/new-agent-ia.md +497 -0
  148. package/workflows/new-automation.md +374 -0
  149. package/workflows/new-feature.md +290 -0
  150. package/workflows/optimize-performance.md +373 -0
  151. package/workflows/resolve-github-issue.md +524 -0
  152. package/workflows/security-review.md +291 -0
  153. package/workflows/spec-driven.md +476 -0
  154. package/workflows/testing-strategy.md +296 -0
  155. package/workflows/third-party-integration.md +277 -0
@@ -0,0 +1,326 @@
1
+ # LMAgent Testing Rules
2
+
3
+ > **Tipo**: `rule` | **Versión**: 2.1 | **Actualización**: 2026-01
4
+
5
+ ## 📌 Quick Reference
6
+
7
+ | Métrica | Mínimo |
8
+ |---------|--------|
9
+ | **Cobertura Total** | >= 80% |
10
+ | **Lógica de Negocio** | >= 90% |
11
+ | **APIs** | >= 85% |
12
+ | **Unit tests** | Cada función pública |
13
+ | **Integration tests** | Cada endpoint |
14
+ | **E2E tests** | Flujos críticos |
15
+
16
+ | Herramienta | Python | TypeScript |
17
+ |-------------|--------|------------|
18
+ | **Runner** | pytest | jest |
19
+ | **Coverage** | pytest-cov | jest --coverage |
20
+ | **Mocking** | respx, unittest.mock | msw, jest.mock |
21
+
22
+ ### 👥 Roles que usan esta regla
23
+ `qa-engineer`, `backend-engineer`, `frontend-engineer`
24
+
25
+ ---
26
+
27
+ Este documento define las reglas y estándares de testing del framework.
28
+
29
+ ## 📊 Objetivos de Cobertura
30
+
31
+ | Tipo de Código | Cobertura Mínima |
32
+ |----------------|------------------|
33
+ | Lógica de negocio | 90% |
34
+ | Endpoints API | 85% |
35
+ | Componentes UI | 75% |
36
+ | Utilidades | 80% |
37
+ | **Total Proyecto** | **80%** |
38
+
39
+ ---
40
+
41
+ ## Estructura de Tests
42
+
43
+ ### Python
44
+
45
+ ```
46
+ tests/
47
+ ├── unit/ # Tests aislados
48
+ │ ├── test_utils.py
49
+ │ └── test_services.py
50
+ ├── integration/ # Tests con DB/APIs
51
+ │ ├── test_users_api.py
52
+ │ └── test_auth_flow.py
53
+ ├── e2e/ # Tests end-to-end
54
+ │ └── test_user_journey.py
55
+ ├── fixtures/ # Test data
56
+ │ └── users.json
57
+ └── conftest.py # Fixtures compartidos
58
+ ```
59
+
60
+ ### TypeScript
61
+
62
+ ```
63
+ src/
64
+ ├── __tests__/ # Unit tests
65
+ │ └── utils.test.ts
66
+ ├── components/
67
+ │ └── Button/
68
+ │ ├── Button.tsx
69
+ │ └── Button.test.tsx # Co-located
70
+ e2e/
71
+ ├── login.spec.ts # Playwright
72
+ └── checkout.spec.ts
73
+ ```
74
+
75
+ ---
76
+
77
+ ## Naming Conventions
78
+
79
+ ### Nombres de Tests
80
+
81
+ ```python
82
+ # Formato: test_{what}_{condition}_{expected}
83
+ def test_calculate_discount_with_percentage_returns_reduced_price():
84
+ def test_create_user_with_duplicate_email_raises_conflict():
85
+ def test_login_with_invalid_password_returns_401():
86
+ ```
87
+
88
+ ### Archivos de Test
89
+
90
+ ```
91
+ # Python
92
+ test_{module}.py
93
+
94
+ # TypeScript
95
+ {Component}.test.tsx
96
+ {module}.test.ts
97
+ ```
98
+
99
+ ---
100
+
101
+ ## Patrones de Testing
102
+
103
+ ### Arrange-Act-Assert (AAA)
104
+
105
+ ```python
106
+ def test_user_creation():
107
+ # Arrange
108
+ user_data = {"email": "test@example.com", "name": "Test"}
109
+
110
+ # Act
111
+ result = create_user(user_data)
112
+
113
+ # Assert
114
+ assert result.email == "test@example.com"
115
+ assert result.id is not None
116
+ ```
117
+
118
+ ### Given-When-Then (BDD)
119
+
120
+ ```python
121
+ def test_discount_application():
122
+ # Given a cart with items totaling $100
123
+ cart = Cart(total=Decimal("100"))
124
+
125
+ # When a 20% discount is applied
126
+ cart.apply_discount(percentage=20)
127
+
128
+ # Then the total should be $80
129
+ assert cart.total == Decimal("80")
130
+ ```
131
+
132
+ ---
133
+
134
+ ## Fixtures y Factories
135
+
136
+ ### pytest Fixtures
137
+
138
+ ```python
139
+ # conftest.py
140
+ @pytest.fixture
141
+ def sample_user() -> User:
142
+ return User(
143
+ id=uuid4(),
144
+ email="test@example.com",
145
+ name="Test User"
146
+ )
147
+
148
+ @pytest.fixture
149
+ async def authenticated_client(client, sample_user):
150
+ token = create_access_token(sample_user)
151
+ client.headers["Authorization"] = f"Bearer {token}"
152
+ return client
153
+ ```
154
+
155
+ ### Factories
156
+
157
+ ```python
158
+ # tests/factories.py
159
+ import factory
160
+ from faker import Faker
161
+
162
+ fake = Faker()
163
+
164
+ class UserFactory(factory.Factory):
165
+ class Meta:
166
+ model = User
167
+
168
+ id = factory.LazyFunction(uuid4)
169
+ email = factory.LazyAttribute(lambda _: fake.email())
170
+ name = factory.LazyAttribute(lambda _: fake.name())
171
+ created_at = factory.LazyFunction(datetime.utcnow)
172
+ ```
173
+
174
+ ---
175
+
176
+ ## Mocking
177
+
178
+ ### Cuándo Mockear
179
+
180
+ - ✅ APIs externas
181
+ - ✅ Servicios de terceros
182
+ - ✅ Operaciones de I/O costosas
183
+ - ✅ Tiempo/fecha
184
+ - ❌ La base de datos en integration tests
185
+ - ❌ Código interno (salvo excepciones)
186
+
187
+ ### Python (unittest.mock)
188
+
189
+ ```python
190
+ from unittest.mock import patch, AsyncMock
191
+
192
+ @patch("app.services.email.send_email")
193
+ async def test_user_registration_sends_email(mock_send):
194
+ mock_send.return_value = AsyncMock()
195
+
196
+ await register_user({"email": "test@example.com"})
197
+
198
+ mock_send.assert_called_once_with(
199
+ to="test@example.com",
200
+ subject="Welcome!"
201
+ )
202
+ ```
203
+
204
+ ### HTTP Mocking (respx)
205
+
206
+ ```python
207
+ import respx
208
+ import httpx
209
+
210
+ @respx.mock
211
+ async def test_external_api_call():
212
+ respx.get("https://api.external.com/data").mock(
213
+ return_value=httpx.Response(200, json={"key": "value"})
214
+ )
215
+
216
+ result = await fetch_external_data()
217
+
218
+ assert result["key"] == "value"
219
+ ```
220
+
221
+ ---
222
+
223
+ ## Testing Async Code
224
+
225
+ ```python
226
+ import pytest
227
+
228
+ @pytest.mark.asyncio
229
+ async def test_async_function():
230
+ result = await async_operation()
231
+ assert result is not None
232
+ ```
233
+
234
+ ---
235
+
236
+ ## Testing Exceptions
237
+
238
+ ```python
239
+ import pytest
240
+
241
+ def test_invalid_input_raises_error():
242
+ with pytest.raises(ValueError, match="must be positive"):
243
+ calculate_price(-10)
244
+
245
+ async def test_not_found_raises_404():
246
+ with pytest.raises(HTTPException) as exc_info:
247
+ await get_user("nonexistent")
248
+
249
+ assert exc_info.value.status_code == 404
250
+ ```
251
+
252
+ ---
253
+
254
+ ## Test Performance
255
+
256
+ ### Markers para Tests Lentos
257
+
258
+ ```python
259
+ @pytest.mark.slow
260
+ def test_large_data_processing():
261
+ # Test que tarda más de 1 segundo
262
+ ...
263
+
264
+ # pytest.ini
265
+ [pytest]
266
+ markers =
267
+ slow: marks tests as slow
268
+ ```
269
+
270
+ ### Ejecutar Excluyendo Lentos
271
+
272
+ ```bash
273
+ pytest -m "not slow"
274
+ ```
275
+
276
+ ---
277
+
278
+ ## CI Integration
279
+
280
+ ```yaml
281
+ # .github/workflows/test.yml
282
+ test:
283
+ runs-on: ubuntu-latest
284
+ steps:
285
+ - uses: actions/checkout@v4
286
+
287
+ - name: Run tests
288
+ run: pytest --cov=app --cov-report=xml
289
+
290
+ - name: Upload coverage
291
+ uses: codecov/codecov-action@v4
292
+ ```
293
+
294
+ ---
295
+
296
+ ## Anti-Patterns a Evitar
297
+
298
+ ```markdown
299
+ ❌ Tests que dependen del orden de ejecución
300
+ ❌ Tests que acceden a estado global
301
+ ❌ Tests que no limpian después de ejecutar
302
+ ❌ Tests demasiado grandes (>30 líneas)
303
+ ❌ Tests sin assertions
304
+ ❌ Mockear todo (tests frágiles)
305
+ ❌ Tests que dependen de la hora real
306
+ ❌ Ignorar tests intermitentes
307
+ ```
308
+
309
+ ---
310
+
311
+ ## Checklist de Testing
312
+
313
+ ```markdown
314
+ ## Antes de Push
315
+ - [ ] Tests unitarios para nueva lógica
316
+ - [ ] Tests de integración para endpoints
317
+ - [ ] Coverage no disminuyó
318
+ - [ ] No hay tests skipped sin razón
319
+ - [ ] Tests locales pasan
320
+
321
+ ## Para Bugs
322
+ - [ ] Test que reproduce el bug (falla primero)
323
+ - [ ] Fix implementado
324
+ - [ ] Test ahora pasa
325
+ - [ ] Otros tests no rompieron
326
+ ```
@@ -0,0 +1,353 @@
1
+ # Flujo de Trabajo - LMAgent
2
+
3
+ > **Tipo**: `rule` | **Versión**: 2.1 | **Actualización**: 2026-01
4
+
5
+ ## 📌 Quick Reference
6
+
7
+ | Paso | Acción |
8
+ |------|--------|
9
+ | 1. **Entender** | Leer AGENTS.md + reglas aplicables |
10
+ | 2. **Clasificar** | Determinar Level (0-4) + skill(s) |
11
+ | 3. **Planear** | (Level 2+) Crear `implementation_plan.md` + pedir aprobación |
12
+ | 4. **Implementar** | Modelos → Repos → Services → Routers → Tests |
13
+ | 5. **Validar** | `pytest` + `ruff check` + `ruff format` |
14
+ | 6. **Documentar** | Actualizar docs si hay cambios de uso |
15
+
16
+ ### Escalado Automático
17
+ - Auth/Security → Mínimo Level 2
18
+ - Migración DB → Mínimo Level 3
19
+ - Breaking change → Mínimo Level 3
20
+
21
+ ### 👥 Roles que usan esta regla
22
+ `orchestrator`, `backend-engineer`, `frontend-engineer`, `qa-engineer`
23
+
24
+ ---
25
+
26
+ Este documento define el flujo de trabajo estándar que los agentes deben seguir dentro de LMAgent.
27
+
28
+ ## Flujo General
29
+
30
+ ```
31
+ ┌─────────────────────────────────────────────────────────────────┐
32
+ │ FLUJO DE TRABAJO LMAGENT │
33
+ └─────────────────────────────────────────────────────────────────┘
34
+
35
+ ┌──────────────────────────────────────────────────────────┐
36
+ │ 1. ENTENDER │
37
+ │ • Leer AGENTS.md y reglas aplicables │
38
+ │ • Entender el contexto y requisitos │
39
+ │ • Identificar sistemas y archivos afectados │
40
+ └────────────────────────┬─────────────────────────────────┘
41
+
42
+
43
+ ┌──────────────────────────────────────────────────────────┐
44
+ │ 2. CLASIFICAR │
45
+ │ • Determinar nivel (0-4) según config/levels.yaml │
46
+ │ • Identificar skill(s) a activar │
47
+ │ • Estimar tiempo y complejidad │
48
+ └────────────────────────┬─────────────────────────────────┘
49
+
50
+ ┌──────────────┴──────────────┐
51
+ │ │
52
+ ▼ ▼
53
+ ┌─────────────────────┐ ┌─────────────────────────────┐
54
+ │ Level 0-1 │ │ Level 2-4 │
55
+ │ • Implementar │ │ • Crear plan/artefactos │
56
+ │ directamente │ │ • Pedir confirmación │
57
+ │ • Sin plan formal │ │ antes de implementar │
58
+ └──────────┬──────────┘ └──────────────┬──────────────┘
59
+ │ │
60
+ │ ▼
61
+ │ ┌─────────────────────────────┐
62
+ │ │ 3. PLANEAR │
63
+ │ │ • Crear implementation_plan│
64
+ │ │ • Listar archivos a tocar │
65
+ │ │ • Definir tests necesarios │
66
+ │ │ • Pedir confirmación │
67
+ │ └──────────────┬──────────────┘
68
+ │ │
69
+ └───────────────┬────────────────┘
70
+
71
+
72
+ ┌──────────────────────────────────────────────────────────┐
73
+ │ 4. IMPLEMENTAR │
74
+ │ • Hacer cambios en pequeños bloques │
75
+ │ • Seguir patrones de código establecidos │
76
+ │ • Commits claros y atómicos │
77
+ └────────────────────────┬─────────────────────────────────┘
78
+
79
+
80
+ ┌──────────────────────────────────────────────────────────┐
81
+ │ 5. VALIDAR │
82
+ │ • Ejecutar tests existentes │
83
+ │ • Agregar tests para código nuevo │
84
+ │ • Verificar linting y formato │
85
+ │ • Probar manualmente si aplica │
86
+ └────────────────────────┬─────────────────────────────────┘
87
+
88
+
89
+ ┌──────────────────────────────────────────────────────────┐
90
+ │ 6. DOCUMENTAR │
91
+ │ • Actualizar README si hay cambios de uso │
92
+ │ • Documentar APIs nuevas │
93
+ │ • Agregar comentarios donde sea necesario │
94
+ │ • Actualizar changelog si aplica │
95
+ └──────────────────────────────────────────────────────────┘
96
+ ```
97
+
98
+ ---
99
+
100
+ ## Paso 1: ENTENDER
101
+
102
+ ### Siempre leer primero:
103
+ 1. **AGENTS.md** - Marco de trabajo general
104
+ 2. **Reglas aplicables** en `rules/`
105
+ 3. **Skill(s) relevante(s)** en `skills/`
106
+
107
+ ### Preguntas clave:
108
+ - ¿Cuál es el objetivo de negocio?
109
+ - ¿Qué sistemas están involucrados?
110
+ - ¿Hay dependencias o restricciones?
111
+ - ¿Existen patrones similares en el código?
112
+
113
+ ### Acciones:
114
+ ```
115
+ 1. Buscar archivos relevantes (grep, find)
116
+ 2. Leer código existente relacionado
117
+ 3. Revisar tests existentes
118
+ 4. Identificar patrones usados
119
+ ```
120
+
121
+ ---
122
+
123
+ ## Paso 2: CLASIFICAR
124
+
125
+ ### Determinar Nivel
126
+
127
+ | Señales | Nivel |
128
+ |---------|-------|
129
+ | Typo, formato, config menor | 0 - Trivial |
130
+ | Bug fix simple, refactor local | 1 - Small |
131
+ | Feature nuevo, integración simple | 2 - Medium |
132
+ | Sistema nuevo, múltiples servicios | 3 - Complex |
133
+ | Migración, seguridad, compliance | 4 - Enterprise |
134
+
135
+ ### Reglas de Escalado Automático
136
+
137
+ Subir nivel si:
138
+ - Afecta archivos de autenticación → mínimo Level 2
139
+ - Es migración de DB → mínimo Level 3
140
+ - Toca seguridad/encriptación → mínimo Level 3
141
+ - Es breaking change → mínimo Level 3
142
+ - Afecta producción → mínimo Level 2
143
+
144
+ ### Identificar Skill(s)
145
+
146
+ ```
147
+ ¿Diseño de sistema? → architect (/arch)
148
+ ¿Implementación backend? → backend-engineer (/dev)
149
+ ¿Frontend/UI? → frontend-engineer (/front)
150
+ ¿Mobile? → mobile-engineer (/mobile)
151
+ ¿Automatización/n8n? → automation-engineer (/auto)
152
+ ¿Agentes de IA? → ai-agent-engineer (/agent)
153
+ ¿Tests? → qa-engineer (/qa)
154
+ ¿Seguridad? → security-analyst (/sec)
155
+ ¿Performance? → performance-engineer (/perf)
156
+ ¿No está claro? → orchestrator (/orch)
157
+ ```
158
+
159
+ ---
160
+
161
+ ## Paso 3: PLANEAR (Level 2+)
162
+
163
+ ### Crear Artefactos según Nivel
164
+
165
+ | Nivel | Artefactos Requeridos |
166
+ |-------|----------------------|
167
+ | 2 | implementation_plan.md |
168
+ | 3 | implementation_plan.md, architecture.md, test_plan.md |
169
+ | 4 | Todos los anteriores + security_review.md, rollback_plan.md |
170
+
171
+ ### Template: implementation_plan.md
172
+
173
+ ```markdown
174
+ # Implementation Plan: [Título]
175
+
176
+ ## Objetivo
177
+ [Descripción del cambio y su propósito]
178
+
179
+ ## Nivel de Complejidad
180
+ Level [X] - [Nombre]
181
+
182
+ ## Archivos a Modificar
183
+ - [ ] `path/to/file1.py` - [Descripción del cambio]
184
+ - [ ] `path/to/file2.py` - [Descripción del cambio]
185
+
186
+ ## Archivos Nuevos
187
+ - [ ] `path/to/new_file.py` - [Propósito]
188
+
189
+ ## Dependencias
190
+ - [Dependencia 1]
191
+ - [Dependencia 2]
192
+
193
+ ## Plan de Implementación
194
+ 1. [Paso 1]
195
+ 2. [Paso 2]
196
+ 3. [Paso 3]
197
+
198
+ ## Tests Necesarios
199
+ - [ ] Test para [funcionalidad 1]
200
+ - [ ] Test para [funcionalidad 2]
201
+
202
+ ## Rollback Plan (si aplica)
203
+ [Cómo revertir si algo sale mal]
204
+
205
+ ## Checklist Pre-implementación
206
+ - [ ] Reglas relevantes leídas
207
+ - [ ] Skill(s) correcto(s) activado(s)
208
+ - [ ] Plan revisado por humano (si Level 3+)
209
+ ```
210
+
211
+ ### Pedir Confirmación
212
+
213
+ Para Level 2+, siempre pedir confirmación antes de implementar:
214
+
215
+ ```
216
+ 📋 Plan de implementación creado.
217
+
218
+ Nivel: [X]
219
+ Archivos afectados: [N]
220
+ Tiempo estimado: [T]
221
+
222
+ ¿Procedo con la implementación? [Sí/No/Ajustar]
223
+ ```
224
+
225
+ ---
226
+
227
+ ## Paso 4: IMPLEMENTAR
228
+
229
+ ### Principios
230
+
231
+ 1. **Cambios pequeños**: Un concepto por commit
232
+ 2. **Seguir patrones**: Usar patrones existentes del proyecto
233
+ 3. **Código limpio**: Type hints, docstrings, sin código muerto
234
+ 4. **Logs apropiados**: Logging estructurado, no prints
235
+
236
+ ### Orden de Implementación
237
+
238
+ ```
239
+ 1. Modelos/Schemas (estructuras de datos)
240
+ 2. Repositories (acceso a datos)
241
+ 3. Services (lógica de negocio)
242
+ 4. Routers (endpoints API)
243
+ 5. Tests
244
+ 6. Documentación
245
+ ```
246
+
247
+ ### Commits
248
+
249
+ Formato: `type(scope): descripción`
250
+
251
+ Tipos:
252
+ - `feat`: Nueva funcionalidad
253
+ - `fix`: Corrección de bug
254
+ - `refactor`: Refactorización
255
+ - `docs`: Documentación
256
+ - `test`: Tests
257
+ - `chore`: Mantenimiento
258
+
259
+ Ejemplos:
260
+ ```
261
+ feat(users): add email verification endpoint
262
+ fix(auth): handle expired tokens correctly
263
+ refactor(services): extract validation logic
264
+ docs(api): update user endpoints documentation
265
+ test(users): add tests for email verification
266
+ ```
267
+
268
+ ---
269
+
270
+ ## Paso 5: VALIDAR
271
+
272
+ ### Checklist de Validación
273
+
274
+ ```bash
275
+ # 1. Tests pasan
276
+ pytest --cov=app --cov-fail-under=80
277
+
278
+ # 2. Linting pasa
279
+ ruff check .
280
+ ruff format --check .
281
+
282
+ # 3. Types check (si usa mypy)
283
+ mypy app/
284
+
285
+ # 4. Build pasa (Docker)
286
+ docker build -t test .
287
+ ```
288
+
289
+ ### Si algo falla
290
+
291
+ 1. **Tests fallan**: Arreglar código o tests según corresponda
292
+ 2. **Linting falla**: Aplicar fixes automáticos (`ruff format .`)
293
+ 3. **Build falla**: Revisar dependencias y Dockerfile
294
+
295
+ ---
296
+
297
+ ## Paso 6: DOCUMENTAR
298
+
299
+ ### Qué documentar
300
+
301
+ | Cambio | Documentación |
302
+ |--------|---------------|
303
+ | Nuevo endpoint | Docstring + OpenAPI schema |
304
+ | Nuevo servicio | README del módulo |
305
+ | Breaking change | CHANGELOG + migrations |
306
+ | Configuración nueva | .env.example + docs |
307
+ | Workflow n8n | Documentación en automations/ |
308
+
309
+ ### Dónde documentar
310
+
311
+ ```
312
+ docs/
313
+ ├── api/ # Documentación de APIs
314
+ ├── architecture/ # Diagramas y ADRs
315
+ ├── deployment/ # Guías de deployment
316
+ └── workflows/ # Documentación de automatizaciones
317
+ ```
318
+
319
+ ---
320
+
321
+ ## Casos Especiales
322
+
323
+ ### Bug de Producción
324
+ 1. Reproducir el bug localmente
325
+ 2. Escribir test que falla
326
+ 3. Implementar fix
327
+ 4. Verificar que test pasa
328
+ 5. Deploy urgente si es crítico
329
+
330
+ ### Refactor Grande
331
+ 1. Crear branch de feature
332
+ 2. Dividir en PRs pequeños
333
+ 3. Mantener backwards compatibility
334
+ 4. Feature flags si es necesario
335
+
336
+ ### Integración con n8n
337
+ 1. Diseñar webhook primero (contract)
338
+ 2. Implementar endpoint
339
+ 3. Documentar para n8n
340
+ 4. Probar con workflow de prueba
341
+
342
+ ---
343
+
344
+ ## Reglas de Oro
345
+
346
+ 1. 📖 **Siempre leer AGENTS.md primero**
347
+ 2. 🎯 **Clasificar correctamente el nivel**
348
+ 3. 📝 **Planear antes de implementar (Level 2+)**
349
+ 4. ✅ **Tests para todo código nuevo**
350
+ 5. 📐 **Seguir patrones existentes**
351
+ 6. 🔄 **Commits pequeños y descriptivos**
352
+ 7. 📚 **Documentar cambios significativos**
353
+ 8. ❓ **Si hay duda, preguntar**