Prerequisites
- The CLI installed and logged in. See Install and Authentication.
- A Claude API key on disk. See Agent authentication for how to push it to the Amika secrets store.
- Run from inside a git repository whose remote you want the agent to work against.
The pattern below uses
amika sandbox ssh with heredocs to control the agent.
Pair it with --agent-credential-type so the right credential is injected
without an interactive picker. See
Pin a credential at sandbox creation.Walkthrough
Push your Claude API key to the Amika vault
--from-file reads the key without prompting, which keeps the script
non-interactive.Create a remote sandbox cloned from the repo
--git mounts the current repo into the sandbox.
--agent-credential-type claude=api-key tells Amika to inject your stored
API-key credential, which avoids the OAuth picker.Configure agent permissions inside the sandbox
Use a heredoc with The unquoted
amika sandbox ssh to write a Claude
settings.local.json. The $AMIKA_AGENT_CWD env var resolves to the cloned
repo root inside the sandbox.<< EOF lets the host shell expand $CLAUDE_SETTINGS before
ssh transmits the body. Guest-side variables like $AMIKA_AGENT_CWD are
escaped with \$ so they survive to the sandbox shell and resolve there.These permissions let the agent run git and gh commands. Adjust the
allowlist to match what your script needs.Generate a session id so you can resume the agent run
Run Claude non-interactively to make code changes
-tallocates a TTY so Claude renders correctly.--dangerously-skip-permissionsis safe here because the allowlist insettings.local.jsonalready constrains what the agent can do.< /dev/nullcloses stdin so Claude exits when the prompt is done instead of waiting for input.
Resume the same session to commit and open a PR
Full script
Drop this into a file and run it end-to-end. Make sure/path/to/your/CLAUDE_API_KEY exists and that your GitHub PAT is configured
in the Git settings so the agent can
push the branch and open the PR.
Next steps
Agent authentication
Push and pin Claude or Codex credentials for sandboxes.
CLI reference
Full flag listings for sandbox, secret, and ssh commands.