Unlocking Custom Copilot Agents in VS Code: A Developer's Guide to Enhanced Productivity

GitHub Copilot is rapidly evolving, offering developers powerful AI assistance. One of its most promising features is the ability to create custom agents, allowing users to tailor Copilot's persona and knowledge for specific tasks. However, as jedrekdomanski discovered in a recent GitHub Community discussion, getting these custom agents to work seamlessly in VS Code can sometimes be tricky.

Jedrek was attempting to create a global linux-engineer agent for a multi-project workspace. Despite following the initial instructions, placing the .agent.md file in the recommended ~/.github/agents/ directory, and configuring VS Code settings, the agent simply wouldn't appear in the Copilot Chat dropdown. This common hurdle highlights several key aspects of custom agent setup that can trip up even experienced users.

Developer selecting a custom Copilot agent from a dropdown in VS Code.
Developer selecting a custom Copilot agent from a dropdown in VS Code.

Common Pitfalls and Solutions for Custom Copilot Agents

The community quickly rallied, with users like Shiven0504 and chamithsilva10 providing comprehensive solutions. Here’s a breakdown of the critical insights:

1. Tilde (~) Is Not Expanded in VS Code Settings

One of the most frequent causes of agents not appearing is the misunderstanding of how VS Code handles file paths in chat.agentFilesLocations. VS Code does not automatically expand the tilde (~) character to your home directory. It treats it as a literal path, meaning your agent file might never be discovered.

  • Fix: Always use absolute paths in your settings.json. For example, instead of ~/.github/agents, use /home/yourusername/.github/agents (replacing yourusername with your actual system username).
"chat.agentFilesLocations": [
    ".github/agents",
    ".claude/agents",
    "/home/yourusername/.copilot/agents",
    "/home/yourusername/.github/agents"
]

2. Malformed YAML Frontmatter

The frontmatter at the beginning of your .agent.md file is crucial for defining the agent's name and description. If this YAML is malformed, VS Code will silently skip the file, preventing your agent from loading.

  • Fix: Ensure your YAML frontmatter is perfectly valid, especially that all strings are properly quoted and closed.

Bad Example:

---
name: linux-engineer
description: "Linux System Administrator and Engineer.
---

Good Example:

---
name: linux-engineer
description: "Linux System Administrator and Engineer."
---

3. Incorrect Invocation Method

Many users, including jedrek, initially try to invoke custom agents by typing @agentname in the chat window. However, this method is reserved for built-in "chat participants" like @workspace or @terminal.

  • Fix: Custom agents are selected via the agent picker dropdown at the bottom of the Copilot Chat panel. Once selected, you can then type your prompts normally without the @ prefix.

4. Custom Agents vs. Chat Participants

As Shiven0504 clarified, it's important to distinguish between "chat participants" and "custom agents." Chat participants are built-in specialists (e.g., @workspace, @terminal) that respond to the @ symbol. Custom agents, on the other hand, act as a custom system prompt or persona that shapes Copilot's behavior in "Agent mode." They are chosen from the dropdown, not invoked with @.

Recommended Setup: Let VS Code Create It

To avoid many of these issues, the most reliable method is to let VS Code create the agent file for you:

  1. Open the Command Palette (Ctrl + Shift + P or Cmd + Shift + P).
  2. Run: Chat: New Custom Agent.
  3. Choose User Profile for a global agent (not Workspace).
  4. VS Code will automatically create the agent file in the correct, discoverable location.
  5. Always reload the window (Developer: Reload Window) after making changes to agent files or settings.
Illustration showing the difference between an unexpanded tilde path and a correct absolute file path for agent configuration.
Illustration showing the difference between an unexpanded tilde path and a correct absolute file path for agent configuration.

Summary Checklist for Custom Copilot Agents

To ensure your custom Copilot agents appear and function correctly, remember these key points:

  • ✅ Use absolute paths in chat.agentFilesLocations.
  • ✅ Ensure your agent's frontmatter has valid YAML.
  • ✅ The file extension must be .agent.md.
  • ✅ Always reload VS Code after changes.
  • Select your agent from the dropdown in Copilot Chat, do not use @.

By understanding these nuances, developers can effectively leverage custom Copilot agents to streamline their workflows, making them a valuable tool in any developer personal development plan aimed at boosting productivity and mastering new technologies. Tailoring your AI assistant is a powerful step towards a more efficient and personalized coding experience.

Track, Analyze and Optimize Your Software DeveEx!

Effortlessly implement gamification, pre-generated performance reviews and retrospective, work quality analytics, alerts on top of your code repository activity

 Install GitHub App to Start
devActivity Screenshot