Files
Claude-Code-Workflow/.claude/skills/team-arch-opt/roles/designer/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

4.6 KiB

role, prefix, inner_loop, message_types
role prefix inner_loop message_types
designer DESIGN false
state_update

Refactoring Designer

Analyze architecture reports and baseline metrics to design a prioritized refactoring plan with concrete strategies, expected structural improvements, and risk assessments.

Phase 2: Analysis Loading

Input Source Required
Architecture report /artifacts/architecture-report.md Yes
Architecture baseline /artifacts/architecture-baseline.json Yes
.msg/meta.json /wisdom/.msg/meta.json Yes
Wisdom files /wisdom/patterns.md No
  1. Extract session path from task description
  2. Read architecture report -- extract ranked issue list with severities and categories
  3. Read architecture baseline -- extract current structural metrics
  4. Load .msg/meta.json for analyzer findings (project_type, scope)
  5. Assess overall refactoring complexity:
Issue Count Severity Mix Complexity
1-2 All Medium Low
2-3 Mix of High/Medium Medium
3+ or any Critical Any Critical present High

Phase 3: Strategy Formulation

For each architecture issue, select refactoring approach by type:

Issue Type Strategies Risk Level
Circular dependency Interface extraction, dependency inversion, mediator pattern High
God Class/Module SRP decomposition, extract class/module, delegate pattern High
Layering violation Move to correct layer, introduce Facade, add anti-corruption layer Medium
Code duplication Extract shared utility/base class, template method pattern Low
High coupling Introduce interface/abstraction, dependency injection, event-driven Medium
API bloat / dead exports Privatize internals, re-export only public API, barrel file cleanup Low
Dead code Safe removal with reference verification Low
Missing abstraction Extract interface/type, introduce strategy/factory pattern Medium

Prioritize refactorings by impact/effort ratio:

Priority Criteria
P0 (Critical) High impact + Low effort -- quick wins (dead code removal, simple moves)
P1 (High) High impact + Medium effort (cycle breaking, layer fixes)
P2 (Medium) Medium impact + Low effort (duplication extraction)
P3 (Low) Low impact or High effort -- defer (large God Class decomposition)

If complexity is High, invoke discuss CLI tool (DISCUSS-REFACTOR round) to evaluate trade-offs between competing strategies before finalizing the plan.

Define measurable success criteria per refactoring (target metric improvement or structural change).

Phase 4: Plan Output

  1. Write refactoring plan to <session>/artifacts/refactoring-plan.md:

    Each refactoring MUST have a unique REFACTOR-ID and self-contained detail block:

    ### REFACTOR-001: <title>
    - Priority: P0
    - Target issue: <issue from report>
    - Issue type: <CYCLE|COUPLING|GOD_CLASS|DUPLICATION|LAYER_VIOLATION|DEAD_CODE|API_BLOAT>
    - Target files: <file-list>
    - Strategy: <selected approach>
    - Expected improvement: <metric> by <description>
    - Risk level: <Low/Medium/High>
    - Success criteria: <specific structural change to verify>
    - Implementation guidance:
      1. <step 1>
      2. <step 2>
      3. <step 3>
    
    ### REFACTOR-002: <title>
    ...
    

    Requirements:

    • Each REFACTOR-ID is sequentially numbered (REFACTOR-001, REFACTOR-002, ...)
    • Each refactoring must be non-overlapping in target files (no two REFACTOR-IDs modify the same file unless explicitly noted with conflict resolution)
    • Implementation guidance must be self-contained -- a branch refactorer should be able to work from a single REFACTOR block without reading others
  2. Update <session>/wisdom/.msg/meta.json under designer namespace:

    • Read existing -> merge -> write back:
    {
      "designer": {
        "complexity": "<Low|Medium|High>",
        "refactoring_count": 4,
        "priorities": ["P0", "P0", "P1", "P2"],
        "discuss_used": false,
        "refactorings": [
          {
            "id": "REFACTOR-001",
            "title": "<title>",
            "issue_type": "<CYCLE|COUPLING|...>",
            "priority": "P0",
            "target_files": ["src/a.ts", "src/b.ts"],
            "expected_improvement": "<metric> by <description>",
            "success_criteria": "<threshold>"
          }
        ]
      }
    }
    
  3. If DISCUSS-REFACTOR was triggered, record discussion summary in <session>/discussions/DISCUSS-REFACTOR.md