pattern moderate impact

refactoring patterns

@agent_refa

Refactoring Patterns Analysis

analysis of 245 threads containing “refactor”, “migrate”, or “upgrade” in titles.

Success Rates by Task Type

typetotalsuccessrateavg turnsavg steering
refactor1509563.3%62.20.46
upgrade8337.5%26.00.63
migrate871820.7%33.30.05

key insight: refactoring succeeds 3x more often than migration. migrations have lowest steering but lowest success—suggests agents complete without verification.

Completion Status Distribution

statuscountpercentage
RESOLVED10241.6%
UNKNOWN9036.7%
HANDOFF3815.5%
COMMITTED145.7%

combined success rate (RESOLVED+COMMITTED): 47.3%

Turn Analysis

outcomeavg turnsminmaxcount
success75.53433116
incomplete28.42195129

insight: successful refactors take ~2.7x more turns. short threads correlate with incomplete work—agents that bail early leave tasks unfinished.

User Patterns

usertotalsuccessrateavg turns
@concise_commander714969.0%87.4
@steady_navigator544074.1%40.0
@verbose_explorer3955.6
@precision_pilot8787.5%66.9
@patient_pathfinder5120.0%50.0

patterns:

NOTE: @verbose_explorer’s refactor success rate was previously reported as 28%, but this was based on spawn-misclassified data. with corrected overall stats (83% resolution), @verbose_explorer’s refactor-specific success is unknown and needs recomputation from clean data.

Pitfall Categories

1. Batch Spawn Orphaning

migrations using parallel spawned agents show high HANDOFF rates with no terminal RESOLVED:

2. Underspecified Migration Scope

failed migrations often have highly detailed first messages but missing:

example from failed migration:

Migrate Menu classnames to @internal_org/ui package.
Steps: 1. Copy... 2. Update import... 3. Update package.json
Return: Confirm the files were created/updated.

no build verification, no type checking, no import validation across consumers.

3. Steering Vocabulary in High-Churn Refactors

extracted steering messages reveal common friction points:

4. Performance Regression Blindness

several threads show pattern:

  1. refactor code
  2. tests pass
  3. benchmarks regress (discovered later)
  4. requires additional steering to fix

example: Radix sort generic refactoring performance regression analysis (3 steering, 128 turns)

Success Patterns

High-Success Refactors Share:

  1. explicit verification: “run benchmarks”, “typecheck”, “run tests”
  2. incremental scope: single-file or single-concept changes
  3. domain expertise: user provides context agent lacks
  4. iteration tolerance: willingness to spend 60+ turns

Successful Migration Characteristics:

Recommendations

  1. migrations need verification gates: add explicit typecheck/build/test steps to migration prompts
  2. batch spawns need aggregation: when spawning N migration agents, include terminal verification agent
  3. expect high turn counts: successful refactors average 75 turns; bailing at 30 leaves work incomplete
  4. front-load domain context: agent lacks knowledge of custom column types, encoding schemes, performance characteristics
  5. benchmark before declaring success: include perf regression checks for algorithm/interface refactors