Skip to content

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.

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.

Terminal window
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.

  1. The command reserves the --out file, empty and readable only by you.
  2. 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.
  3. You open the address and press the button. The page sends the manifest to GitHub, and you confirm the app there.
  4. GitHub sends the browser back to the command, which exchanges the one-time code for the app’s credentials.
  5. The command writes two lines to --out and prints the app’s name, owner, id, slug and install link. It never prints the key or the secret.

Then finish the setup:

  1. Copy the two lines from --out into 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 \n for each line break.
    • WEBHOOK_SECRET=, the secret GitHub signs every delivery with.
  2. Put the printed id in config.local.yml as app.id.
  3. 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).

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.

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.

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 .env as WEBHOOK_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 requiredChecks are 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.

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:

  1. Set the Callback URL to <ui.publicUrl>/api/auth/callback.
  2. Copy the Client ID into the config as app.clientId.
  3. Generate a client secret, put it in .env (for example as APP_CLIENT_SECRET), and name that variable in app.clientSecret.

When ui.team names a team, the app also needs the organisation permission Members read, which the manifest already asks for.

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.