dist/codex/plugins/dev-workflow/skills/refactoring-code/SKILL.md
Batch refactoring via MorphLLM edit_file. Use for "refactor across files", "batch rename", "update pattern everywhere", large files (500+ lines), 5+ edits in same file, or applying an approved architecture-deepening refactor. NOT for single-file targeted edits (use built-in Edit) or code review (use reviewing-code).
npx skillsauth add alexei-led/claude-code-config refactoring-codeInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
MorphLLM edit_file provides semantic code merging at 10,500+ tokens/sec with 98% accuracy. Use the MorphLLM edit_file / batch refactoring workflow for broad changes. Refactoring here means behavior-preserving change or architecture deepening, not cosmetic churn.
Critical rule: preserve existing behavior unless the user explicitly asks for a behavior change. State the preservation target before editing.
Detect your capability from your tools, not from prose:
Detect the language from the file extensions in scope and preserve that language's idioms in the rewritten code. This skill has no per-language reference files — operate from the generic procedure.
Use edit_file when:
Use Built-in Edit/MultiEdit when:
When applying an approved architecture-deepening refactor, keep the seam rule (one adapter means a hypothetical seam; two adapters means a real seam — do not add interfaces without real variation) and the deletion test in mind. The module-depth vocabulary is owned upstream by improving-codebase-architecture (references/LANGUAGE.md) and reviewing-code; match the design agreed there and do not redefine the terms here. Read relevant CONTEXT.md, CONTEXT-MAP.md, and ADRs when present. Preserve domain names.
1. Use WarpGrep or semantic search to find all locations needing change
2. State: "Behavior must be preserved unless the user explicitly requested a behavior change."
3. Use MorphLLM `edit_file` or the batch refactoring workflow for each batch/file, grouping related edits
4. Batch all edits for the same file into one edit operation
5. Verify with lint/test
6. Delete obsolete shallow tests once deeper interface tests cover the behavior
For multi-file renames, say this is a batch refactor, map all occurrences before editing, use the batch refactoring tool/workflow by name, preserve behavior, and run relevant lint/tests after the rename.
1. Call edit_file with dryRun: true
2. Review preview output
3. If approved, call again with dryRun: false
path: "/absolute/path/to/file"
code_edit: "changed lines with // ... existing code ... markers"
instruction: "brief description of changes"
dryRun: false (set true to preview)
Use // ... existing code ... markers for unchanged sections:
// ... existing code ...
function updatedFunction() {
// new implementation
}
// ... existing code ...
instruction: "Add error wrapping to all repository methods"
code_edit: Shows only changed functions with context markers
instruction: "Update imports from old-pkg to new-pkg"
code_edit: Shows import section with changes
instruction: "Rename getUserById to findUser throughout file"
code_edit: Shows all locations with changes
Engineer (applied the refactor): report the preservation target, files changed, and the lint/test verification result per touched file.
Reviewer (planned only — emit the refactor as a proposal, apply nothing):
## Proposed Changes
Preservation target: <behavior that must not change>
### Change 1: <brief description>
File: `path/to/file`
Action: CREATE | MODIFY | DELETE
Code:
<changed regions with // ... existing code ... markers>
Rationale: <why this change>
For multi-file renames, list every occurrence mapped before the proposal so the applier can replay it.
edit_file unavailable → fall back to built-in Edit/MultiEdit; warn the user that large batches may be slowertools
Idiomatic shell development for POSIX sh, Bash, Zsh, Fish, hooks, CI shell steps, and scriptable CLI glue. Use when writing or changing `.sh`, `.bash`, `.zsh`, `.fish`, `.bats`, shell functions, shell pipelines, or command-runner recipes. Emphasizes portability, quoting, safe filesystem/process handling, non-TUI CLI tools, ShellCheck, shfmt, Bats, and ShellSpec. NOT for Python, TypeScript, Go, web code, or infrastructure operations.
tools
Use when planning, executing, checkpointing, finishing, or inspecting lightweight spec-driven work. Runs one task at a time using `.spec/` markdown files and the bundled `specctl` helper. NOT for broad product discovery beyond a short requirement interview.
testing
Author, inspect, troubleshoot, and review infrastructure across IaC, Kubernetes, cloud resources, containers, CI/CD, and Linux hosts. Use when changing Terraform/OpenTofu, Kubernetes, Helm, Kustomize, Dockerfiles, GitHub Actions, AWS, GCP, Cloud Run, BigQuery, IAM, logs, instances, or service health. NOT for deploy/apply/rollback workflows (see deploying-infra). NOT for shell scripts or generic command pipelines (see writing-shell).
development
Configure safe git workflow hygiene: pre-commit/pre-push hooks, Gitleaks secret scanning, .gitignore rules, local git config, and guardrails. Use when setting up git hooks, gitleaks/git leaks, staged pre-commit checks, pre-push validation, core.hooksPath, .gitignore, or git config best practices. NOT for creating commits (use committing-code), cleaning branches/worktrees (use cleanup-git), or creating worktrees (use using-git-worktrees).