Skip to content
AI

GitHub embeds repo rules and agent skills into codebases to guide Copilot behavior

Developers can now embed repository-specific rules, specialised agents and external tool connections directly into their codebases to guide AI behaviour.

Illustration: A sleek silver laptop sits on a wooden desk, its screen displaying lines of abstract white code against a dark background.
AI-generated illustration: TechSec Observer

Key points

  • Repository custom instructions define baseline coding conventions and architecture rules for Copilot.
  • Agent skills package repeatable procedures like testing or debugging into loadable resources.
  • Model Context Protocol servers connect the AI assistant to external tools and data sources.

GitHub published a blog post detailing how developers can tailor GitHub Copilot’s behaviour to specific codebases using custom instructions, agents and Model Context Protocol servers. The update allows teams to embed project-specific knowledge directly into repositories, ensuring the AI assistant adheres to internal standards. This approach enables Copilot to pick up knowledge automatically instead of requiring users to explain the same standards, scripts and workflows every time they start a new task.

Root cause

The need for these features arises because every codebase possesses unique house rules regarding component structure, script execution and framework conventions. Copilot functions most effectively when it understands these specific parameters. By storing this knowledge within the repository, the tool can automatically ingest standards, scripts and workflows. This eliminates the need to manually explain project-specific requirements to the AI assistant at the start of new development tasks.

Attack path

This is not a security vulnerability but a feature enhancement designed to improve developer productivity. The mechanism involves defining context layers that Copilot consults before generating code or executing tasks. These layers include repository-wide instructions, path-specific guidance and specialised agent profiles. The system is designed to interpret these inputs as authoritative context, thereby aligning AI output with the project’s architectural and stylistic expectations rather than relying on generic training data alone.

Affected versions

The features are available to users of the GitHub Copilot app. The documentation outlines four primary methods for tailoring the assistant’s behaviour: custom instructions, custom agents, agent skills and Model Context Protocol servers. Each method serves a different scope, from broad repository standards to specific procedural tasks or external tool integration. Developers can implement these configurations by adding specific files and folders to their repository structure, such as `.github/copilot-instructions.md` or `.github/skills`.

Mitigation

  • Define repository custom instructions in `.github/copilot-instructions.md` to establish baseline architecture and naming conventions.
  • Create path-specific instruction files within `.github/instructions` using the `applyTo` field for targeted guidance.
  • Package repeatable procedures into agent skills located in `.github/skills` for tasks like testing or debugging.
  • Configure custom agents in `.github/agents` for broader, specialised work spanning multiple files and tools.

What to do and how to stay safe: GitHub

  • Audit your repository for existing coding standards and document them in a centralised instruction file.
  • Identify repetitive manual procedures, such as linting or release preparation, and package them as agent skills.
  • Evaluate which external tools or data sources could benefit from integration via Model Context Protocol servers.
  • Review your team’s workflow to determine if custom agents would streamline complex, multi-file tasks.

Step-by-step guide: Prevent Prompt Injection Attacks: Practical Defences for AI Systems

General security guidance from the TechSec Observer newsroom. It is not confirmed advice from the organisations named in this story.

Frequently asked questions

How do custom instructions differ from agent skills?

Custom instructions provide baseline conventions for the whole repository, while agent skills package specific procedures and resources for particular tasks like testing.

Can Copilot connect to external tools?

Yes, through Model Context Protocol servers, which allow the assistant to access external data sources and services like Playwright.

Where are custom agent profiles stored?

Repository-level agent profiles are stored in the `.github/agents` directory within the codebase.

Sources

  1. GitHub
GitHubCopilotAIMCPdeveloper tools

Related stories