Run Claude Code on your Claude plan
Claude Code in a sandbox can sign in with your Claude Pro or Max subscription. Model usage then counts against your Claude plan, and Tangle bills only the sandbox’s compute. For Codex on a ChatGPT plan, see Codex on your ChatGPT plan.
1. Create a token
On your machine, with Claude Code installed:
claude setup-tokenIt signs you in to your Claude account in a browser and prints a long-lived token. Anyone holding the token can use your plan.
2. Store it as a secret
await client.secrets.create("CLAUDE_TOKEN", process.env.CLAUDE_CODE_OAUTH_TOKEN!);Secrets covers how stored values are kept and delivered.
3. Start Claude Code
import { Sandbox } from "@tangle-network/sandbox";
const client = new Sandbox({
apiKey: process.env.TANGLE_API_KEY!,
baseUrl: "https://sandbox.tangle.tools",
});
const box = await client.create({
backend: {
type: "claude-code",
model: {
cliAuth: { account: "me", secretEnv: "CLAUDE_TOKEN", format: "token" },
},
},
secrets: ["CLAUDE_TOKEN"],
git: { url: "https://github.com/tangle-network/sandbox-demo" },
});
try {
const run = await box.prompt("Summarize this repository in five bullets.", {
sessionId: "main",
});
console.log(run.success ? run.response : run.error);
} finally {
await box.delete();
}| Field | Meaning |
|---|---|
backend.type: "claude-code" | Run Claude Code. |
backend.model.cliAuth | Names the secret that holds the token. format: "token" means the secret is the claude setup-token value. account is your own label: letters, digits and @._+-. |
secrets: ["CLAUDE_TOKEN"] | Grants this sandbox the secret. |
The create request is refused when cliAuth names a secret that is not in
secrets. The CLI’s --cli-auth <secret> adds the secret to secrets for you.
cliAuth is the whole credential. It cannot be combined with apiKey,
apiKeyEnv, baseUrl or authFiles on the same backend.
Grant the token to a running sandbox
box.grantNativeCredential() installs a stored token in a sandbox that is
already running. The call names the secret; the value never crosses it.
await box.grantNativeCredential({
harness: "claude-code",
cliAuth: { account: "me", secretEnv: "CLAUDE_TOKEN", format: "token" },
});A sandbox already signed in to a different account refuses the switch:
create a new sandbox for the other account. The Python SDK has no
grantNativeCredential; call POST /v1/sandboxes/{id}/native-credentials
with client.fetch() and the same body.
Rotate the token
After claude setup-token prints a new token, replace the stored value.
client.secrets.update() replaces it and re-keys running sandboxes that use
it:
await client.secrets.update("CLAUDE_TOKEN", process.env.CLAUDE_CODE_OAUTH_TOKEN!);An update that answers 503 stored the new value, but not every running sandbox confirmed the re-key. To cut access everywhere at once, revoke the token in your Claude account settings.
In a workflow
A workflow’s agent.run step uses the same token when its profile declares the
source. Store the token as CLAUDE_TOKEN, then set
model.metadata.credentialSource: subscription on a claude-code profile:
- id: review
agent.run:
profile:
harness: claude-code
model:
metadata: { credentialSource: subscription }
prompt: { instructions: ["Review the change."] }
prompt: "Review the last commit."The run creates its sandbox with cliAuth and CLAUDE_TOKEN in secrets.
An account with no CLAUDE_TOKEN fails with No stored secret named CLAUDE_TOKEN. A subscription profile runs only in a sandbox, never as a
worker or inference step. See Workflows.
From HTTP
Credential fields sit under backend.model. The body names the secret; the
token never appears in it.
curl -X POST https://sandbox.tangle.tools/v1/sandboxes \
-H "Authorization: Bearer $TANGLE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"backend": {
"type": "claude-code",
"model": {
"cliAuth": { "account": "me", "secretEnv": "CLAUDE_TOKEN", "format": "token" }
}
},
"secrets": ["CLAUDE_TOKEN"]
}'Troubleshooting
| Message | Fix |
|---|---|
Native authentication secret CLAUDE_TOKEN must be listed in secrets | Add the secret name to secrets. |
No stored secret named CLAUDE_TOKEN | Store the token first, under exactly that name. |
cliAuth cannot be combined with API credentials, baseUrl, or inline authFiles | Use cliAuth alone on the backend. |
Next
- Codex on your ChatGPT plan
- AgentProfiles: give the agent a role, skills and tools.
- Network access: keep the agent to the hosts it needs.