← Back to Main Page

Let Copilot Help You Name Things

Posted on Apr 25, 2025

Naming things is hard. Whether it’s a new function, a database field, or a variable inside a loop, finding the right name can break your flow. GitHub Copilot can help suggest clear, consistent names based on the surrounding code and its intended purpose. Let’s break it down!

ProTip
Use Copilot to Generate Better Names—Functionally and Descriptively
Instead of overthinking or leaving temp, foo, or xyz in your code, ask Copilot for name suggestions that are more descriptive and easier to maintain.

Here’s how to do it:
1️⃣ Copilot Chat: Ask for a Better Name
// Suggest a more descriptive name for this function that calculates discount based on user role and cart total
2️⃣ Edit Mode: Inline Rename Prompt
Highlight the function or variable, then use a comment like:
# Rename this variable to better reflect what it represents
Then trigger Copilot Agent Mode and apply the change in one go.
3️⃣ Agent Mode: Naming Conventions at Scale
Generate consistent variable and method names across all controllers based on their purpose (CRUD pattern)
Perfect for larger refactors or codebase cleanups.

Extra Prompts to Try:
• # Rename this class to better describe what it models
• # What’s a better name for this loop counter?
• # Suggest field names for a form collecting user contact details
• // Rename this test to clearly describe what it's testing

Quick Takeaway
Don’t let naming slow you down. Let Copilot help you pick clear, practical names that make your code easier to read—and easier to revisit next week.