# Claude Code Agent - Documentation

> For the complete documentation index, see [llms.txt](/llms.txt). Markdown is available with `Accept: text/markdown` and `.md` URL variants.

Source: /docs/guides/sandbox-coding-agent-claude-code

# Claude Code Agent

Copy pageCopy page

Copy pageCopy page

Claude Code is Anthropic’s coding agent. On Novita Sandbox, the `claude-code` template gives you a ready-to-use, isolated environment where Claude Code can read and edit code, run commands, and complete multi-step engineering tasks autonomously — without directly modifying files on your local machine.
Typical use cases:

- Autonomous coding tasks — hand Claude Code a prompt (e.g. “add error handling to all API endpoints”) and let it implement changes end to end.

- Working on real repositories — clone a Git repo into the sandbox and have Claude Code refactor, fix bugs, or add features.

- Safe, unattended automation — run the agent fully automatically inside an isolated sandbox, so file and command actions never affect your own environment.

- Multi-step workflows — start a session to plan, then resume it to carry out each step.

The `claude-code` template comes with Claude Code pre-installed, so you can spin up a sandbox and drive Claude Code in just a few lines. The example below runs Claude Code in headless mode — a non-interactive, one-shot run that takes a prompt, produces its output, and exits, with no interactive terminal session — which is exactly what you want when driving it programmatically inside a sandbox. Create a sandbox from the template, run the `claude` CLI through `commands.run`, stream its output, then kill the sandbox.

##

[​](#quick-start)

Quick start

`-p "<prompt>"` (`--print`): runs Claude Code in non-interactive mode — it processes the prompt, prints the result to stdout, and exits, instead of opening an interactive session. This is what makes it scriptable inside a sandbox.

`--dangerously-skip-permissions`: skips the interactive approval prompts Claude Code normally shows before running tools (editing files, executing commands, etc.). It lets the agent act fully unattended, which is convenient in an isolated sandbox — but as the flag name warns, use it only in trusted, sandboxed environments, since the agent can take file and command actions without asking.

Python

JavaScript & TypeScript

```
import os
from novita_sandbox import Novita

def main() -> None:
novita = Novita(api_key=os.environ["NOVITA_API_KEY"])
sandbox = novita.sandbox.create(
"claude-code",
envs={"ANTHROPIC_API_KEY": os.environ["ANTHROPIC_API_KEY"]},
)
print("Sandbox created:", sandbox.sandbox_id)

execution = sandbox.commands.run(
'claude --dangerously-skip-permissions -p "Hello"',
on_stdout=lambda data: print(data),
on_stderr=lambda data: print(data),
)
print(execution)

sandbox.kill()
print("Sandbox killed")

if __name__ == "__main__":
main()
```

```
import { Novita } from 'novita-sandbox'

const novita = new Novita({ apiKey: process.env.NOVITA_API_KEY })
const sandbox = await novita.sandbox.create('claude-code', {
envs: { ANTHROPIC_API_KEY: process.env.ANTHROPIC_API_KEY },
})
console.log('Sandbox created:', sandbox.sandboxId)

const execution = await sandbox.commands.run(
'claude --dangerously-skip-permissions -p "Hello"',
{
onStdout: (data) => console.log(data),
onStderr: (data) => console.log(data),
}
)
console.log(execution)

await sandbox.kill()
console.log('Sandbox killed')
```

##

[​](#custom-claude-configuration)

Custom Claude configuration

To make Claude Code use a custom LLM (custom API token, base URL, or model), write the configuration to `~/.claude/settings.json` after creating the sandbox and before running `claude`. The `env` block in settings.json is injected into Claude Code as environment variables.

Python

```
import os
from novita_sandbox import Novita

def main() -> None:
novita = Novita(api_key=os.environ["NOVITA_API_KEY"])
sandbox = novita.sandbox.create("claude-code")
print("Sandbox created:", sandbox.sandbox_id)

sandbox.files.write(
"~/.claude/settings.json",
"""{
"env": {
"ANTHROPIC_AUTH_TOKEN": "",
"ANTHROPIC_BASE_URL": "",
"ANTHROPIC_MODEL": "",
"ANTHROPIC_REASONING_MODEL": "",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "",
"ANTHROPIC_DEFAULT_OPUS_MODEL": ""
},
"model": ""
}""",
)

execution = sandbox.commands.run(
'claude --dangerously-skip-permissions -p "Hello"',
on_stdout=lambda data: print(data),
on_stderr=lambda data: print(data),
)
print(execution)

sandbox.kill()
print("Sandbox killed")

if __name__ == "__main__":
main()
```

##

[​](#work-on-a-cloned-repository)

Work on a cloned repository

A common workflow is to clone a Git repository into the sandbox and let Claude Code work on it. Use `sandbox.git.clone` to check out the repo (with credentials for private repos), then run `claude` from inside the cloned directory.

Python

JavaScript & TypeScript

```
import os
from novita_sandbox import Novita

novita = Novita(api_key=os.environ["NOVITA_API_KEY"])
sandbox = novita.sandbox.create("claude-code")

sandbox.git.clone(
"https://github.com/your-org/your-repo.git",
path="/home/user/repo",
username="x-access-token",
password=os.environ["GITHUB_TOKEN"],
depth=1,
)

result = sandbox.commands.run(
'cd /home/user/repo && claude --dangerously-skip-permissions -p "Add error handling to all API endpoints"',
on_stdout=lambda data: print(data, end=""),
)
print(result)

sandbox.kill()
```

```
import { Novita } from 'novita-sandbox'

const novita = new Novita({ apiKey: process.env.NOVITA_API_KEY })
const sandbox = await novita.sandbox.create('claude-code')

await sandbox.git.clone('https://github.com/your-org/your-repo.git', {
path: '/home/user/repo',
username: 'x-access-token',
password: process.env.GITHUB_TOKEN,
depth: 1,
})

const result = await sandbox.commands.run(
'cd /home/user/repo && claude --dangerously-skip-permissions -p "Add error handling to all API endpoints"',
{ onStdout: (data) => process.stdout.write(data) }
)
console.log(result)

await sandbox.kill()
```

##

[​](#resume-a-session)

Resume a session

Claude Code can continue a previous session, so you can run a multi-step workflow across several invocations. Start a session with `--output-format json` to get a `session_id` in the response, then pass it to `--resume` on the next run to continue where you left off.

Python

JavaScript & TypeScript

```
import os
import json
from novita_sandbox import Novita

def main() -> None:
novita = Novita(api_key=os.environ["NOVITA_API_KEY"])
sandbox = novita.sandbox.create(
"claude-code",
envs={"ANTHROPIC_API_KEY": os.environ["ANTHROPIC_API_KEY"]},
)
print("Sandbox created:", sandbox.sandbox_id)

sandbox.git.clone(
"https://github.com/your-org/your-repo.git",
path="/home/user/repo",
username="x-access-token",
password=os.environ["GITHUB_TOKEN"],
depth=1,
)

# Start a new session with JSON output to capture the session ID
initial = sandbox.commands.run(
'cd /home/user/repo && claude --dangerously-skip-permissions --output-format json -p "Analyze the codebase and create a refactoring plan"',
)
session_id = json.loads(initial.stdout)["session_id"]
print("Session ID:", session_id)

# Resume the session with a follow-up task
follow_up = sandbox.commands.run(
f'cd /home/user/repo && claude --dangerously-skip-permissions --resume {session_id} -p "Now implement step 1 of the plan"',
on_stdout=lambda data: print(data, end=""),
)
print(follow_up)

sandbox.kill()
print("Sandbox killed")

if __name__ == "__main__":
main()
```

```
import { Novita } from 'novita-sandbox'

const novita = new Novita({ apiKey: process.env.NOVITA_API_KEY })
const sandbox = await novita.sandbox.create('claude-code', {
envs: { ANTHROPIC_API_KEY: process.env.ANTHROPIC_API_KEY },
})
console.log('Sandbox created:', sandbox.sandboxId)

await sandbox.git.clone('https://github.com/your-org/your-repo.git', {
path: '/home/user/repo',
username: 'x-access-token',
password: process.env.GITHUB_TOKEN,
depth: 1,
})

// Start a new session with JSON output to capture the session ID
const initial = await sandbox.commands.run(
'cd /home/user/repo && claude --dangerously-skip-permissions --output-format json -p "Analyze the codebase and create a refactoring plan"',
)
const sessionId = JSON.parse(initial.stdout).session_id
console.log('Session ID:', sessionId)

// Resume the session with a follow-up task
const followUp = await sandbox.commands.run(
`cd /home/user/repo && claude --dangerously-skip-permissions --resume ${sessionId} -p "Now implement step 1 of the plan"`,
{ onStdout: (data) => process.stdout.write(data) }
)
console.log(followUp)

await sandbox.kill()
console.log('Sandbox killed')
```

Last modified on August 6, 2026

[Codex Agent](/docs/guides/sandbox-coding-agent-codex)[VNC Desktop](/docs/guides/sandbox-integrations-desktop)
