Catalog
affaan-m/orch-refine-code

affaan-m

orch-refine-code

Orchestrate a behavior-preserving refactor — confirm tests are green, restructure without changing behavior, keep tests green, review, and gated commit. Use when the structure should improve but behavior must not change.

global
New~430
v1.0Saved Jun 7, 2026

orch-refine-code

Actor · action · target: orch · refine · code. Thin wrapper over the shared engine in orch-pipeline.

When to Use

  • Same behavior, better structure: extract modules, remove duplication, kill dead code, reduce nesting, rename for clarity.
  • Distinguish from siblings: if behavior is meant to change at all, this is the wrong skill (orch-change-feature / orch-fix-defect).

Operation settings

  • Default size floor: standard — restructures touch multiple files.
  • Phase mask: 0 → 2 (plan the restructure) → 4 (keep green) → 5 → 6. No new behavior tests are written — the existing suite is the safety net.
  • First move (phase 4): confirm the relevant tests exist and are green before touching code; if coverage is thin, add characterization tests first. Then restructure in small steps, re-running tests after each.

How It Works

  1. Run the orch-pipeline engine with the settings above.
  2. For dead-code / duplication sweeps, delegate to the refactor-cleaner agent (it runs knip / depcheck / ts-prune and removes safely).
  3. Stop at Gate 1 (restructure plan) and Gate 2 (pre-commit).
  4. Commit as refactor: — the diff must be behavior-neutral.

Example

orch-refine-code: extract the NWS HTTP client out of poller.py
→ confirm tests green → plan extraction  [GATE 1: approve]
→ move in small steps, tests green throughout → code-review
→ commit refactor:  [GATE 2: confirm]
Files1
1 files · 1.0 KB

Select a file to preview

Overall Score

77/100

Grade

B

Good

Safety

82

Quality

72

Clarity

80

Completeness

68

Summary

This skill orchestrates behavior-preserving code refactoring by confirming tests pass, restructuring code without changing behavior, re-running tests, reviewing, and gating commits with a "refactor:" prefix. It delegates to a shared `orch-pipeline` engine and optionally invokes `refactor-cleaner` for dead code removal.

Detected Capabilities

test executioncode analysisfile restructuringgit commitdelegation to external agent (orch-pipeline, refactor-cleaner)

Trigger Keywords

Phrases that MCP clients use to match this skill to user intent.

extract modulesremove dead codereduce duplicationrefactor structureimprove code clarityrename for readabilityconsolidate functions

Use Cases

  • Extract modules while keeping tests green
  • Remove dead code and duplication safely
  • Reduce code nesting and improve structure
  • Rename variables/functions for clarity without behavior changes
  • Refactor monolithic files into smaller, well-scoped components

Quality Notes

  • Skill is appropriately scoped to behavior-preserving refactoring and explicitly distinguishes itself from feature/defect work
  • Phase mask and gate structure (phases 0→2→4→5→6, gates at plan and pre-commit) provide clear checkpoints and human oversight
  • Emphasis on confirming tests are green before and after changes is a strong safety pattern for refactoring
  • Example provided is concrete and illustrative (NWS HTTP client extraction)
  • Relies on external skills (orch-pipeline, refactor-cleaner) and assumes their availability and correct behavior — dependencies are documented but not detailed
  • No explicit guidance on what constitutes 'thin coverage' or when to add characterization tests, though the intent is clear
  • Missing concrete guidance on 'small steps' — no explicit size thresholds or examples of incremental restructuring
  • No coverage of edge cases: what if tests are flaky? What if a refactor breaks subtle behavior assumptions?
Model: claude-haiku-4-5-20251001Analyzed: Jun 7, 2026

Reviews

Add this skill to your library to leave a review.

No reviews yet

Be the first to share your experience.

Add affaan-m/orch-refine-code to your library

Command Palette

Search for a command to run...

affaan-m/orch-refine-code | SkillRepo