okayus/okayus-skills/sandboxed-agent-github-token-via-1password
Claude Code and agent skill by okayus/okayus-skills
- community
- ext:[{"type":"hook","description":"Pre/post lifecycle hooks"}]
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-1passwordSemi-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
gitandgh - The agent needs
gh pr create,gh pr view,gh pr checksdirectly instead of unauthenticatedcurl - 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-relay | this skill | ||
|---|---|---|---|
| Credential in the sandbox | none | one fine-grained PAT, in the env of ./shell.sh shells only | |
| Moving parts | systemd timer + relay.mjs + App private key on the host | two shell wrappers (up.sh, shell.sh) + an inline git credential helper | |
| Who pushes / opens PRs | the relay, as the App (bot author) | the agent, as you | |
| Policy enforcement | relay code outside the boundary + ruleset | ruleset + token scope; Claude Code allow/deny rules are convenience, not a boundary | |
| Merge | Relay-Merge: yes trailer → relay merges after CI | human merges by default; opt-in gh pr merge --auto by the agent | |
| CI status from the sandbox | unauthenticated curl | gh pr checks (fine-grained PATs can't call the Checks REST API — see pitfalls) | |
| Workflow-file edits | refused (App lacks workflows) | refused (token lacks workflows) — same deliberate gap | |
| Misconfiguration shows as | REFUSE lines in the journal | push 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 —
reposcope 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 - [ ]
opis installed on the host with desktop-app integration (or you accepteval $(op signin)every 30 min) - [ ]
.docker/sandbox.env(gitignored) holds the secret reference,.docker/sandbox.env.example(committed) the key - [ ]
./up.shis a plaindocker compose up -d— no credential, idempotent, safe to repeat;./shell.shdoesop read→export GH_TOKEN→exec docker exec -e GH_TOKEN <container> "$@"(neverop runaround the exec), and fails loudly when the container is down, theop://reference is missing, orop readreturns nothing - [ ] A shell opened with
./shell.shrenders normally — full-width prompt,stty sizematching 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'is0, and a second./up.shon a running container reportsRunning(same container id), neverRecreated - [ ] Fail closed: a shell opened without the wrapper (
docker exec -it <container> zsh) has no token —git pushgets401,ghsays 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.jsonno longer deniesBash(git push:*)(a broad deny beats every allow); it allowsgit push origin claude/*+gh pr create/view/checksand denies force pushes, pushes tomain, remote branch deletion (the--deleteflag as a deny rule; thegit push origin :branchrefspec 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'sbypassPermissionsdefault only the denies bite; the allows serve host / non-bypass sessions) - [ ] Ruleset on
main: PR + required check +non_fast_forward+bypass_actors: [](thecloudflare-workers-builds-keyless-deployruleset); optional second ruleset~ALLbranches:non_fast_forward - [ ]
CLAUDE.mdstates the convention: work onclaude/<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 checksshows CI;gh pr mergeis refused by the deny rule; a push tomainis refused by GitHub - [ ] If migrating from the relay: timer disabled, App kept as the revert path,
Relay-Mergeconvention removed fromCLAUDE.md - [ ] Every
UNVERIFIED:bullet below checked on the real setup and written back
Architecture in one screen
| Layer | Owns | Must not do | |
|---|---|---|---|
| 1Password item | the only copy of the token, its expiry | be read by anything but op run / op read on the host | |
op read + docker exec -e | token → one shell's env, once per ./shell.sh | put the value in argv, in a file, or in the container's config; wrap the interactive exec in op run | |
| git credential helper | answer git push from $GH_TOKEN | persist (store / cache helpers are out) | |
gh | API calls with GH_TOKEN | gh auth login (would write a token to ~/.config/gh/hosts.yml on disk) | |
| Claude Code rules | keep the well-behaved agent on claude/* and off merge | be mistaken for the security boundary | |
| ruleset + token scope | the 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
- SKILL.md in the repositoryCheckingskills/sandboxed-agent-github-token-via-1password/SKILL.md
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
[](https://verified-skill.com/skills/okayus/okayus-skills/sandboxed-agent-github-token-via-1password)