refactor

Orchestrates multi-target code and documentation refactoring with verification gates and review loops.

189|25|Updated Jan 30, 2026
One-click install
npx skills add https://github.com/sd0xdev/sd0x-harness --skill refactor-sd0xdev
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: refactor
Source: https://github.com/sd0xdev/sd0x-harness/tree/main/skills/refactor
Command: npx skills add https://github.com/sd0xdev/sd0x-harness --skill refactor-sd0xdev

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Cleaning up messy code and documents across a repository is risky and tedious: each change needs behavioral verification, review, and lint/test gating. This Skill automates multi-target refactoring by detecting candidates, dispatching the right cleanup routine per file type, and enforcing verification gates before anything is marked committable. ## Core Features & Use Cases - Multi-Target Orchestration: Refactor specific files or directories with --target, or auto-detect up to 10 high-priority targets with --auto using a complexity/change-frequency/isolation scoring formula. - Behavioral Safety Gates: Code targets run /verify fast before and after refactoring to detect behavioral regressions; failing baselines or regressions are skipped with structured [REFACTOR_SKIPPED] logs. - Typed Dispatch: Routes code files to /simplify, AI-artifact docs to /de-ai-flavor, and structural docs to /doc-refactor, each followed by Codex review loops (max 3 rounds). - Reference-Stability Mode: A narrow --mode reference-stability pass converts bare path:line pointers into durable semantic anchors across at most 5 explicitly enumerated files. - Use Case: Run /refactor --auto --max-targets 5 before a release to clean up the five most complex, frequently changed files, then review the per-target result table and commit with /smart-commit --execute. ## Quick Start Ask the assistant to refactor a specific file or directory, for example by requesting to clean up and simplify src/utils.ts with verification and review gates applied.

Frequently Asked Questions about refactor

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I refactor multiple files in a repository at once?▼

Use the refactor skill with --target for specific files or directories, or --auto to auto-detect up to 10 targets scored by complexity, change frequency, and isolation. Each target is refactored, verified, and reviewed independently with a per-target result table.

How does automated refactoring avoid changing code behavior?▼

It runs /verify fast before and after each code refactor and compares exit codes. A 0-to-nonzero transition marks BEHAVIOR_CHANGED and the target is skipped; a failing baseline also skips the target since preservation cannot be verified.

What is the difference between refactor, simplify, and de-ai-flavor?▼

Refactor is the orchestrator for multi-target cleanup across a repo. Use /simplify directly for a single known code file, /de-ai-flavor for a known document with AI artifacts, and /bug-fix or /feature-dev for fixes and new features instead.

Can I refactor test files, shell scripts, or config files?▼

Not in v1. Test files (*.test.*, *.spec.*), shell scripts, and config files (JSON/YAML/TOML) are classified as v2 types and skipped with a [REFACTOR_SKIPPED] log. Only code and Markdown documentation targets are dispatched.

Why was my refactoring target skipped or blocked?▼

Targets are skipped when the baseline verification fails, a behavioral regression is detected, or the file type is v2-only. Targets are blocked when the Codex review loop fails after 3 rounds or the precommit lint/test gate fails.

Does the refactor skill commit changes automatically?▼

No. Git add, commit, and push are prohibited. After all gates pass, it lists committable files and suggests running /smart-commit --execute, which remains a user-initiated action.