Skip to content

LearnTutorials

Connect an agent to GitHub with DigitalOcean Action Gateway

Connect a cloud Claude Code agent to GitHub with DigitalOcean Action Gateway in 20 minutes, and keep the GitHub token out of its sandbox.

By Recaply EditorsAdvanced20 min6 stepsUpdated

A hand pushes a sealed envelope through the slot of a small door, while a key hangs on a hook beside it

What you need

Managed Agents is in public preview, so commands and fields can still change.

  1. Step 1: Install doctl and sign in

    4 min

    Every Harness Runtime command runs through doctl, so you need a recent build that's signed in.

    1. Install doctl. On a Mac, run brew install doctl. On other systems, follow DigitalOcean's install guide.
    2. In the control panel, click Account, then API, then Generate New Token. Pick Full Access.
    3. Run the commands below and paste the token when asked.
    Run this
    doctl auth init
    doctl harness-runtime --help

    You should see a list of session commands, including launch, list, pause and remove.

    doctl says harness-runtime is an unknown command?

    Your doctl build is too old. Install the latest version, open a new terminal and run the help command again.

    This token can change anything in your DigitalOcean team. Keep it out of spec files, chats and repos.

  2. Step 2: Connect GitHub at the gateway

    3 min

    The gateway stores the GitHub login and adds it to each tool call, so the agent never holds the token.

    1. Open the Connections page and click Add connection.
    2. Pick GitHub, then DigitalOcean's OAuth app. Keep the Actor ID it fills in from your login email.
    3. Review the Permissions, click Connect, and approve access on GitHub.

    You should see your GitHub connection marked Active.

    GitHub connected the wrong account?

    GitHub approves whichever account your browser is signed in to. Sign out of GitHub, or use a private window, and connect again.

    This grant isn't limited to one repository. It reaches every repository the GitHub account can open.

  3. Step 3: Write the environment spec

    5 min

    One YAML file sets the agent, its model key, the gateway tools and what needs your approval.

    1. Save the text below as github-agent.yaml.
    2. Don't add a GITHUB_TOKEN line. The gateway brings the GitHub login, so the sandbox doesn't need one.
    3. Swap registry.npmjs.org for the package host your project uses.
    Your spec
    name: github-helper
    harness: claude-code
    size: mars-2vcpu-4gb
    secrets:
      ANTHROPIC_API_KEY: ${ANTHROPIC_API_KEY}
    egress:
      - registry.npmjs.org
    tools:
      - do.actions
    permissions:
      default: ask
      rules:
        - tool: file.read
          action: allow
        - tool: do.actions/action_search
          action: allow

    You should see a saved github-agent.yaml with harness: claude-code, do.actions and no GitHub token.

    The launch fails with a 400 error that names a field?

    DigitalOcean checks spec fields strictly, so a typo fails instead of being skipped. Fix the field it names and launch again.

    default: ask makes every GitHub call wait for you. Naming one host under egress blocks all others, and DigitalOcean adds GitHub and the model hosts itself.

  4. Step 4: Launch the agent and approve its calls

    5 min

    Watching the first calls shows you which GitHub tools the agent picks and what each one sends.

    1. Run the commands below, with your Anthropic key in place of [YOUR ANTHROPIC KEY].
    2. When Claude Code starts, ask: List the 5 newest open issues in [OWNER/REPO]. Draft a comment for the oldest one and wait for my OK.
    3. Read each approval request, then press y to approve or n to reject.
    Run this
    export ANTHROPIC_API_KEY=[YOUR ANTHROPIC KEY]
    doctl harness-runtime launch github-agent.yaml

    You should see approval requests that name each GitHub tool and its arguments, then the issue list and a draft comment.

    The agent shows a GitHub sign-in link instead of the issues?

    The session's actor ID doesn't match your connection. Find the actor on the Action Gateway Sessions page, and connect GitHub under that exact ID.

    Your key fills the ${ANTHROPIC_API_KEY} slot at launch. Never save or share a copy of the spec with the key filled in.

  5. Step 5: Check the sandbox has no GitHub token

    2 min

    The agent can read anything in its environment, so confirm the GitHub token isn't in there.

    1. Ask the agent to run the command below. It prints variable names only, not their values.
    2. Approve the shell command when asked.
    3. Look through the list for GITHUB_TOKEN or any other GitHub variable.
    Your prompt
    Run this and show me the output: env | cut -d= -f1 | sort

    You should see a list of names with ANTHROPIC_API_KEY in it and no GitHub token.

    You see GITHUB_TOKEN in the list?

    A secrets slot in your spec declared it. Remove that slot, remove this session, and launch a new one.

    Your Anthropic key is readable in there, like any secret. Use a key you can rotate, and rotate it if anything looks wrong.

  6. Step 6: End the session

    1 min

    A session bills for compute until it pauses or you remove it.

    1. Press Ctrl+D to detach. The session keeps running in the cloud.
    2. Run the command below to remove it.
    3. Done with GitHub access? Run doctl harness-runtime connections list, then doctl harness-runtime connections revoke with the connection's ID.
    Run this
    doctl harness-runtime remove github-helper

    You should see no github-helper session when you run doctl harness-runtime list.

You get

A Claude Code agent in a DigitalOcean sandbox that works on GitHub through the gateway, with no GitHub token inside

Did this guide work for you?

Sources