Back to insights
Length:
8 min
Published:
November 26, 2025
This time we'll follow up on the first part of "How to get started with GitHub Copilot? #1", where we covered its main features, setup, and overall first steps to get started. If you missed that article, we recommend starting there.
Now we'll move on a bit and show you what else Copilot can help you with, specifically going over refactoring, optimization and test generation.
It is in these areas that Copilot can deliver very concrete results. Teams that use it to its fullest extent report significant reductions in code editing time, faster test generation, and overall higher quality output. Developers spend less time on routine tasks and can focus more on key parts of the application.
What exactly does Copilot bring to the table:
Copilot is useful not only for writing new code, but also for modifying existing code - improving readability, structure and performance.
Examples of use:
You can mark a complex function and ask Copilot to break it down into logical, separate parts:
def process_data_and_generate_report(data):
# loading, cleaning, analysis, report generation...
pass
# Prompt in Copilot Chat:
# "/refactor Split this function `process_data_and_generate_report` into smaller parts."
# One of Copilot's possible suggestions:
def load_data(data):
pass
def clean_data(data):
pass
def analyze_data(data):
pass
def generate_report(data):
pass
Ask Copilot for more meaningful names:
tmp = 10
# Prompt:
# "Rename `tmp` to a more descriptive name."
# Copilot might suggest:
customer_age = 10
For example, complex conditions can be made clearer:
if (user.isAdmin === true && user.isActive === true && user.hasPermission('edit')) {
// ...
}
// Prompt:
// "/refactor Simplify this condition"
// Copilot may suggest:
if (user.isAdmin && user.isActive && user.hasPermission('edit')) {
// ...
}
Copilot can design more efficient data structures or algorithms:
# Original:
for i in range(len(my_list)):
if my_list[i] == value:
# ...
# Prompt:
# "/optimize This loop for better performance"
# Copilot's suggestion:
if value in my_list:
# ...
/refactor - refactors the selected block according to the input/optimize - suggests performance improvements/explain - explains what the code block does, which helps you understand it better before editingSource: GitHub Docs
In this section, Copilot combines test generation with support for debugging and bug fixing to speed up development and improve code quality.
/tests in Copilot Chat (or highlight the code in the editor) to have Copilot design unit tests according to your function./setupTests, which sets up a test environment for the whole project (select a framework, create a file, etc.)./fix - Copilot will offer the corrected version./fixTestFailure can be used - Copilot analyzes the failure and suggests a fix./startDebugging to create a debugging configuration ("launch configuration") and start debugging directly from Copilot Chat.def compute_factorial(n):
factorial = 1
for i in range(1, n + 1):
factorial *= i * factorial # bug: multiplies by factorial extra
return factorial
Prompt for debugging:
/explain Why does this function compute factorial incorrectly?
After that:
/fix Fix the logic so it calculates factorial correctly.
Copilot can suggest a corrected version:
def compute_factorial(n):
factorial = 1
for i in range(1, n + 1):
factorial *= i
return factorial
This section is about how Copilot will make it easier to write documentation and get new developers involved in the project.
/doc command to let Copilot generate docstrings, comments, or descriptions of functions and classes.GitHub Copilot is more than just a tool for quickly writing new code. It's a powerful assistant that greatly helps with activities that developers often put off - like refactoring, optimizing, or generating tests. And it's in these areas that it can deliver immediate results: from speeding up development and reducing technical debt to better quality code and increased test coverage.
In the next article, we'll summarize how to improve the quality of Copilot's outputs and go over advanced features and integrations.
Back to insights
Don't miss our best insights. No spam, just practical analyses, invitations to exclusive events, and podcast summaries delivered straight to your inbox.