rename-method

Refactoring technique to improve code readability by renaming methods to better reflect their purpose and functionality

16 stars

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

$curl -o ~/.claude/skills/rename-method/SKILL.md --create-dirs "https://raw.githubusercontent.com/diegosouzapw/awesome-omni-skill/main/skills/development/rename-method/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/rename-method/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How rename-method Compares

Feature / Agentrename-methodStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/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 transitions

Related Skills

sparc-methodology

16
from diegosouzapw/awesome-omni-skill

SPARC (Specification, Pseudocode, Architecture, Refinement, Completion) comprehensive development methodology with multi-agent orchestration

methodical-debugging

16
from diegosouzapw/awesome-omni-skill

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

16
from diegosouzapw/awesome-omni-skill

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

16
from diegosouzapw/awesome-omni-skill

Apply agile development practices. Use when planning sprints, running ceremonies, or improving team processes. Covers Scrum, Kanban, and agile principles.

actor-critic-methods

16
from diegosouzapw/awesome-omni-skill

Master A2C, A3C, SAC, TD3 - actor-critic methods for continuous control

bgo

10
from diegosouzapw/awesome-omni-skill

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.

Coding & Development

ssh-server-admin

16
from diegosouzapw/awesome-omni-skill

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

16
from diegosouzapw/awesome-omni-skill

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

16
from diegosouzapw/awesome-omni-skill

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

16
from diegosouzapw/awesome-omni-skill

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

16
from diegosouzapw/awesome-omni-skill

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

16
from diegosouzapw/awesome-omni-skill

SQL query optimization, schema design, indexing strategies, and relational database mastery for production data systems