๐Ÿ“– Usage
Sandbox: Giving Sweep Dev Tools


The sandbox executes a set of commands to validate Sweep's changes using linters and type-checkers after every edit and fixes them when they fail. By default we use Trunk (opens in a new tab), an opinionated super-linter that installs all the common formatters and linters for your codebase.


Go to your local clone of your repo. Create your sweep.yaml if it doesn't already exist and copy the following template into it:

Templateย sweep.yamlย to copy
# Sweep AI turns bug fixes & feature requests into code changes (https://sweep.dev)
# For details on our config file, check out our docs at https://docs.sweep.dev
# If you use this be sure to frequently sync your default branch(main, master) to dev.
branch: 'main'
# By default Sweep will read the logs and outputs from your existing Github Actions. To disable this, set this to false.
gha_enabled: True
# This is the description of your project. It will be used by sweep when creating PRs. You can tell Sweep what's unique about your project, what frameworks you use, or anything else you want.
# Here's an example: sweepai/sweep is a python project. The main api endpoints are in sweepai/api.py. Write code that adheres to PEP8.
description: ''
# Default Values: https://github.com/sweepai/sweep/blob/main/sweep.yaml

Sweep uses our own Sandbox base image based this Dockerfile (opens in a new tab), and first installs everything in the install section. Then on every edit, it runs the commands in the check section for the edited file. When it errors (non-zero return code), the logs get fed back into Sweep to fix the error, guaranteeing that every commit generates validated code.

By default we use Trunk, an opinionated super-linter that installs all the common formatters and linters for your codebase. You can set up and configure Trunk for yourself by following https://docs.trunk.io/get-started (opens in a new tab). This is equivalent to having the following sandbox config in your sweep.yaml:

Default Sweep sandbox setup: Trunk
    - trunk init
    - trunk fmt {file_path}
    - trunk check --fix {file_path}

However, you can set up custom commands for your Sandbox. Here are some example sweep.yaml sandbox configurations:

Python withย pylint

Here's an example sweep.yaml for a Python repo that uses pylint.

    - pip install -r requirements.txt
    - pylint --errors-only {file_path}
Sweep's Own Config: Python 3.11, Poetry, and ย pylint

Sweep's own repo's sweep.yaml Python 3.11, Poetry and pylint.

    - apt install python3.11 -y
    - pip install poetry
    - poetry env use python3.11
    - poetry install
    - poetry run pylint --errors-only {file_path}
Sweep's landing page: Yarn withย prettier,ย eslintย andย tsc

Our landing page, which is Typescript-based, we have the following config:

    - yarn install --ignore-engines
    - yarn run prettier --write {file_path}
    - yarn run eslint {file_path}
    - yarn run tsc

We recommend starting with the formatters, followed by the linters and type-checkers. This is because formatters give clear error messages for syntax errors.


To ensure that your sandbox is set up properly, you can test it by creating an issue on a Sweep-installed repo with a title like

Sweep (sandbox): FILE_PATH

where FILE_PATH is the path to the file you want to run the sandbox on. For example, we can test the sandbox on sweepai/api.py by titling the issue Sweep (sandbox): sweepai/api.py. You can find this at https://github.com/sweepai/sweep/issues/2371 (opens in a new tab).