# Sandbox

This integration is required for **Baz Fixer** and enables high quality, CI safe fixes.

### 1. How Baz Fixer works

1. When you trigger a fix, Baz spins up an isolated environment with dedicated resources, memory, and filesystem resources.
2. The repository is cloned into a secure working directory using a short lived access token, then runs any configured setup scripts to prepare the environment.
3. The AI agent executes within the sandbox where it can access the cloned repository only.
4. The agent iterates through code edits, runs validation commands, and attempts to resolve the requested fix.&#x20;
5. Once complete, Baz retrieves a write token and pushes the fix as a new commit to your branch.
6. The sandbox environment is cleaned up after the session ends.

### 2. What is a Sandbox? <a href="#id-1.-what-is-a-preview-environment" id="id-1.-what-is-a-preview-environment"></a>

Baz Sandbox is an isolated environment where **Baz Fixer** can read, edit, run and test code. \
Each fix runs in a temporary, self contained environment powered by AWS Bedrock AgentCore with no access outside the scoped repository.

#### Where to set up a Sandbox

To configure a Sandbox in Baz, go to:\
Settings → Integrations → Preview Environment → Sandbox → Add environment

<figure><img src="/files/6m6JCxKlb8enMeNJWYtK" alt=""><figcaption><p>Set up a new Sandbox</p></figcaption></figure>

### 3. What *you* need to provide <a href="#id-2.-what-you-need-to-provide" id="id-2.-what-you-need-to-provide"></a>

To define a Sandbox environment, Baz needs the following inputs:

#### 1. Repository

Select the repository Baz should clone and run inside the sandbox, one repository per sandbox configuration.

#### 2. Runtime

Select the runtime Baz should use to execute your code. This determines the base environment Baz provisions for the sandbox.&#x20;

* Baz supports latest versions of `node`, `python`, `go` and `rust`. &#x20;
* Each runtime comes pre-installed with `curl`, `jq`, and `uv/uvx`, which you can use in your setup script.

More environments are added every day, if yours isn't supported in the app, email <support@baz.co>.

#### 3. Environment Variables

Required to install dependencies, run formatters, linters and tests.

Examples:

* URL + tokens for private package registries
* Feature flags
* Database connection strings

You can:

* Set variables manually
* Import variables from a .env file

#### 4. Setup Script

A script Baz will run to install dependencies and prepare the environment before running your code.

Typical use cases:

* Installing dependencies
* Building the project
* Preparing test fixtures

Example:

```
npm ci
npm build
```

This script runs once per sandbox execution.

#### 5. Validation Script (Optional)&#x20;

An optional script Baz will run after applying fixes and before committing changes.&#x20;

Use this to verify that changes are safe and correct.&#x20;

Common examples:&#x20;

* Running tests&#x20;
* Running linters&#x20;
* Running type checks&#x20;
* Example:

```
npm run format
```

## FAQ

<details>

<summary>How secure is my sandbox?</summary>

The sandboxes are built on-demand, using the base image you selected and the setup script. They are created when a baz fix is requested, and maintain their state for 8 hours. After 8 hours of no activity, the sandbox is deleted and it is not possible to restart it.

Each sandbox has a shallow git clone of the relevant repository. Every repository is completely separated from other repositories.

</details>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.baz.co/basics/integrations/sandbox.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
