/refactoring-code
Batch behavior-preserving refactors for multi-file, repeated-pattern,
$ npx -y skills add alexei-led/cc-thingz --skill refactoring-code --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.
- You can call itInvoke it directly when you want it.
- Slash command
/refactoring-code
Context preview
The summary Claude sees to decide when to auto-load this skill.
Batch behavior-preserving refactors for multi-file, repeated-pattern,
SKILL.md
refactoring-code.SKILL.mddescription: Batch behavior-preserving refactors for multi-file, repeated-pattern,
large-file, rename, move, extract, split, or restructure work. Use for "refactor
across files", "batch rename", "update pattern everywhere", large files (500+ lines),
or 5+ coordinated edits in one file. NOT for single targeted edits, behavior changes
or bug fixes (use fixing-code), test-only refactors (use improving-tests), code
review (use reviewing-code), or architecture redesign (use architecture-design/review).
name: refactoring-code
Batch Refactoring
Use this when many edits must preserve externally observable behavior. Stop if you cannot name the maintenance value and the behavior that must stay unchanged.
Role-gated action
Detect capability from tools:
- Write-capable role: map scope, apply one batch, run verification.
- Read-only role: map scope and emit the refactor in the Proposed Changes contract. Apply nothing; run nothing.
Route elsewhere
Do not use this for:
- one small edit that normal coding tools can handle
- behavior changes, bug fixes, or failing checks → `fixing-code`
- test-only cleanup, coverage, or TDD → `improving-tests`
- review findings without edits → `reviewing-code`
- target architecture design or repo-wide structural audit → architecture skills
- cosmetic churn with no maintenance value
Language references
Load the matching reference for the language being refactored:
- C# /.NET: `references/csharp.md`
- Go: `references/go.md`
- Java/Kotlin: `references/java-kotlin.md`
- Python: `references/python.md`
- Rust: `references/rust.md`
- TypeScript/JavaScript: `references/typescript.md`
Unsupported language: use the general workflow in this file only.
Evidence first
Before editing:
1. Define goal, non-goals, preservation target, and safety gate. 2. Map every affected site with text search and language-aware tools. 3. For renames, moves, extracts, splits, or broad restructures, use graph tools when available:
- GitNexus dry-run rename for renames; GitNexus context, impact, and query for callers, callees, execution flows, and string/dynamic refs.
- codegraph status first; if fresh, use codegraph context or affected to size dependency/call blast radius.
4. Treat stale graph indexes as no evidence. Refresh if allowed; otherwise fall back to search/LSP and report the gap. 5. Check non-code references when names or paths change: config, routes, DI wiring, serialization keys, CLI entries, generated sources, scripts, and docs. 6. Read representative implementation files and tests. 7. Add characterization tests at the public boundary when behavior is under-specified and risk is not low.
No mapped site, no edit.
Batch rules
Good batches are small, reversible, and single-purpose:
- rename one symbol/concept and all callers
- move one module/function and its tests
- extract one cohesive responsibility behind the same public behavior
- remove one duplicate implementation after tests prove equivalence
- update one repeated pattern across mapped sites
Rules:
- Separate mechanical structure changes from logic changes.
- Do not rename many concepts while changing APIs or control flow.
- Prefer semantic refactoring tools; use precise text edits only for mapped sites.
- For public APIs, keep compatibility shims or deprecations unless the user approved a breaking change.
- Run narrow tests after each batch; run broader lint/type/test checks before the next batch or final report.
- Delete dead code exposed by the refactor. Do not hand-edit generated or vendored files unless the project regenerates them from source.
Output
Engineer:
REFACTOR COMPLETE
=================
Preservation target: <behavior that must not change>
Safety gate: <tests/checks used>
Files changed: N
Status: CLEAN | NEEDS ATTENTION
Mapping:
- <tool/search> — <key affected sites or graph gap>
Changes:
- path:line — change
Verification:
- <command> — pass/fail
Reviewer:
## Proposed Changes
Preservation target: <behavior that must not change>
Safety gate: <tests/checks the applier should run>
Mapping:
- <tool/search> — <affected sites or graph gap>
### Change 1: <brief description>
File: `path/to/file`
Action: CREATE | MODIFY | DELETE
Code:
<changed regions with enough context to locate them>
Rationale: <why this preserves behavior while improving structure>
For multi-file renames, list every mapped occurrence or explicitly mark ambiguous/unmapped references.
Failure handling
- Scope unclear: ask which files/concept and what behavior to preserve.
- Tests/checks missing for risky code: ask to add characterization tests or shrink/defer the refactor.
- Tests fail after a batch: inspect or revert that batch before continuing.
- Required behavior change appears: stop and split into refactor first, then feature/fix.
- Graph tool missing or stale: report the gap and use search/LSP evidence instead.
- Generated or vendored occurrence: skip it unless regeneration is part of the verified workflow.
Read more
description: Batch behavior-preserving refactors for multi-file, repeated-pattern, large-file, rename, move, extract, split, or restructure work. Use for "refactor across files", "batch rename", "update pattern everywhere", large files (500+ lines), or 5+ coordinated edits in one file. NOT for single targeted edits, behavior changes or bug fixes (use fixing-code), test-only refactors (use improving-tests), code review (use reviewing-code), or architecture redesign (use architecture-design/review). name: refactoring-code
Batch Refactoring
Use this when many edits must preserve externally observable behavior. Stop if you cannot name the maintenance value and the behavior that must stay unchanged.
Role-gated action
Detect capability from tools:
- Write-capable role: map scope, apply one batch, run verification.
- Read-only role: map scope and emit the refactor in the Proposed Changes contract. Apply nothing; run nothing.
Route elsewhere
Do not use this for:
- one small edit that normal coding tools can handle
- behavior changes, bug fixes, or failing checks → `fixing-code`
- test-only cleanup, coverage, or TDD → `improving-tests`
- review findings without edits → `reviewing-code`
- target architecture design or repo-wide structural audit → architecture skills
- cosmetic churn with no maintenance value
Language references
Load the matching reference for the language being refactored:
- C# /.NET: `references/csharp.md`
- Go: `references/go.md`
- Java/Kotlin: `references/java-kotlin.md`
- Python: `references/python.md`
- Rust: `references/rust.md`
- TypeScript/JavaScript: `references/typescript.md`
Unsupported language: use the general workflow in this file only.
Evidence first
Before editing:
1. Define goal, non-goals, preservation target, and safety gate. 2. Map every affected site with text search and language-aware tools. 3. For renames, moves, extracts, splits, or broad restructures, use graph tools when available:
- GitNexus dry-run rename for renames; GitNexus context, impact, and query for callers, callees, execution flows, and string/dynamic refs.
- codegraph status first; if fresh, use codegraph context or affected to size dependency/call blast radius.
4. Treat stale graph indexes as no evidence. Refresh if allowed; otherwise fall back to search/LSP and report the gap. 5. Check non-code references when names or paths change: config, routes, DI wiring, serialization keys, CLI entries, generated sources, scripts, and docs. 6. Read representative implementation files and tests. 7. Add characterization tests at the public boundary when behavior is under-specified and risk is not low.
No mapped site, no edit.
Batch rules
Good batches are small, reversible, and single-purpose:
- rename one symbol/concept and all callers
- move one module/function and its tests
- extract one cohesive responsibility behind the same public behavior
- remove one duplicate implementation after tests prove equivalence
- update one repeated pattern across mapped sites
Rules:
- Separate mechanical structure changes from logic changes.
- Do not rename many concepts while changing APIs or control flow.
- Prefer semantic refactoring tools; use precise text edits only for mapped sites.
- For public APIs, keep compatibility shims or deprecations unless the user approved a breaking change.
- Run narrow tests after each batch; run broader lint/type/test checks before the next batch or final report.
- Delete dead code exposed by the refactor. Do not hand-edit generated or vendored files unless the project regenerates them from source.
Output
Engineer:
REFACTOR COMPLETE ================= Preservation target: <behavior that must not change> Safety gate: <tests/checks used> Files changed: N Status: CLEAN | NEEDS ATTENTION Mapping: - <tool/search> — <key affected sites or graph gap> Changes: - path:line — change Verification: - <command> — pass/fail
Reviewer:
## Proposed Changes Preservation target: <behavior that must not change> Safety gate: <tests/checks the applier should run> Mapping: - <tool/search> — <affected sites or graph gap> ### Change 1: <brief description> File: `path/to/file` Action: CREATE | MODIFY | DELETE Code: <changed regions with enough context to locate them> Rationale: <why this preserves behavior while improving structure>
For multi-file renames, list every mapped occurrence or explicitly mark ambiguous/unmapped references.
Failure handling
- Scope unclear: ask which files/concept and what behavior to preserve.
- Tests/checks missing for risky code: ask to add characterization tests or shrink/defer the refactor.
- Tests fail after a batch: inspect or revert that batch before continuing.
- Required behavior change appears: stop and split into refactor first, then feature/fix.
- Graph tool missing or stale: report the gap and use search/LSP evidence instead.
- Generated or vendored occurrence: skip it unless regeneration is part of the verified workflow.
Portable skills, agents, hooks, and Pi-native extensions for Claude Code, Codex CLI, GitHub Copilot, Cursor, Grok, and Pi. Gemini is retired.
Repo: alexei-led/cc-thingz
Other skills on cc-thingz.
- /browser-automation
Use this for browser exploration, validation, screenshots, recordings, frontend debugging, accessibility checks, and E2E/user-flow testing. Do not delete, reset, or mutate non-test data without explicit user confirmation.
Open skill - /playwright-skill
Support-only helper for `browser-automation`. Provides Playwright primitives: dev-server detection, a script runner (`scripts/run.js`), screenshot CLIs, and helper utilities (`scripts/lib/helpers.js`).
Open skill - /committing-code
Scope: inspect changes, group them, and create normal commits only. Do not rewrite history, amend existing commits, force-push, or stage secrets. Ground the proposal in git status, diff, and recent log output.
Open skill - /documenting-code
Scope: documentation files, agent instruction files, and useful code comments only. Not for code-quality review; use `reviewing-code` for that.
Open skill - /fixing-code
Follow the base skill. This Claude overlay only defines tool use and execution details.
Open skill - /improving-tests
Follow the base skill. This Claude overlay only defines tool use and execution details.
Open skill

