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.

What you need
Managed Agents is in public preview, so commands and fields can still change.
Step 1: Install doctl and sign in
4 minEvery Harness Runtime command runs through doctl, so you need a recent build that's signed in.
- Install doctl. On a Mac, run
brew install doctl. On other systems, follow DigitalOcean's install guide. - In the control panel, click Account, then API, then Generate New Token. Pick Full Access.
- Run the commands below and paste the token when asked.
Run thisdoctl auth init doctl harness-runtime --help
You should see a list of session commands, including
launch,list,pauseandremove.doctl says
harness-runtimeis 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.
- Install doctl. On a Mac, run
Step 2: Connect GitHub at the gateway
3 minThe gateway stores the GitHub login and adds it to each tool call, so the agent never holds the token.
- Open the Connections page and click Add connection.
- Pick GitHub, then DigitalOcean's OAuth app. Keep the Actor ID it fills in from your login email.
- 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.
Step 3: Write the environment spec
5 minOne YAML file sets the agent, its model key, the gateway tools and what needs your approval.
- Save the text below as
github-agent.yaml. - Don't add a
GITHUB_TOKENline. The gateway brings the GitHub login, so the sandbox doesn't need one. - Swap
registry.npmjs.orgfor the package host your project uses.
Your specname: 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: allowYou should see a saved
github-agent.yamlwithharness: claude-code,do.actionsand 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: askmakes every GitHub call wait for you. Naming one host underegressblocks all others, and DigitalOcean adds GitHub and the model hosts itself.- Save the text below as
Step 4: Launch the agent and approve its calls
5 minWatching the first calls shows you which GitHub tools the agent picks and what each one sends.
- Run the commands below, with your Anthropic key in place of [YOUR ANTHROPIC KEY].
- 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. - Read each approval request, then press
yto approve ornto reject.
Run thisexport 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.Step 5: Check the sandbox has no GitHub token
2 minThe agent can read anything in its environment, so confirm the GitHub token isn't in there.
- Ask the agent to run the command below. It prints variable names only, not their values.
- Approve the shell command when asked.
- Look through the list for
GITHUB_TOKENor any other GitHub variable.
Your promptRun this and show me the output: env | cut -d= -f1 | sort
You should see a list of names with
ANTHROPIC_API_KEYin it and no GitHub token.You see
GITHUB_TOKENin the list?A
secretsslot 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.
Step 6: End the session
1 minA session bills for compute until it pauses or you remove it.
- Press
Ctrl+Dto detach. The session keeps running in the cloud. - Run the command below to remove it.
- Done with GitHub access? Run
doctl harness-runtime connections list, thendoctl harness-runtime connections revokewith the connection's ID.
Run thisdoctl harness-runtime remove github-helper
You should see no
github-helpersession when you rundoctl harness-runtime list.- Press
You get
A Claude Code agent in a DigitalOcean sandbox that works on GitHub through the gateway, with no GitHub token inside
Try next
Did this guide work for you?
Thanks. It helps us fix the steps.


