Create the GitHub App
Visto AI reads pull requests and posts reviews through a GitHub App that you own. Each deployment has its own app, so your code, your keys and your installation stay yours. You can create the app with one command, which sets every permission and event from a manifest, or by hand in GitHub’s settings.
Create it with one command
Section titled “Create it with one command”npm run app:create registers the app from the manifest shipped in the repository (app-manifest.json). Run it from a checkout of the repository, on the machine whose browser you will use. It needs Node 26 and nothing else: it uses only Node’s own modules, so you do not need npm ci.
npm run app:create -- --webhook-url https://reviews.example.com/webhooks/github --out .env.visto-app --name "Visto AI Acme"
# For an organisation's repositories:npm run app:create -- --webhook-url https://reviews.example.com/webhooks/github --out .env.visto-app --name "Visto AI Acme" --org acme| Option | What it is |
|---|---|
--webhook-url |
The service’s public https address, with the path /webhooks/github. |
--out |
The file that receives the app’s secrets. It must not exist yet, and its folder must. Through npm, a relative path lands in the repository’s root; .gitignore covers .env*, so .env.visto-app is never committed. |
--name |
The app’s name: 1 to 34 letters, digits, spaces, hyphens, dots or underscores. GitHub requires app names to be unique, so include your organisation’s name. |
--org |
Optional. The login of the organisation that will own the app. Without it, the app belongs to the account signed in to GitHub in your browser. |
A missing or invalid option prints the usage line and exits with code 2 before anything is created.
What happens
Section titled “What happens”- The command reserves the
--outfile, empty and readable only by you. - It starts a small page on
127.0.0.1, on a port the system picks, and prints its address with a random token:http://127.0.0.1:<port>/<token>. Only a browser on the same machine can reach it. - You open the address and press the button. The page sends the manifest to GitHub, and you confirm the app there.
- GitHub sends the browser back to the command, which exchanges the one-time code for the app’s credentials.
- The command writes two lines to
--outand prints the app’s name, owner, id, slug and install link. It never prints the key or the secret.
Then finish the setup:
- Copy the two lines from
--outinto your deployment’s.env, then delete the file so the secrets are not kept twice:APP_PRIVATE_KEY=, the private key on one line, with\nfor each line break.WEBHOOK_SECRET=, the secret GitHub signs every delivery with.
- Put the printed id in
config.local.ymlasapp.id. - Open the install link (
<the app's address>/installations/new) and install the app on the repositories you want reviewed.
The app is private: only the account that owns it can install it. That is why an organisation’s app must be created with --org. Keep it private: a public demo that lets anyone sign in uses a second, public app for sign-in only (see Open sign-in to anyone).
What the app is given
Section titled “What the app is given”| Permission | Access | Why |
|---|---|---|
| Pull requests | Write | Post reviews and reply in their threads. |
| Contents | Write | Read the files of a pull request, and resolve a thread that a later review cleared. Visto AI never pushes code. |
| Issues | Write | Answer a /review comment. |
| Checks | Write | Write the merge gate’s check. |
| Commit statuses | Read | Read the commit statuses that the gate’s requiredChecks name. |
| Members (organisation) | Read | Check whether a commenter is in the gate’s skip team, or in a UI sign-in team. |
| Administration | Read | Check that a base branch dismisses stale approvals, for automatic approval. |
| Metadata | Read | Required by GitHub for every app. |
Events: pull_request, issue_comment, pull_request_review, pull_request_review_comment and pull_request_review_thread, to start reviews, read commands and learn from what people do; and check_run, to hear when someone re-runs the gate’s check. A re-run of the app’s whole check suite (check_suite, the Re-run all checks button) needs no subscription: GitHub sends it to any app with Checks write.
The manifest asks for everything every feature needs, so you can switch features on later without changing the app. If you prefer the app not to hold write access to contents, lower Contents to read-only in the app’s settings before you install it. The app then leaves a thread it cleared open instead of resolving it, and the service notes this at each start.
If something goes wrong
Section titled “If something goes wrong”| Output | What it means |
|---|---|
the file ... exists or cannot be created |
--out already exists, or its folder does not. Nothing was done. |
failed: github_<status>, github_network, github_bad_response |
GitHub refused the exchange, could not be reached, or sent credentials that do not look like a key and a secret. On a network error or a 5xx answer, the command tries once more after two seconds. |
failed: write_failed |
The secrets could not be written, for example because --out was moved or deleted while the command ran. |
failed: listen_failed, internal_error |
The local page could not start, or the command failed before GitHub was involved. |
After any failure, the reserved file is removed and the command exits with code 1. If GitHub had already created the app, it may exist with no private key in anyone’s hands: the command prints the app settings page (https://github.com/settings/apps, or https://github.com/organizations/<org>/settings/apps). Generate a private key and a webhook secret there, or delete the app and run the command again.
Stopping the command (Ctrl-C, closing the terminal) removes the reserved file unless the secrets were already written, and exits with code 130. With --org, if the app ends up owned by another account (you picked a different one on GitHub’s page), the command says so.
Create the app by hand
Section titled “Create the app by hand”To register the app in GitHub’s own form (Settings → Developer settings → GitHub Apps → New GitHub App, or the same under your organisation’s settings), set:
- Webhook: active, URL
https://<your service>/webhooks/github, and a secret of your own. Put the same secret in.envasWEBHOOK_SECRET. - Permissions, always: Pull requests write, Contents write (read is enough if threads should not be resolved), Issues write, Metadata read.
- Events, always: Pull request, Issue comment, Pull request review, Pull request review comment, Pull request review thread.
- For the merge gate: Checks write, the event Check run, Commit statuses read (only when
requiredChecksare named), and the organisation permission Members read (only when a skip team is named). - For automatic approval: Administration read.
- Where it can be installed: only on this account.
Then generate a private key, put it in .env as APP_PRIVATE_KEY (on one line, with \n for each line break), put the app’s id in the config as app.id, and install the app on your repositories.
In dry run only the read permissions are used. To add the gate’s or automatic approval’s permissions to an existing app later, change them in the app’s settings, accept them on each installation, and restart the service, as The merge gate and Automatic approval describe.
Sign in to the UI with GitHub
Section titled “Sign in to the UI with GitHub”The manifest names no callback URL, and the command does not keep the app’s OAuth client credentials. To let people sign in to the UI with GitHub, open the app’s settings page and:
- Set the Callback URL to
<ui.publicUrl>/api/auth/callback. - Copy the Client ID into the config as
app.clientId. - Generate a client secret, put it in
.env(for example asAPP_CLIENT_SECRET), and name that variable inapp.clientSecret.
When ui.team names a team, the app also needs the organisation permission Members read, which the manifest already asks for.
What the service checks at start
Section titled “What the service checks at start”The service reads the app’s permissions and events from GitHub once, at start, and logs feature_off for each switched-on feature that lacks something. Restart the service after you change the app’s permissions. See Leave dry run for the full list of checks.