Skip to main content
You need a Styne API key and the unmodified E2B SDK with E2B_API_KEY and E2B_API_URL=https://api.styne.ai set (Switch from E2B). The base template has git.

Clone, change, commit

The first example needs no network and no account: it makes a bare repository inside the sandbox to act as origin, so you can run the whole loop and see every step. Replace that repository with your own remote in the next section.
The last line prints the commit that reached origin, with its own hash:

Use your own repository and a token

Pass the token to the one command that needs it, as an environment variable of that command. It is never written into a URL, a git config or a file in the sandbox, and it is gone when the command ends. This block is shown, not run by the docs smoke: it needs your repository and your token.
Give the token the least it needs: a fine-grained token for one repository with contents write access. Anything the sandbox runs can read an environment variable of its own commands, so use a token you would be content to see leaked into that sandbox, and revoke it when the task ends.

Keep the workspace between tasks

A workspace on a paused sandbox is exactly where you left it: files, branches and uncommitted changes. To start many tasks from one prepared clone, save it as a snapshot and start every task from the snapshot; see Timeouts, pause and resume and Evals and RL fan-out.

Things to know

  • Clone with --depth 1 for large repositories: it is quicker and uses less of the sandbox’s disk (51 GiB on base).
  • The default working directory of a command is /root, the home directory of the base template. Give cwd or an absolute path when it matters.
  • Output of git goes to stderr for progress lines. commands.run returns both; a non-zero exit raises CommandExitException in Python and CommandExitError in TypeScript.