Data Report · RedactSure Research
Chris Sowa · Founder, RedactSure
Published
Last updated
Does Claude Code Need My GitHub Token to Open a Pull Request?
It needs a credential that can push to the repository and call the API, and in a local session that is usually your GitHub token in the environment. Ask whether a sandboxed command sees the raw value or only a sentinel, and whether the Read tool can still open a file that holds it.

A developer asks Claude Code to open a pull request and the agent reaches for the one thing that makes the push possible. A local session normally presents the developer's own GitHub credential, exported in the environment or stored by the gh CLI after a login; a workflow can present an app instead. The pull request opens either way, and the difference that matters sits one layer down: which component held the raw token, and which one only saw a placeholder. On one machine the answer can differ among the terminal, the editor's integrated shell, and the browser window where the token was created.
A developer who declares the token as a sandbox credential and runs gh pr create inside the sandbox gets a pull request and a question the output does not answer: what the model received and what the command received. Two limits the vendor pages state plainly decide the answer: the mask covers sandboxed commands only, and the tools that read files run outside the sandbox. A team that knows both limits can say whether the agent ever had the value, which is the fact that decides how much a leaked token is worth and which control to review first.
Key findings
- For a GitHub token to stay out of what a model reads, the value on the page that displays it would have to be replaced with a consistent token before any model reads it, with the real value resolving only at the approved destination (What Is Least Exposure?).
- It would also require a named person approving the push and a record of what the model received, because a token's scope decides where a command can write and not what the model saw (How Do I Let a Coding Agent Open Pull Requests Without Giving It My Credentials?).
- The gap sits outside the command: masking covers sandboxed Bash commands only, and the documentation does not extend it to Read, Edit, Write, WebFetch, WebSearch, MCP servers and hooks, which run outside the sandbox (Anthropic, Sandboxing, 2026).
- GitHub tells developers to "Treat your access tokens like passwords" and says a fine-grained token can be "limited to only access specific repositories," a reach limit that leaves the value where the session keeps it (GitHub, Managing, 2026).
- The workflow path documented for the Claude Code action says that "When omitted, the Claude Code GitHub Action authenticates as the Claude GitHub App," so a personal token is not the only way to open a pull request (Anthropic, GitHub Actions, 2026).
- GitGuardian's 2026 count of public GitHub commits puts about 29 million credentials exposed in 2025, with AI-service leaks up 81% year over year, and its CEO says "AI agents need local credentials to connect across systems" (GitGuardian, 2026).
What does Claude Code need a GitHub token for?
Opening a pull request takes two operations: pushing a branch to the repository and calling the GitHub API to create the pull request. Claude Code performs them through commands, and a command needs a credential the host accepts. In a local session that credential is normally the developer's own, exported in the environment or stored by the gh CLI after a login. In a workflow, the Action can authenticate as an app instead (Anthropic, GitHub Actions, 2026).
The scope of a browser control matters here, because most of this work is not on a page. A governed browser environment covers what an agent reads and does on a rendered page: dashboards, consoles, settings pages, sign-up forms. It does not cover the terminal, the IDE, the local filesystem, direct API calls or MCP. A git push from a shell is the terminal case. A token that the same agent reads on the GitHub token settings page is the rendered-page case, and the two are governed by different controls.
One worked record carries the analysis: a pull request opened with a masked token. The developer declares the token as a credential for the sandbox, the agent runs gh pr create inside it, and the command sends the request. Which value the command saw, and which component attached the real one, is the question the vendor documentation answers. The masked token is the case where the command and the model see different values; an unmasked token is the case where they see the same one.
Does the pull request need your token, or can the agent use its own?
The workflow path is documented, and it does not require a personal token. Anthropic's page for the Claude Code GitHub Action lists a github_token input and states that when the input is omitted, "the Claude Code GitHub Action authenticates as the Claude GitHub App" (Anthropic, GitHub Actions, 2026). That covers the workflow. The same page does not say which GitHub credential a local Claude Code session uses, and on a developer's machine the session presents whatever git or gh already holds.
The app path carries a permission bill. Installing the app accepts "its full permission set," and the page advises, "Grant the workflow only the permissions it needs, and review Claude's changes before merging" (Anthropic, GitHub Actions, 2026). For a production repository, scope the workflow and treat the app's install as an organization-wide decision.
For a local session, the token's scope is the control a team can set today. GitHub's token page says to "Treat your access tokens like passwords" and that a fine-grained token can be "limited to only access specific repositories" (GitHub, Managing, 2026). That limit decides which repository a leaked token can write to. It does not decide whether the value is readable in the session, because the token still lives in the environment or in the file the CLI wrote.
A workflow token is a different object with a different warning. GitHub's GITHUB_TOKEN page says, "As a good security practice, you should grant the GITHUB_TOKEN the least required access," and for more access, "create a GitHub App and generate an installation access token within your workflow" (GitHub, Authentication, 2026). The page does not state the token's lifetime, so a team should not read a session length into it.
The scope is a reach limit: a fine-grained token narrows what a stolen value can touch and does not change what the session reads (Does a GitHub Fine-Grained Token Replace a Secure Agent Workspace?).
What do the vendors themselves say?
The two vendors document different halves of the answer. GitHub documents how far a token reaches and how a workflow token is scoped. Anthropic documents how a sandboxed command can use a token it does not see, and where that mechanism stops.
| Dimension | GitHub and Anthropic, per their documentation | What a buyer should verify |
|---|---|---|
| A personal token's handling | "Treat your access tokens like passwords"; fine-grained tokens can be "limited to only access specific repositories" (GitHub, Managing, 2026) | Which repository the token can write to, and how long it lives |
| The workflow token | "grant the GITHUB_TOKEN the least required access"; a GitHub App installation token for more (GitHub, Authentication, 2026) | The permissions the workflow actually needs |
| The Action's own login | When github_token is omitted, the Action authenticates as the Claude GitHub App; installing accepts "its full permission set" (Anthropic, GitHub Actions, 2026) |
Whether the app's permission set is wider than the job |
| The mask | With mask set, a sandboxed command sees a sentinel and the local proxy substitutes the real value for hosts in injectHosts (Anthropic, Sandboxing, 2026) |
That every GitHub host the run uses is on the list, and that the mask is set in user or managed settings |
| The mask's scope | sandbox.credentials affects sandboxed Bash commands only; Read, Edit, Write, WebFetch, WebSearch, MCP servers and hooks run outside (Anthropic, Sandboxing, 2026) |
Whether a Read deny rule covers the file that holds the token |
| The log | ::add-mask::VALUE masks a value in a workflow log (GitHub, Using, 2026) |
Whether the log shows what the job printed or what the model read |
The GitHub controls act at the repository and the log: a pushed value is scanned, and a printed value is masked. The Anthropic controls act at the command's environment and its outbound request. Neither page describes an approver for the token's use or a record of what the model received on the page where the token was displayed. A control that acts before any model reads the page would sit in front of both, and neither vendor documents one.
What does a masked token change in what a sandboxed command reads?
Masking is the documented mechanism that lets a command use a token it does not print. Anthropic's Sandboxing page says sandbox.credentials affects sandboxed Bash commands only; with mask set, the sandboxed command sees a sentinel and the local proxy substitutes the real value only on hosts in injectHosts, or every host in network.allowedDomains when that list is empty (Anthropic, Sandboxing, 2026).
In the worked record, the developer declares the token as a masked credential, puts the GitHub hosts the run uses, api.github.com among them, in injectHosts, and asks the agent to open the pull request. The gh pr create command inside the sandbox reads a sentinel where the token would be. The request leaves the sandbox, the proxy attaches the real token for each listed host, and GitHub accepts the push and creates the pull request. The output the model reads carries the sentinel, not the value.
Two settings decide whether the mask exists. sandbox.credentials is honored from user settings, managed settings and the --settings flag and ignored in .claude/settings.json and .claude/settings.local.json, so a repository's own settings file cannot be the place the mask is declared (Anthropic, Sandboxing, 2026). On macOS a masked credential file cannot be read at all inside the sandbox, the same effect as a deny, so the file is unavailable to a sandboxed command rather than replaced.
The limit is the first clause: sandboxed Bash commands only. The mask changes what a command sees. It does not change what the Read tool opens. Docker's proxy keeps the real credential on the host and shows the sandbox a sentinel (Can Credentials Stay Outside the Sandbox and Still Be Used Inside It?). The distinction between using a credential and reading it is the one Can a Coding Agent Use a Credential It Cannot Read? sets out.
What can the agent still read outside the sandbox?
The Sandboxing page is explicit that Read, Edit, Write, WebFetch, WebSearch, MCP servers and hooks run outside the boundary (Anthropic, Sandboxing, 2026). A token that a developer exported into the environment, or that gh wrote to a config file, is a file the Read tool can open unless a permission rule stops it. The permission rules are a separate configuration from the sandbox.
Anthropic's permissions page describes how to write one: a Read deny rule blocks Claude's file tools "from reading a file or directory," with Read(./.env) as the example (Anthropic, Permissions, 2026). Two limits belong in the same breath. A .claudeignore file "has no effect, so move its entries into Read deny rules," and the rules "don't apply to a command that reads files without naming them, such as grep -r pattern ." (Anthropic, Permissions, 2026). A token in a file the agent can open is one Read call or one search away from the context, and a masked credential does not cover the Read tool.
One lever covers subprocesses rather than the tool. CLAUDE_CODE_SUBPROCESS_ENV_SCRUB strips credentials from all subprocesses regardless of sandboxing (Anthropic, Sandboxing, 2026). It keeps an exported token out of the commands a session spawns and does not remove a file the Read tool can open.
So the test for a masked pull request is not whether the command printed the token. It is whether the raw value exists anywhere in the session's reach: the environment, the CLI config file, a .env file, an MCP server's config, or a page the agent fetches. Masking answers one of those routes. GitHub's guidance narrows what a token reaches but does not record which reads happened (How Do I Know Which Credentials a Coding Agent Has Touched?). Whether the token belongs in the session at all is its own review (Is It Safe to Give Claude Code My GitHub Token?).
What does a governed environment change?
A governed environment changes the page where a value is shown, not the command that later uses it. Values chosen by policy are replaced with consistent tokens before any model reads the screen, so a token settings page renders GH_TOKEN_001 and the model reads that value instead of the credential. Real values resolve only at the approved destination, at the moment of an approved action. A named person approves each consequential action, and every screen as tokens, every action and every approval is written to a record that exports to the organization's own monitoring.
For this page's question, the boundary is the part to take seriously. A token's display page is a rendered page, so a control at the render layer can keep the value out of the model there. The push is a command in a shell, and that is outside it. A team that wants both halves needs the render-layer control for the page and the token's scope, the mask and the Read rules for the terminal. Neither half substitutes for the other.
The research library compares the two designs for a coding agent (RedactSure vs Claude Code: 2026 Comparison & Alternative). The sequence to carry into a review is the page rendered, the value replaced there, the person approving, and the record exported. A command that runs later starts from the token the session holds, which is why the terminal settings still decide what the agent can do.
What the record shows
A render-layer control decides what the model receives on the screen before it reads the page, and the vendor pages locate the token's custody precisely. A token's scope limits where a leaked value can write; the mask changes what a sandboxed command sees; neither changes what the Read tool opens, and neither produces a record of what the model read. The pull request opens in each of those arrangements. What differs is the custody: the raw value sits in an environment or a config file, or it exists only for the proxy and the approved destination. A team can check its own session without reading another product page. Name the credential the agent uses, run one pull request on a test repository, and write down which component held the raw value at each step: the environment, the sandboxed command, the proxy, the Read tool, the transcript. Then compare that list with what the vendor's page says each control covers. The step that shows the value in the transcript is the one to fix first.
Methodology and limitations
This page rests on GitHub and Anthropic product documentation, one industry research release, and existing RedactSure research pages. The vendor pages were read between October 20, 2026 and November 4, 2026, and each Sources entry carries the date for its page; public documentation read in full gives a sound view of where each product applies its control. Quoted facts are cited to the page that states them, and the GitGuardian count is cited as the company reported it.
None of the products on this page was tested hands-on. The products are described from their public documentation, and none was tested for this page; vendor features change, and the page carries its date. RedactSure is deploying now with enterprise and government customers. The worked example describes a record type, a pull request opened with a masked token, and not an organization. Determinations about whether a workflow meets a contractual or regulatory requirement belong to counsel, assessors and the organization's own security and compliance officers. Nothing here replaces a pilot of one workflow on the organization's own repositories.
Frequently asked questions
Does Claude Code need my GitHub token to open a pull request?
Not necessarily, but it needs a credential GitHub accepts for the push and the API call, and in a local session that is usually the developer's own token. Anthropic's page states that "When omitted, the Claude Code GitHub Action authenticates as the Claude GitHub App" (Anthropic, GitHub Actions, 2026). What the credential reaches is then set by its scope. Check which identity the session presents before assuming the token must be yours.
What does a sandboxed command read when the token is masked?
A sentinel. With mask set, the sandboxed command sees a sentinel where the token would be, and the local proxy substitutes the real value only on hosts in injectHosts (Anthropic, Sandboxing, 2026). The command can open the pull request, and its output carries the sentinel rather than the credential. The mechanism covers sandboxed Bash commands only. Read, WebFetch, WebSearch, MCP servers and hooks run outside it, so a token in a file those tools reach is a separate exposure.
Can the agent still read the token from a file outside the sandbox?
Yes, unless a permission rule denies it. Read is outside the sandbox, and a .claudeignore file has no effect, so the entry belongs in a Read deny rule (Anthropic, Permissions, 2026). Deny rules also do not apply to a command that reads files without naming them, such as a recursive grep. A token in a config file is reachable by both routes. Keep it out of the files the session can open, not only out of the command's environment.
Who approves the push to the repository?
The person at the permission prompt, under whatever permission mode the session uses; GitHub then accepts the push if the token's scope allows it. The vendor pages reviewed describe permission rules and the sandbox, not a named approver recorded per action. A token scoped to one repository is the stronger control for a push, because the request fails at the host when the repository is not on the list. Ask who approves, and what the approval leaves behind.
What record shows which token the agent used?
The repository and API logs show the account or token that performed the action, and a masked command's output shows a sentinel. Neither shows what the model read. Push protection scans a push for hardcoded credentials, and Actions log masking hides a value in a log line (GitHub, Push, 2026; GitHub, Using, 2026). What the model received on the rendered token page is not described in the pages reviewed. Keep the token's use and the model's view as separate evidence.
What should a security team ask for in writing?
Which credential the agent presents, where it is stored, and which repository and permissions it reaches. Whether the mask is set in user or managed settings rather than a repository file, and which hosts are in injectHosts. Which Read deny rules cover the token's file, and whether a command can read it without naming it. What record shows what the model received from the rendered settings page. Ask for each answer beside a test run on a test repository, not instead of one.
How RedactSure Keeps a GitHub Token Off the Page the Model Reads
A developer who masks a token still has to trust that no file or tool outside the sandbox hands the value to the model. Anthropic's own page puts Read, Edit, Write, WebFetch, WebSearch, MCP servers and hooks outside the sandbox (Anthropic, Sandboxing, 2026).
The environment that enforces this is built by RedactSure, an AI agent controls, governance and data protection company.
Before, the token settings page renders the raw value into the model's context and the agent carries it into the shell. Inside the governed environment the same page renders GH_TOKEN_001, the real value resolves only at the approved destination when a named person approves, and the page, action and approval land in the AI Control Record.
RedactSure is deploying now with enterprise and government customers.
Everyone else controls where data can go. RedactSure controls what the AI can see.
See it on your own workflow
A raw token shown on a settings page stays in the model's context for the run. Bring a token you would ask an agent to use and see, with test values, what the model reads, the approval and the record. Book a demo