Files
Claude-Code-Workflow/.claude/skills/team-arch-opt/roles/analyzer/role.md
catlog22 29a1fea467 feat: Add templates for epics, product brief, and requirements documentation
- Introduced a comprehensive template for generating epics and stories in Phase 5, including an index and individual epic files.
- Created a product brief template for Phase 2 to summarize product vision, goals, and target users.
- Developed a requirements PRD template for Phase 3, outlining functional and non-functional requirements, along with traceability matrices.

feat: Implement tech debt roles for assessment, execution, planning, scanning, validation, and analysis

- Added roles for tech debt assessment, executor, planner, scanner, validator, and analyst, each with defined phases and processes for managing technical debt.
- Each role includes structured input requirements, processing strategies, and output formats to ensure consistency and clarity in tech debt management.
2026-03-07 13:32:04 +08:00

3.9 KiB

role, prefix, inner_loop, message_types
role prefix inner_loop message_types
analyzer ANALYZE false
state_update

Architecture Analyzer

Analyze codebase architecture to identify structural issues: dependency cycles, coupling/cohesion problems, layering violations, God Classes, code duplication, dead code, and API surface bloat. Produce quantified baseline metrics and a ranked architecture report.

Phase 2: Context & Environment Detection

Input Source Required
Task description From task subject/description Yes
Session path Extracted from task description Yes
.msg/meta.json /wisdom/.msg/meta.json No
  1. Extract session path and target scope from task description
  2. Detect project type by scanning for framework markers:
Signal File Project Type Analysis Focus
package.json + React/Vue/Angular Frontend Component tree, prop drilling, state management, barrel exports
package.json + Express/Fastify/NestJS Backend Node Service layer boundaries, middleware chains, DB access patterns
Cargo.toml / go.mod / pom.xml Native/JVM Backend Module boundaries, trait/interface usage, dependency injection
Mixed framework markers Full-stack / Monorepo Cross-package dependencies, shared types, API contracts
CLI entry / bin/ directory CLI Tool Command structure, plugin architecture, configuration layering
No detection Generic All architecture dimensions
  1. Use explore CLI tool to map module structure, dependency graph, and layer boundaries within target scope
  2. Detect available analysis tools (linters, dependency analyzers, build tools)

Phase 3: Architecture Analysis

Execute analysis based on detected project type:

Dependency analysis:

  • Build import/require graph across modules
  • Detect circular dependencies (direct and transitive cycles)
  • Identify layering violations (e.g., UI importing from data layer, utils importing from domain)
  • Calculate fan-in/fan-out per module (high fan-out = fragile hub, high fan-in = tightly coupled)

Structural analysis:

  • Identify God Classes / God Modules (> 500 LOC, > 10 public methods, too many responsibilities)
  • Calculate coupling metrics (afferent/efferent coupling per module)
  • Calculate cohesion metrics (LCOM -- Lack of Cohesion of Methods)
  • Detect code duplication (repeated logic blocks, copy-paste patterns)
  • Identify missing abstractions (repeated conditionals, switch-on-type patterns)

API surface analysis:

  • Count exported symbols per module (export bloat detection)
  • Identify dead exports (exported but never imported elsewhere)
  • Detect dead code (unreachable functions, unused variables, orphan files)
  • Check for pattern inconsistencies (mixed naming conventions, inconsistent error handling)

All project types:

  • Collect quantified architecture baseline metrics (dependency count, cycle count, coupling scores, LOC distribution)
  • Rank top 3-7 architecture issues by severity (Critical / High / Medium)
  • Record evidence: file paths, line numbers, measured values

Phase 4: Report Generation

  1. Write architecture baseline to <session>/artifacts/architecture-baseline.json:

    • Module count, dependency count, cycle count, average coupling, average cohesion
    • God Class candidates with LOC and method count
    • Dead code file count, dead export count
    • Timestamp and project type details
  2. Write architecture report to <session>/artifacts/architecture-report.md:

    • Ranked list of architecture issues with severity, location (file:line or module), measured impact
    • Issue categories: CYCLE, COUPLING, COHESION, GOD_CLASS, DUPLICATION, LAYER_VIOLATION, DEAD_CODE, API_BLOAT
    • Evidence summary per issue
    • Detected project type and analysis methods used
  3. Update <session>/wisdom/.msg/meta.json under analyzer namespace:

    • Read existing -> merge { "analyzer": { project_type, issue_count, top_issue, scope, categories } } -> write back