# The GitHub App

The GitHub App is how Momentic writes back to your repository: status comments on pull requests, auto-heal repair PRs, and AI routing for where a repair lands.

## What the app does

| Capability                                                        | What it looks like                                                                                                                                               |
|-------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------| 
| **Status comment** on each PR                                    | One comment summarizing the Momentic runs against that branch; updates in place                                                                                 |  
| **Healing PRs** from [`momentic ai triage`](/content/docs/reliability/auto-maintenance/index.html) | A PR (or direct commit, draft PR, or patch: your triage setting) carrying repaired tests                                                                 |  
| **AI routing**                                                    | Decides per repair whether the failure came from the branch under test; needs [`gitMainBranch`](/content/docs/configuration/momentic-config#gitmainbranch/index.html) |  
| **Author resolution**                                             | Assigns and requests review from original commit authors on healing PRs when enabled; skipped for authors without repo access                                    |  
| **PR template pickup**                                           | Healing PRs use `pull_request_template.md`/`PULL_REQUEST_TEMPLATE.md` found in the repo root, `.github/`, or `docs/`                                          |

## Install

1. Open [Settings > Integrations](https://app.momentic.ai/settings/integrations) in the dashboard.
2. Click **Connect** on the GitHub card and authorize Momentic to check which installations your GitHub account can access.
3. Pick an existing installation, or choose **Install on another account** and select either **All repositories** or a subset in GitHub.

The same GitHub App installation can be linked to multiple Momentic workspaces. This is useful when those workspaces use repositories from the same GitHub organization. To reuse an installation, you must be able to manage integrations in both the workspace that already uses it and the workspace you are connecting. Each Momentic workspace still connects to only one installation.

Status comments are on by default once the app is installed. Configure them under **Pull request comments** on the integration card.

## Pull request comments

The **Pull request comments** section of the GitHub integration card controls what Momentic posts on the pull request for a branch:

- **Post pull request comments** turns the status comment on or off for the workspace.
- **Passing runs** keeps a compact comment when every test passes. Turn it off to remove the Momentic comment once every run group for the commit has been evaluated and is passing. A failing or still-running group keeps the comment in place.
- **Failure details** picks what the comment shows for up to four unresolved tests: **Failed tests** lists each test with a direct run link and notes, and **Run groups** shows the run group summary instead.

Both options require **Post pull request comments** to be on.

## Data flow

How a run becomes a PR comment:

```
your CI runs `momentic run` -> results upload to Momentic
       |
Momentic matches the run's branch/commit to an open PR via the app
       |
status comment is created (or updated) on the PR
```

The comment links each run back to the dashboard’s video, trace, and step evidence. New runs on the same branch edit the existing comment rather than posting a new one. Healing goes the other direction: `ai triage` writes repaired test files, then opens a PR through the app. [AI routing](/content/docs/reliability/auto-maintenance#ai-routing/index.html) decides the target: a commit on the branch under test when the branch caused the failure, a separate PR against `gitMainBranch` when it did not, or a reference to an existing PR when the fix already exists.

## Permissions

The app requests repository permissions at install time. Two are worth knowing:

- **Issues or pull requests: write**: required for the status comment. If a reviewer approved the app with a reduced permission set, comments silently skip.
- **Contents: write**: required for healing PRs and AI-routed commits. Without it, triage still analyzes but cannot deliver a PR.

When Momentic ships a feature that needs a new scope, GitHub emails the org admins a “new permissions” request. The capability stays off until an admin approves it in GitHub; the request does not appear in Momentic settings.

## Gotchas

- **Subset installs.** If you installed on selected repositories, PRs in other repos get no comment and heals cannot push there. Update the repo list on the installation’s GitHub page (org Settings > GitHub Apps > Momentic > Configure).
- **Forks.** Runs triggered on fork PRs comment on the upstream PR only when the app is installed on the upstream repo: the normal case. Runs inside the fork’s own repo need the app installed on the fork.
- **Renames and transfers.** Repository renames are followed by GitHub, but a repo transferred to a different org leaves the installation. Reinstall under the new org.
- **One installation per workspace.** A Momentic workspace can connect to one GitHub App installation. Disconnect the current installation before linking a different one.

## Uninstall or disconnect

- **From Momentic**: disconnect on the GitHub card in [Settings > Integrations](https://app.momentic.ai/settings/integrations). If other Momentic workspaces share the installation, this unlinks only the current workspace. Otherwise, it also uninstalls the GitHub App, preserving the behavior of an unshared connection.
- **From GitHub**: uninstall the Momentic app under the org’s **Settings > GitHub Apps** (or **Settings > Applications** for a personal install). The `installation.deleted` webhook marks the Momentic side disconnected automatically.
