adr
Write an Architecture Decision Record (ADR) for a feature — Context / Decision / Status / Consequences / Alternatives, filed as…
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
Claude Code
$ npx -y skills add sd0xdev/sd0x-harness --skill refactor --agent claude-code
Codex
$ npx skills add sd0xdev/sd0x-harness --skill refactor -a codex -y
Cursor
$ npx skills add sd0xdev/sd0x-harness --skill refactor -a cursor -y
Gemini CLI
$ npx skills add sd0xdev/sd0x-harness --skill refactor -a gemini-cli -y
GitHub Copilot
$ npx skills add sd0xdev/sd0x-harness --skill refactor -a github-copilot -y
OpenCode
$ npx skills add sd0xdev/sd0x-harness --skill refactor -a opencode -y
Windsurf
$ npx skills add sd0xdev/sd0x-harness --skill refactor -a windsurf -y
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." allowed-tools: Read, Grep, Glob, Edit, Write, Bash, Skill, AskUserQuestion
| 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 |
❌ git add | git commit | git push — per @rules/git-workflow.md
<budget:token_budget>150000</budget:token_budget>
| 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` |
Phase 0: Target Detection → Phase 2: Incremental Refactor Loop → Phase 3: Report (Phase 1: reserved for v2 — parallel exploration)
---
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.
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
1. **Validate path** (per `references/target-detection.md`):
2. **Detect file type**:
3. **Classify refactor types** from `references/refactor-catalog.md` (R01-R09 for v1)
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
4. **Sort** descending, take top `--max-targets` (default 10) 5. **Classify** each target's file type and refactor types
---
Process each target in priority order. Budget: max `--max-targets` targets per run.
FOR EACH code target:
1. /verify fast → capture baseline exit code
IF baseline exit ≠ 0:
[REFACTOR_SKIPPED] {target}: baseline failing, cannot verify preservation
CONTINUE
2. /simplify {target}
3. /verify fast → capture post-refactor exit code
4. Behavioral gate (per references/behavioral-gate.md):
IF BEHAVIOR_CHANGED (0→non-0):
[REFACTOR_SKIPPED] {target}: behavioral regression detected
CONTINUE
IF NO_TESTS (all steps skipped):
⚠️ NO_TESTS: behavioral preservation not verified (advisory, continue)
5. /codex-review-fast (auto-loop, max 3 rounds)
IF still blocked:
[REFACTOR_BLOCKED] {targeLanguage: English | 繁體中文 | 简体中文 | 日本語 | 한국어 | Español The harness layer for Claude Code. Let the model choose the path. Keep "done" verifiable. Claude has discretion inside a closed, test-pinned anchor set.
Write an Architecture Decision Record (ADR) for a feature — Context / Decision / Status / Consequences / Alternatives, filed as…
Install and set up the optional agentctl mod (task scope, refusal before execution, evidence that goes stale, model-free…
Architecture design and documentation. Produces 3-architecture.md with component diagrams, data flow, integration points, and…
Context-aware Q&A with auto context gathering. Use when: user has a quick question about codebase, git history, rules, docs, or…
Industry best practices conformance audit with mandatory adversarial debate. Produces audit artifact: verdict (OK/WARN/FAIL) +…
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…
Ask which skill or flow fits your situation. A router over the skills in this repo.