> ## Documentation Index
> Fetch the complete documentation index at: https://docs.runlayer.com/llms.txt
> Use this file to discover all available pages before exploring further.

# GitHub access for agents

> Let an agent clone, commit, push and open pull requests on your repositories as your own GitHub App, with short-lived, repository-scoped tokens.

GitHub access lets a Runlayer agent work on your code the way a developer does: `git clone` a repository into its sandbox, change files, run your tests, commit, push a branch, and open a pull request. The agent acts as a GitHub App that your organization owns, so every commit and push shows up as `<your-app>[bot]`, never as a person.

> [!TIP]
>
> Importing skills from a private repository? You only need the workspace GitHub App connection. Follow setup steps 1–4 below, then continue with [private skill imports](https://docs.runlayer.com/platform-skills.md#import-from-private-github-repositories). You do not need an agent, Agent Account or agent GitHub access grant.

> [!NOTE]
>
> Connecting the App needs the **Manage org settings** capability. Granting it to an agent also needs [Agent Accounts](https://docs.runlayer.com/platform-agent-accounts.md) to be enabled for your workspace; if the agent's **GitHub access** section shows "Agent accounts are not enabled for this organization", contact Runlayer.

## GitHub access vs the GitHub connector

These are two different things, and an agent can use both.

| | GitHub connector | GitHub access |
| - | - | - |
| What the agent gets | MCP tools (search code, read issues, comment, review) | Real `git` in the agent's sandbox (clone, commit, push) |
| Who it acts as | The person whose GitHub account is connected | Your organization's GitHub App bot |
| Set up in | [Connectors](https://docs.runlayer.com/platform-connectors.md) | **Settings → Integrations** and the agent's **GitHub access** section |
| Good for | Reading and talking about GitHub | Changing code: fixes, refactors, dependency bumps, PRs |

## How it works

1. A GitHub org admin creates a GitHub App in your GitHub organization and installs it on the repositories agents may touch.
2. A Runlayer workspace admin connects that App in **Settings → Integrations**. Runlayer checks the credentials with GitHub before saving them.
3. A workspace admin grants the connection to an agent, optionally limited to specific repositories.
4. On every git network operation, the agent's sandbox asks Runlayer for a token. Runlayer mints a short-lived (about one hour) installation token scoped to that agent's repositories. No GitHub secret ships with the run or is written to disk.

## What you need

* **On GitHub:** an owner of the GitHub organization (or someone allowed to create and install GitHub Apps in it).
* **In Runlayer:** a workspace admin with the **Manage org settings** capability (Super Admins have it). Both connecting the App and granting it to an agent need this capability, because a grant hands the agent the App's reach.
* **For agent Git access:** an agent to grant access to. See [Agents](https://docs.runlayer.com/platform-agents.md). Private skill imports do not require an agent.

## Set up

Steps 1–4 connect the workspace's GitHub App. Step 5 is only for giving an agent Git access.

**1. Create a GitHub App**

In GitHub, open your organization's **Settings → Developer settings → GitHub Apps** and click **New GitHub App**.

* **GitHub App name:** anything you like, for example `acme-runlayer-agents`. Commits will show as `acme-runlayer-agents[bot]`.
* **Homepage URL:** any URL, for example your Runlayer workspace URL.
* **Callback URL** and **Setup URL:** leave them empty, and leave **Request user authorization (OAuth) during installation** unchecked. Runlayer only uses the App's installation, never a user sign-in, so it needs no redirect URL.
* **Webhook:** clear **Active**. Runlayer does not use GitHub App webhooks.
* **Repository permissions:**
  * **Contents:** Read-only for private skill imports; Read and write for agent Git access
  * **Metadata:** Read-only (GitHub sets this automatically)
  * **Pull requests:** Read and write (optional; add it if agents should open pull requests)
* **Where can this GitHub App be installed?** Only on this account.

Click **Create GitHub App**. Agents only ever get the permissions above, even if you give the App more.

**2. Note the App ID and generate a private key**

On the App's settings page, copy the numeric **App ID**.

In the left sidebar, click **Credentials**, then **Key pairs**. Click **New key**. GitHub downloads a `.pem` file containing the App's private key. Save this file: you paste its entire contents into Runlayer in a later step.

See GitHub's [private-key instructions](https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/managing-private-keys-for-github-apps#generating-private-keys) for the current key-management flow.

**3. Install the App on your organization**

On the App's page, open **Install App** and click **Install** next to your organization. Choose **All repositories** or **Only select repositories**. Agents can never reach a repository the installation doesn't include.

The **Installation ID** only exists after this step. Once you click **Install**, GitHub opens the installation's settings page; copy the number at the end of its URL, for example `https://github.com/organizations/acme/settings/installations/12345678` (or `https://github.com/settings/installations/12345678` for an App installed on a personal account). The App's public page, `https://github.com/apps/<app-name>`, doesn't contain it. To find it later, open your organization's **Settings → GitHub Apps** and click **Configure** next to the App.

**4. Connect the App in Runlayer**

In Runlayer, open **Settings → Integrations**, find **GitHub App** and click **Connect GitHub App**. Enter:

* **App ID**
* **Installation ID**
* **Private key:** paste the whole contents of the `.pem` file, including the `BEGIN` and `END` lines

Click **Connect**. Runlayer checks the three values together with GitHub and reads the organization the App is installed on from GitHub itself. The private key is stored encrypted and never shown again.

A workspace can connect one App per GitHub organization or account.

For private skill imports, App setup is complete. Open **Skills → Add skill → Import from GitHub** and follow the [private skill import steps](https://docs.runlayer.com/platform-skills.md#import-from-private-github-repositories). Skip the agent grant below.

**5. Grant the connection to an agent (agent Git access only)**

For an agent that needs to clone repositories, push code or open pull requests, open that agent under **Agents**, go to the **Agent** tab and find **GitHub access**. Click **Grant access**, then:

* **GitHub App connection:** pick the organization.
* **Repositories:** type the repositories this agent may use, as `owner/repo` (for example `acme/web`). Runlayer doesn't list the installation's repositories, so enter each name yourself. Every entry must belong to the connection's organization. Leave the list empty to allow every repository the installation can access.

Click **Grant access**. Each agent can hold one grant at a time; to switch organizations or repositories, revoke it and grant again.

The change applies to the agent's next run.

You can also grant, read and revoke an agent's GitHub access from an AI client through [Runlayer MCP](https://docs.runlayer.com/runlayer-mcp.md): `grant_agent_github_access`, `get_agent_github_access` and `revoke_agent_github_access` take the agent's id and need the same capability.

## Use it in a run

Ask the agent to work with HTTPS repository URLs. Git authenticates through Runlayer automatically; the agent never handles a password or personal access token. There is nothing else to turn on for the agent: it doesn't need Code mode or any other built-in tool for `git`.

Git access works in every run of the agent, whatever started it: the playground, a [Slack](https://docs.runlayer.com/platform-slack-notifications.md#agent-slack-apps) mention or DM, a schedule, a webhook or the API. To ask the agent for code changes from Slack, set up its Slack app on the agent page under **Slack**, then mention it with the task.

```text theme={null}
Clone https://github.com/acme/web.git, fix the failing date formatting test in
src/utils/date.ts, run the test suite, commit on a new branch named
fix/date-format, push it, and open a pull request against main.
```

What to expect:

* **Clone, fetch, pull and push** work for the granted repositories over `https://github.com/...`. SSH remotes (`git@github.com:...`) are not supported.
* **Commits** are authored as the App's bot (`<app-name>[bot]`), so GitHub links them to the App.
* **Pull requests** need the App's **Pull requests: Read and write** permission. The sandbox includes the GitHub CLI, so the agent can open them with `gh pr create`. `gh` uses the same credential as Git for each call, so the agent doesn't set `GH_TOKEN` itself.
* **Branch protection and rulesets still apply.** The agent can't push to a protected branch or merge anything your rules don't allow for the App.
* **Workflow files are off limits.** Tokens never carry the `workflows` permission, so GitHub rejects pushes that change files under `.github/workflows/`.
* **Network access policy:** if the agent uses an [allow list](https://docs.runlayer.com/platform-agents.md#network-access-policy), add `github.com`, and `api.github.com` if it opens pull requests or uses `gh`.
* **Offline eval replays** never get GitHub access.

## Security model

* **Short-lived tokens.** Each token lasts about an hour and is minted on demand. Nothing long-lived is stored in the sandbox.
* **Scoped twice.** The installation decides which repositories the App can see on GitHub; the agent's repository list narrows that further for each agent.
* **Per agent, not per run.** The repository list applies to every run of the agent. A run can reach any repository on the list, whichever one its task is about. To keep each run on one repository, see [Limit a run to one repository](#limit-a-run-to-one-repository).
* **Minimal permissions.** Tokens carry only Contents (read and write), Metadata (read) and, if the App has it, Pull requests (read and write). Other App permissions such as Workflows, Administration or Secrets never reach the agent.
* **Admins only.** Connecting an App and granting it to an agent both need the **Manage org settings** capability. Agent owners without it don't see the **GitHub access** section.
* **Audited.** Connecting or deleting an App and granting or revoking an agent's access appear in [Audit Logs](https://docs.runlayer.com/platform-audit-logs.md) as `github_app_installation_created`, `github_app_installation_deleted`, `installation_grant_created` and `installation_grant_revoked`, with who did it and which repositories were granted. Each private-repo read for a skill import or auto-update appears as `github_app_repo_read_token_minted`, with the admin it ran as, the repository, and whether it came from the web app (`skill_import_rest`), Runlayer MCP (`skill_import_mcp`) or auto-update (`skill_auto_update`).

## Limit a run to one repository

The repository list belongs to the agent, so you can't narrow it for a single run. If one agent reviews pull requests across many repositories and each run should only touch the repository it was started for, you have two options:

* **One agent per repository**, or per small group of repositories, each granted only its own repositories. This is the only option that also limits `git` in the sandbox.
* **Pin GitHub connector calls to the first repository a run touches.** Every run of a Runlayer agent is its own policy session, so the [repository isolation](https://docs.runlayer.com/platform-policies.md#repository-isolation) policy on your GitHub connector denies calls to a second repository in the same run, and the next run starts fresh. Apply it to the agent's [agent account](https://docs.runlayer.com/platform-agent-accounts.md). It only checks tools that take a `repo` argument, so deny tools that search across repositories with a free-form query if the agent doesn't need them. It doesn't limit `git` in the sandbox.

## Revoke access

* **One agent:** in the agent's **GitHub access** section, click the trash icon. The agent's next git operation against GitHub fails, and the token it holds is revoked at GitHub.
* **Every agent using an App:** in **Settings → Integrations → GitHub App**, delete the connection. All of its grants are revoked at once.
* **Disabled or deleted agents** can't get new tokens. For a disabled agent account, the token already in the sandbox is also revoked at GitHub within about a minute.
* **On GitHub:** uninstalling the App or deleting its private key stops all access immediately.

To rotate the private key, generate a new key on GitHub, delete the connection in Runlayer, connect it again with the new key, and grant it to the agents again.

## Troubleshooting

| Symptom | What to do |
| - | - |
| No **GitHub App** section in **Settings → Integrations** | You lack **Manage org settings**. Ask a workspace admin. |
| **Connect** stays disabled after you paste the Installation ID | The field takes only the number. Paste the digits at the end of the installation URL, not the whole URL. |
| The agent's **GitHub access** section shows "Agent accounts are not enabled for this organization" | Agent Accounts isn't enabled for your workspace. Contact Runlayer. |
| No **GitHub access** section on the agent | Only workspace admins see it. It is also hidden on the built-in Runlayer Assistant. |
| **Grant access** is disabled | Connect a GitHub App in **Settings → Integrations** first. |
| "GitHub rejected this App ID, installation ID and key together" | The three values don't belong together. Check the App ID on the App's page, the Installation ID from the installation URL, and that the key was generated for this App. |
| "The private key is not a readable PEM" | Paste the full `.pem` contents, including the `BEGIN` and `END` lines. |
| "A GitHub App is already connected for …" | That organization already has a connection. Delete it first to replace it. |
| "… is outside …, the account this GitHub App is installed on" | Repository entries must use the connection's organization as the owner. |
| "This agent already has GitHub access; revoke it first." | An agent holds one grant. Revoke the current one, then grant again. |
| Git asks for a username, or fails with "could not read Username" | The run has no GitHub access: the agent has no grant, or the remote isn't an `https://github.com/...` URL. Grant access, then start a new run. |
| Git fails with "Runlayer git credentials: This agent has no GitHub access" | The grant was revoked during the run. Grant access again, then start a new run. |
| Git fails with "repository not found" or HTTP 403 on push | The repository isn't in the agent's list or the installation's repositories, or the App lacks **Contents: Read and write**. |
| Opening a pull request fails with "Resource not accessible by integration" | Give the App **Pull requests: Read and write** on GitHub and accept the new permission on the installation. The next token picks it up. |
| `egress_denied` naming `github.com` | The agent's network access policy blocks GitHub. Add `github.com` (and `api.github.com`) to its allow list. |

## Related docs

> [card] [Agents](https://docs.runlayer.com/platform-agents.md)
>
> Build, schedule and run agents

> [card] [Agent Accounts](https://docs.runlayer.com/platform-agent-accounts.md)
>
> The identity every agent carries

> [card] [GitHub connector setup](https://docs.runlayer.com/github-mcp-oauth-setup.md)
>
> Give agents GitHub MCP tools that act as a user

> [card] [Audit Logs](https://docs.runlayer.com/platform-audit-logs.md)
>
> Review who granted which agent access to what


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.