K2by Alakazam Labs
Menu
Why K2For youDevelopersBusinessEnterprisePricingWhat's newLog in
Download
Guide · Claude Code in CI

A failed build starts a session you can watch live.

K2 runs AI agents on a server you own. Add one job to your pipeline, and a failed build starts Claude Code in that repo's workspace. Read along, type in or stop it.

  • Free on your own Apple Silicon Mac or Linux box
  • $2.99 a month if a hosted runner needs an address
  • Sessions auto-approve unless you switch that off

Sample data.

Teams at these companies use K2
InnovAsiaRPM AVSLocal KinMontimberQuillifyBallardAFSDeep Blue
One failed build

Your CI job ends. The session stays open.

  1. Your CI: Test fails on main
  2. Your CI: Hand-off job sends one POST, ends
  3. Agent: Reads the log, plans a fix
  4. You, if you want: Type a change into the live tabOr let it finish with nobody there.
  5. Agent: Takes your change
  6. Agent: Tests pass on a branch
  7. Agent: Opens a pull request, reports back
  8. You: Review it and merge
  • Watch

    A live tab, on desktop or web.

  • Join

    POST …/<id>

  • Read back

    GET …/<id>/messages

  • Stop

    POST …/<id>/kill

Your prompt sets the rule against merging, so keep it in the workflow.

Copy and paste

One server, one key, one step in your workflow.

CI must reach your server.

Use a K2 Connect address, or a self-hosted runner.

How K2 Connect works
  1. 1

    Give the repo a workspace

    Run these yourself on your server, and sign in Claude Code there once.

    your server
    $ k2 agent hire ~/agents/shop-api \
        --agent claude
    $ git clone git@github.com:you/shop-api.git \
        ~/agents/shop-api/repo
    $ gh auth login
    $ k2 workspace trust ~/agents/shop-api \
        --always
    $ k2 api on
  2. 2

    Scope a key to it

    It opens that one workspace and nothing else. CI runs bill to your Anthropic key. Save the k2sk_ key as a CI secret; you see it once. To use your Claude plan instead, leave the Anthropic key out. That's automated use, so check your provider's terms.

    your server
    $ printf %s "$ANTHROPIC_API_KEY" | \
        k2 api-key create --label ci \
        --workspaces shop-api \
        --allow host-sessions \
        --provider anthropic --key-stdin
  3. 3

    Add the failure job

    It runs only after a failed push, so pull requests from forks stay away from the agent. The session outlives this job. Any CI that can send HTTP works.

    .github/workflows/ci.yml
      hand-off:
        needs: test
        if: >-
          failure() &&
          github.event_name == 'push'
        runs-on: ubuntu-latest
        env:
          K2_URL: ${{ secrets.K2_URL }}
          K2_KEY: ${{ secrets.K2_KEY }}
          K2_WS: shop-api
        steps:
          - run: |
              P="Run $GITHUB_RUN_ID failed. In repo/, read it with
              gh run view $GITHUB_RUN_ID --log-failed. Fix the cause
              in a new git worktree and open a pull request. Don't merge."
              B='{prompt:$p,timeout_secs:1800}'
              A="Authorization: Bearer $K2_KEY"
              jq -n --arg p "$P" "$B" |
              curl -fsS --json @- -H "$A" \
              "$K2_URL/v1/w/$K2_WS/host-sessions"
    Swipe sideways to read the longest lines →
Permissions and limits

Auto-approve is on by default. Choose it on purpose.

A pipeline can't answer a prompt, so API sessions start with prompts off. One switch per workspace.

Flip it. Sample data.

On, the default

The agent acts without asking, with the full shell of the K2 user.

k2 workspace api-skip-permissions set shop-api on Use it on a box you can wipe.
  1. Edit a fileRuns
  2. Open a pull requestRuns

Off

The agent stops at each CLI prompt until someone answers in the live tab.

k2 workspace api-skip-permissions set shop-api off Use it when someone is watching.
  1. Edit a fileWaits for you
  2. Open a pull requestNot reached

Read this before it runs unattended.

Full list on our security page

No spend caps

K2 shows token use but can't cap it.

Set a limit with your provider.

Commands and edits aren't logged

K2 records sign-ins, mail sends, agent messages, approvals and app calls.

Read git history for what changed.

One user account

Agents on one server share one user account, so text in a build log could steer one past K2's rules.

Give CI agents their own box.

No SSO, SAML or MFA. Logins use passwords, so give them only to people you'd trust with the box.

Side by side

Three ways to run Claude Code from CI.

For a one-shot job in the runner, the first two are less to set up and can cap a run. K2 fits when you want the session on your own box, open to you while it works.

claude -pClaude Code GitHub ActionK2 host session
Where it runsWherever you call itGitHub-hosted runners, on your Actions minutesYour K2 server
What you seeText, JSON or a streamA comment, or the run logA live terminal tab you can type into
PermissionsBy default, a call needing approval is denied. --allowedTools lists what runsWith a plain prompt, no shell or GitHub API access until you grant toolsAuto-approve on by default
Spend limits--max-budget-usd, --max-turns--max-turns, workflow timeoutsNo caps. A kill route and your provider's limits

Claude Code details from Anthropic's docs at code.claude.com, read 5 November 2026. K2 runs Claude Code and isn't affiliated with Anthropic.

What it costs

Free to try. You pay for an address if CI needs one.

The softwareFreeOn your own box, no seat or agent fees
A public address$2.99 /moK2 Connect, for hosted runners
A server we runFrom $14.99 /moK2 Cloud Basic, plus $2.99 a month for its address

Your API key or AI plan is separate, with no markup. K2 is open source (MIT). Why K2

Hand your next failed build to an agent.

  1. Download K2 for Apple Silicon Mac or Linux.
  2. Hire one agent on a box you can wipe.
  3. Break a test in a throwaway pipeline.