CodePilot supports two GitHub authentication modes.
auto -> use GitHub App when app config is present, otherwise use PAT
pat -> always use CODEPILOT_GITHUB_TOKEN
app -> always use GitHub App installation tokens
PAT mode is the simplest self-hosted setup.
CODEPILOT_GITHUB_AUTH_MODE=pat
CODEPILOT_GITHUB_TOKEN=<fine-grained token>Recommended fine-grained token permissions:
Metadata: ReadContents: ReadPull requests: Read and writeIssues: Read and writeContents: Read and writeonly if@x-pilotx fixis enabled and allowed to push commits
PAT mode is acceptable for local development and small self-hosted instances. It is not a good enterprise or SaaS story because one long-lived token can cross repository boundaries if it is over-scoped.
GitHub App mode is the preferred production direction. CodePilot creates a short-lived app JWT, resolves the repository installation, mints an installation access token, and caches it until shortly before expiration.
CODEPILOT_GITHUB_AUTH_MODE=app
CODEPILOT_GITHUB_APP_ID=<app id>
CODEPILOT_GITHUB_APP_PRIVATE_KEY_BASE64=<base64 encoded private key>
CODEPILOT_GITHUB_APP_INSTALLATION_ID=
CODEPILOT_GITHUB_APP_TOKEN_CACHE_SKEW_SECONDS=60CODEPILOT_GITHUB_APP_INSTALLATION_ID is optional. When it is empty, CodePilot looks up the installation by repository with GET /repos/{owner}/{repo}/installation. Set it only for a single-installation self-hosted deployment where you want to avoid that lookup.
Recommended GitHub App permissions:
Metadata: ReadContents: ReadPull requests: Read and writeIssues: Read and writeContents: Read and writeonly if fix mode is enabled
Recommended GitHub App webhook events:
Pull requestIssue comment
Prefer CODEPILOT_GITHUB_APP_PRIVATE_KEY_BASE64 for Docker, CI, and server .env files.
# PowerShell
[Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes((Get-Content .\codepilot-app.private-key.pem -Raw)))CODEPILOT_GITHUB_APP_PRIVATE_KEY also works when the runtime supports multi-line values or escaped \n newlines.
- Store PATs, app private keys, webhook secrets, and internal API keys in
.envfiles, server secret stores, or GitHub Actions secrets. - Do not commit real secrets to the repository.
- Do not paste real secrets into PR comments, issue bodies, shell history, or CI logs.
- Use least-privilege GitHub permissions and install the GitHub App only on repositories CodePilot should review.
- Set
CODEPILOT_GITHUB_ALLOWED_REPOSITORIES=owner/repo,org/servicein production to keep webhook-triggered work inside the expected repository boundary.
This implementation removes the hard dependency on a single global PAT for review, linked issue lookup, summary comments, inline comments, file reads, and fix-mode clone tokens.
It does not implement a multi-tenant SaaS installation database. A self-hosted instance still has one configured GitHub App identity. Multi-tenant SaaS would need persistent tenant/install mapping, per-tenant policy, audit logs, and admin UI.