Loading...
Loading...
Audits architectural patterns against best practices (MCP Ref, Context7, WebSearch). Maintains patterns catalog, calculates 4 scores, creates refactor Stories via ln-220. Use when user asks to: (1) Check architecture health, (2) Audit patterns before refactoring, (3) Find undocumented patterns in codebase.
npx skill4agent add levnikolaevich/claude-code-skills ln-640-pattern-evolution-auditordocs/project/patterns_catalog.md| Score | What it measures | Threshold |
|---|---|---|
| Compliance | Industry standards, ADR/Guide, naming, layer boundaries | 70% |
| Completeness | All components, error handling, tests, docs | 70% |
| Quality | Readability, maintainability, no smells, SOLID, no duplication | 70% |
| Implementation | Code exists, production use, integrated, monitored | 70% |
CRITICAL: All delegations use Task tool withfor context isolation.subagent_type: "general-purpose"
| Worker | Purpose | Phase |
|---|---|---|
| ln-641-pattern-analyzer | Calculate 4 scores per pattern | Phase 4 |
| ln-642-layer-boundary-auditor | Detect layer violations | Phase 3 |
| ln-643-api-contract-auditor | Audit API contracts, DTOs, layer leakage | Phase 4 |
| ln-220-story-coordinator | Create refactor Stories | Phase 6 |
Task(description: "[Audit/Create] via ln-6XX",
prompt: "Execute {skill-name}. Read skill from {skill-name}/SKILL.md. Pattern: {pattern}",
subagent_type: "general-purpose")1. Load docs/project/patterns_catalog.md
IF missing → create from shared/templates/patterns_template.md
2. Load docs/reference/adrs/*.md → link patterns to ADRs
Load docs/reference/guides/*.md → link patterns to Guides
3. Auto-detect undocumented patterns
Use patterns from common_patterns.md "Pattern Detection" table
IF found but not in catalog → add as "Undocumented"FOR EACH pattern WHERE last_audit > 30 days OR never:
# MCP Ref + Context7 + WebSearch
ref_search_documentation("{pattern} best practices {tech_stack}")
IF pattern.library: query-docs(library_id, "{pattern}")
WebSearch("{pattern} implementation best practices 2026")
→ Store: contextStore.bestPractices[pattern]Task(ln-642-layer-boundary-auditor)
Input: architecture_path, codebase_root, skip_violations
Output: violations[], coverage{}
# Apply deductions to affected patterns (per scoring_rules.md)
FOR EACH violation IN violations:
affected_pattern = match_violation_to_pattern(violation)
affected_pattern.issues.append(violation)
affected_pattern.compliance_deduction += get_deduction(violation)# Analyze individual patterns
FOR EACH pattern IN catalog:
Task(ln-641-pattern-analyzer)
Input: pattern, locations, adr_reference, bestPractices
Output: scores{}, issues[], gaps{}
# Analyze API contracts (always, in parallel with patterns)
Task(ln-643-api-contract-auditor)
Input: pattern="API Contracts", locations=[service_dirs, api_dirs], bestPractices
Output: scores{}, issues[], gaps{}
**Worker Output Contract:**
- ln-641 returns: `{overall_score: X.X, scores: {compliance, completeness, quality, implementation}, issues: [], gaps: {}}`
- ln-642 returns: `{category, score, total_issues, critical, high, medium, low, findings: []}`
- ln-643 returns: `{overall_score: X.X, scores: {compliance, completeness, quality, implementation}, issues: [], gaps: {}}`
# Merge layer violations from Phase 3
pattern.issues += layer_violations.filter(v => v.pattern == pattern)
pattern.scores.compliance -= compliance_deduction
pattern.scores.quality -= quality_deductiongaps = {
undocumentedPatterns: found in code but not in catalog,
implementationGaps: ADR decisions not implemented,
layerViolations: code in wrong architectural layers,
consistencyIssues: conflicting patterns
}Stories MUST include: "Zero Legacy / Zero Backward Compatibility" — no compatibility hacks, clean architecture is priority.
refactorItems = patterns WHERE any_score < 70%
IF refactorItems.length > 0:
# Auto-detect Epic (Architecture/Refactoring/Technical Debt)
targetEpic = find_epic(["Architecture", "Refactoring", "Technical Debt"])
IF not found → AskUserQuestion
FOR EACH pattern IN refactorItems:
Task(ln-220-story-coordinator)
Create Story with AC from issues list
MANDATORY AC: Zero Legacy principle# Step 1: Get all worker scores (0-10 scale)
pattern_scores = [p.overall_score for p in ln641_results] # Each 0-10
layer_score = ln642_result.score # 0-10
api_score = ln643_result.overall_score # 0-10
# Step 2: Calculate architecture_health_score
all_scores = pattern_scores + [layer_score, api_score]
architecture_health_score = round(average(all_scores) * 10) # 0-100 scale
# Status mapping:
# >= 80: "healthy"
# 70-79: "warning"
# < 70: "critical"1. Update patterns_catalog.md:
- Pattern scores, dates, Story links
- Layer Boundary Status section
- Quick Wins section
- Patterns Requiring Attention section
2. Calculate trend: compare current vs previous scores
3. Output summary (see Return Result below){
"audit_date": "2026-02-04",
"architecture_health_score": 78,
"trend": "improving",
"patterns_analyzed": 5,
"layer_audit": {
"architecture_type": "Layered",
"violations_total": 5,
"violations_by_severity": {"high": 2, "medium": 3, "low": 0},
"coverage": {"http_abstraction": 85, "error_centralization": true}
},
"patterns": [
{
"name": "Job Processing",
"scores": {"compliance": 72, "completeness": 85, "quality": 68, "implementation": 90},
"avg_score": 79,
"status": "warning",
"issues_count": 3,
"story_created": "LIN-123"
}
],
"quick_wins": [
{"pattern": "Caching", "issue": "Add TTL config", "effort": "2h", "impact": "+10 completeness"}
],
"requires_attention": [
{"pattern": "Event-Driven", "avg_score": 58, "critical_issues": ["No DLQ", "No schema versioning"]}
],
"stories_created": ["LIN-123", "LIN-124"]
}shared/references/task_delegation_pattern.mdshared/templates/patterns_template.mdreferences/common_patterns.mdreferences/scoring_rules.md../ln-641-pattern-analyzer/SKILL.md../ln-642-layer-boundary-auditor/SKILL.md../ln-643-api-contract-auditor/SKILL.md../ln-220-story-coordinator/SKILL.md