Skip to content

Commit ada5e82

Browse files
montfortclaude
andauthored
feat: use devtrail analyze as primary doc trigger with >20 lines fallback (#31)
Replace the static ">20 lines of business logic" heuristic with a two-tier approach: agents now run `devtrail analyze --output json` on changed files and create AILOGs when `summary.above_threshold > 0`. The >20 lines rule is preserved as an explicit fallback when the CLI is unavailable. Updated 18 files across governance (AGENT-RULES, DEVTRAIL.md, AI-GOVERNANCE-POLICY, QUICK-REFERENCE), agent directives (Claude, Gemini, Copilot, Cursor), skills/workflows, and CLI-REFERENCE docs in both EN and ES. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent bb4595d commit ada5e82

18 files changed

Lines changed: 34 additions & 20 deletions

File tree

dist/.agent/workflows/devtrail-new.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ git diff --stat HEAD~1 2>/dev/null || git diff --stat
3232

3333
# Count lines changed
3434
git diff --numstat HEAD~1 2>/dev/null || git diff --numstat
35+
36+
# Check code complexity (primary method for AILOG trigger)
37+
devtrail analyze --output json 2>/dev/null
38+
# If CLI unavailable, fall back to line count heuristic in step 3
3539
```
3640

3741
### 3. Classify and Suggest Type
@@ -40,7 +44,7 @@ Based on the analysis, suggest a document type:
4044

4145
| Pattern | Suggested Type |
4246
|---------|---------------|
43-
| New code in `src/`, `lib/`, `app/` (>20 lines) | AILOG |
47+
| Complex code (`devtrail analyze` `above_threshold > 0`; fallback: >20 lines) | AILOG |
4448
| Multiple implementation alternatives discussed | AIDEC |
4549
| Structural/architectural changes, new modules | ADR |
4650
| Files with `auth`, `user`, `privacy`, `gdpr` | ETH (draft) |

dist/.claude/skills/devtrail-new/SKILL.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
name: devtrail-new
33
description: Create DevTrail documentation. Analyzes context to suggest document type or accepts explicit type parameter. Always confirms before creating.
4-
allowed-tools: Read, Write, Glob, Bash(git diff *, git log *, git status *, date *, wc *)
4+
allowed-tools: Read, Write, Glob, Bash(git diff *, git log *, git status *, date *, wc *, devtrail analyze *)
55
---
66

77
# DevTrail New Skill
@@ -34,6 +34,10 @@ git diff --stat HEAD~1 2>/dev/null || git diff --stat
3434

3535
# Count lines changed
3636
git diff --numstat HEAD~1 2>/dev/null || git diff --numstat
37+
38+
# Check code complexity (primary method for AILOG trigger)
39+
devtrail analyze --output json 2>/dev/null
40+
# If CLI unavailable, fall back to line count heuristic in step 3
3741
```
3842

3943
### 3. Classify and Suggest Type
@@ -42,7 +46,7 @@ Based on the analysis, suggest a document type:
4246

4347
| Pattern | Suggested Type |
4448
|---------|---------------|
45-
| New code in `src/`, `lib/`, `app/` (>20 lines) | AILOG |
49+
| Complex code (`devtrail analyze` `above_threshold > 0`; fallback: >20 lines) | AILOG |
4650
| Multiple implementation alternatives discussed | AIDEC |
4751
| Structural/architectural changes, new modules | ADR |
4852
| Files with `auth`, `user`, `privacy`, `gdpr` | ETH (draft) |

dist/.devtrail/00-governance/AGENT-RULES.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ confidence: high | medium | low
2828
2929
| Situation | Type | Notes |
3030
|-----------|------|-------|
31-
| >20 lines of business logic | AILOG | Use qualitative judgment for borderline cases |
31+
| Code complexity above threshold | AILOG | Run `devtrail analyze <changed-files> --output json`. If `summary.above_threshold > 0`, create AILOG (default threshold: 8). **Fallback**: if CLI unavailable, apply >20 lines of business logic heuristic |
3232
| Decision between 2+ technical alternatives | AIDEC | Document alternatives |
3333
| Changes in auth/authorization/PII | AILOG + ETH | `risk_level: high`, ETH requires approval |
3434
| Changes in public API or DB schema | AILOG | `risk_level: medium+`, consider ADR |
@@ -37,7 +37,6 @@ confidence: high | medium | low
3737
| Addition/removal/upgrade of security-critical dependencies | AILOG | Human review required |
3838
| Changes affecting AI system lifecycle (deployment, retirement) | AILOG + ADR | Human review required |
3939
| Changes to OTel instrumentation (spans, attributes, pipeline) | AILOG | Tag `observabilidad`, see §9 |
40-
| Function with cognitive complexity > threshold | AILOG | Run `devtrail analyze` to identify; default threshold: 8 |
4140

4241
### PROHIBITED - Do not document
4342

dist/.devtrail/00-governance/AI-GOVERNANCE-POLICY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ Per AGENT-RULES.md, documentation is required when:
193193
- Changes affect auth/authorization/PII → AILOG + ETH draft
194194
- Changes in public API or DB schema → AILOG
195195
- Changes in ML models or AI prompts → AILOG + human review
196-
- Business logic changes > 20 lines → AILOG
196+
- Code above cognitive complexity threshold (run `devtrail analyze`; fallback: >20 lines) → AILOG
197197
- Decision between 2+ alternatives → AIDEC
198198
- Security-critical dependency changes → AILOG + human review
199199

dist/.devtrail/00-governance/QUICK-REFERENCE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ language: en # Options: en, es (default: en)
6363
6464
| Situation | Action |
6565
|-----------|--------|
66-
| >20 lines business logic | AILOG |
66+
| Complex code (`devtrail analyze`; fallback: >20 lines) | AILOG |
6767
| Decision between alternatives | AIDEC |
6868
| Auth/authorization/PII changes | AILOG + `risk_level: high` + ETH |
6969
| Public API or DB schema changes | AILOG + consider ADR |

dist/.devtrail/00-governance/i18n/es/AGENT-RULES.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ confidence: high | medium | low
3030
3131
| Situación | Tipo | Notas |
3232
|-----------|------|-------|
33-
| >20 líneas de lógica de negocio | AILOG | Usar juicio cualitativo para casos límite |
33+
| Complejidad de código sobre el umbral | AILOG | Ejecutar `devtrail analyze <archivos-modificados> --output json`. Si `summary.above_threshold > 0`, crear AILOG (umbral por defecto: 8). **Alternativa**: si el CLI no está disponible, usar heurística de >20 líneas de lógica de negocio |
3434
| Decisión entre 2+ alternativas técnicas | AIDEC | Documentar alternativas |
3535
| Cambios en auth/autorización/PII | AILOG + ETH | `risk_level: high`, ETH requiere aprobación |
3636
| Cambios en API pública o esquema de BD | AILOG | `risk_level: medium+`, considerar ADR |
@@ -39,7 +39,6 @@ confidence: high | medium | low
3939
| Adición/eliminación/actualización de dependencias críticas de seguridad | AILOG | Revisión humana requerida |
4040
| Cambios que afectan el ciclo de vida del sistema de IA (despliegue, retirada) | AILOG + ADR | Revisión humana requerida |
4141
| Cambios en instrumentación OTel (spans, atributos, pipeline) | AILOG | Tag `observabilidad`, ver §9 |
42-
| Función con complejidad cognitiva > umbral | AILOG | Ejecutar `devtrail analyze` para identificar; umbral por defecto: 8 |
4342

4443
### PROHIBIDO - No documentar
4544

dist/.devtrail/00-governance/i18n/es/AI-GOVERNANCE-POLICY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ Según AGENT-RULES.md, la documentación es requerida cuando:
193193
- Cambios que afectan auth/autorización/PII → AILOG + borrador ETH
194194
- Cambios en API pública o esquema de BD → AILOG
195195
- Cambios en modelos ML o prompts de IA → AILOG + revisión humana
196-
- Cambios en lógica de negocio > 20 líneas → AILOG
196+
- Código sobre umbral de complejidad cognitiva (ejecutar `devtrail analyze`; alternativa: >20 líneas) → AILOG
197197
- Decisión entre 2+ alternativas → AIDEC
198198
- Cambios en dependencias críticas de seguridad → AILOG + revisión humana
199199

dist/.devtrail/00-governance/i18n/es/QUICK-REFERENCE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ language: en # Opciones: en, es (por defecto: en)
6363
6464
| Situación | Acción |
6565
|-----------|--------|
66-
| >20 líneas lógica de negocio | AILOG |
66+
| Código complejo (`devtrail analyze`; alternativa: >20 líneas) | AILOG |
6767
| Decisión entre alternativas | AIDEC |
6868
| Cambios en auth/autorización/PII | AILOG + `risk_level: high` + ETH |
6969
| Cambios en API pública o esquema de BD | AILOG + considerar ADR |

dist/.devtrail/QUICK-REFERENCE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ Mark `review_required: true` when:
160160

161161
| I just... | Create |
162162
|-----------|--------|
163-
| Implemented >20 lines | AILOG |
163+
| Implemented complex logic | AILOG |
164164
| Chose between options | AIDEC |
165165
| Fixed security issue | AILOG + `risk_level: high` |
166166
| Found tech debt | TDE |

dist/.gemini/skills/devtrail-new/SKILL.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ git diff --stat HEAD~1 2>/dev/null || git diff --stat
3333

3434
# Count lines changed
3535
git diff --numstat HEAD~1 2>/dev/null || git diff --numstat
36+
37+
# Check code complexity (primary method for AILOG trigger)
38+
devtrail analyze --output json 2>/dev/null
39+
# If CLI unavailable, fall back to line count heuristic in step 3
3640
```
3741

3842
### 3. Classify and Suggest Type
@@ -41,7 +45,7 @@ Based on the analysis, suggest a document type:
4145

4246
| Pattern | Suggested Type |
4347
|---------|---------------|
44-
| New code in `src/`, `lib/`, `app/` (>20 lines) | AILOG |
48+
| Complex code (`devtrail analyze` `above_threshold > 0`; fallback: >20 lines) | AILOG |
4549
| Multiple implementation alternatives discussed | AIDEC |
4650
| Structural/architectural changes, new modules | ADR |
4751
| Files with `auth`, `user`, `privacy`, `gdpr` | ETH (draft) |

0 commit comments

Comments
 (0)