# Open pull requests

Clone a private GitHub repository into a VM, let an agent push a branch, open a pull request and confirm that the VM holds no token.

Source: https://slashinfra.com/docs/agents/pull-requests
Last modified: 2026-11-30T16:36:19.000Z

Your VM clones a private repository, an agent pushes a branch, and you open a pull request from the VM. The VM never holds the GitHub token: `env` shows only the placeholder `GH_TOKEN=injected`.

## Before you start

- A GitHub account with access to the repository, and a fine-grained personal access token for it. The token needs Contents and Pull requests set to read and write. 
- A `GH_PAT` shell variable that holds the token. 
- The `si` CLI, installed as shown in [From your terminal](https://slashinfra.com/docs/start/cli).

## 1. Connect GitHub

Store the token as a secret named `github`. The VM never reads it.

```bash
printf '%s' "$GH_PAT" | si org secret create github
```

The secret is write-only: after you save it, only its name is visible. The `github` preset adds the token to HTTPS requests to GitHub hosts only.

If your organization has a GitHub [connection](https://slashinfra.com/docs/platform/connections), skip the token: run `si org connection add github` once, then create the VM in step 2 with `si create --name "$VM" --github` instead of `--inject github:github`. The vault adds an installation token that it refreshes every hour, for the repositories you chose at the install.

## 2. Clone the repository

Create a VM with the `github` preset, then clone over HTTPS. Git over SSH does not receive the credential.

```bash
VM=pr-example
si create --name "$VM" --inject github:github
si exec "$VM" -- git clone https://github.com/octo-org/private-app.git /home/user/private-app
```

## 3. Let the agent push a branch

```bash
si agent run "$VM" --agent claude --cwd /home/user/private-app -- 'Fix the failing parser test on a new branch named fix. Commit the change and push the branch to origin.'
```

The agent pushes with the same injected credential as your own commands, so it never sees the token either.

## 4. Open the pull request

```bash
si exec "$VM" -- gh pr create --repo octo-org/private-app --head fix --fill
```

`--head` names the branch the agent pushed. Open the new pull request in GitHub.

## 5. Check `env`

```bash
si exec "$VM" -- env
```

Output

```text
GH_TOKEN=injected
...
```

`GH_TOKEN` holds the word `injected`. The token itself is not in the VM, so no line of `env` contains it.

## Check it works

You should now see an open pull request on GitHub with the branch `fix`. Its `env` output has `GH_TOKEN=injected` and no other GitHub credential.

## If it doesn’t work

| Answer | Cause | Fix |
| --- | --- | --- |   
| `Repository not found` on clone | The token cannot reach the repository, or the URL uses SSH | Check the repository access of the token, and use an `https://github.com/` URL. | 
| `git push` is refused | The token has only read access to Contents | Create a token with write access to Contents, then replace the value of the `github` secret. | 
| `gh pr create` fails | The token has no write access to Pull requests | Create a token with write access to Pull requests, then replace the value of the `github` secret. | 
| `github_conflict` on create | `--github` and `--inject github:github` were both given | Use one of them: the connection or the token. |

## Clean up

```bash
si rm "$VM"
```

Output

```text
deleted <id>
```

The VM and its files are deleted. The branch stays on GitHub.

## Next

- [Connections](https://slashinfra.com/docs/platform/connections): link a GitHub account so a VM clones a private repository without a token. 
- [Secrets](https://slashinfra.com/docs/platform/secrets): rules, presets and the domains that receive a credential. 
- [Claude Code](https://slashinfra.com/docs/agents/claude-code): sign in an agent and ask it for a fix. 
- [Private network](https://slashinfra.com/docs/platform/private-network): reach your other VMs by name.
