For the complete documentation index, see llms.txt. A markdown version of this page is at /guides/lock-down-claude-code/index.md.

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 use acme. Your organization’s policies then judge the workstation, as Node-bound workstations describes.
  • A GitHub provider that you hold the use right on, which an org admin sets up as Connect workstations to GitHub with the Ringleader GitHub App shows. The examples name it acme-github and use the repository acme/web. With no provider, set userAuthorization: boxOwner in 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.

  1. 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: audit
  2. Apply the file:

    rl apply -f my-agent-box.yaml
  3. Wait for the workstation:

    rl workstation wait my-agent-box -n acme --for condition=Configured --timeout 20m
  4. Check that recording has started. status.egress.recorded lists allowed in the output:

    rl workstation get my-agent-box -n acme -o yaml

An audit policy blocks nothing

The workstation can reach any host, your local network included, until you replace the 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.

  1. 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>
  2. Save this as agent-keys.yaml. The first Integration adds a GitHub token that reaches only acme/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: token
  3. Apply 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.yaml
  4. Wait until the workstation’s network process holds the new rules:

    rl workstation wait my-agent-box -n acme --for=EgressApplied
  5. Open 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.

  1. Add this inside the existing spec: block of my-agent-box.yaml:

    toolconfigs:
      - id: claude-code
        name: claude-code
        config:
          claudeAiConnectors: deny
  2. Apply 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.

  1. 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.

  2. Wait 10 minutes for Ringleader to store the connections.

  3. On your computer, list what the workstation reached:

    rl workstation egress my-agent-box -n acme --allowed
  4. In my-agent-box.yaml, replace the egress block with the one below. Its hosts are the ones that installing Claude Code and git uses. 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.org

    Leave out the hosts in Destinations Ringleader adds.

  5. Apply the file again.

The workstation then reaches your list and the destinations Ringleader adds, and nothing else.

Listed hosts can still receive data

The agent can still send what it reads to any host on the list, to GitHub and to the model endpoint. DNS lookups also leave the workstation, so data can leave in names. Connections a policy does not stop says more.

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

Push the agent’s work to GitHub before the deadline. The ttl counts from when you created the workstation, so one that has already passed deletes it and its disk at once.
  1. Add this inside the existing spec: block of my-agent-box.yaml, with a ttl that outlasts the task:

    lifecycle:
      ttl: 7d
  2. Apply the file again.

Check the result

Confirm that the settings hold.

  1. On your computer, run rl workstation describe my-agent-box -n acme. The EgressEnforced condition reads True, and its reason is no longer Audit.

  2. 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.1
  3. Reach GitHub with no key. The command lists the repository’s references:

    git ls-remote https://github.com/acme/web.git
  4. Read 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 apply refuses 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 EgressEnforced reads False, do not leave the agent alone. EgressEnforced reasons says what each reason means.
  • If the model Integration’s status message says that your deployment does not run the model endpoint, ask whoever runs Ringleader for your organization.
  • If git asks for a password or GitHub answers 401, read the Credential injection section of rl 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 with rl 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