Claude Code Hands-On (6): The SDK, GitHub Integration, and Claude in CI
The SDK turns Claude Code from a CLI into a library. GitHub Action makes it answer @claude on PRs. Together they let you put Claude inside the same CI pipeline that already runs your tests — without giving up control.
The CLI is the obvious surface. The SDK is the interesting one. The GitHub integration is where it pays off.
The SDK in one paragraph
@anthropic-ai/claude-code is the npm package. It exposes the same Claude Code engine the CLI uses, with the same tools and permissions, as a programmatic interface. You give it a prompt; you get an async iterable of conversation events. Plug it into anything — a script, a service, a CI step.
Install:
| |
The hello-world:
| |
Run it. You’ll see the same agent loop play out in your terminal — tool calls and all. It’s the CLI minus the chat UI.
Permissions, programmatically
This is the bit you have to get right. The CLI defaults to “ask the human.” A script can’t ask. So the SDK exposes permission modes:
| Mode | Meaning |
|---|---|
default | Errors on any tool that would normally need a confirmation |
acceptEdits | Auto-accepts file edits, asks for shell |
bypassPermissions | Auto-accepts everything (dangerous) |
| Custom | You provide a callback that decides per call |
For real work, use the callback:
| |
Now you have programmatic policy. The script can run unattended and you know it can’t do the things you’ve explicitly forbidden.
A real script: auto-update CHANGELOG
I have this in scripts/update-changelog.ts in a few projects:
| |
Run before every release. The CHANGELOG writes itself, the commit log gets curated into prose, and I review and commit. Five minutes saved per release × every release for the last six months.
The GitHub Action
Anthropic ships an official Action: anthropic/claude-code-action@v1. Add it to a workflow:
| |
Now anyone in your repo can write @claude please review the failing test in a PR comment and Claude will:
- Check out the branch
- Read the comment thread for context
- Run whatever it needs to (tests, linters, file reads)
- Reply on the PR with its analysis
- Optionally push commits if asked
The Action respects .claude/settings.json from the repo. The hooks you wrote in piece 5 still apply. The slash commands you wrote in piece 3 still work — @claude /review does what you’d expect.
What I use the GitHub Action for
Three things have stuck:
1. PR triage. New PR opens, a workflow runs @claude /review automatically. By the time a human looks, there’s already a first-pass review on the conversation. Saves the reviewer 10 minutes per PR and catches the obvious stuff.
2. Issue summarization. A workflow runs on new issues to label them, suggest a fix scope, and link related code. The reporter gets a faster ack and the maintainer gets a head start.
3. Doc updates. When the schema changes, an Action runs that asks Claude to update the docs to match. Not always perfect, but ~80% of the work is mechanical.
The boundary between SDK and Action
I use the SDK when:
- I want Claude inside a script I run locally
- The trigger is a cron, a file change, or a manual command
- I need to inspect the events programmatically
I use the Action when:
- The trigger is a GitHub event
- The output should land in a PR or issue
- I want a human in the loop and the loop is
@mention
There’s overlap, of course. The Action is built on the SDK underneath.
Putting the series together
Six pieces, one progression:
- Install + the three-layer config
- Shortcuts and modes
- Slash commands for personal workflows
- MCP for external integrations
- Hooks for safety rails
- SDK + Action for programmatic and CI use
Each piece on its own buys you something concrete. Together they turn Claude Code from a chat client for code into a piece of programmable infrastructure that lives inside your repo.
The single trait that distinguishes power users I’ve watched: they treat .claude/ as part of the codebase. Settings, commands, hooks all committed, all reviewed in PRs, all evolving with the project. That’s the muscle memory worth building.
Happy shipping.