Blog

GitHub Copilot: Custom Agents

There is immense value in customizing the GitHub Copilot Coding agent for GitHub Enterprise Organizations.

Recently, I wanted to build a custom agent to evaluate source code against our standards—specifically around linting, unit tests, code quality, and style requirements for all of our Python AWS Lambda functions.

In the customer’s environment, each Lambda function lives in its own dedicated Git repository with its own distinct workflows for CI, CD, and Infrastructure as Code (IaC). The goal was straightforward: ensure that every single Lambda repository adhered to the following standards:

  • Dependency & Project Management: Standardized pyproject.toml using uv.
  • Testing: Minimum 80% unit test coverage requirement.
  • Code Quality: pylint score of 8.0 or higher.
  • Directory Structure: A consistent, enforced folder layout across every repo.

With multiple developers on a team working on different Lambda functions, it’s natural for everyone to want to bring their own personal style. However, when you’re evaluating or maintaining several Lambdas that comprise a larger serverless application, maintaining identical layout and quality standards is crucial.

It’s a lesson I learned back in my early sysadmin days managing hundreds of physical servers. Back then, every server was jumpstarted / kickstarted with a specific, baseline configuration. When something broke at 2 AM, troubleshooting was significantly easier simply because you always knew where to look for logs, configs, and scripts. The same principle applies to modern serverless codebases.

After multiple iterative prompts with GitHub Copilot to draft the custom agent’s instructions and supply concrete examples of the expected repository structure, the results were better than expected. When the agent is executed against out-of-standard repositories, it immediately finds the gaps and provides tailored code suggestions.

The agent was shared across the GitHub organization by placing the .agent.md file in a central .github-private repository under .github-private/agents/. This allows other Python developers across teams to use the agent to evaluate their source code locally as well.

While our CI workflows still perform the definitive quality gates for linting, coverage, and static analysis, allowing developers to execute a targeted agent before pushing code saves valuable developer time—and reduces unnecessary compute costs on our GitHub runners.