answered from live GitHub & Hugging Face data
How do I set up a separate GitHub App for my coding agent like Claude Code to handle its identity?
Register one GitHub App for each agent, install it on one repository, and give the agent short-lived installation tokens. This gives the agent its own actor on GitHub. It does not use your personal login.
Why a GitHub App fits this need
GitHub Apps use fine-grained permissions. You can limit an app to the repositories and permissions it needs. Installation tokens expire after 1 hour. (Generating an installation access token)
Setup steps
- Open your account settings. For an organization-owned app, open the organization settings instead. Go to Developer settings > GitHub Apps > New GitHub App. (Registering a GitHub App)
- Enter a name of 34 characters or fewer. Name it for the agent, for example
claude-code-bot. The name must be unique on GitHub. - Turn off Active if the agent does not need webhooks.
- Under Permissions, choose only what the agent needs. For code changes, set Contents and Pull requests to read and write. Leave other permissions at No access.
- Under Where can this GitHub App be installed?, choose Only on this account.
- Click Create GitHub App. Note the App ID on the settings page. The app ID is different from the client ID.
- Generate a private key. Go to Credentials > Key pairs > New key. GitHub downloads a PEM file once. (Managing private keys)
- Store the PEM file in a secrets manager. Do not put it in the repository. The docs say an environment variable is weaker than a key vault.
- Install the app on one repository. Go to Developer settings > GitHub Apps > Edit > Install App. Select Only select repositories, then choose the repository. (Installing your own GitHub App)
- Create a JWT for the app. Sign it with RS256. Set
issto the client ID or app ID. Keepexpwithin 10 minutes. (Generating a JWT) - Get the installation ID. Call
GET /repos/{owner}/{repo}/installationwith the JWT. - Request an installation token. Call
POST /app/installations/INSTALLATION_ID/access_tokens. Add arepositoriesvalue to limit the token to one repository. Addpermissionsto limit its scope. (Authenticating as an installation) - Give the agent the token for Git access. The docs show this form:
git clone https://x-access-token:TOKEN@github.com/owner/repo.git. The app needs the Contents permission for this.
Limits to plan for
- Each token expires after 1 hour. Your agent wrapper must mint a new token when needed. The Octokit SDK does this for you. (Octokit guidance)
- Private keys do not expire. You must revoke them by hand. You can hold up to 25 keys, so rotate keys without downtime.
- Since April 27, 2026, GitHub is rolling out a new token format (
ghs_APPID_JWT) to new installation tokens. If your agent code expects a 40-character token, check it first. (Token format note)
What I did not verify
I did not check how commits made with an app token appear in the GitHub UI. I also did not check how Claude Code loads a Git credential. Test both with a throwaway repository before you rely on them.
Recommendation
Use one app per agent. Use a separate app if you run more than one agent. Several agents that share one app appear as the same bot.
Choose a self-built GitHub App if you want full control and can maintain token minting yourself.
Choose githug if you want this setup done for you. Its hug init --repo owner/repo command sets it up for Claude Code, Codex, Cursor, or any agent that runs git. Each agent gets its own key, which mints one-hour tokens for one repository. Commits are authored as the agent and name the accountable human. The beta is free, and the tool is open source (AGPL-3.0).