- Create a rig from a git repository.
- Send a prompt to Claude Code to change the code.
- Continue the same chat to commit the change and open a pull request.
- Delete the rig.
Prerequisites
- An Amika API key in
AMIKA_API_KEY. Create one at app.amika.dev/settings/api-keys. See Authentication. - For the CLI: the CLI and
jq. See Install. For TypeScript:npm install @amika/sdk. See the TypeScript quickstart. - A Claude credential stored in Amika. This guide uses the name
ci-claude. - GitHub access to the repository. A request with an API key has no GitHub App connection, so the rig uses your organization’s GitHub personal access token (PAT). Save a PAT that can push to the repository and open pull requests. See GitHub authentication.
Walkthrough
1
Store a Claude credential
Do this one time. Give the credential a name, so that the script can select
it. See Manage secrets for the other credential
types.
--from-file and --name keep the command non-interactive.2
Create a rig
--agent-credential claude=ci-claude(agentCredentials) injects the stored credential by name. Without it, the rig gets no agent credential.- The
GIT_*variables set the commit author. A rig that you create with an API key has no git author, so commits fail without them. - The CLI returns when the rig is ready. In TypeScript,
rigs.createreturns before setup finishes, so callrig.wait().
3
Send a prompt to the agent
-o json, the CLI prints
one JSON object. Keep its session_id (sessionId) to continue the chat.An agent failure sets is_error (isError) to true, also when the request
succeeds. Check it before you continue.4
Continue the chat to open a pull request
5
Delete the rig
--force skips the confirmation prompt.Full script
Each script deletes the rig, also when a step fails.Next steps
Command runs
Run shell commands on a rig through the API, without an agent.
Jobs
Run commands on a rig on a cron schedule.
Send a message to an agent
All options for agent prompts and chats.
TypeScript SDK
Every collection and method on
AmikaClient.