Skip to main content
The Amika CLI is shell-friendly, so you can wire it into bash scripts, CI jobs, and code-gen pipelines. This guide walks through a complete automated flow: push a credential, create a remote rig cloned from a git repo, drive Claude Code non-interactively to make a change and open a PR, then tear the rig down.

Prerequisites

  • The CLI installed and logged in. See Install and Authentication.
  • A Claude API key on disk. See Manage secrets 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 rig ssh with heredocs to control the agent. Pair it with --agent-credential-type so the right credential is injected without an interactive picker. See Inject credentials.

Walkthrough

1

Push your Claude API key to the Amika vault

--from-file reads the key without prompting, which keeps the script non-interactive.
2

Create a remote rig cloned from the repo

Running the command inside a Git repository selects that repository. --agent-credential-type claude=api-key tells Amika to inject your stored API-key credential, which avoids the OAuth picker.
3

Configure agent permissions inside the rig

Use a heredoc with amika rig ssh to write a Claude settings.local.json. The $AMIKA_AGENT_CWD env var resolves to the cloned repo root inside the rig.
The unquoted << 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 rig shell and resolve there.These permissions let the agent run git and gh commands. Adjust the allowlist to match what your script needs.
4

Generate a session id so you can resume the agent run

Holding the session id lets you continue the same conversation across multiple agent invocations. This is useful when you want to break the work into phases.
5

Run Claude non-interactively to make code changes

A few details that matter for scripting:
  • -t allocates a TTY so Claude renders correctly.
  • --dangerously-skip-permissions is safe here because the allowlist in settings.local.json already constrains what the agent can do.
  • < /dev/null closes stdin so Claude exits when the prompt is done instead of waiting for input.
6

Resume the same session to commit and open a PR

Splitting the code change and the git/PR work into two prompts is more reliable than asking the agent to do both at once.
7

Tear down the rig

--force skips the confirmation prompt, which is what you want in a script.

Full script

Drop this into a file and run it end-to-end. Make sure /path/to/your/CLAUDE_API_KEY exists and that GitHub access is set up in GitHub settings so the agent can push the branch and open the PR. See GitHub authentication.
For long agent runs, drop set -e around the agent invocations or wrap them so a single failed run does not leak a rig. amika rig rm --force should always run, even on failure.

Next steps

Inject credentials

Push and pin Claude or Codex credentials for rigs.

CLI reference

Full flag listings for rig, secret, and ssh commands.