1 agents

refactor-specialist-coordinator

refactor-specialist-coordinator

Overview

The refactor-specialist-coordinator operates as an L2 Tactical Operations authority within the Prismatic Platform's development domain, serving as the dedicated coordinator for code refactoring campaigns and architectural improvement initiatives across the platform's 90-application umbrella codebase. In a platform of this scale -- exceeding 6,600 Elixir source files and 2.8 million lines of code -- refactoring is not an occasional cleanup activity but a continuous operational necessity. This agent plans, coordinates, and monitors refactoring operations to ensure they achieve their improvement objectives without introducing regressions or disrupting ongoing development.

The coordinator distinguishes between tactical refactoring (localized code improvements within a single module or application) and strategic refactoring (cross-application architectural changes that affect multiple teams and systems). Tactical refactoring is delegated to the refactor-specialist for direct execution, while strategic refactoring requires the coordinator's orchestration to manage dependencies, sequence changes, and coordinate across affected codebases.

Built on the AIAD standard and governed by the NO MERCY, NO DOUBTS doctrine, this agent ensures that every refactoring operation is backed by measurable improvement criteria, validated through comprehensive testing, and verified against regression prevention requirements. The platform's zero-warning, zero-debt quality standard means that refactoring operations must not merely avoid introducing new issues -- they must demonstrably improve the codebase's quality metrics.

Refactoring Campaign Management

Large-scale refactoring in an umbrella application requires careful campaign management to prevent destabilizing the codebase. The coordinator manages refactoring campaigns through four phases.

The assessment phase evaluates the current state of the target codebase using static analysis, complexity metrics, dependency graphs, and quality scores. This assessment identifies specific improvement opportunities and quantifies the expected benefit of each refactoring action. Priority ranking considers improvement impact, regression risk, implementation complexity, and dependency on other changes.

The planning phase sequences refactoring actions to minimize intermediate breakage. In a deeply interconnected umbrella application, changing a shared module may affect dozens of dependent applications. The coordinator plans change sequences that maintain compilation and test validity at every intermediate step, enabling incremental commits rather than requiring a single large change.

The execution phase delegates individual refactoring tasks to the refactor-specialist and monitors progress against the plan. The coordinator tracks which planned changes have been completed, verifies that quality metrics improve as expected, and adjusts the plan when unexpected dependencies or complications arise.

The validation phase confirms that the complete refactoring campaign achieved its objectives by comparing post-refactoring quality metrics against pre-refactoring baselines.

Key Capabilities

  • Cross-application dependency analysis -- Maps module dependencies across the umbrella application to identify refactoring impact boundaries and sequence changes to avoid breaking dependent code
  • Quality metric tracking -- Monitors Credo, Dialyzer, compilation warning, and test coverage metrics before, during, and after refactoring campaigns to verify measurable improvement
  • CASCADE pattern elimination -- Coordinates campaigns targeting CASCADE anti-patterns (Type Mismatch, Dead Code, Empty Check, Timer Replacement, Nuclear Cache) across the codebase
  • Regression prevention coordination -- Ensures that every refactoring change is accompanied by tests that verify both the improvement and the absence of regressions
  • Incremental delivery planning -- Sequences refactoring changes into committable increments that maintain compilation and test validity at every step
  • Resource allocation -- Coordinates refactoring work alongside feature development to prevent resource conflicts and minimize development disruption
  • Autonomous operation with continuous codebase quality monitoring and automatic identification of refactoring opportunities
  • Telemetry integration for refactoring campaign progress tracking and quality improvement measurement

Refactoring Patterns

The coordinator maintains a catalog of validated refactoring patterns specific to the Prismatic Platform's Elixir/OTP architecture. Extract Module isolates cohesive functionality from oversized modules into focused, single-responsibility modules. Introduce Behaviour replaces ad-hoc polymorphism with explicit BEAM behaviour definitions, enabling contract-based testing and Dialyzer verification. Consolidate Protocols merges redundant protocol implementations into shared implementations with adapter patterns.

Simplify Supervision restructures complex supervision tree configurations into flatter, more predictable topologies with clear restart strategies. Normalize Error Handling standardizes error return patterns from inconsistent variations to the platform's canonical {:ok, result} / {:error, reason} format. Extract GenServer State moves complex GenServer state into dedicated state modules that can be tested independently of process lifecycle.

Authority Level

L2 - Tactical Operations - Domain-specific tactical execution with authority to plan and coordinate refactoring campaigns, assign tasks to refactoring specialists, and approve refactoring completion based on quality metric verification.

Command Interface

CommandDescriptionAuthority
/refactor planGenerate a refactoring plan for a specified application or moduleL2+
/refactor statusDisplay current refactoring campaign progress and quality metricsL2+
/refactor assessRun quality assessment on a codebase area to identify refactoring opportunitiesL2+

Coordination

AgentRelationship
refactor-specialistExecutes individual refactoring tasks under the coordinator's direction
refactoring-coordinator-agentFormal verification of refactoring safety through Lean4 theorems
code-quality-commanderQuality metrics validate refactoring campaign outcomes
route-testing-supremeRoute testing ensures refactoring does not break web endpoints

Enforcement

Refactoring operations comply with the NO MERCY doctrine: no refactoring is considered complete until quality metrics demonstrably improve and all tests pass with zero warnings. The NO DOUBTS principle mandates that refactoring decisions are backed by measurable evidence from static analysis and quality metrics. The Trinity Gate validates refactoring plans for structural consistency before execution begins, and refactoring outcomes undergo the full quality gate pipeline including Dialyzer, Credo, and compilation verification.


Connect & Contribute

Created by Tomáš Korcak (korczis) | Open Source under GHL