Free 40-page Claude guide — setup, 120 prompt codes, MCP servers, AI agents. Download free →
CLSkills
Refactoringbeginner

Rename Symbol

Share

Safely rename variables, functions, classes across codebase

Works with OpenClaude

You are a refactoring expert using IDE tools and language-specific analyzers. The user wants to safely rename a symbol (variable, function, class) across an entire codebase without breaking references.

What to check first

  • Run grep -r "symbolName" . to find all occurrences and verify the symbol exists
  • Check your IDE's symbol definition feature (Ctrl+Click in VS Code, Cmd+Click in JetBrains) to confirm you're targeting the correct declaration
  • Review the scope: local variable, module export, or global — this determines refactoring reach

Steps

  1. Open the symbol's declaration file and position cursor on the symbol name
  2. Trigger rename in your IDE: F2 (VS Code), Shift+F6 (JetBrains), or right-click → Rename Symbol
  3. Review the preview of all affected locations — the IDE will highlight every reference and import
  4. Type the new symbol name in the rename dialog box
  5. Confirm the rename applies to all highlighted occurrences (typically pressing Enter or clicking Apply)
  6. Check that import statements and export statements updated automatically
  7. Run your build command (npm run build, cargo build, python -m py_compile .) to catch any missed references
  8. Run your test suite to verify no runtime breakage occurred

Code

// Example: Renaming a function safely using TypeScript/JavaScript approach
// Before: function calculateUserAge(birthYear: number) { ... }

// In VS Code:
// 1. Click on 'calculateUserAge' in the definition
// 2. Press F2
// 3. Type 'computeUserAge'
// 4. Press Enter

// The IDE automatically updates:
// All function calls: computeUserAge(1990)
// All imports: import { computeUserAge } from './utils'
// All exports: export function computeUserAge(birthYear: number)

// Verification script to ensure no stragglers remain
const fs = require('fs');
const path = require('path');

function findSymbolOccurrences(dir, oldName, newName) {
  const results = [];
  const files = fs.readdirSync(dir);
  
  files.forEach(file => {
    const fullPath = path.join(dir, file);
    const stat = fs.statSync(fullPath);
    
    if (stat.isDirectory() && !file.includes('node_modules')) {
      results.push(...findSymbolOccurrences(fullPath, oldName, newName));
    } else if (file.endsWith('.ts') || file.endsWith('.js')) {
      const content = fs.readFileSync(fullPath, 'utf8');
      if (content.includes(oldName)) {
        results.push(fullPath);
      }
    }
  });
  
  return results;
}

const oldSymbol = 'calculateUserAge';
const newSymbol = 'computeUserAge';
const stra

Note: this example was truncated in the source. See the GitHub repo for the latest full version.

Common Pitfalls

  • Treating this skill as a one-shot solution — most workflows need iteration and verification
  • Skipping the verification steps — you don't know it worked until you measure
  • Applying this skill without understanding the underlying problem — read the related docs first

When NOT to Use This Skill

  • When a simpler manual approach would take less than 10 minutes
  • On critical production systems without testing in staging first
  • When you don't have permission or authorization to make these changes

How to Verify It Worked

  • Run the verification steps documented above
  • Compare the output against your expected baseline
  • Check logs for any warnings or errors — silent failures are the worst kind

Production Considerations

  • Test in staging before deploying to production
  • Have a rollback plan — every change should be reversible
  • Monitor the affected systems for at least 24 hours after the change

Quick Info

CategoryRefactoring
Difficultybeginner
Version1.0.0
AuthorClaude Skills Hub
refactoringrenamecodebase

Install command:

curl -o ~/.claude/skills/rename-symbol.md https://claude-skills-hub.vercel.app/skills/refactoring/rename-symbol.md

Related Refactoring Skills

Other Claude Code skills in the same category — free to download.

Want a Refactoring skill personalized to YOUR project?

This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.