Featured image of post GitHub Copilot With VS Code Tricks 101

GitHub Copilot With VS Code Tricks 101

A comprehensive guide to the most important tricks for maximizing your productivity with GitHub Copilot in VS Code.

“The more efficiently you utilize tools, the more time you save for yourself.”


1. Microsoft’s Developer Tools Evolution

1.1 Visual Studio Code

ms money
Source

Launched in 2015, Visual Studio Code (VS Code) quickly became the editor of choice for millions of developers. Its open-source foundation, cross-platform support, and rich extension ecosystem make it both lightweight and powerful.

  • Key Facts: Open-source, includes a web version, and offers IDE-level features.
  • 2021: Integration with GitHub Copilot, bringing AI-powered code suggestions.
  • 2024: Remains the most popular and powerful code editor.

Which development environments did you use regularly over the past year, and which do you want to work with over the next year? Please check all that apply

vscode

Ask yourself why people love it; try it yourself and you will love it too.

1.2 GitHub Copilot

“The more efficiently you utilize tools, the more time you save for yourself.”

  • 2014: Microsoft’s Bing Code Search plugin for Visual Studio.

  • 2018: Microsoft acquires GitHub for $7.5B, gaining massive code data for AI.

    People Hate Acquisitions

  • 2019: Microsoft invests $1 billion and supports many initiatives with OpenAI.

  • 2020: OpenAI’s GPT-3 launches, enabling code generation.

  • 2021: Copilot debuts in VS Code, then expands to JetBrains IDEs and Neovim.

  • 2022: Copilot becomes a paid subscription, available in Visual Studio.

Which AI-powered search and developer tools did you use regularly over the past year, and which do you want to work with over the next year? Select all that apply.

github copilot

Copilot Usage & Privacy

Admins see only high-level usage, not your code or prompts.

Our Subscription Type


2. Key Features of GitHub Copilot

2.1 Code Completion

Copilot provides smart, context-aware suggestions as you type, supporting multiple IDEs.

Three ways to use Code Completion:

  • Ghost Text: As you type, Copilot suggests code in a faded ‘ghost text’ format. Accept with Tab.

    ghost text

  • Inline Chat: For interactive suggestions, use Copilot’s inline chat (Ctrl+I) for conversational code generation.

    inline chat

  • Comment-driven Suggestions: Write comments describing your intent, and Copilot generates code to match.

    ghost text from code comments

2.2 Interact Via Chat Windows

Mode Control Style Feature Ideal For
Ask 🟢 Manual Google for code—embedded in your editor Learning, exploring, debugging logic
Edit 🟡 Semi-automated A dev who follows your exact orders Refactoring, quick fixes, inline changes
Agent 🔴 Autonomous A 10x dev who takes your idea and runs with it Feature building, automation, workflows

Showcase: Agent in Action

Agent edits code and adds debug comments for verification.

Agent edits code and adds debug comments

Agent uses git to revert file after an error.

Agent uses git to revert file


3. Choosing the Right Model

By default, Copilot Chat uses GPT-4.1 for fast, capable responses across coding, summarization, and reasoning tasks.

Each model has unique strengths. You may prefer a specific model for certain tasks.

Model type Models
Fast coding • GPT-4o• Claude Sonnet 3.5• Claude Sonnet 3.7• Gemini 2.0 Flash
Reasoning/planning • Claude Sonnet 3.7 Thinking• o1• o3-mini

The higher the Rate value, the more professional the model might seem — but I’m not so sure about that.

Example:

  • Using o1 in Copilot Chat: With a 10× multiplier, one interaction counts as 10 premium requests.
  • Using GPT-4.1 on Copilot Free: Each interaction counts as 1 premium request.
  • Using GPT-4.1 on a paid plan: No premium requests are consumed.

models models

Source


4. Prompting Tips for Copilot

4.1 The Three “S’s”: Simple, Specific, Short

  • Keep prompts concise and focused for best results.

4.2 Start General, Then Get Specific

1
2
3
Generate a PemConverter class.
Add methods for convert_to_pkcs12, encrypt_rsa, decrypt_rsa
Don't use any external libraries

4.3 Give Examples of Input/Output

If you don’t have the right keyword vocabulary to hit the main point, then instead of rambling, it’s better to give Copilot an example with input and output.

io

4.4 Break Down Complex Tasks

Instead of asking Copilot to generate a travel planner app, break it down into smaller tasks:

  • Generate a function that takes a list of destinations and returns the best route.
  • Generate a function that takes a list of hotels and returns the best hotel for each destination.
  • Generate a function that takes a list of restaurants and returns the best restaurant for each destination.

4.5 Keep Chat History Relevant

  • Reset or revert context by deleting questions/responses in the chat window.
  • Create multiple chat windows to separate context, and switch between them easily via the “Show Chat” button.

4.6 Provide the Right Context

Give Copilot relevant context: code selections, files, terminal output, and more.

  • Example: Where is the audit class used in the #codebase to add a new model for auditing?

More tips in the official guide and here.


5. Copilot Cheat Code For Context

Context is the key for Copilot to provide relevant solutions. Always provide the context of your question.

  • Code Selection: When prompting, always have the related parts of your code selected. This is the most direct way to provide immediate context.
  • Adding Relevant Files: Use the “Add Context” button in Copilot Chat to include additional files that might be relevant to your query, such as Source Control to help find a specific commit.
    • source_control
  • Visual Context: You can even paste images directly into the Chatbox for visual context, which can be particularly useful for UI-related tasks or explaining complex diagrams.
  • Specific Location Mentions: Copilot supports various mentions to refer to specific locations within your project or external resources:
    • #file:: Mention a file in your project (e.g., #file.py, #file.js).
    • #class:: Reference a specific class (e.g., #class MyClass).
    • #header:: Point to a header within a document (e.g., #header MyHeader).
    • #extensions: Find existing extensions based on your needs (e.g., #extensions The tool helps format the code on save).
    • #fetch: Refer to a website (e.g., who is he #fetch https://hoangyell.com/about/).
    • #githubRepo: Reference a GitHub repository (e.g., what does this repo do #githubRepo opendatalab/MinerU).
    • #problems: Address issues raised in the PROBLEMS tab (e.g., /fix #problems).
    • #testFailure: Refer to test failures in the TEST tab (e.g., /fix #testFailure).
    • #codebase:: Refer to your entire codebase for broad queries (e.g., list all the functions in this project from #codebase).
  • Scope-based Context (@scope_name): For broader context, especially in Ask/Edit Mode, use @scope_name at the beginning of your prompt:
    • @workspace:: Refers to your entire project, allowing Copilot to understand the context of your codebase (e.g., @workspace list some shortcodes defined in this project?). This is often the most powerful scope in Ask Mode.
      • @workspace
      • @workspace
      • @workspace is the most powerful scope in Ask/Edit Mode; remember to use it in most cases.
    • @terminal:: Interact with the terminal (e.g., @terminal I want to get the path of the current directory).
    • @github:: Interact with GitHub (e.g., @github some of HoangYell's repositories).
      • @github
      • @github
    • @vscode:: Ask VS Code to perform actions directly (e.g., @vscode change theme).
  • Quick Commands: Leverage pre-defined quick commands to streamline common tasks and avoid recreating existing prompts.Examples include /fix (proposes solutions for problems in selected code), /search (integrates with VS Code\’s search UI), /explain (explains selected code), and /tests (generates tests).
    • /search author is hoangngo@paradox.ai or hoang.ngo@paradox.ai → VS Code will help you by hinting a Search UI and prefill regex value to achieve that purpose in case you don’t know what regex should be or where the UI button is.

Managing Agent Mode Changes:

  • While Agent Mode offers significant autonomy, it cannot undo all changes. Fortunately, the “Undo Last Request” and “Redo Last Request” buttons in the top right corner of the chat panel provide a safety net for reverting or redoing your last request.
  • Additionally, you can save time by reusing previous prompts by hitting the up arrow when your cursor is at the bottom of the chat panel, allowing you to navigate through your prompt history.

6. MCP (Model Context Protocol)

The Model Context Protocol (MCP) lets AI agents like Copilot interact with data from external sources—bridging your AI assistant and your favorite apps.

  • @github
  • @github

6.1 Example Scenario

Suppose you have a powerful AI Agent tool (like VS Code + GitHub Copilot) and you love using your favorite Note App (like Notion).

You dream: “What if my AI Agent could read and write my notes? That would be awesome!” 🚀

But there’s a problem: your Note App doesn’t “speak AI” yet — no MCP adapter. 😢 And… you don’t know how to build one yourself.

One day, a mysterious hacker in a black hoodie 🕵️‍♂️ pops up on GitHub:

“Hey! I built an unofficial MCP adapter for Notion. Just give me your API key — it’ll work like magic!”

Excited, you think: “Wow! This is exactly what I need!” 🤩 You plug it in — boom! Your AI Agent is happily reading and writing your notes. Life is good.

…until a few days later — you check your crypto wallet (Metamask). 💸 It’s empty. You’re broke.

Why?
Because you trusted an unverified MCP server — a total stranger — with full access to your data. The server acted as a man-in-the-middle 🕵️, intercepting everything:

  • The hacker now has your API key 🔑
  • They can:
    • Steal your personal information
    • Phish you — using your own notes!

6.2 Safe MCP Usage

Q: Sound scary?
A: Yes, but here’s how to use MCP safely:

Option 1: Build Your Own MCP Server

MCP Security Checklist

  • ✅ DO: Use official, verified MCP servers
  • ✅ DO: Build your own if you have the expertise
  • ❌ DON’T: Trust random MCP servers from unknown sources
  • ❌ DON’T: Share API keys with unverified third parties

7. ToolSet

ToolSet = Agent Prompt + Limited Declared Tools
Helps the Agent know what tools it can use, avoiding overuse of MCP tools.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
{
  "yell-tool-sets-1": {
    "tools": [
      "fetch",
      "get_me",
      "get_pull_request",
      "get_pull_request_comments",
      "list_notifications",
      "get_notification_details"
    ],
    "description": "\n1. Fetch the latest post title from hoangyell.com.\n2. Using GitHub MCP, browse the repository `Hoang-Yell/Test`, create a new issue summarizing the latest blog post, and add a comment with the post title from hoangyell.com",
    "icon": "tools"
  }
}

8. 🛎️ Configure Custom Instructions

Source

VS Code Copilot supports custom instructions for different scenarios:

Type of instruction Description
Chat behavior chat.instructionsFilesLocations - These instructions influence Copilot’s conversational style and how it responds to your queries in the chat interface. You can set its persona, verbosity, or preferred tone.
Code generation github.copilot.chat.codeGeneration.instructions - These instructions guide Copilot when generating code snippets or full functions. You can specify preferred languages, coding conventions, or even architectural patterns.
Test generation github.copilot.chat.testGeneration.instructions - Define how Copilot should generate unit tests, including preferred testing frameworks, assertion styles, and coverage requirements.
Code review github.copilot.chat.reviewSelection.instructions - Provide guidelines for Copilot when it performs code reviews, such as focusing on specific code quality metrics, security vulnerabilities, or performance optimizations.
Commit message generation github.copilot.chat.commitMessageGeneration.instructions - Customize the style and content of commit messages generated by Copilot, ensuring they adhere to your team’s conventions (e.g., conventional commits, Jira ticket integration).
Pull request title and description generation github.copilot.chat.pullRequestDescriptionGeneration.instructions - Instruct Copilot on how to generate clear and concise pull request titles and descriptions, including relevant information like changes made, features implemented, or bugs fixed.

8.1 Prepare Instruction Files

Create a file-name.instructions.md for each instruction type, e.g.:

  • component-feature-checklist.instructions.md
  • code-review-checklist.instructions.md
  • auto-commit-message-complement.instructions.md

Tips for Defining Custom Instructions

  • Keep instructions short and self-contained.
  • Use multiple files for organization.
  • Version control your instruction files.
  • Use the applyTo property to target specific files/folders.
1
2
3
---
applyTo: "**/*.js,**/*.py"
---
  • Reference instruction files in your prompt files to keep prompts clean.

8.2 Customizing Instruction File Locations

By default, Copilot looks for instruction files in specific locations within your project. However, you can customize these locations to better suit your project structure or personal preferences. This is particularly useful for monorepos or projects with complex directory layouts.

To change the default instruction folders, navigate to your VS Code settings and search for github.copilot.chat.. Here, you can specify an array of glob patterns that point to the directories where your .instructions.md files are stored. This allows for flexible organization of your custom instructions.

config_custom_instruction_path

8.3 Usage

Example: Custom Instruction for Auto-Generated Commit Message

  • Settings -> github.copilot.chat.commitMessageGeneration
  • Use a .instructions.md file or direct text in settings
1
2
3
4
5
6
7
8
"github.copilot.chat.commitMessageGeneration.instructions": [
    {
        "text": "Use conventional commit message format. Follow format `<type>(YELL-1234): <subject>`"
    },
    {
        "file": "content/post/ai/instructions/copilot-commit-message.instructions.md"
    }
],

Integration tests, or end-to-end tests, and define the structure and assertion methods to be used.

8.4 Configuration Example

Reference custom instruction files in .vscode/settings.json:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"chat.instructionsFilesLocations": {
    "your/path/to/instructions": true,
    ".github/instructions": false,
},
"github.copilot.chat.codeGeneration.instructions": [
  {
    "text": "Always add a comment: 'Generated by YellCode'. Variable/class/method names always start with 'yell'."
  }
],
"github.copilot.chat.commitMessageGeneration.instructions": [
  {
    "text": "Use conventional commit message format. Follow format `<type>(YELL-1234): <subject>`"
  }
],
"github.copilot.chat.reviewSelection.instructions": [
  {
    "text": "Always add with Prefix is YellReview."
  },
  {
    "file": ".copilot-review-instructions.md"
  }
],
"github.copilot.chat.testGeneration.instructions": [
  {
    "text": "Always try uniting related tests in a suite."
  }
],
"github.copilot.chat.pullRequestDescriptionGeneration.instructions": [
  {
    "text": "Include every commit message in the pull request description with Prefix is YellReview."
  }
]

9. Key Takeaways

🎯 Context is King:
Always provide relevant context—select code, mention files, and use scopes like @workspace or #file: to help Copilot understand exactly what you want.

🛠️ Choose the Right Mode:
Use Ask for learning and exploration, Edit for precise refactoring or quick fixes, and Agent for automating complex workflows or building features.

💡 Prompt Effectively:
Write prompts that are simple, specific, and short. Break down complex tasks, provide examples, and iterate step by step for best results.

🔍 Leverage Chat and Tools:
Take advantage of Copilot Chat, context commands, and toolsets to streamline your workflow. Use quick commands like /fix, /explain, and /tests to save time.

🔒 Prioritize Security:
Only use official or self-hosted MCP servers. Never share sensitive credentials with untrusted sources. Always review Copilot’s code for correctness and security.

⚙️ Personalize and Automate:
Customize Copilot with instruction files, commit message templates, and code generation preferences to match your team’s standards and your own workflow.

📈 Stay in Control:
Copilot should stick to its name—co-pilot. So, who’s the pilot? You are! Never let Copilot overtake your knowledge or decision-making. Trust me, if you let it fly solo, you might end up with a bowl of spaghetti soup code you’ll regret one day.

🚀 Keep Exploring:
Copilot and VS Code are evolving rapidly. Stay updated with new features, experiment with different models, and share your learnings with the community.

🤝 Collaborate and Share:
Share your custom instructions, prompt strategies, and toolsets with your team to help everyone get the most out of Copilot.


With these takeaways, you’ll be equipped to make Copilot a true partner in your development journey—helping you code smarter, faster, and more securely.

Made with the laziness 🦥
by a busy guy

Subscribe to My Newsletter