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

# GitHub Integration

> Connect your GitHub repositories to Magnet for automated cloning, branching, and pull request creation from AI coding sessions.

## Overview

Magnet's GitHub integration enables the AI agent to:

* **Clone repositories** into sandboxed environments
* **Create branches** for agent-generated changes
* **Open pull requests** against your base branch
* **Track PR status** (draft, open, merged, closed)
* **Auto-complete issues** when linked PRs are merged

## Setting up GitHub

<Steps>
  <Step title="Install the GitHub App">
    Go to **Settings** > **Integrations** in the Magnet dashboard and click **Connect GitHub**. This redirects you to GitHub to install the Magnet GitHub App.
  </Step>

  <Step title="Select repositories">
    Choose which repositories the app can access. You can grant access to all repositories or select specific ones.
  </Step>

  <Step title="Authorize the installation">
    Approve the permissions. Magnet requests:

    * **Read** access to code, metadata, and pull requests
    * **Write** access to pull requests and webhooks
  </Step>

  <Step title="Link a repository">
    Back in Magnet, link specific repositories to your workspace. Linked repos appear in the repository picker when creating sessions.
  </Step>
</Steps>

## How it works

### Repository cloning

When you create a session with a repository:

1. Magnet authenticates with GitHub using your organization's app installation
2. The sandbox clones the repository at the branch you specified
3. The agent works in an isolated copy — your repository is never modified directly

### Pull request creation

When the agent finishes making changes:

1. Changes are committed to a new branch (e.g., `agent/fix-signup-validation`)
2. A pull request is opened against the base branch
3. The PR link appears in the session for in-app review

### PR status syncing

Magnet keeps PR status up to date automatically. As PRs are reviewed, approved, or merged on GitHub, the status updates in Magnet.

## Disconnecting GitHub

To disconnect GitHub:

1. Go to **Settings** > **Integrations**
2. Click **Disconnect GitHub**
3. Optionally, uninstall the GitHub App from your GitHub organization settings

<Warning>
  Disconnecting GitHub will prevent existing sessions from creating new PRs or accessing repository data. Already-opened PRs are not affected.
</Warning>
