Install
Works with Claude Code. Read the repository before you give any tool access to your data.
npx agentmarket install skill/sd0xdev-refactor
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/refactor
Tools it pre-approves 8
From allowed-tools in SKILL.md: the agent may use these without asking you each time.
Read,Grep,Glob,Edit,Write,Bash,Skill,AskUserQuestion
What's inside
- Skill name
refactor- Description
- Multi-target refactoring orchestrator. Use when: cleaning up messy code/docs, simplifying code, restructuring documents, batch cleanup. Not for: new features (use feature-dev), bug fixes (use bug-fix), code understanding (use code-explore). Output: refactored code/docs + review gate.
- License
- MIT
- Allowed tools
- Read,, Grep,, Glob,, Edit,, Write,, Bash,, Skill,, AskUserQuestion
- Instructions
- 272 lines in SKILL.md · view on GitHub
Before installing
- Pre-approves some shell commands
Files (5)
- SKILL.md
- behavioral-gate.md · references/
- output-template.md · references/
- refactor-catalog.md · references/
- target-detection.md · references/
SKILL.md (first lines)
# Refactor — Multi-Target Refactoring Orchestrator
## Trigger
- Keywords: refactor, cleanup, clean up, simplify code, restructure, tidy up, reduce complexity, batch refactor
- zh-TW: 重構, 整理, 清理, 簡化
## When NOT to Use
| Scenario | Alternative |
|----------|------------|
| New feature development | `/feature-dev` |
| Bug fix | `/bug-fix` |
| Code understanding | `/code-explore` |
| Doc review only | `/codex-review-doc` |
| Single file simplify (known target) | `/simplify` directly |
| Remove AI artifacts (known doc) | `/de-ai-flavor` directly |
## Prohibited Actions
```
❌ git add | git commit | git push — per @rules/git-workflow.md
```
<budget:token_budget>150000</budget:token_budget>
## Arguments
| Flag | Default | Description |
|------|---------|-------------|
| `--target <path>` | — | Specific file or directory (repo-relative) |
| `--auto` | — | Auto-detect targets using inline metrics |
| `--max-targets N` | 10 | Maximum targets per run |
| `--mode reference-stability` | — | Narrow pointer-conversion pass (see § Reference-Stability Targets). Requires explicit `--target` files — repeat the flag for multiple files (`--target a.md --target b.js`, ≤ 5); incompatible with `--auto` |
## Workflow
```
Phase 0: Target Detection → Phase 2: Incremental Refactor Loop → Phase 3: Report
(Phase 1: reserved for v2 — parallel exploration)
```
---
## agentctl (optional)
At the start, run `node "${CLAUDE_PLUGIN_ROOT}/skills/agentctl-setup/scripts/agentctl-setup.js" status`
once. Only when `state` is `installed/enabled`, offer to draft a task proposal from the ticket per
`@skills/agentctl-setup/references/workflow-integration.md` — the user accepts it with
`/agentctl accept`; any other state, say nothing about agentctl and continue. It is never a gate:
every review and precommit obligation in this skill is unchanged, and its evidence is context
beside a verdict, never the verdict.
## Phase 0: Target Detection & Planning
### `--mode reference-stability` Branch (checked first)
When this mode is passed, Phase 0 takes this branch and **bypasses the generic pipeline
below entirely** — no AI-artifact heuristic, no refactor-catalog classification, and no v2
type skip (the mode accepts any maintained text file its transformation table covers: docs,
code, tests, instruction surfaces — a `*.test.js` target is valid here even though the
generic path skips test files as v2). In code and test files, **only comment and
documentation regions are conversion candidates**: executable strings, assertion
expectations, fixtures, snapshots, generated content, and ordinary data are never touched —
that is INV-005's boundary, and it is what makes skipping the behavioral gate sound (an
eligible **prose-only** comment cannot change runtime behavior — tool-consumed directives and
pragmas such as lint/type-checker directives or source-map metadata are *not* eligible
regions, since comments can carry machine semantics; anything that could change behavior is
out of this mode's reach):
1. Validate each `--target` path (same path-safety rules as below)
2. Enumerate: more than **5** files (after resolving any directory) → `[REFACTOR_BLOCKED] <target>: reference-stability accepts at most 5 enumerated files`
3. Reject `--auto`: `[REFACTOR_BLOCKED] --auto: incompatible with reference-stability`
4. Determine each file's review plane (doc vs code) for step 3 of the mode's loop
5. Proceed to § Reference-Stability Targets — never to the generic code/doc paths
### `--target` Mode
1. **Validate path** (per `references/target-detection.md`):
- Reject absolute paths (starts with `/`)
- Reject `..` traversal
- Reject symlink escape (resolved path outside repo root)
- Reject non-existent files
- On rejection: `[REFACTOR_BLOCKED] <path>: <reason>`
2. **Detect file type**:
- Use extension mapping from `references/target-detection.md`
- For `.md` files: run AI artifact heuristic (scan for tool names, boilerplate, etc.; 3+ matches → `doc-ai`, else → `doc-structure`)
- v2 types (config/shell/test): log `[REFACTOR_SKIPPED] {target}: type not yet dispatched (v2)` and skip
3. **Classify refactor types** from `references/refactor-catalog.md` (R01-R09 for v1)
### `--auto` Mode
1. **(Optional) Baseline**: Run `/project-audit` to capture health score
2. **Scan** repo for candidate files (code + doc)
3. **Score** each candidate:
```
score = 0.40 × complexity + 0.35 × change_frequency + 0.25 × isolation
```
- `complexity`: `wc -l <file>` normalized 0-1
- `change_frequency`: `git log --oneline -- <file> | wc -l` normalized 0-1
- `isolation`: `1 - (import_count / max_import_count)`
4. **Sort** descending, take top `--max-targets` (default 10)
5. **Classify** each target's file type and refactor types
---
## Phase 2: Incremental Refactor Loop
Process each target in priority order. Budget: max `--max-targets` targets per run.
### Code Targets
```
FOR EACH code target:
1. /verify fast → capture baseline exit codeFrom sd0xdev/sd0x-harness, MIT.
More from sd0xdev/sd0x-harness
- 0.713score
debug
sd0xdev
Interactive debugging workflow with hypothesis-driven probe loop.
SkillAFreshness: A★ 194Claude Code - 0.713score
contract-decode
sd0xdev
EVM contract error and calldata decoder.
SkillAFreshness: A★ 194Claude Code - 0.713score
codex-brainstorm
sd0xdev
Adversarial brainstorming via Claude+Codex debate.
SkillAFreshness: A★ 194Claude Code +9 - 0.713score
best-practices
sd0xdev
Industry best practices conformance audit with mandatory adversarial debate.
SkillAFreshness: A★ 194Claude Code - 0.713score
codex-cli-review
sd0xdev
Code review via Codex CLI with full disk access.
SkillAFreshness: A★ 194Claude Code +9 - 0.713score
codex-explain
sd0xdev
Explain complex code via Codex exec.
SkillAFreshness: A★ 194Claude Code +9 - 0.713score
ask
sd0xdev
Context-aware Q&A with auto context gathering.
SkillAFreshness: A★ 194Claude Code +9 - 0.713score
claude-health
sd0xdev
Claude Code config health check + plugin sync.
SkillAFreshness: A★ 194Claude Code +9 - 0.713score
code-explore
sd0xdev
Pure Claude code investigation.
SkillAFreshness: A★ 194Claude Code +9 - 0.713score
code-investigate
sd0xdev
Dual-perspective code investigation.
SkillAFreshness: A★ 194Claude Code +9 - 0.713score
codex-architect
sd0xdev
Codex architecture consulting.
SkillAFreshness: A★ 194Claude Code +9 - 0.713score
deep-explore
sd0xdev
Multi-wave parallel code exploration orchestrator.
SkillAFreshness: A★ 194Claude Code +9
Signals
- Stars
- 194
- Forks
- 26
- Open issues
- 5
- Last commit (this folder)
- Oct 6, 2026 (22 days ago)
- Last release
- Oct 6, 2026 (22 days ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/sd0xdev/sd0x-harness
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from sd0xdev
- 0.713score
code-investigate
sd0xdev
Dual-perspective code investigation.
SkillAFreshness: A★ 194Claude Code +9 - 0.713score
code-explore
sd0xdev
Pure Claude code investigation.
SkillAFreshness: A★ 194Claude Code +9 - 0.713score
ask
sd0xdev
Context-aware Q&A with auto context gathering.
SkillAFreshness: A★ 194Claude Code +9 - 0.713score
best-practices
sd0xdev
Industry best practices conformance audit with mandatory adversarial debate.
SkillAFreshness: A★ 194Claude Code - 0.713score
claude-health
sd0xdev
Claude Code config health check + plugin sync.
SkillAFreshness: A★ 194Claude Code +9 - 0.713score
codex-architect
sd0xdev
Codex architecture consulting.
SkillAFreshness: A★ 194Claude Code +9
Cite this page
refactor skill. Agent Mart. https://agentmart.dev/skills/sd0xdev-refactor (last updated 2026-10-24)