Claude Code SDK and GitHub Action: headless agents in CI
2 min read
Originally from vm.tiktok.com
View source
My notes
Watch on TikTok Tap to open video
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(orstream-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-toolsto 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-tooloffloads 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:
- Claude Code SDK (foundation)
claude-code-base-action, thin wrapper that calls SDK, returns responseclaude-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
claudethen/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.