Lock down Claude Code for unattended runs
Set up a workstation so Claude Code can run with nobody watching, holding none of your keys and reaching only the hosts you list.
Set up a workstation so Claude Code can run with nobody watching, holding none of your keys and reaching only the hosts you list. Use this when Claude Code runs overnight, with nobody there to stop a command. You first record which hosts the agent uses while you work with it, and then allow only those.
For another agent, the allowlist, the GitHub token and the deadline work the same way, and Run your own coding agent in Ringleader covers its key.
Prerequisites
- Install Ringleader, with the Ringleader application running, and
sign in with
rl auth login. - A namespace that Ringleader holds, not
local. The examples useacme. Your organization’s policies then judge the workstation, as Node-bound workstations describes. - A GitHub provider that you hold the
useright on, which an org admin sets up as Connect workstations to GitHub with the Ringleader GitHub App shows. The examples name itacme-githuband use the repositoryacme/web. With no provider, setuserAuthorization: boxOwnerin the first Integration, which reaches every repository you can reach. The credential source has the fields. - An Anthropic API key for Claude Code, and a Ringleader deployment that runs the model endpoint.
- No workstation yet. The first task creates one named
my-agent-box. Replace the name with yours.
Record what the workstation reaches
Create the workstation with an audit policy, which records each connection. You build your list
from those records later.
Save this as
my-agent-box.yaml. It names no provider, so the workstation runs on your computer’s Default local provider:apiVersion: workstations.ringleader.dev/v1 kind: Workstation metadata: name: my-agent-box namespace: acme labels: role: agent spec: devtools: - name: claude-code - name: git egress: enforcement: auditApply the file:
rl apply -f my-agent-box.yamlWait for the workstation:
rl workstation wait my-agent-box -n acme --for condition=Configured --timeout 20mCheck that recording has started.
status.egress.recordedlistsallowedin the output:rl workstation get my-agent-box -n acme -o yaml
An audit policy blocks nothing
audit
policy below. Do not leave the agent alone before then.Keep your keys off the workstation
Ringleader adds the GitHub token and the model key to a request outside the workstation, so no program in it can read either.
Store the model key in a Secret that nobody can read back. Claude Code reaches the model through Ringleader’s endpoint, which holds the key:
rl secret create anthropic -n acme --ringleader-only --from-string token=<your-anthropic-key>Save this as
agent-keys.yaml. The first Integration adds a GitHub token that reaches onlyacme/web. The second points Claude Code at the model endpoint:apiVersion: workstations.ringleader.dev/v1 kind: Integration metadata: name: agent-github namespace: acme spec: type: httpProxy selector: matchLabels: role: agent httpProxy: vendor: github credentialSource: provider: kind: OrgCredentialProvider name: acme-github repositories: [acme/web] --- apiVersion: workstations.ringleader.dev/v1 kind: Integration metadata: name: agent-claude namespace: acme spec: type: llm selector: matchLabels: role: agent llm: endpoint: source: ringleader providers: anthropic: credentialRef: name: anthropic key: tokenApply the file yourself, not through someone else. A local workstation gets the GitHub token only when its owner is the person who first applied the Integration:
rl apply -f agent-keys.yamlWait until the workstation’s network process holds the new rules:
rl workstation wait my-agent-box -n acme --for=EgressAppliedOpen a shell on the workstation and clone the repository, which needs no credential in the command:
rl shell my-agent-box -n acme git clone https://github.com/acme/web.git
Do not forward an SSH key for Git. Cost of an SSH key says why.
Turn off claude.ai connectors
Claude Code connects the connectors of any claude.ai account signed in on the workstation. This turns that off, so the agent uses only the MCP servers you declare.
Add this inside the existing
spec:block ofmy-agent-box.yaml:toolconfigs: - id: claude-code name: claude-code config: claudeAiConnectors: denyApply the file again with
rl apply -f my-agent-box.yaml.
Allow only the hosts the agent used
Work with the agent once, then replace the audit policy with a strict one.
In a shell on the workstation, have Claude Code do the kind of task you plan to leave it with. A host it does not reach now is missing from your list.
Wait 10 minutes for Ringleader to store the connections.
On your computer, list what the workstation reached:
rl workstation egress my-agent-box -n acme --allowedIn
my-agent-box.yaml, replace theegressblock with the one below. Its hosts are the ones that installing Claude Code andgituses. Add each host your task needs, and none you don’t recognize:egress: enforcement: strict destinations: - host: deb.debian.org # Debian packages ports: [80, 443] - host: deb.nodesource.com - host: registry.npmjs.orgLeave out the hosts in Destinations Ringleader adds.
Apply the file again.
The workstation then reaches your list and the destinations Ringleader adds, and nothing else.
Listed hosts can still receive data
Hold every link for approval
On your computer, run rl urlopenrules default queue. Your computer then holds each link that any
workstation asks to open, and drops it if nobody answers within 10 minutes.
URL open rules shows how to answer one.
Set a deadline
Have Ringleader delete the workstation and its disk at a deadline, so a forgotten workstation does not keep what the agent wrote.
The deadline deletes the disk
ttl counts from when you created the
workstation, so one that has already passed deletes it and its disk at once.Add this inside the existing
spec:block ofmy-agent-box.yaml, with attlthat outlasts the task:lifecycle: ttl: 7dApply the file again.
Check the result
Confirm that the settings hold.
On your computer, run
rl workstation describe my-agent-box -n acme. TheEgressEnforcedcondition readsTrue, and its reason is no longerAudit.In a shell on the workstation, request a host that is not on the list, and an address on your local network, such as your router’s. Both requests fail:
curl --max-time 5 https://example.com curl --max-time 5 http://192.168.1.1Reach GitHub with no key. The command lists the repository’s references:
git ls-remote https://github.com/acme/web.gitRead the variables the model Integration sets, such as
ANTHROPIC_BASE_URL. The file holds no key:cat /etc/ringleader/integrations/agent-claude.json
Troubleshoot
- If
rl applyrefuses the workstation, New workstation refused says what to do for each reason. - If recording has not started, Audit recording says what it waits for.
- If the agent cannot reach a host it needs, run
rl workstation egress my-agent-box -n acme, which lists the refused connections. Add the host to the list and apply the file again. - If
EgressEnforcedreadsFalse, do not leave the agent alone.EgressEnforcedreasons says what each reason means. - If the model Integration’s status
messagesays that your deployment does not run the model endpoint, ask whoever runs Ringleader for your organization. - If
gitasks for a password or GitHub answers401, read the Credential injection section ofrl workstation describe my-agent-box -n acme. Ringleader renews the token only while you are signed in and your computer can reach Ringleader, so sign in withrl auth login. Troubleshoot lists each reason. - If that section gives a reason for a host, such as
RingleaderOnly, Reasons a host is not injected says what to do. - If the workstation stops when you sign out of Windows, lock the PC instead. Keep a workstation running after you sign out describes the other choice.
Next steps
- Limits of protection says who these settings protect against, and the limits that remain.
- Workstation reach audit explains what an
auditpolicy records. - MCP servers for coding agents declares the MCP servers the agent may use.