Enterprise development teams often need AI code suggestions that reflect internal libraries, proprietary APIs, and company-specific coding standards. GitHub Copilot works well with public code, but without access to your private repositories or documentation, its suggestions can miss the mark. Custom knowledge bases let you feed Copilot your own code context so it generates relevant completions. This article explains how to configure and use GitHub Copilot with custom knowledge bases in an enterprise environment.
Key Takeaways: Setting Up GitHub Copilot Custom Knowledge Bases
- GitHub Copilot Enterprise > Repositories tab: Add internal repositories as knowledge bases to improve code suggestions.
- Indexing permissions: Repository admins must grant read access to the Copilot service account for indexing.
- Knowledge base refresh: Copilot re-indexes knowledge bases every 24 hours or on demand from the settings page.
How GitHub Copilot Custom Knowledge Bases Work
GitHub Copilot Enterprise includes a feature called knowledge bases. A knowledge base is a collection of repositories that Copilot indexes and uses as context when generating code suggestions. When you type code in an IDE connected to GitHub Copilot, the model retrieves relevant snippets from your knowledge base repositories. This makes suggestions more accurate for internal frameworks, custom libraries, and proprietary APIs.
The indexing process runs on GitHub’s servers. The service reads the default branch of each repository you add. It does not store copies of your code outside your GitHub organization. The index is updated automatically every 24 hours, or you can trigger a manual refresh. Only repositories within your GitHub Enterprise organization are eligible for knowledge bases.
To use this feature, you need a GitHub Copilot Enterprise subscription. Individual developers must have a seat assigned in the organization. Repository admins must grant read access to the Copilot service account named github-copilot. Without this permission, the repository will not be indexed and will not appear in suggestions.
Prerequisites for Using Custom Knowledge Bases
Before you begin, verify these requirements:
- Your organization has a GitHub Copilot Enterprise plan. Copilot Business and Copilot Individual do not support custom knowledge bases.
- You are an organization owner or have admin permissions for the repositories you want to add.
- The repositories you add contain code that is relevant to your team’s daily work. Adding unrelated repositories reduces suggestion quality.
- Your IDE is connected to GitHub Copilot and authenticated with your enterprise account.
Steps to Create and Configure a Custom Knowledge Base
- Open GitHub Copilot settings in your organization
Go to your organization’s GitHub page. Click Settings in the top navigation. In the left sidebar, click Copilot then Knowledge bases. This page lists all existing knowledge bases and lets you create new ones. - Create a new knowledge base
Click New knowledge base. Enter a name that describes its purpose, such as internal-api-docs or shared-libraries. The name must be unique within your organization. Click Create. - Add repositories to the knowledge base
On the knowledge base detail page, click Add repositories. Select repositories from the list. You can add up to 100 repositories per knowledge base. Click Add selected. The service begins indexing each repository. Indexing time depends on repository size and number of files. - Verify indexing status
After adding repositories, the knowledge base page shows a status column. Indexed means the repository is ready. Indexing means the process is still running. Failed means the service could not read the repository. Click the status to see error details. - Grant read access to the Copilot service account
For each repository, go to Settings > Collaborators and teams. Add github-copilot with Read role. Without this, indexing fails silently. This step is required only once per repository. - Trigger a manual refresh if needed
On the knowledge base page, click Refresh all to re-index all repositories immediately. The refresh takes a few minutes. Use this after pushing critical updates to a repository.
Using the Knowledge Base in Your IDE
Once the knowledge base is indexed, Copilot automatically uses it when you write code. No additional configuration is needed in VS Code, JetBrains, or other supported IDEs. The model retrieves relevant snippets from your knowledge base repositories and includes them as context for each suggestion.
To verify that the knowledge base is active, open a file that references one of your internal libraries. Start typing a function name from that library. If the suggestion includes your internal code, the knowledge base is working. If suggestions still show only public code, check the indexing status and repository permissions.
Things to Avoid When Using Custom Knowledge Bases
Adding too many repositories reduces suggestion quality
Copilot uses a limited context window. If your knowledge base contains dozens of unrelated repositories, the model may not find the right snippet. Create separate knowledge bases for different teams or projects. For example, create one for front-end libraries and another for backend services.
Storing sensitive secrets in indexed repositories
Copilot indexes files including configuration files and environment examples. If a repository contains real secrets, tokens, or passwords, those values become part of the index. Remove secrets before adding a repository to a knowledge base. Use GitHub secret scanning to detect exposed credentials.
Expecting immediate updates after code changes
The automatic refresh runs every 24 hours. If you push a critical update, trigger a manual refresh. Until the index updates, Copilot uses the previous version of the code. Plan deployments accordingly if your team relies on the knowledge base for new features.
GitHub Copilot Enterprise vs GitHub Copilot Business: Knowledge Base Support
| Item | GitHub Copilot Enterprise | GitHub Copilot Business |
|---|---|---|
| Custom knowledge bases | Supported | Not supported |
| Maximum repositories per knowledge base | 100 | N/A |
| Manual refresh trigger | Yes | N/A |
| Automatic refresh interval | 24 hours | N/A |
| IDE integration | VS Code, JetBrains, Visual Studio, and more | Same IDEs but no knowledge base context |
GitHub Copilot Enterprise includes knowledge bases as a core feature. Copilot Business users cannot create or use knowledge bases. If your organization already uses Copilot Business, upgrading to Enterprise is required to access custom knowledge base functionality.
Now you can configure custom knowledge bases in GitHub Copilot Enterprise to improve code suggestions for your internal codebase. Start by creating a knowledge base for your most-used shared library. After indexing, test suggestions in a file that imports that library. For larger organizations, create multiple knowledge bases per team and refresh them manually after major releases to keep suggestions current.