Skip to main content
In this lesson you’ll get a handful of practical, low-friction changes that make GitHub Copilot produce better code for you right away. These quick wins focus on repository-level configuration, editing habits, how to review completions, choosing models, and keeping your editor context tight so Copilot’s suggestions are more accurate and consistent.

1) Repository-level Copilot instructions

A simple, high-impact step is to add repository-specific instructions so Copilot knows your coding standards and style preferences. Create a .github folder at the repo root and add a Markdown file named copilot-instructions.md. GitHub Copilot will consult this file when generating code for that repository. Steps to create the file:
Where to put it and why: Example copilot-instructions.md (PEP 8–oriented) — this is a practical template you can adapt to your project:
Saving this file at .github/copilot-instructions.md biases Copilot toward the conventions you enforce across the repository, producing more consistent and reviewable suggestions.
Put repository-wide rules in .github/copilot-instructions.md so Copilot automatically uses them for code generation in that repo.

2) Example output you can expect

When Copilot follows the PEP 8 guidance above, generated Python code will be more consistent: proper naming, type hints, docstrings, and readable formatting. Here are two concise examples that illustrate the expected style. Example: function with type hints and docstring
Example: another well-documented, PEP 8–style function
Tip: prompting Copilot with a clear comment such as # function to calculate the sum of two integers can produce quick results, but using Copilot Chat or the completions panel typically yields suggestions that better respect copilot-instructions.md.

3) Copilot Chat, completions panel, and keyboard shortcuts

Copilot provides both a Chat interface and a Completions panel. The Completions panel surfaces multiple candidate implementations so you can compare alternatives (different shapes of type hints, various docstring styles, handling edge cases, etc.) and pick the best fit. Customizing and memorizing keybindings for actions like opening Copilot Chat, toggling completions, and accepting suggestions saves time. Make sure you know the shortcuts your editor exposes and optionally customize them to match your workflow.
A code editor's keyboard shortcuts/settings panel listing GitHub Copilot commands, their keybindings, conditions, and sources, with "Chat: Open Copilot Edits" highlighted. A cursor points at an Enter key icon in the keybinding column.
When you open the completions panel and ask for something like “Create square of a number,” you’ll often see several suggestions side-by-side. Review for type hints, docstrings, and edge-case handling, then accept the variant that best matches your style and requirements.

4) Model selection and editor context

Copilot may offer different backend models depending on your plan and environment. Switching models is a fast way to get a different style or level of reasoning when the first set of completions isn’t ideal. Also ensure the file you want Copilot to consider (for example, main.py) is the active editor tab — Copilot uses the active editor context to generate relevant completions. If the wrong file is active or the editor has too many open tabs, Copilot may use less relevant context.
A screenshot of a dark-themed code editor (likely VS Code) showing a terminal tab, a large mouse cursor over an empty editor pane, and a Copilot chat box asking "How do I test this function?". The status bar at the bottom shows editor details like line/column, encoding, and Python environment.
Practical checklist:
  • Try switching models if suggestions lack creativity or precision.
  • Keep the target file open and active during code generation.
  • Use Copilot Chat for stepwise reasoning or to ask clarifying questions.

5) Keep the editor context focused

Large projects and many open files can push relevant code out of Copilot’s context window. To improve suggestion accuracy:
  • Close unrelated tabs and only keep files relevant to the current task open.
  • Fold large files or split work into smaller focused files/modules where possible.
  • Open and highlight the specific function or class you want Copilot to reason about.
Smaller, focused context results in more relevant completions and fewer false positives.

Next steps: comment-driven development

After you’ve added repository instructions, explored the completions panel, and tuned your editor settings, try comment-driven development: write clear comments or TODOs that describe the behavior you want, then use Copilot to generate the implementation. Iterate by refining comments or asking Copilot Chat for improvements. A good hands-on exercise is building a fake-data generator or a small CLI that demonstrates generating functions, tests, and docs from comments. This helps you practice prompting, model switching, and instruction refinement.

Watch Video