rename-method
Refactoring technique to improve code readability by renaming methods to better reflect their purpose and functionality
Best use case
rename-method is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Refactoring technique to improve code readability by renaming methods to better reflect their purpose and functionality
Teams using rename-method should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/rename-method/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How rename-method Compares
| Feature / Agent | rename-method | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Refactoring technique to improve code readability by renaming methods to better reflect their purpose and functionality
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Rename Method
## Overview
Rename Method is a fundamental refactoring technique applied when method names no longer accurately describe what the method does. Clear, descriptive method names are essential for code readability and maintainability. This refactoring improves code quality by making method intent explicit through proper naming conventions.
## Motivation
Methods acquire poor names for several reasons:
- Rushed initial development leaves temporary names in place
- Method functionality evolves beyond its original scope
- Inconsistent naming conventions across the codebase
- Comments become necessary to explain what a poorly-named method does
Unclear method names force developers to read implementation details to understand intent, reducing productivity and increasing the chance of misuse.
## Mechanics
The refactoring process follows these essential steps:
1. **Declare a new method** with the desired name, copying the original implementation
2. **Delegate the old method** to call the new method to maintain backward compatibility during transition
3. **Find and update all references** throughout the codebase to use the new method name
4. **Remove the old method** once all references are updated, or mark as deprecated if it's a public API
## Before/After Examples (PHP 8.3+)
### Example 1: Descriptive Method Name
**Before:**
```php
class UserRepository
{
public function get(int $id): User
{
return $this->queryBuilder
->where('id = ?', $id)
->fetchOne();
}
}
$user = $repository->get(1);
```
**After:**
```php
class UserRepository
{
public function findUserById(int $id): User
{
return $this->queryBuilder
->where('id = ?', $id)
->fetchOne();
}
#[Deprecated(
message: 'Use findUserById() instead',
since: '2.0'
)]
public function get(int $id): User
{
return $this->findUserById($id);
}
}
$user = $repository->findUserById(1);
```
### Example 2: Boolean Getter Clarity
**Before:**
```php
class Order
{
public function valid(): bool
{
return $this->items->count() > 0 &&
$this->total > 0 &&
$this->customer !== null;
}
}
if ($order->valid()) {
// process order
}
```
**After:**
```php
class Order
{
public function isReadyForProcessing(): bool
{
return $this->items->count() > 0 &&
$this->total > 0 &&
$this->customer !== null;
}
#[Deprecated(
message: 'Use isReadyForProcessing() instead',
since: '1.5'
)]
public function valid(): bool
{
return $this->isReadyForProcessing();
}
}
if ($order->isReadyForProcessing()) {
// process order
}
```
### Example 3: Transformation Methods
**Before:**
```php
class ProductPresenter
{
public function calc(Product $product): array
{
return [
'name' => $product->name,
'price' => $product->price * 1.19,
'stock' => $product->quantity,
];
}
}
```
**After:**
```php
class ProductPresenter
{
public function formatProductForDisplay(Product $product): array
{
return [
'name' => $product->name,
'price' => $product->price * 1.19,
'stock' => $product->quantity,
];
}
#[Deprecated(
message: 'Use formatProductForDisplay() instead',
since: '3.0'
)]
public function calc(Product $product): array
{
return $this->formatProductForDisplay($product);
}
}
```
## Benefits
- **Self-documenting code** – Method names clearly communicate intent without needing comments
- **Reduced cognitive load** – Developers understand code purpose at a glance
- **Fewer bugs** – Clear names reduce misuse and misunderstanding
- **Improved maintainability** – Future developers spend less time deciphering code logic
- **Better IDE support** – Clear names enable better autocomplete and refactoring suggestions
- **Cleaner codebase** – Eliminates the need for explanatory comments
## When NOT to Use
- **Public API contracts** – Renaming public methods breaks backward compatibility; use deprecation instead
- **Framework hooks** – Methods that override parent/interface contracts shouldn't be renamed
- **Legacy systems** – When widely dependent code can't be updated simultaneously
- **Name conflicts** – If a new name conflicts with existing methods in the class hierarchy
- **During active development** – Wait until functionality stabilizes before finalizing names
## Related Refactorings
- **Extract Method** – Often applied before Rename Method to isolate and clarify functionality
- **Move Method** – Combines renaming with relocating methods to more appropriate classes
- **Change Function Declaration** – Related technique for updating function signatures alongside names
- **Rename Variable** – Similar principle applied to variable naming clarity
- **Deprecation** – Use PHP 8.1+ `#[Deprecated]` attribute for safe public API transitionsRelated Skills
sparc-methodology
SPARC (Specification, Pseudocode, Architecture, Refinement, Completion) comprehensive development methodology with multi-agent orchestration
methodical-debugging
Systematic debugging approach using parallel investigation and test-driven validation. Use when debugging issues, when stuck in a loop of trying different fixes, or when facing complex bugs that resist standard debugging approaches.
debugging-methodology
Systematic debugging methodology following reproduce → locate → hypothesize → verify → fix → regression workflow. Use when debugging issues, investigating bugs, troubleshooting problems, or when asked about debugging process, problem-solving, or issue investigation.
agile-methodology
Apply agile development practices. Use when planning sprints, running ceremonies, or improving team processes. Covers Scrum, Kanban, and agile principles.
actor-critic-methods
Master A2C, A3C, SAC, TD3 - actor-critic methods for continuous control
bgo
Automates the complete Blender build-go workflow, from building and packaging your extension/add-on to removing old versions, installing, enabling, and launching Blender for quick testing and iteration.
ssh-server-admin
Securely connect to and manage remote Linux/Unix servers via SSH. Execute commands, transfer files (SCP/SFTP), set up port forwarding and tunnels. Use when the user asks to SSH into a server, connect to a remote machine, run remote commands, upload/download files to servers, set up tunnels, or perform server administration tasks. Works on Windows, macOS, and Linux.
sqlmodel-task-models
This skill should be used when defining a robust, type-safe, and async-compatible database schema for the Todo application using SQLModel, ensuring compatibility with Better Auth and optimized for PostgreSQL.
sql-server-dba-dev-expert
Use when designing, implementing, optimizing, or troubleshooting AF.ECT.Database schemas, queries, stored procedures, performance tuning, data integrity, or operational database tasks while following Microsoft best practices
sql-pro
Master modern SQL with cloud-native databases, OLTP/OLAP optimization, and advanced query techniques. Expert in performance tuning, data modeling, and hybrid analytical systems. Use PROACTIVELY for database optimization or complex analysis.
sql
Guide for working with SQL queries, in particular for SQLite. Use this skill when writing SQL queries, analyzing database schemas, designing migrations, or working with SQLite-related code.
sql-databases
SQL query optimization, schema design, indexing strategies, and relational database mastery for production data systems