okayus/okayus-skills/sandboxed-agent-github-token-via-1password

Claude Code and agent skill by okayus/okayus-skills

Trust tier 3
  • community
  • ext:[{"type":"hook","description":"Pre/post lifecycle hooks"}]
Source check pending

Checking that the SKILL.md file is still in the repository.

Let a sandboxed coding agent (Claude Code in the docker sandbox) push branches and open PRs itself with a GitHub fine-grained PAT scoped to ONE repository, resolved from 1Password into the shell that runs it (`op read` the reference, then `docker exec -e GH_TOKEN`, wrapped in `./shell.sh`). Use when in-container pushes fail with `401` or `gh` is not logged in; when a plain `docker compose up -d` recreated the container and killed the agent session; when `docker inspect` shows a bare `GH_TOKEN` with no `=`; when a shell opened via `op run` has a broken prompt (raw `${...}` templates, pty stuck at 80x24); when the agent needs `gh pr create` / `gh pr checks` directly; or when choosing between this and sandboxed-agent-git-relay. Covers why it must be your own PAT, the permission set (no Workflows), the allow/deny rules replacing the blanket `git push` deny, the rulesets that stay the real boundary, merge policy, rotation, and the service-account variant.

Install

npx vskill@latest install okayus/okayus-skills/sandboxed-agent-github-token-via-1password

Semi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard

SKILL.md

The same SKILL.md was published earlier as okayus/okayus-skills/sandboxed-agent-github-token-via-1password.

Sandboxed-agent GitHub token via 1Password (repo-scoped PAT, injected per shell)

Get the sandbox to the state where the agent runs `git push origin claude/<topic>` and `gh pr create` itself, and the only credential inside the container is a GitHub fine-grained PAT that can reach one repository, cannot touch workflow files, expires, and is resolved from 1Password into the shell the agent runs in — never written to disk on the host or in the container, and never part of the container's configuration.

Written ahead of production, 2026-08-22, as the lighter replacement for `sandboxed-agent-git-relay` (in production on mazuoboeru since 2026-06). Facts about GitHub fine-grained PATs, 1Password CLI and Docker Compose were verified against their docs on 2026-08-22; the wiring was first applied to mazuoboeru the same day (PR #88), then to kokemusu, where a day of running it moved the injection point — see Verified on mazuoboeru and Verified on kokemusu for what held, what surprised, and what is still open.

Where the token enters — changed in 0.2.0. environment: { GH_TOKEN: … } in the compose file was the original design; it is now the documented alternative, because a token in the compose file is part of the container's configuration. One plain docker compose up -d that doesn't go through op run then counts as a configuration change, and compose stops and recreates the container — dropping the token and killing every process inside, including a running agent session. The default is now exec-time injection: ./up.sh is a credential-free, idempotent docker compose up -d, and ./shell.sh resolves the token with op read and hands it to docker exec -e GH_TOKEN <container> …, putting it in that one shell and its children. Copy-ready files for both in references/compose-and-git-wiring.md.

How `shell.sh` reaches 1Password — fixed in 0.2.1. 0.2.0 wrapped the whole thing in op run --env-file=… -- docker exec -it …. Don't: op run conceals secrets on its child's stdout/stderr, which means it interposes on those streams, and an interactive docker exec -it loses its real terminal — the prompt emits raw ${…} escape templates and the pty falls back to 80x24 in a corner of the window. Resolve first, exec second: GH_TOKEN=$(op read "$ref"), export it, then exec docker exec -e GH_TOKEN. The value still travels in the environment and never in argv. Everything else about 0.2.0 stands.

The trade in one sentence: the relay keeps every credential outside the boundary and pays for it with moving parts (systemd timer, relay script, GitHub App key, Relay-Merge trailer, squash-residue guards); this skill puts a narrowly scoped credential inside the boundary and pays for it with a residual risk — a compromised sandbox can push to non-protected branches and open / merge PRs that pass CI on that one repo, until you revoke the token.

When to use this skill

  • The relay works but its machinery costs more than it protects for a solo project, and you want the agent to push / PR with plain git and gh
  • The agent needs gh pr create, gh pr view, gh pr checks directly instead of unauthenticated curl
  • You are choosing how a new sandbox authenticates to GitHub and the rule is "a credential may be inside, but only one repo's worth"

Do not use for:

  • Projects whose rule is "no plaintext credential in the sandbox" — that is the relay's job, keep it
  • Repositories where you are an outside or repository collaborator — GitHub documents that fine-grained PATs can't contribute there (a GitHub App / the relay is the option)
  • Org repositories with a PAT policy that blocks fine-grained tokens, or anything multi-org

Decision: relay vs token-in-sandbox

sandboxed-agent-git-relaythis skill
Credential in the sandboxnoneone fine-grained PAT, in the env of ./shell.sh shells only
Moving partssystemd timer + relay.mjs + App private key on the hosttwo shell wrappers (up.sh, shell.sh) + an inline git credential helper
Who pushes / opens PRsthe relay, as the App (bot author)the agent, as you
Policy enforcementrelay code outside the boundary + rulesetruleset + token scope; Claude Code allow/deny rules are convenience, not a boundary
MergeRelay-Merge: yes trailer → relay merges after CIhuman merges by default; opt-in gh pr merge --auto by the agent
CI status from the sandboxunauthenticated curlgh pr checks (fine-grained PATs can't call the Checks REST API — see pitfalls)
Workflow-file editsrefused (App lacks workflows)refused (token lacks workflows) — same deliberate gap
Misconfiguration shows asREFUSE lines in the journalpush 401/403, or no GH_TOKEN at all → fail closed

Why it must be your fine-grained PAT

GitHub's limitations list (verified 2026-08-22) rules out the tempting alternatives:

  • A bot account added as collaborator — "Using fine-grained personal access token to contribute to repositories where the user is an outside or repository collaborator" is unsupported. So the token is minted on your account, and it "has the same capabilities … that the owner of the token has, and is further limited by any scopes or permissions granted to the token" → the ruleset must have `bypass_actors: []`, or your admin bypass is the token's bypass.
  • A classic PAT — repo scope is every repository you can reach. Never.
  • A GitHub App token minted inside — needs the App private key inside the sandbox, which mints tokens for every installation repo. Worse than the PAT.
  • A deploy key — can push, cannot open PRs (no API).

Token shape: resource owner = you; Repository access = Only select repositories → the one repo; permissions Contents: Read and write, Pull requests: Read and write (Metadata: Read comes along), optionally Actions: Read for gh run view; no Workflows — the agent must not be able to edit its own CI gate; expiry 90 days (infinite is allowed by GitHub but defeats the point). Full click-path in references/token-and-1password-setup.md.

Deliverables (completion criteria)

  • [ ] Fine-grained PAT exists with exactly the scope above; its expiry date is in the 1Password item (expires) and in your calendar
  • [ ] The token lives only in 1Password (op read "op://<vault>/<item>/credential" works); it was never pasted into a file, a compose file, or a shell history
  • [ ] op is installed on the host with desktop-app integration (or you accept eval $(op signin) every 30 min)
  • [ ] .docker/sandbox.env (gitignored) holds the secret reference, .docker/sandbox.env.example (committed) the key
  • [ ] ./up.sh is a plain docker compose up -d — no credential, idempotent, safe to repeat; ./shell.sh does op read → export GH_TOKEN → exec docker exec -e GH_TOKEN <container> "$@" (never op run around the exec), and fails loudly when the container is down, the op:// reference is missing, or op read returns nothing
  • [ ] A shell opened with ./shell.sh renders normally — full-width prompt, stty size matching your terminal, no raw ${…} in the prompt
  • [ ] The token is not in the compose config: docker inspect -f '{{range .Config.Env}}{{println .}}{{end}}' <container> | grep -c '^GH_TOKEN' is 0, and a second ./up.sh on a running container reports Running (same container id), never Recreated
  • [ ] Fail closed: a shell opened without the wrapper (docker exec -it <container> zsh) has no token — git push gets 401, gh says it is not logged in
  • [ ] The container's startup command sets an inline, env-reading git credential helper and a distinguishable git identity — no token on disk
  • [ ] .claude/settings.json no longer denies Bash(git push:*) (a broad deny beats every allow); it allows git push origin claude/* + gh pr create/view/checks and denies force pushes, pushes to main, remote branch deletion (the --delete flag as a deny rule; the git push origin :branch refspec form with a PreToolUse hook, because a deny pattern ending in :* is read as the legacy prefix syntax and never matches it), gh pr merge, gh auth, gh api (in the container's bypassPermissions default only the denies bite; the allows serve host / non-bypass sessions)
  • [ ] Ruleset on main: PR + required check + non_fast_forward + bypass_actors: [] (the cloudflare-workers-builds-keyless-deploy ruleset); optional second ruleset ~ALL branches: non_fast_forward
  • [ ] CLAUDE.md states the convention: work on claude/<topic>, push + gh pr create, never merge (or the opt-in rule below)
  • [ ] E2E: in-container commit → git push origin claude/e2e → gh pr create --fill → gh pr checks shows CI; gh pr merge is refused by the deny rule; a push to main is refused by GitHub
  • [ ] If migrating from the relay: timer disabled, App kept as the revert path, Relay-Merge convention removed from CLAUDE.md
  • [ ] Every UNVERIFIED: bullet below checked on the real setup and written back

Architecture in one screen

host ./up.sh = docker compose up -d ← no credential; idempotent, safe to repeat
./shell.sh = GH_TOKEN=$(op read "op://<vault>/<item>/credential"); export GH_TOKEN
[ -t 0 ] && [ -t 1 ] && TT=-it || TT=-i
exec docker exec $TT -e GH_TOKEN <container> "$@"
│ (1Password unlock. NOT `op run …`: it interposes on stdout/stderr and
│ an interactive `docker exec -it` then loses its terminal — see pitfalls)
│ -e GH_TOKEN is NAME-ONLY: value comes from this script's env, never argv (`ps`-safe)
└─ no op session / op read fails / empty → shell.sh exits before exec: no token, no push
container no token in Config.Env or PID 1; GH_TOKEN exists in ./shell.sh shells and their children only
├─ git credential.helper = inline sh that echoes $GH_TOKEN (nothing under ~/.git-credentials)
├─ gh reads GH_TOKEN itself ("takes precedence over previously stored credentials")
└─ Claude Code allow: git push origin claude/*, gh pr create|view|checks deny: --force, main, --delete, gh pr merge, gh auth, gh api
GitHub fine-grained PAT → ONE repo · Contents + Pull requests · no Workflows · 90-day expiry
rulesets: main = PR + required check + no force + bypass_actors: [] (optional: ~ALL = no force push)
LayerOwnsMust not do
1Password itemthe only copy of the token, its expirybe read by anything but op run / op read on the host
op read + docker exec -etoken → one shell's env, once per ./shell.shput the value in argv, in a file, or in the container's config; wrap the interactive exec in op run
git credential helperanswer git push from $GH_TOKENpersist (store / cache helpers are out)
ghAPI calls with GH_TOKENgh auth login (would write a token to ~/.config/gh/hosts.yml on disk)
Claude Code ruleskeep the well-behaved agent on claude/* and off mergebe mistaken for the security boundary
ruleset + token scopethe boundary: what a compromised sandbox can still do—

Setup

Human steps once; copy-ready files in the references.

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 90 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
5

Not refreshed yet.

Extension points

  • hookPre/post lifecycle hooks

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/okayus/okayus-skills/sandboxed-agent-github-token-via-1password/badge)](https://verified-skill.com/skills/okayus/okayus-skills/sandboxed-agent-github-token-via-1password)

Something wrong with this skill or its page? Tell us.