Inspect

Repository builds

Repository builds install tools and dependencies into an image that Inspect can restore for new sessions. Use them for setup that would otherwise run each time an agent starts work, such as installing system packages or resolving a lockfile.

You need the Edit repositories role to change repository scripts. Managing shared scripts requires the Manage secrets role. See Users and roles.

Configure setup scripts

Open Repositories, select your repository, and choose Build scripts. Inspect has two repository-level scripts:

  • The Pre-install script runs before cloning, with /root as the working directory. Use it for toolchains and other setup that does not read repository files.
  • The Post-install script runs after cloning and repository image setup. Use it for dependency installation and setup that reads the checkout.

Between these scripts, Inspect clones the configured base branch and runs .inspect/image-setup.sh from the repository if that file exists. The image captures the resulting filesystem, including installed dependencies.

Setup scripts receive variables with the Build scope. Read credentials from environment variables instead of embedding their values in scripts. A script can still write credentials into files that become part of the image; marking a variable Secret does not prevent that.

Default dependency installation

The default Post-install script installs dependencies only when the corresponding dependency directory is missing:

  • package.json and bun.lock or bun.lockb: bun install --frozen-lockfile, then bun install --no-cache if needed.
  • package.json and package-lock.json: npm ci, then npm install if needed.
  • package.json and pnpm-lock.yaml or yarn.lock: warns that you must add an install command.
  • package.json without those lockfiles: bun install, then bun install --no-cache if needed.
  • uv.lock without .venv: uv sync --frozen.

JavaScript installation is skipped when node_modules exists. Each default install attempt has a 15-minute timeout. Failed installs print a warning and let the default script continue, so a successful image build does not guarantee that dependencies installed. Add the commands your repository needs when the defaults do not cover it.

Shared scripts

Configure reusable setup in Environment → Build scripts. Each shared script applies to all repositories or the repositories you select. Names must be unique.

Shared scripts run in their configured order before the repository's Pre-install script. Move up and Move down change that order. Each runs in its own Bash process: files written by one script remain available to later scripts, but shell exports do not carry over. A shared script failure stops the build.

Saving a shared script does not start builds for all affected repositories. New session setup uses the updated scripts, and images pick them up on their next build. Shared scripts and repository scripts can run again during session setup, so commands must tolerate files or packages that the image already contains. During session setup, script failures produce warnings and setup continues.

If a shared script needs a credential during both image builds and session setup, give its environment variable both Build and Runtime scopes.

Rebuilds and failures

Saving repository scripts or repository environment variables starts a rebuild and supersedes any active build for that repository. The current published image normally remains available until the replacement is ready. Deleting a repository variable or updating an existing Secret invalidates the published image at once, because an earlier script may have persisted that value into it.

Organization environment variables and shared-script changes take effect in future builds without starting a rebuild for every repository.

Each build command has a maximum runtime of 30 minutes, further limited by the build's remaining execution budget. The build execution deadline is 2 hours 15 minutes after queuing; publishing the completed image can take additional time. A nonzero exit from a custom setup command fails the build unless the script handles that error itself.

When dependencies are missing despite a successful build, check for the default install script's warnings and whether an existing node_modules or .venv caused installation to be skipped. For an authentication failure during session setup, check that the credential has Runtime scope as well as Build scope.