Refactor

From Vrooli/Vrooli · View interactive version

Refactor is an AI agent skill from the GitHub repository Vrooli/Vrooli. Prioritize **code quality, structure, and maintainability** across this scenario’s implementation.

How to use this skill

Skill file

Steer focus: Refactor & Structural Improvement

Prioritize code quality, structure, and maintainability across this scenario’s implementation.

Do not change the intended behavior, regress tests, or weaken safety guarantees; all changes must maintain or improve completeness.

Focus on producing a cleaner, clearer, easier-to-extend codebase, guided by the following principles:

Required reading:

**1. Preserve Behavior & Intent**

**2. Improve Code Structure & Readability**

**3. Reduce Duplication & Complexity**

**4. Align with Existing Patterns & Architecture**

**5. Strengthen Tests & Safety (Without Gaming Metrics)**

**6. Scope & Change Size**

**7. Memory Management with Tidiness Manager**

To ensure systematic coverage without repetition, use tidiness-manager to get intelligent refactor recommendations combining visited-tracker data with code quality metrics.

At the start of each iteration:

# Get 5 top-priority files (auto-scans if needed)
# Priority score combines: staleness + length + complexity + tech debt + missing tests
tidiness-manager recommend-refactors {{TARGET}} \
  --limit 5 \
  --sort-by priority \
  --min-lines 50

# For scripting (returns just file paths, one per line):
tidiness-manager recommend-refactors {{TARGET}} \
  --limit 5 \
  --format paths

# Alternative sort options for specific improvement targets:
# --sort-by complexity  # For reducing cyclomatic complexity
# --sort-by length      # For breaking down long files
# --sort-by staleness   # For unvisited/stale files (equivalent to visited-tracker)
# --sort-by duplication # For removing code duplication

Output formats:

Output includes enriched data:

After analyzing each file:

# Record your visit with specific notes about improvements and remaining work
tidiness-manager visit <file-path> \
  --scenario {{TARGET}} \
  --note "<summary of refactorings made and what remains>"

When a file is irrelevant to refactoring (config, build scripts, generated files, etc.):

# Mark it excluded so it doesn't resurface - this is NOT a refactor target
tidiness-manager exclude <file-path> \
  --scenario {{TARGET}} \
  --reason "Not a refactor target - config/generated/tooling/etc."

When a file is fully refactored:

# Mark it excluded so it doesn't resurface in future queries
tidiness-manager exclude <file-path> \
  --scenario {{TARGET}} \
  --reason "All refactoring complete - clean structure, clear naming, no duplication"

Before ending your session:

# Add campaign note for handoff context to the next iteration
tidiness-manager campaign-note \
  --scenario {{TARGET}} \
  --note "<overall progress summary, patterns observed, priority areas for next iteration>"

Interpreting the response:

Note format guidelines:

**8. Output Expectations**

You may update:

You must:

Focus this loop on delivering practical, targeted refactors that reduce complexity, remove duplication, and improve clarity, so future loops (and agents) can build on a stronger foundation.


**9. Documentation**

Use knowledge-observatory-tools to read the current problems doc for {{TARGET}}, then update the Tech Debt section with your findings (high-leverage refactoring targets, duplication patterns, refactors completed, remaining structural issues).

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.