answered from live GitHub & Hugging Face data
How do I create a separate GitHub App for Claude Code to manage its identity and contributions?
Create one GitHub App per agent, and give each app access to only the repositories it needs. Installation tokens from the app show as activity from the app itself, so a shared app would hide which agent acted. Claude Code needs a GitHub App that its own token and commits use.
I did not check how Claude Code itself stores or passes git credentials. The steps below cover the GitHub side.
Steps
- Open your profile menu. Click Settings. For an organization app, click Your organizations, then Settings.
- In the left sidebar, click Developer settings, then GitHub Apps.
- Click New GitHub App.
- Enter a name. The name can be at most 34 characters and must be unique across GitHub. (Registering a GitHub App)
- Enter a homepage URL. Use your repository URL if you have no website.
- Leave Callback URL empty if the agent acts without a user. The field is only needed for user tokens.
- Deselect Active if the app does not need webhooks.
- Under Permissions, select the minimum access the agent needs. Choose Read-only, Read & write, or No access for each. (Best practices)
- Under Where can this GitHub App be installed?, select Only on this account.
- Click Create GitHub App.
- Generate a private key on the app settings page. Store it in a key vault. An environment variable is weaker. The docs warn that the private key grants access to every account where the app is installed. (Best practices)
- Install the app on one repository only.
- Have the agent create a JSON Web Token (JWT) from the private key. Then send
POST /app/installations/INSTALLATION_ID/access_tokens. (Installation access tokens) - Add a
repositoriesvalue to the request. This limits the token to that repository. - Add a
permissionsvalue to the request. This limits the token to the listed permissions.
Token limits
- Installation token: expires after 1 hour. Use this for agent work that does not need a user. (docs)
- User access token: expires after 8 hours. Refresh tokens last 6 months. Use this when a user must authorize the action. (docs)
Commit attribution
- Installation tokens attribute activity to the app. (docs)
- To credit a human, add a
Co-authored-by:trailer to the commit message. The email must be linked to that person's GitHub account for the commit to count toward their contributions. (docs)
Recommendation
Use one app per agent, installed on one repository, with the smallest permission set. Rotate the private key if it leaks.
If you want this setup without doing the steps by hand, githug gives each agent its own key. Its tokens last one hour and work on one repository. The hug init --repo owner/repo command sets this up for Claude Code. It is free during the beta.