workspace-v1/orchestration/checklists/CHECKLIST-PRE-DELEGACION.md
rckrdmrd ff3038f183 feat(orchestration): Add subagent token management system
Sistema completo de gestión de tokens para subagentes NEXUS v4.0:

Nuevas directivas SIMCO:
- SIMCO-SUBAGENTE.md: Protocolo para agentes en modo subagente
- SIMCO-CCA-SUBAGENTE.md: CCA ligero para subagentes (~1,500 tokens)
- SIMCO-CONTROL-TOKENS.md: Gestión de límites de tokens
- SIMCO-DELEGACION-PARALELA.md: Delegación paralela

Perfiles compact (~250 tokens cada uno):
- PERFIL-BACKEND-COMPACT.md
- PERFIL-FRONTEND-COMPACT.md
- PERFIL-DATABASE-COMPACT.md
- PERFIL-DEVOPS-COMPACT.md
- PERFIL-ML-COMPACT.md
- PERFIL-GENERIC-SUBAGENT.md

Templates de delegación escalonados:
- TEMPLATE-DELEGACION-MINIMA.md (~250 tokens)
- TEMPLATE-DELEGACION-ESTANDAR.md (~600 tokens)
- TEMPLATE-DELEGACION-COMPLETA.md (~1,800 tokens)

Nuevos perfiles especializados:
- PERFIL-MCP-ARCHITECT.md
- PERFIL-MCP-DEVELOPER.md
- PERFIL-RAG-ENGINEER.md
- PERFIL-CICD-SPECIALIST.md
- PERFIL-PRODUCTION-MANAGER.md
- PERFIL-MONITORING-AGENT.md
- PERFIL-SECRETS-MANAGER.md
- PERFIL-PROPAGATION-TRACKER.md

Checklists y documentación:
- CHECKLIST-PRE-DELEGACION.md
- Análisis y planes de implementación

Métricas de mejora:
- ~59% reducción de tokens por delegación
- Perfiles compact: 69% más ligeros
- CCA subagente: 85% más ligero

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-07 04:43:01 -06:00

294 lines
7.1 KiB
Markdown

---
version: "1.0.0"
fecha: "2026-01-07"
tipo: checklist
sistema: "SIMCO - NEXUS v4.0"
proposito: "Validar ANTES de delegar cualquier tarea a subagente"
obligatorio: true
aplica_a: "Orquestadores y agentes que delegan"
---
# CHECKLIST: PRE-DELEGACION A SUBAGENTE
## CHECKLIST RAPIDO (5 puntos)
```yaml
ANTES_DE_DELEGAR:
- [ ] 1. Tarea delimitada (max 2 archivos)
- [ ] 2. Template correcto seleccionado
- [ ] 3. Contexto heredado incluido
- [ ] 4. Tokens estimados < 2,500
- [ ] 5. Perfil COMPACT especificado
```
**Si todos pasan:** Delegar
**Si alguno falla:** Revisar o desglosar
---
## 1. VALIDACION DE TAREA
### Checklist
```yaml
TAREA:
- [ ] Descripcion en 1-2 oraciones claras
- [ ] Maximo 2 archivos a crear/modificar
- [ ] Criterios de aceptacion definidos (max 5)
- [ ] SIN dependencias no resueltas
- [ ] Codigo de referencia identificado (file:line)
```
### Alertas Rojas (DESGLOSAR)
```yaml
DESGLOSAR_SI:
- "Crear modulo completo" → Dividir en Entity, Service, Controller
- ">3 archivos" → 1 subtarea por archivo
- "Multiples endpoints" → 1 subtarea por endpoint
- "Con tests" → Tests como subtarea separada
```
---
## 2. SELECCION DE TEMPLATE
### Matriz de Decision
```yaml
TEMPLATE_SEGUN_COMPLEJIDAD:
simple:
condicion: "1 archivo, tarea muy clara"
usar: "TEMPLATE-DELEGACION-MINIMA.md"
tokens: ~250
estandar:
condicion: "1-2 archivos, tarea tipica"
usar: "TEMPLATE-DELEGACION-ESTANDAR.md"
tokens: ~600
compleja:
condicion: ">2 archivos o multiples dependencias"
accion: "DESGLOSAR primero"
usar: "TEMPLATE-DELEGACION-COMPLETA.md (solo si necesario)"
tokens: ~1,800
```
### Ejemplos
| Tarea | Template |
|-------|----------|
| Crear tabla X | MINIMA |
| Crear Entity + DTOs | ESTANDAR |
| Crear modulo completo | DESGLOSAR |
---
## 3. CONTEXTO HEREDADO
### Obligatorio Incluir
```yaml
CONTEXTO_OBLIGATORIO:
- [ ] Variables proyecto resueltas (sin placeholders):
- DB_NAME: "{valor}"
- BACKEND_ROOT: "{valor}"
- etc.
- [ ] Aliases resueltos (rutas completas):
- @DDL: "{ruta}"
- @BACKEND: "{ruta}"
- etc.
- [ ] Estado actual relevante:
- tablas_existentes: [lista]
- entities_existentes: [lista]
- [ ] Codigo de referencia (file:line, no inline completo)
```
### Formato Segun Tokens Disponibles
```yaml
FORMATO_HERENCIA:
si_tokens_disponibles > 15,000:
usar: "Formato Completo"
tokens: ~1,000
incluir: "Variables + Aliases + Estado + Docs + Patrones"
si_tokens_disponibles 8,000-15,000:
usar: "Formato Compactado"
tokens: ~300
incluir: "Variables + Aliases esenciales"
si_tokens_disponibles < 8,000:
usar: "Formato Ultra-compactado"
tokens: ~100
incluir: "Solo tarea + 1 referencia"
```
---
## 4. ESTIMACION DE TOKENS
### Calcular
```yaml
CALCULAR_TOKENS:
template_seleccionado: "{250 | 600 | 1800}"
perfil_compact: "250"
simco_operacion: "800"
contexto_heredado: "{100 | 300 | 1000}"
---
TOTAL_ESTIMADO: "Sumar arriba"
```
### Limites
```yaml
LIMITES:
seguro: "< 2,500 tokens total delegacion"
alerta: "> 2,500 tokens → revisar"
error: "> 3,500 tokens → DESGLOSAR obligatorio"
```
### Estimacion Rapida
```yaml
ESTIMACION_RAPIDA:
1_linea_codigo: "~20 tokens"
1_archivo_pequeno: "~300 tokens"
1_archivo_mediano: "~800 tokens"
perfil_compact: "~250 tokens"
simco: "~800 tokens"
```
---
## 5. PERFIL DE SUBAGENTE
### Especificar
```yaml
ESPECIFICAR:
- [ ] Perfil: "PERFIL-{TIPO}-COMPACT.md"
- [ ] Ruta: "orchestration/agents/perfiles/compact/"
```
### Perfiles Disponibles
| Perfil | Dominio |
|--------|---------|
| PERFIL-BACKEND-COMPACT.md | NestJS/TypeScript |
| PERFIL-FRONTEND-COMPACT.md | React/TypeScript |
| PERFIL-DATABASE-COMPACT.md | PostgreSQL DDL |
| PERFIL-DEVOPS-COMPACT.md | Docker/CI/CD |
| PERFIL-ML-COMPACT.md | Python/ML |
| PERFIL-GENERIC-SUBAGENT.md | Cualquier tarea |
### NUNCA USAR
```yaml
NUNCA_PARA_SUBAGENTES:
- Perfil completo (PERFIL-*.md sin COMPACT)
- Perfil no existente
```
---
## 6. RESUMEN VISUAL
```
+---------------------------------------------------------------+
| ANTES DE DELEGAR |
+---------------------------------------------------------------+
| |
| 1. TAREA 2. TEMPLATE |
| +--------------------+ +--------------------+ |
| | [ ] 1-2 oraciones | | [ ] MINIMA (250) | |
| | [ ] Max 2 archivos | | [ ] ESTANDAR (600) | |
| | [ ] 5 criterios | | [ ] COMPLETA (1800)| |
| +--------------------+ +--------------------+ |
| |
| 3. CONTEXTO 4. TOKENS |
| +--------------------+ +--------------------+ |
| | [ ] Variables OK | | Template: ___ | |
| | [ ] Aliases OK | | Perfil: 250 | |
| | [ ] Estado actual | | SIMCO: 800 | |
| | [ ] Refs file:line | | Contexto: ___ | |
| +--------------------+ | TOTAL: < 2,500 | |
| +--------------------+ |
| 5. PERFIL |
| +--------------------+ |
| | [ ] *-COMPACT.md | RESULTADO: |
| +--------------------+ [ ] LISTO PARA DELEGAR |
| [ ] REVISAR O DESGLOSAR |
+---------------------------------------------------------------+
```
---
## 7. FLUJO DE DECISION
```
TAREA RECIBIDA
|
v
+---------------+
| >2 archivos? |--SI--> DESGLOSAR
+---------------+
|NO
v
+---------------+
| Template |
| seleccionado? |--NO--> SELECCIONAR (ver seccion 2)
+---------------+
|SI
v
+---------------+
| Contexto |
| completo? |--NO--> AGREGAR (ver seccion 3)
+---------------+
|SI
v
+---------------+
| Tokens |
| < 2,500? |--NO--> REDUCIR O DESGLOSAR
+---------------+
|SI
v
+---------------+
| Perfil |
| COMPACT? |--NO--> ESPECIFICAR (ver seccion 5)
+---------------+
|SI
v
DELEGAR
```
---
## 8. ERRORES COMUNES
| Error | Causa | Solucion |
|-------|-------|----------|
| Subagente no entiende tarea | Contexto incompleto | Agregar variables y aliases |
| Archivos en ubicacion incorrecta | Rutas no especificadas | Usar rutas absolutas resueltas |
| Tokens excedidos | Template muy grande | Usar MINIMA o ESTANDAR |
| Subagente carga CCA completo | No se especifico COMPACT | Indicar PERFIL-*-COMPACT.md |
---
## 9. REFERENCIAS
| Documento | Uso |
|-----------|-----|
| `SIMCO-SUBAGENTE.md` | Protocolo de subagente |
| `SIMCO-CONTROL-TOKENS.md` | Limites de tokens |
| `templates/TEMPLATE-DELEGACION-*.md` | Templates por complejidad |
| `agents/perfiles/compact/` | Perfiles compactos |
---
**Version:** 1.0.0 | **Sistema:** SIMCO-NEXUS v4.0 | **Tipo:** Checklist Obligatorio