Skip to content

Bulk, consistent code refactoring across files that renames identifiers, replaces patterns, and updates API calls safely.

CCM score
55 of 100
skills.sh installs
306
GitHub stars
697
last updated
Aug 21, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers renaming identifiers, replacing deprecated code patterns, and updating method or API calls across multiple locations
  • Uses Grep to find every occurrence and Edit with replace_all to apply changes, then verifies none remain
  • Switches to the code-execution skill automatically for 10 or more files to reduce token usage
  • Follows a safe process of search, analyze, inform, execute, verify, and test, with edge cases like strings and exported APIs flagged
  • Integrates with test-fixing, code-transfer, and feature-planning for follow-up test repair and larger refactors

Install

$ npx -y skills add mhattingpete/claude-skills-marketplace --skill code-refactor -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

Code Refactor

Systematic code refactoring across files. Auto-switches to execution mode for 10+ files (90% token savings).

Mode Selection

  • 1-9 files: Use native tools (Grep + Edit with replace_all)
  • 10+ files: Automatically use code-execution skill

Execution example (50 files):

from api.code_transform import rename_identifier
result = rename_identifier('.', 'oldName', 'newName', '**/*.py')
# Returns: {'files_modified': 50, 'total_replacements': 247}
# ~500 tokens vs ~25,000 tokens traditional

When to Use

  • "rename [identifier] to [new_name]"
  • "replace all [pattern] with [replacement]"
  • "refactor to use [new_pattern]"
  • "update all calls to [function/API]"
  • "convert [old_pattern] to [new_pattern]"

Core Workflow (Native Mode)

1. Find All Occurrences

Grep(pattern="getUserData", output_mode="files_with_matches")     # Find files
Grep(pattern="getUserData", output_mode="content", -n=true, -B=2, -A=2)  # Verify with context

2. Replace All Instances

Edit(
  file_path="src/api.js",
  old_string="getUserData",
  new_string="fetchUserData",
  replace_all=true
)

Details

Repository
github.com/mhattingpete/claude-skills-marketplace
Category
Code Review & Quality
License
Apache-2.0
First seen
Jun 3, 2026

Questions

What does the code-refactor skill do?

code-refactor performs bulk refactoring across many files, such as renaming variables or functions, replacing deprecated code patterns, and updating API calls. It finds every occurrence first, then applies consistent edits in each location. For runs of 10 or more files, code-refactor switches to the code-execution skill to save tokens.

How do I install the code-refactor skill?

Run npx -y skills add mhattingpete/claude-skills-marketplace --skill code-refactor -y in your project. Once installed, code-refactor lets your agent rename identifiers across a codebase and replace patterns in every matching file.

Which category does code-refactor belong to, and what sets it apart?

code-refactor is in the Code Review & Quality category on Claude Marketplaces, led by improve-codebase-architecture, codebase-design and code-review. Unlike those skills, code-refactor focuses on mechanical multi-file edits such as renames and API call updates. It recommends running tests afterward to confirm the changes.

More from mhattingpete/claude-skills-marketplace

All 18

Similar to Code Refactor

More Code Review & Quality