# Claude Code SDK and GitHub Action: headless agents in CI

> Anthropic engineer demos the Claude Code SDK and GitHub Action, showing how headless agents open PRs, push commits, and review code on existing runners.

Published: 2026-04-29
URL: https://daniliants.com/insights/30-minutes-free-from-the-person-shipping-it-in-production-not-the/
Tags: claude-code, claude-code-sdk, github-actions, agent-automation, ci-cd, mcp, headless-agents

---

## Summary

An Anthropic engineer walks through the Claude Code SDK and the Claude GitHub Action. The SDK gives programmatic, headless access to the Claude Code agent, and the GitHub Action is a reference implementation built on top of it. Live demo: comment on a GitHub issue, Claude opens a PR with a working feature; comment on a PR, Claude pushes a commit. No infra to run, it uses your existing GitHub Action runners.

## Key Insight

- **Claude Code SDK = headless agent as a Unix primitive.** `claude -p "prompt"` runs the full Claude Code agent non-interactively. Composes in pipelines: `cat app.log | claude -p "summarise failures"`. This is the building block for everything else.
- **`--output-format json` (or `stream-json`)** is what makes it programmable. Stream mode emits messages as they happen; plain JSON dumps one blob at the end. Parse the JSON to build UIs, CI gates, chatbots.
- **Permissions have two modes.**
  - `--allow-tools` to pre-grant tools (e.g. `--allow-tools "Bash(npm run build),Bash(npm test),Write"`), good when you can predict what the agent needs.
  - `--permission-prompt-tool` offloads permission decisions to an MCP server at runtime, ask the user mid-run, accept/reject per call. Newer feature, designed for cases where you can't pre-list.
- **Session resumption.** Each run returns a session ID; pass it back to continue from the same context. Enables multi-turn user-driven flows on top of headless calls.
- **System prompt is configurable** via `--system-prompt`, so the same SDK can be tuned per app (linter persona, code reviewer, doc writer, pirate).
- **Three-layer architecture of the GitHub Action**, all open source:
  1. Claude Code SDK (foundation)
  2. `claude-code-base-action`, thin wrapper that calls SDK, returns response
  3. `claude-code-action` (the "PR action"), handles comments, todo-list rendering, PR links, commit pushing
  This layering is the template if you want to build your own integration (Linear, Jira, Slack).
- **What the GitHub Action does today:** read code, open PRs from issues, push commits to existing PRs (just comment on the PR), answer questions inline, run code reviews. All on existing GitHub runners, zero infra.
- **Install path:** in any repo, run `claude` then `/install-github-action`. Generates the YAML, walks through API key config, opens a PR. Bedrock/Vertex users have a slightly more manual path, check docs.
- **Python and TypeScript SDK bindings** were called out as "coming soon", until then it's the CLI as the interface.