Architectural Refactoring — act101 Agent Skill
Execute structural decompositions based on an architectural analysis report. Use when breaking circular dependencies, splitting god classes, reducing coupling between modules, extracting interfaces at seam boundaries, or executing any large-scale structural change identified in an architectural analysis. Requires the architectural-analysis skill to have been run first.
Architectural Refactoring with act
Execute structural decompositions based on an architectural analysis report.
Prerequisites
The architectural-analysis report must exist at docs/architectural-analysis-report.md.
If it doesn't exist, run the architectural-analysis skill first.
Rules
-
Start from the report — Read the analysis report first. Every refactoring decision should trace back to a finding in the report.
-
Find seams, don't invent them — Use
act analyze seamsto identify natural boundaries. Refactor along these boundaries, not against them. -
Evaluate before cutting — Before extracting a module, use
act analyze surface --files <files>to measure the API surface. If the surface is too wide, the extraction will create more coupling, not less. -
Break cycles first — Circular dependencies are the highest priority. Use
act analyze cyclesto find them, then break the simplest edge in each cycle. -
Extract interfaces at seams — At each seam boundary, extract an interface that both sides depend on. Use
act query interface <file>to understand the current API, thenact refactor extract-interfaceto create it. -
Stable foundations first — Start with the most stable modules (lowest instability in
act analyze coupling). Make them independent before touching unstable modules. -
Measure coupling reduction — After each refactoring step, re-run
act analyze couplingandact analyze cyclesto verify that coupling decreased and cycles were broken. -
Use dead code analysis for cleanup — Before and after each major refactoring, run
act analyze dead-codeto identify symbols that are no longer needed. -
Document the architecture — After each major change, update the analysis report by re-running
architectural-analysis. -
Incremental, verifiable steps — Each refactoring step should be small enough to verify independently. Commit after each step. Never make multiple structural changes at once.
Workflow
- Read the analysis report
- Prioritize findings: cycles > god classes > high coupling > dead code
- For each finding:
a. Verify it's still present (
act analyze cycles/act analyze coupling) b. Plan the refactoring (identify seams, measure surface) c. Execute the refactoring usingact refactoroperations d. Verify the fix (re-run analysis, check tests) e. Commit
Delegation
- Use
refactoringskill for individual operations (rename, extract, move) - Use
code-generationskill for scaffolding new modules - Use
code-navigationskill to understand code before modifying it
Token-Saving Hints
- Use
act analyze cycleswith--max-length 3to focus on the tightest cycles first - Use
act analyze coupling --threshold 0.7to focus on the most unstable modules - Use
act query skeletoninstead of reading full files - Re-run only the specific analysis that your change affects, not the full suite