Rule of Two Detector
Purpose
Find patterns in git history that indicate documentation opportunities. The Rule of Two: if the team has hit the same friction twice, the third time should be prevented by documentation.
Five signals analyzed:
- Repeated fix patterns (same issue, different files)
- Defensive comments added (IMPORTANT, DON'T, NEVER)
- High-churn files (≥5 changes — confusion zone)
- Terminology inconsistencies (multiple names for same concept)
- Explicit learning words in commits (TIL, gotcha, figured out)
Execution
-
Run git-learning-detector:
${CLAUDE_PLUGIN_ROOT}/git-learning-detector.sh --since=3.months -
Parse output for the five signal types.
-
For each high-priority pattern:
- Verify against code — Read mentioned files; confirm pattern exists today
- Check existing docs — Search the Context Tree for prior coverage (don't duplicate)
- Assess value — Would documenting prevent a third occurrence?
-
Present recommendations one at a time:
HIGH PRIORITY: clientid filtering (5 occurrences) Pattern: 5 defensive comments about multi-tenant filtering Files: app/controllers/*.java (3 controllers) Last: 4 days ago Recommendation: Add to CLAUDE.md Common Pitfalls Draft: ❌ DON'T write queries without clientid filter ✅ DO always include: String clientid = request().host() Security critical: Missing clientid causes tenant data leakage Verified: - ✅ Pattern in 47 controller methods - ✅ 3 recent fixes - ✅ Security-critical Add now? (y/n) -
Apply approved changes:
- Read target file, identify section, Edit to add content
- Commit:
docs: capture [pattern] from git analysis
Distinction from learning-capture
- This skill looks at team-wide patterns over months (repeated mistakes, churn hotspots).
learning-capturelooks at individual learnings over days (recent breakthroughs).- This skill asks "what does the team keep getting wrong?"
learning-captureasks "what did we just figure out?"
Use both for full coverage.
Core Principles
- Verify against code, not docs — patterns may have been refactored away
- Signal-to-noise — only document if it would justify token cost in CLAUDE.md
- Single source of truth — check before adding; reference, don't duplicate
Run when: /maintain-context-tree (option 1), or whenever the user asks for a git pattern analysis or wants to find documentation gaps from history.