A seamless development workflow, where tools are always ready and builds run without surprises, is key to productivity. You can achieve this level of efficiency and reliability by tailoring the environment for the GitHub Copilot Coding Agent. This customization eliminates the delays and errors that can occur when Copilot installs dependencies on its own, allowing it to focus on generating code.
How Preinstallation Works in Copilot
Copilot operates within an ephemeral GitHub Actions environment. To ensure all the right dependencies are available, you can set up a dedicated workflow file called .github/workflows/copilot-setup-steps.yml
in your repository. This file defines a single, crucial job: copilot-setup-steps.
It runs before Copilot takes over, giving you control to install compilers, libraries, and any other project essentials.
- Job Naming: Name the job copilot-setup-steps for it to be recognized.
- Permissions: Use the minimum permissions necessary, such as
contents: read
for code checkout.- Customization: Adjust steps, permissions, runner types, containers, services, and timeouts (up to 59 minutes) as needed.
Example: Preparing a TypeScript Environment
For a TypeScript project, your workflow might:
- Clone the repository with
actions/checkout@v4
- Set up Node.js using
actions/setup-node@v4
- Install dependencies via
npm ci
This setup file runs automatically with changes and can be triggered manually, letting you validate the environment before Copilot gets to work.
name: "Copilot Setup Steps"
# Automatically run the setup steps when they are changed to allow for easy validation, and
# allow manual testing through the repository's "Actions" tab
on:
workflow_dispatch:
push:
paths:
- .github/workflows/copilot-setup-steps.yml
pull_request:
paths:
- .github/workflows/copilot-setup-steps.yml
jobs:
# The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot.
copilot-setup-steps:
runs-on: ubuntu-latest
# Set the permissions to the lowest permissions possible needed for your steps.
# Copilot will be given its own token for its operations.
permissions:
# If you want to clone the repository as part of your setup steps, for example to install dependencies, you'll need the `contents: read` permission. If you don't clone the repository in your setup steps, Copilot will do this for you automatically after the steps complete.
contents: read
# You can define any steps you want, and they will run before the agent starts.
# If you do not check out your code, Copilot will do this for you.
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
- name: Install JavaScript dependencies
run: npm ci
In your copilot-setup-steps.yml file, you can only customize the following settings of the copilot-setup-steps job. If you try to customize other settings, your changes will be ignored.
- steps
- permissions
- runs-on
- container
- services
- snapshot
- timeout-minutes (maximum value: 59)
Configure Environment Variables and Secrets
If your project relies on configuration or authentication, set environment variables and secrets within the copilot environment under repository settings. Use GitHub Actions secrets for sensitive information like API keys, keeping them secure and out of your codebase.
Boosting Performance with Larger Runners
Handling large projects or heavy testing? Upgrade to bigger GitHub-hosted runners for more CPU, RAM, and storage. Just add the appropriate runners to your repo and specify them in the runs-on
field of your workflow. This ensures Copilot has the resources it needs for demanding workflows.
- Supported runners: Only Ubuntu x64 Linux
- Unsupported: Self-hosted, Windows, and macOS runners
Enable Git LFS Support
For teams using Git Large File Storage (LFS), be sure to enable LFS in your workflow. Add the lfs: true
option to the actions/checkout
step, ensuring Copilot has access to all necessary assets and files.
Workflow Management and Validation
Every update to your setup workflow triggers a validation run in GitHub Actions, with results shown alongside other pull request checks. You can also trigger the workflow manually, making it easy to catch and fix environment issues early.
Key Takeaway: Consistency and Speed for Automated Coding
By preconfiguring your development environment, Copilot Coding Agent can focus on what it does best, coding, testing, and automating workflows, without unnecessary setup delays. Managing dependencies, environment variables, compute resources, and LFS support from the start leads to faster feedback and more predictable automation outcomes.
Source: GitHub Docs: Customizing the development environment for Copilot coding agent
Supercharge GitHub Copilot Coding Agent with a Customized Dev Environment