EXAMPLE 04
  • credentials
  • github
  • sentry
  • agents

gh and sentry without a token

gh, git push and sentry work in the sandbox; the tokens stay on your host.


The problem

An agent needs gh to open its PR and sentry to read the crash, but a token in the container is a token for everything that runs there. With the gh and sentry features, the sandbox holds a phantom token and devsandbox, on your host, swaps in the real one on each call it allows.

Let your agent set this up

Config

devsandboxes.yaml
profiles:
  work: {}

sandbox:
  web:
    folder: ../web
    image: node:22
    features:
      ghcr.io/devsandboxes/features/gh:1: {}
      ghcr.io/devsandboxes/features/sentry:1: {}

Log in once, on the host

TERMINAL
devsandbox login github --feature ghcr.io/devsandboxes/features/gh:1 --profile work
devsandbox login sentry --feature ghcr.io/devsandboxes/features/sentry:1 --profile work --org my-org
  • github opens GitHub’s fine-grained token page with the permissions gh needs filled in. Pick the repos, create it, paste it back.
  • sentry opens Sentry’s own login page and waits for you to approve it. --org (repeatable) names the Sentry orgs sandboxes may reach; calls naming any other are refused.
  • Each shows what the feature may do with the token and whose account it is before storing it. --profile work grants it to instances in the work profile only.

Try it

TERMINAL
devsandbox run web --name fix-login
devsandbox exec fix-login sh -c 'echo $GH_TOKEN'   # a phantom, not your token
devsandbox exec fix-login gh pr list
devsandbox exec fix-login git push                 # ssh remotes go over https too
devsandbox exec fix-login sentry issue list
devsandbox access ls                               # credentials, versions, instances using them

How it works

  • gh writes only to the sandbox’s own repos (its folders’ remotes at the first run) plus any in access.github.repos. Outside them, reads go without a token and writes are refused.
  • access.<kind>.scopes narrows what one sandbox may do, e.g. scopes: [repo.read, pr.write].
  • When a feature update changes what its token may be used for, devsandbox run shows the change and asks you to approve it. Off a terminal it refuses; approve with devsandbox access approve github.
  • devsandbox access revoke github drops the credential from your host.

Agent instructions

Paste it into Claude Code, Codex or any agent with a shell. It finds your repo and config itself and asks only what it can't tell. Agent skills (opens in a new tab)

Source: site/src/content/examples/credentials.mdxEdit this page on GitHub(opens in a new tab)

MENU /
View on GitHub