Skip to main content
Run the Cursor command-line interface (CLI) against a repository in a CoreWeave sandbox. Attach your terminal for interactive work, or run a prompt through the Sandbox software development kit (SDK) and collect the result. The CLI process, workspace, and commands run in the sandbox. Model requests go to Cursor. Cursor also supports Self-Hosted Machines, where Cursor’s cloud runs the agent loop and a separate worker executes tool calls.

Prerequisites

Before you begin, you need the following:
  • A Cursor user API key and access to a model supported by Cursor CLI.
  • A public repository URL. Private repositories require Git credentials inside the sandbox.
  • Outbound connectivity to Cursor, its download host, and your Git host.
In your local terminal, set the sandbox credential you want to use:
Si vous supprimez la variable CWSANDBOX_API_KEY, cws-agent utilise l’authentification W&B. Cursor reads CURSOR_API_KEY inside the sandbox. Cursor can send prompts, file contents, and tool output to its service. Use a repository and credentials appropriate for the task.

Run Cursor CLI with cws-agent

Use cws-agent to create a sandbox, install Cursor, and attach your terminal. Interactive attachment requires an interactive terminal (TTY) on macOS, Linux, or Windows Subsystem for Linux (WSL). Native Windows terminals aren’t supported. Export your Cursor key locally. cws-agent forwards it into the sandbox’s environment:
  1. Follow the cws-agent installation instructions.
  2. Replace [SANDBOX-NAME] with a session name containing 1 to 40 lowercase letters, digits, or hyphens, starting with a letter or digit. Replace [REPOSITORY-URL] with your repository URL:
    Cursor opens in /workspace/project. If a workspace trust prompt appears, accept it. --permission-mode native retains Cursor’s approval settings. cws-agent otherwise uses --force. --no-config-sync skips importing your local skills and Model Context Protocol (MCP) configuration.
  3. Ask Cursor to create a file you can retrieve:
    Approve any prompts for the task. Exit Cursor with /exit. In your local terminal, read the file:
    The output should be Hello from CoreWeave. Exiting Cursor leaves the sandbox running.
  4. After exiting all Cursor sessions in the sandbox, remove Cursor’s leftover worker.sock socket files, save the workspace, and stop compute:
    The cleanup removes socket files that can block snapshot creation. down takes a snapshot before stopping the sandbox. If snapshot creation fails, the sandbox stays running. Resolve the error and retry down before restoring.
  5. To return to the saved workspace, keep CURSOR_API_KEY exported locally and run:
    Ask Cursor to read the sandbox-proof.txt file to verify that it was restored. When finished, exit Cursor and repeat the cleanup and down commands.

Run an unattended prompt

Choose a new session name. In your local terminal, launch with --detach to skip terminal attachment, then send a prompt:
cws-agent run passes Cursor’s --force flag by default so the headless task can write files without interactive approval. Cursor retains explicit deny rules. To attach your terminal to the running session, run:
When finished, exit Cursor if attached, read the result with cws-agent exec, then clean up the sockets and save with cws-agent down as shown in Run Cursor CLI with cws-agent.

Run a task with the Sandbox SDK

Use the Sandbox SDK to manage a task directly. This path creates a separate sandbox, runs Cursor in print mode, retrieves the file, and stops the sandbox in a cleanup block. It doesn’t configure snapshots or require cws-agent.

Choose how to supply the Cursor key

Both scripts take an authentication mode as their first argument: L’injection de secrets W&B nécessite l’authentification W&B et un placement serverless. Demandez à un administrateur W&B d’ajouter votre clé Cursor en tant que secret d’équipe. Dans votre terminal local, remplacez [WANDB-TEAM] par le nom de votre équipe et [CURSOR-SECRET-NAME] par le nom du secret :
Votre clé API W&B doit avoir accès à cette équipe. Les scripts associent le secret indiqué à CURSOR_API_KEY dans la sandbox. Voir Utiliser les secrets W&B.

Install a client

Choose a language and install the client locally:
Use Python 3.11 or later and uv. In a new project directory, run:

Create, run, and clean up

Save the script for your language using the filename shown. Each script installs Cursor, clones the repository passed on the command line, and asks Cursor to write the sandbox-proof.txt file. The --print, --force, and --trust flags enable non-interactive output, permit file changes, and trust the workspace. Use this example only with a repository you trust. See Cursor headless mode.
run_cursor_sandbox.py
Dans le terminal local où vous avez défini vos identifiants d’authentification, remplacez [AUTH-MODE] par wandb et [REPOSITORY-URL] par l’URL de votre dépôt :
The script prints Cursor’s response followed by the file contents, Hello from CoreWeave. The cleanup block calls stop() even if setup or execution raises an error. Retrieve any additional files before the cleanup block runs. For larger results, use file operations. The 2-hour lifetime is a maximum wall-clock limit, including startup. Each command also has its own timeout. Changing the command timeout doesn’t extend the sandbox lifetime.

Troubleshoot

Use these checks to resolve common issues:
  • If sandbox creation fails, verify the credential for your selected authentication mode.
  • Si un secret W&B ne peut pas être résolu, vérifiez WANDB_ENTITY, CURSOR_SECRET_NAME ainsi que l’accès de votre clé API à l’équipe.
  • Si Cursor signale une erreur d’authentification, vérifiez la clé contenue dans votre secret W&B ainsi que l’accès de votre compte aux modèles.
  • If an SDK prompt only proposes changes, confirm that the Cursor command includes --force.
  • Si l’installation, le clonage ou les requêtes au modèle échouent, vérifiez la connectivité sortante et les identifiants d’authentification du fournisseur.

Next steps

For more information, see these guides:
Dernière modification le 30 septembre 2026