Agent CLIs
Hive ships ready-made images for the most popular CLI-based agents. Provision a sandbox with the right image, inject your API key, and the agent is ready to run — no local install required.
Supported CLIs
| CLI | Image |
|---|---|
| Claude Code | hive/claude-code:latest |
| Aider | hive/aider:latest |
| Codex | hive/codex:latest |
Running a one-shot task
sandbox.exec runs the agent command and returns once it exits. Use this for tasks where you only need the final output.
import { getOrCreateSandbox, shutdown } from "hive";
const sandbox = await getOrCreateSandbox("claude-session", {
image: "hive/claude-code:latest",
env: { ANTHROPIC_API_KEY: process.env.ANTHROPIC_API_KEY! },
fs: [{ backend: "local", mount: "/workspace", acls: [{ path: "/workspace/**", access: "rw" }] }],
egress: [{ access: "allow", host: "api.anthropic.com" }],
});
const result = await sandbox.exec("claude -p 'Fix the bug in src/main.ts'", { cwd: "/workspace" });
console.log(result.stdout);
await shutdown(sandbox);The return value has three fields: stdout, stderr, and exit_code.
Streaming output
CLI agents can produce a large amount of output and take a long time to finish. Use sandbox.execStream to receive stdout and stderr in real time rather than waiting for the process to complete.
const proc = await sandbox.execStream("claude -p 'Refactor the auth module'", { cwd: "/workspace" });
for await (const chunk of proc.pipes) {
process.stdout.write(chunk.stdout ?? "");
}
await proc.exitCode;How image + env works
Environment variables passed in the env field are injected at provision time and are immutable for the lifetime of the sandbox — the agent process inherits them automatically on every exec call without any extra configuration.
This means your API key only needs to be provided once when the sandbox is created. Subsequent exec and execStream calls on the same sandbox automatically have access to it.
// Key provided once at provision time
const sandbox = await getOrCreateSandbox("claude-session", {
image: "hive/claude-code:latest",
env: { ANTHROPIC_API_KEY: process.env.ANTHROPIC_API_KEY! },
// ...
});
// All subsequent calls inherit the env — no need to pass the key again
await sandbox.exec("claude -p 'Task one'", { cwd: "/workspace" });
await sandbox.exec("claude -p 'Task two'", { cwd: "/workspace" });Next: Agent Loop