If you run coding agents on your own repositories, they probably push and open PRs under your login. A separate GitHub identity for them sounds like the fix: a “Luis Moribot” account, or a GitHub App. It fixes less than you’d hope.
A separate identity tells you which commits and PRs an agent made. It does not limit what that agent can reach, and it does not stop a merge. Both limits come from two other things: how narrow the agent’s token is, and a ruleset the agent cannot bypass. This article lays out what GitHub documents for personal repositories as of 2026-11-19. It gives you a ruleset to copy and a test to run before you rely on any of it. We did not run that test, so every step we could not confirm is labeled.
TL;DR
- A separate account or App gives attribution. Control comes from token scope plus a default-branch ruleset that requires code-owner review, with
.github/CODEOWNERSnaming you for every file. You keep a pull-request-only bypass that covers any PR, so keep your own credentials outside the agent’s runtime. - On a personal repo, GitHub’s docs support an App installed on selected repositories as our preferred route: selected-repository access, granular permissions and one-hour tokens. A collaborator machine account cannot use a fine-grained PAT, so it is left with a classic PAT, which reaches every repository the account can access.
- A collaborator on a personal repo always gets write access. Only a rule on the default branch stops it from writing there.
- A private personal repo needs GitHub Pro for required reviews and rulesets. If the repo’s plan can’t enforce them, a broader token fixes nothing: change the plan or keep the rollout blocked.
- We did not run the canary below. The App-opens-a-PR step on a personal repo is documented, not tested.
Why “should agents have their own account?” is the wrong first question
Two things get mixed up here, and they need different fixes.
- Attribution answers “who did this?” A bot identity gives you that. Commits and PRs carry its name instead of yours.
- Control answers “what could it do?” That depends on the credential the agent holds and on the rules the merge has to pass.
If an agent runs as you, you lose both. GitHub’s docs say that by default, classic branch protection does not apply to people with admin permission, and on a personal repo that is you. The setting “Do not allow bypassing the above settings” turns that off. An agent session that inherits your account inherits that bypass.
Two recent reports show what that looks like:
- Vitruvian Software, which runs ten agents in one monorepo, wrote on 2026-10-09 that agent sessions running under the owner’s account inherited an admin merge bypass. Over two days, five of forty merges skipped the merge queue. One had been rejected by the queue eight minutes earlier, and
mainwent red. - A preprint published on 2026-10-19 studied twelve weeks at one fintech startup. In its gated phase, 71 of 263 merges (27%) rested only on an approval that an agent had submitted through the technical lead’s account, and the platform recorded each as an ordinary approval by the lead. This is one company, so it shows the failure mode, not how common it is.
The fix in both cases is the same: give the agent a credential that is not yours, then make the merge rules apply to everyone.
What GitHub documents for a personal repo
Here are the routes, with what each one can reach and how well we can back it up. All quotes come from GitHub’s docs, which show no publication date unless noted.
| Route | What the credential reaches | Can it open a PR on a personal repo? | Evidence |
|---|---|---|---|
| Your own login (baseline) | Everything you can access, including admin bypass | Yes | Docs |
| Machine account + fine-grained PAT | Selected repos, but see the next column | No for a collaborator: the PAT docs list contributing as a collaborator as unsupported | Docs |
| Machine account + classic PAT | Every repository the account can access, with repo scope | Documented as the fallback for collaborator work | Docs; not tested |
| GitHub App on selected repos | Write access only on the repos you pick, with only the permissions you grant (public repos stay readable); installation tokens last an hour | Documented: the create-PR endpoint lists installation tokens and requires “Pull requests” write | Docs; not tested on a personal repo |
| Deploy key | One repo, read-only unless you grant write; no expiry | Not by itself: it authenticates SSH Git, not the REST API [INFERENCE] | Docs, plus inference |
Four facts sit behind this table:
- Machine account. GitHub’s terms say a human creates it and answers for what it does, and you may keep no more than one free machine account in addition to your own account. They also say accounts registered by bots are not permitted.
- Fine-grained PAT gap. The PAT docs list “contribute to repositories where the user is an outside or repository collaborator” as unsupported. A roadmap item for it was opened on 2022-11-16, last updated on 2026-08-21, and is open with a Paused label.
- Classic PAT scope. The
reposcope “Grants full access to public and private repositories”, including collaborators and webhooks. It does not grant more than the account already has. Scopes limit the kind of operation, but a classic token cannot be limited to chosen repositories. So the way to narrow it is to limit which repositories the account owns or can access. - Collaborator access. A personal repository has two permission levels, owner and collaborator. In a private repo, “Collaborators can’t have read-only access”. A bot that is a collaborator can push to every branch unless a rule says otherwise.
One report disagrees with the App row. A practitioner wrote in 2026 that an App installed on a personal-account repo could not open a PR. GitHub’s documentation that we read states no such restriction. The endpoint page lists installation tokens, and another page says “You can install a GitHub App on your personal repository.” We found no primary source for the report and did not reproduce it. That is why the next section exists.
The canary: three tokens, one throwaway repo
Before you rely on any row above, run this on a repo you can delete. It tries the same three actions with each token and prints only HTTP status codes. We did not run it. The commands follow GitHub’s REST API.
Set up in this order, as the repository owner, so each token can actually reach the new repo:
- Create the repo:
gh repo create OWNER/canary-agent-identity --private --add-readme. - Invite your machine account as a collaborator, and accept the invitation from that account.
- Install the App on this one repo with Contents and Pull requests write, then mint its installation token (see GitHub’s instructions).
- From the machine account, create a fine-grained PAT and a classic PAT with
reposcope.
Then open a fresh interactive Bash shell. The script turns tracing off, reads each token without echoing it, and gives curl the header on stdin so the token never appears in its arguments. Do not run it in a recorded CI job.
set +x # no tracing while tokens are in this shell
OWNER=your-username REPO=canary-agent-identity
for V in TOKEN_APP TOKEN_FINEGRAINED TOKEN_CLASSIC; do read -r -s -p "$V: " "$V"; echo; done
api() { # token, method, path, body -> prints the HTTP status only
printf 'Authorization: Bearer %s\n' "$1" | curl -s -o /dev/null -w "%{http_code}" \
-H @- -H "Accept: application/vnd.github+json" \
-X "$2" "https://api.github.com/repos/$OWNER/$REPO/$3" ${4:+-d "$4"}
}
# run with the owner's gh login, not an agent token
BASE=$(gh api "repos/$OWNER/$REPO" --jq .default_branch)
SHA=$(gh api "repos/$OWNER/$REPO/git/ref/heads/$BASE" --jq .object.sha)
echo "base=$BASE sha=${SHA:0:7}" # both must be non-empty before you continue
for NAME in APP FINEGRAINED CLASSIC; do
VAR="TOKEN_$NAME"; TOKEN="${!VAR}"; BR="canary-$NAME"
echo "$NAME branch: $(api "$TOKEN" POST git/refs "{\"ref\":\"refs/heads/$BR\",\"sha\":\"$SHA\"}")"
echo "$NAME file: $(api "$TOKEN" PUT "contents/canary-$NAME.txt" "{\"message\":\"canary\",\"content\":\"Y2FuYXJ5Cg==\",\"branch\":\"$BR\"}")"
echo "$NAME PR: $(api "$TOKEN" POST pulls "{\"title\":\"canary $NAME\",\"head\":\"$BR\",\"base\":\"$BASE\"}")"
done
A 201 means the action worked. A failure tells you less than it seems to, because the script discards the response body. Here is how to read each outcome:
| Result | What it means for you |
|---|---|
APP returns 201 on all three | The App route worked for this repo and installation. Go on to the enforcement checks below. Creating a PR does not show that the agent cannot merge. |
APP fails on the PR step, CLASSIC succeeds | Inconclusive. Rerun the failing request and read the error message privately. Check the App’s Pull requests write permission, its installation on this repo, and token expiry before you choose a broader credential. These status codes alone do not show a personal-repo restriction. |
FINEGRAINED succeeds | Check that the token belongs to the collaborator account and not to you. If it does, record that configuration and prefer the fine-grained PAT over a classic one. One result does not show that GitHub closed the documented gap. |
| Everything fails | Check the access setup above before you read anything into it. |
Keep the repo until you have run the enforcement checks in the next section. Then delete it, revoke the tokens, and unset TOKEN_APP TOKEN_FINEGRAINED TOKEN_CLASSIC TOKEN.
The verification loop: make the ruleset the only road to main
Once an agent has its own credential, require your approval before it can merge to the default branch, and keep your own pull-request-only bypass as an explicit trust exception. GitHub’s docs say: “Pull request authors cannot approve their own pull requests.” That rule alone does not name you as the reviewer. One required approval means one eligible non-author, and another collaborator or App can supply it. Vitruvian reports exactly that: an App approval satisfied its required review. So the ruleset below also requires a code-owner review, and a CODEOWNERS file on the default branch names you:
# .github/CODEOWNERS
* @YOUR_LOGIN
A solo owner also cannot approve their own PRs, so the ruleset gives you one narrow exception, a pull-request-only bypass.
{
"name": "default branch: code-owner review, owner bypass on PRs only",
"target": "branch",
"enforcement": "active",
"conditions": { "ref_name": { "include": ["~DEFAULT_BRANCH"], "exclude": [] } },
"bypass_actors": [ { "actor_id": 123456, "actor_type": "User", "bypass_mode": "pull_request" } ],
"rules": [
{ "type": "pull_request",
"parameters": {
"required_approving_review_count": 1,
"dismiss_stale_reviews_on_push": true,
"require_code_owner_review": true,
"require_last_push_approval": false,
"required_review_thread_resolution": false } },
{ "type": "non_fast_forward" },
{ "type": "deletion" }
]
}
Save the JSON as ruleset.json, then create it from the owner’s setup shell with gh api -X POST "repos/OWNER/REPO/rulesets" --input ruleset.json. Creating a ruleset needs administration rights, so do it with your own login, never with an agent token. We did not run this either, so check the field names against GitHub’s ruleset API reference before you trust it. Four points matter more than the syntax:
- The bypass is yours, and it covers every PR. GitHub documents rulesets as an explicit bypass list, with an “always” mode and a pull-requests-only mode. Since 2026-05-07 individual users can be on it, and Apps and roles were already allowed. Replace
123456with your numeric id fromgh api user --jq .id, and keep the agent’s App off the list. The bypass is not limited to your own PRs: you can merge an agent’s PR without approval. So the exception trusts your merge decision. It does not record an approval on every merge. - Your credentials must be out of the agent’s reach. An agent that can use your login inherits that bypass. Giving it a token in
GH_TOKENis not a boundary if it can still reach your savedghlogin, a Git credential helper, your keychain or your SSH agent socket. Run the agent in a sandbox, a container or a separate OS user that has none of those. - New reviewable changes dismiss stale approvals. If the agent pushes a code-changing fix after you approved, review the changed diff again.
- The
require_last_push_approvaloption stays off here. With it on, the most recent reviewable push needs an approval from someone other than its pusher. If you push the final fix as the only human reviewer, you cannot satisfy that yourself, and you would have to use your bypass. We leave it off so the normal review path keeps working. That follows GitHub’s description of the option and we did not test it.
Then set the agent’s git identity so the history matches the credential. A token changes who pushes, but git takes authorship from local config. Vitruvian reports that without this, the PR shows the bot while the commit log still shows the machine owner. For an App, the address is <bot_user_id>+<app-slug>[bot]@users.noreply.github.com:
export GIT_AUTHOR_NAME="your-app[bot]" GIT_COMMITTER_NAME="your-app[bot]"
export GIT_AUTHOR_EMAIL="<bot_user_id>+your-app[bot]@users.noreply.github.com"
export GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"
flowchart TD
A["Agent with its own token<br/>(selected repos only)"] --> B["Branch + PR"]
B --> C{{"Ruleset: code-owner<br/>review, no agent bypass"}}
C --> D["You review the diff"]
D -->|approve| E["Merge"]
D -->|request changes| A
After you create the ruleset and the CODEOWNERS file, run these checks on the same throwaway repo. We did not run them, so treat each as an expected result to confirm:
- A direct push to the default branch with the agent token is rejected.
- The agent cannot merge its own PR before you approve it.
- An approval from a second identity, such as another bot or collaborator, does not unblock the merge, because the code-owner rule needs you.
- Your approval unblocks the merge.
- A new code-changing commit from the agent after your approval dismisses it.
This ruleset enforces reviews, not CI checks. If your repo requires CI, configure its named status checks separately and confirm they passed on the exact commit you merge. For each agent PR, also check that the author is the bot and that you are the approver.
The plan can stop all of this. GitHub’s docs say rulesets are available in public repositories with Free, and in public and private repositories with Pro, Team and Enterprise Cloud. The plans page lists “Required pull request reviewers” and “Protected branches” under Pro for private repositories. If your repo is private on a free plan, you have a different problem from the token, and a broader token does not fix it. You can upgrade the personal account to Pro, or move the repo to an organization on a plan that supports these protections, such as Team. You can also make it public, but only if you already intend to publish its contents and history. A transfer to a Free organization is not enough. Until enforcement works, the agent should not push to a repo whose default branch it could change.
What this does not fix
Identity and a ruleset narrow the damage. They do not make the agent trustworthy.
- The agent still holds a token while it runs. Researchers disclosed on 2026-04-15 that text in PR titles, issue bodies and comments made three vendors’ agents leak credentials such as
GITHUB_TOKEN. The Cloud Security Alliance note on 2026-04-17 summarizes it. A narrow App token limits what a leak costs. It does not prevent the leak. - A classic PAT is a large target. It reaches every repo its account can access. Keep the account a member of as few repos as you can, give the PAT an expiry, and revoke it when you are done.
- An App’s private key outlasts its one-hour tokens. Whoever holds the key can mint new installation tokens, so a leaked key is worse than a leaked token. Vitruvian says its agents’ App keys sit in one directory every agent can read, so nothing stops one agent from minting another’s token. Keep each App’s private key outside the agent’s runtime, in a small token issuer or secret store, and hand the agent only the installation token. Rotate the key if it might have leaked.
- Branch CI is a second boundary. Protecting the default branch does not isolate workflows that run on the agent’s branches. Check what credentials those jobs can reach. Build Your Own Autonomous Bot covers that.
- Approvals through your own login defeat the loop. That is the 27% case above. If the agent can run
gh pr reviewas you, the ruleset sees your approval.
What comes next
This article covers the GitHub side only. GitHub is one connection an agent may use, and credential boundaries for the others are a separate design that a follow-up article will cover. For secrets that are already inside an agent’s environment, see Keep Secrets Out of the Agent. For where an autonomous bot’s controls should sit, see Build Your Own Autonomous Bot.
Sources
GitHub docs, the roadmap item and the vendor pages below can change. We opened every page on 2026-11-19; dates are the page’s own where it shows one.
- GitHub Terms of Service, effective 2026-04-27: machine accounts, one free machine account.
- Managing your personal access tokens: fine-grained PAT collaborator gap; a classic PAT can access every repository you can.
- GitHub roadmap #601: collaborator support for fine-grained PATs, open and paused, updated 2026-08-21.
- Scopes for OAuth apps: what the
reposcope grants. - Installing your own GitHub App and Differences between GitHub Apps and OAuth apps: installing an App on selected personal repositories.
- Create a pull request and Permissions required for GitHub Apps: installation tokens and “Pull requests” write. The authentication block appears on the rendered page, not in its Markdown export.
- Permission levels for a personal account repository: owner and collaborator roles.
- About protected branches and Approving a pull request with required reviews: admin bypass, stale approvals, author cannot approve.
- GitHub changelog, 2026-05-07 and Create a repository ruleset: individual bypass actors and ruleset fields.
- About rulesets and GitHub’s plans: plan availability.
- Managing deploy keys: single-repo SSH keys with optional write and no expiry.
- Every AI agent gets its own GitHub identity, Vitruvian Software, 2026-10-09: inherited bypass, git author identity, shared key directory.
- Who Approved This?, preprint, 2026-10-19: 71 of 263 merges rested on agent approvals through the lead’s account.
- Comment and Control research note, Cloud Security Alliance, 2026-04-17: prompt injection through PR and issue text.
- My Coding Agent Needed Its Own GitHub Identity, 2026-04-27, updated 2026-07-02: the unreproduced report about Apps on personal repos.