Skip to main content
Agent skill

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.

Get started

Get the complete skill folder, including its scripts and reference files.

When to use this skill

Use Orch Refine Code when an AI agent needs a reusable SKILL.md workflow for this job: 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.

When not to use it

Skip Orch Refine Code when the task is outside the coding category, or when a more specific skill in this directory already covers the same workflow with clearer triggers.

How to install

Where will you use it?

Install scope
Claude Code folder setup
mkdir -p ~/.claude/skills/orch-refine-code
# Save SKILL.md to ~/.claude/skills/orch-refine-code/SKILL.md
  1. Claude Code personal install: place the skill and its bundled files at ~/.claude/skills/orch-refine-code/SKILL.md. For a shared project, commit the folder at .claude/skills/orch-refine-code/ instead.
  2. Current Claude Code detects SKILL.md changes in watched directories during the session. If you just created a top-level skills directory, run /reload-skills. Check that the skill is listed before testing its trigger.
  3. For Claude chat or Cowork in the Desktop app, manage uploaded skills in Customize > Skills; copying files into a local Claude Code folder is not a Desktop install. Other agents may use different install locations.

Full install guide for Claude, Cursor, and Codex →

Try a starter prompt

After installing the skill, paste this starter prompt into your agent to verify it triggers on a small task.

Starter prompt
Use the Orch Refine Code skill for this task: Same behavior, better structure: extract modules, remove duplication, kill. Confirm any required inputs or files before making changes.

What supports this recommendation?

67/100 provisional content score. This measures documentation, practical detail and source signals. It is not a measured task success rate or a security certification.

Documentation
72/100
Practical detail
62/100
Source evidence
63/100
Source signals
72/100
Model compatibility evidence
  • claudeuntested

    No model-specific signal or recorded compatibility test was found.

  • chatgptuntested

    No model-specific signal or recorded compatibility test was found.

  • geminiuntested

    No model-specific signal or recorded compatibility test was found.

  • copilotuntested

    No model-specific signal or recorded compatibility test was found.

  • llamauntested

    No model-specific signal or recorded compatibility test was found.

  • perplexityuntested

    No model-specific signal or recorded compatibility test was found.

  • mistraluntested

    No model-specific signal or recorded compatibility test was found.

  • grokuntested

    No model-specific signal or recorded compatibility test was found.

Inferred compatibility is based on content signals. Check the app, its available tools and setup requirements before running a skill.

What this skill does

# orch-refine-code

Actor · action · target: **orch · refine · code**. Thin wrapper over the shared engine in [`orch-pipeline`](../orch-pipeline/SKILL.md).

## 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] ```

Intended uses

  • Same behavior, better structure: extract modules, remove duplication, kill
  • Distinguish from siblings: if behavior is meant to change at all, this is the

Implementation notes

  • Review the source instructions and adapt inputs before running the workflow.

Try it, then tell us how it went

A copied prompt does not tell us whether the task worked. Report your result after checking the output. We collect your tool and outcome, never your files or prompt.