Your coding agent should not log in as youDelegation leaves two names on the record
Most coding agents work under their owner's identity: your GitHub token, your cloud login, your SSH key. Every system downstream then records the agent's actions as yours, applies your review rights to its pull requests, and gives you no way to cut the agent off without cutting yourself off too. Hiding the key does not change that. Giving the agent its own identity does.
-
01
Today
Agent acts as you
Your token, your audit entries, your approvals
No separate revoke -
02
Identity
Agent has its own login
Machine user or app, added with a narrow role
Two names on the record -
03
Grant
Token per task
Chosen repos and permissions only
GitHub App tokens: 1 hour
TL;DR· the answer, in twenty seconds
What happened: On November 17 a post about lend, a tool that keeps credentials on a laptop while remote coding agents ask to use them, reached Hacker News. The top thread argued that hiding the key changes little when the agent can still do everything the key does, and one reply put the fix plainly: "Wanting agents to act like you is wrong."
The minimum fix: Give the agent its own login, either a machine user or a GitHub App, with a role scoped to the repositories it works in. Hand each session a short-lived token from that identity, never your personal one.
The lesson: Where a key lives decides who can steal it. Whose name the key carries decides what the agent may approve, what the logs show and what you can revoke. Those are separate controls, and most setups only address the first.
On November 13, the developer behind the GitHub account antoniomika published Running coding agents without handing them my credentials. The author runs Claude Code and Codex on throwaway VMs, keeps SSH keys, a 1Password vault and a logged-in gh on a laptop, and wrote a tool called lend so an agent on the VM can ask the laptop to run gh for it. Each request needs a Touch ID approval. The token never leaves the laptop. The problem statement is one line: "Agents on a VM still need to act as me."
The post reached Hacker News on November 17 and had 134 points and 115 comments when I read it two days later. The top thread was not about lend's design. It was about that line. User saagarjha wrote that "Everyone seems to be super laser focused on 'not allowing their AI to have keys' when basically giving their AI direct access to what the keys enable," with a tap to approve in front. A reply from fractorial went further: "Wanting agents to act like you is wrong." That commenter runs a second GitHub account for the agent, pointed at their human one, so a trusted proxy can control access by identity. lend's author answered the critique directly: "Truthfully, I tend to agree with you." lend exists to run laptop-only commands from a remote machine, and the author calls the agent safety a by-product.
lend does what its author built it to do, and the thread is right about what it leaves alone. Keeping a key away from the agent changes who can steal it. It does not change whose name every downstream system writes down when the agent acts. That second question has its own answer, and it is older than coding agents: a process that acts for a person should have an identity of its own.
What goes wrong when the agent is you
Start with what GitHub sees when Claude Code pushes from your laptop. The push authenticates with your token. Your account opens the pull request. In GitHub Actions, github.actor is you. The audit log lists you as the actor. GitHub cannot tell the agent from you because, as far as its records go, there is no agent.
A Claude Code user ran into this in April and filed it as anthropics/claude-code#44292: "There is no way to distinguish Claude's git actions from the user's own actions." The issue lists three things that broke. A rule requiring one approving review could not tell an agent PR from a human one. A workflow condition meant to fire only on the agent's PRs, if: github.actor != 'myusername', never fired. The git history showed the same author for human and machine commits. The workaround the reporter settled on was to "Auto-approve all PRs unconditionally and rely on the merge button as the sole human gate." Approval stopped working as a control, and it took the reporter's own identity to make that happen.
That issue is about attribution, but the shared identity causes four separate failures.
Review rules count the wrong person. GitHub will not let a pull request's author approve it. When the agent opens a PR as you, you are the author, so you cannot approve the agent's work under your own branch protection. That is how the reporter of #44292 ended up auto-approving everything. On a team the rule still runs but means less: a teammate's agent PR, opened under the teammate's account, gets a second reviewer who has no record that no person wrote it.
Every grant you have, the agent has. A personal token or a logged-in CLI carries your permission set: every repository you can push to, every organization you belong to, every admin setting you can change. The agent does not need most of it, and nothing in the token tells the server which part the agent meant to use. The blast radius of a prompt injection is your account.
You cannot revoke the agent alone. When something looks wrong, the fast response is to cut off the agent. If the agent holds your token, revoking that token breaks your other sessions, your other tools and your CI jobs that share it. If it uses your SSH key or your cloud login, there is no agent credential to revoke at all. A kill switch that also locks you out is one you will hesitate to pull.
The record cannot answer the question you will be asked. After an incident, someone asks which changes a person made and which ones the agent made. With one identity, the only evidence is commit messages, timing and memory. Git author fields do not help, because they are plain text any process can set.
None of these failures depends on where you store the key. Put your token in a vault, behind a proxy, or on a laptop that runs gh for a remote VM, and every one of them still holds, because the request reaching GitHub still carries your name. That is the part of the saagarjha critique I would keep. Custody changes who can copy the credential. It does not change whose authority the credential spends.
Delegation leaves two names on the record
Identity systems have a vocabulary for this. Impersonation means the acting party presents itself as the user, and downstream systems see only the user. Delegation means the acting party keeps its own identity and carries a record of whom it acts for. OAuth token exchange, RFC 8693, writes this into the token: its act (actor) claim exists "to express that delegation has occurred and identify the acting party to whom authority has been delegated." A server reading such a token sees the user the agent works for and the agent itself, as two names.
A coding agent on your personal token is impersonation. It is the default because it is the least setup, not because anyone chose it.
GitHub's Copilot cloud agent shows what delegation looks like in practice. Its risks and mitigations page lists the controls, and most of them depend on Copilot having an identity separate from the person who asked:
- Commits are authored by Copilot, with the developer who requested the change marked as co-author. The record shows who did the work and who asked for it.
- The developer who asked Copilot to open a pull request cannot approve it, which keeps required-approval rules meaningful.
- When Copilot opens a pull request under its own app identity, one more approval is required before merge, as long as the repository already requires at least one.
- The agent can push only to the one branch it was given, and by default workflows on its PRs do not run until a user with write access approves them.
Each of those rules needs the server to know which actions came from the agent. A third-party agent pushing with your token cannot get any of them, however carefully you store its token.
Two names matter beyond GitHub. A cloud provider can scope a role for the agent apart from yours. A database can deny the agent's user the DROP rights your own user keeps. An API with rate limits can throttle the agent without throttling you. Each control needs a principal to attach to. If the agent has no principal of its own, there is nothing to attach it to.
Give the agent a login and a short token
On GitHub there are two workable identities for an agent and one rule for the token you hand it. The two identities trade setup cost against how short-lived and how narrow the credential can be.
A machine user. A second GitHub account that exists only to run the agent. GitHub's Terms of Service permit this: a machine account is "set up by an individual human who accepts the Terms on behalf of the Account," and "the owner of the Account is ultimately responsible for the machine's actions." The free-plan limit is explicit: "You may maintain no more than one free machine account in addition to your free Personal Account." Add the account to your organization or as a collaborator on the repositories it needs, with write access and nothing higher. Its pull requests now have an author who is not you, so you can approve them, and branch rules can target it by name. The cost is a second account to secure, and a token on it that lives as long as you configure it to.
A GitHub App. An app installed on the repositories the agent works in. The app holds a private key, and from that key you mint installation access tokens. GitHub's documentation states the two properties that matter: an installation token "cannot be granted permissions that the app was not granted," and it "will expire after 1 hour." The token request can narrow further, to named repositories and a subset of the app's permissions. Actions show up under the app's bot name. This is more setup than a machine user, but it gives you a credential that expires on its own and that you scope per task.
A per-session token from the agent's identity. Whichever identity you pick, hand the agent a token for the current task, not a stored one. With an app, that means minting one when the session starts:
# APP_JWT is signed with the GitHub App's private key, which stays outside
# the agent's environment. Narrow the token to one repo and two permissions.
curl -s -X POST \
-H "Authorization: Bearer $APP_JWT" \
-H "Accept: application/vnd.github+json" \
"https://api.github.com/app/installations/$INSTALLATION_ID/access_tokens" \
-d '{"repositories":["api-server"],
"permissions":{"contents":"write","pull_requests":"write"}}'
The response includes the token, its expiry, and the repositories and permissions it carries. Start the agent with that value and with git configured so commits carry the agent's name:
export GH_TOKEN="$AGENT_INSTALLATION_TOKEN"
export GIT_AUTHOR_NAME="api-server-agent[bot]"
export GIT_AUTHOR_EMAIL="api-server-agent@example.invalid"
export GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"
export GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"
claude
gh reads GH_TOKEN ahead of stored credentials. If git uses gh as its credential helper (gh auth setup-git), pushes use the same token; with GH_TOKEN set, gh auth git-credential get returns it as the password with username x-access-token. Your own gh login stays on disk and still works in your shell, and the agent's session never touches it.
Use the email the app or machine account actually owns, not the placeholder above, if you want GitHub to link the commits to the account. The author fields are a label. Whose authority a push spends comes from the token, and that is the part the server enforces.
The same split works outside GitHub. A cloud account gets a role or service account for the agent, with its own policy, rather than your SSO session. A database gets an agent user with the grants the task needs. Infrastructure tools get an agent profile instead of your default profile. The pattern stays the same each time: a separate principal, a narrow grant, a short-lived credential minted per session.
What a separate identity does not fix
This is not a complete defense, and the thread raised some of the gaps.
The agent still holds a credential. A machine user's token or an installation token sits in the agent's environment while the session runs. A prompt injection can still read it and send it out. The difference is what the thief gets: one hour, one repository, two permissions, under a name you can suspend without touching your own account. That is a smaller loss, not no loss. If you also want the agent never to see the value, a credential proxy or a broker that injects the token per command handles that, and it works with any identity.
An identity is only as narrow as its grants. A machine user added as an organization owner is your account under a second name. The identity creates a principal you can scope. You still have to scope it, and review the scope when the agent's job changes.
The agent's name is not proof of what it did. Git author fields are text. An agent can write commits under any name, and so can anything else with push access. What you can rely on is the server-side record: which token made the push, which identity opened the PR, which app called the API. If commit-level attribution matters, sign the agent's commits with a key only the agent identity holds, and require signed commits on protected branches.
Approvals still need judgment. Two names on the record make approval rules work again. They do not make the approver read the diff. The commenter who said they saw nothing in lend's approval dialog that allowed "an informed choice" was describing a prompt shown at the moment of action. A separate identity moves the decision to review time, where you have the diff, the tests and the history. It does not make the decision for you.
Some actions need you, and should. There are tasks where an agent working as a person is the point: reading your inbox, acting in a SaaS tool that has no machine accounts, using your personal cloud console. Handle those case by case, with the narrowest delegation the service offers. Do not let the exception become the default for git and CI, where GitHub documents machine identities and supports them.
Another commenter, __MatrixMan__, described the most extreme version of the split: two laptops, no SSH between them, and an HTTP API on the laptop with the secrets that the agent can call. New capabilities arrive as commits the human reviews before deploying. That is delegation built by hand, with the API as the agent's identity and its code as the grant. Most teams do not need two laptops. They need the same idea applied to accounts they already have.
What this means for your stack
Run one check today. Open the session your agent uses and run gh auth status and git config user.name. If either shows your own account, the agent is you to every system it touches. Then look at the last ten pull requests the agent opened and ask whether you could prove, from server records alone, that a person did not write them.
The fix comes in two parts, and they are separate decisions. First, decide whose name the agent acts under. Create a machine user or a GitHub App, give it write access to the repositories it works in and nothing else, and let branch rules and audit logs treat it as its own principal. Second, decide what the agent holds and for how long. Mint a token per session, narrow it to the task, and keep your own login out of the agent's environment.
hasp is one working implementation of the second part. Its run command hands a stored secret, such as the machine user's token, to one approved command and keeps the value out of the agent's shell environment and config files. Source-available (FCL-1.0), local-first, macOS and Linux, no account.
Start with the identity. A short-lived token in your name is still your name.
Sources· cited above, in one place
- antonio's blog Running coding agents without handing them my credentials
- Hacker News Discussion: Running coding agents without handing them my credentials
- anthropics/claude-code#44292 Feature: Bot identity for git operations (separate from user account)
- GitHub Terms of Service: account requirements and machine accounts
- GitHub Generating an installation access token for a GitHub App
- GitHub Risks and mitigations for Copilot cloud agent
- RFC 8693 OAuth 2.0 Token Exchange
- Fair Core License FCL-1.0-ALv2 text
Stop handing the agent your real keys.
hasp keeps secrets in one local encrypted vault, brokers them into the child process at exec, and never lets the agent read the value.
- Local, encrypted vault — no account, no cloud, no telemetry by default.
- Brokered run — agent gets a reference, the child process gets the value.
- Pre-commit + pre-push hooks catch managed values before they ship.
- Append-only HMAC audit log answers "did the agent touch the prod token?" in seconds.
macOS & Linux. Source-available (FCL-1.0, converts to Apache 2.0). No account.