How to Integrate Claude Code Into Your Workflow
Integrating Claude Code depends on what you're actually trying to do. If you want an AI pair programmer in your terminal, that's a CLI install and a few config steps. If you want Claude reviewing pull requests automatically, that's a CI job. If you want Claude's capabilities inside your own product or internal tool, that's an API integration — and Claude Code itself isn't built for that.
This guide walks through the three real integration paths, when each one makes sense, and how to wire Claude into automated pipelines or applications without fighting the tool's design.
Path 1: Claude Code as a terminal tool
Claude Code is designed to run in your terminal, read your repository, make edits, run tests, and commit changes with your oversight. Integration here means installing it and giving it the right permissions and context.
npm install -g @anthropic-ai/claude-code
claude
Once running, Claude Code reads your working directory, respects .gitignore, and can execute shell commands you approve. Most "integration" work at this level is really configuration:
- Project context: add a
CLAUDE.mdfile at your repo root describing conventions, build commands, and architecture decisions so Claude doesn't have to guess. - Permissions: decide whether Claude Code can run destructive commands (like
rmorgit push --force) without asking each time. - Scope: point it at a specific directory rather than your whole monorepo if you want tighter control.
This is the right choice when a human is driving the session and reviewing output in real time.
Path 2: Claude Code in CI/CD and git hooks
A common next step is running Claude Code non-interactively — for example, as a pre-commit check, a PR reviewer, or a script that flags risky diffs before merge.
#!/bin/bash
# pre-push hook: ask Claude Code to review staged changes
git diff --cached | claude -p "Review this diff for bugs and security issues. Reply with PASS or FAIL and a one-line reason."
In GitHub Actions, the pattern looks similar: install the CLI, authenticate, and pipe diffs or logs into a prompt, then parse the output to gate the pipeline.
- name: Claude code review
run: |
npm install -g @anthropic-ai/claude-code
git diff origin/main...HEAD | claude -p "Summarize risk level: low/medium/high" > review.txt
This works, but it comes with friction: authentication in headless environments, rate limits tied to your individual account, and no built-in way to separate "my interactive coding session" usage from "CI job that runs on every push." If your team runs Claude Code checks on every commit across multiple repos, you'll hit those limits faster than expected.
Path 3: Calling Claude from your own application
Sometimes what you actually need isn't Claude Code the CLI tool — it's Claude the model, called from inside a backend service, a bot, or an internal dashboard. Claude Code is optimized for interactive coding sessions, not for being embedded as a backend dependency in a product you ship to users.
For that, you want direct API access: send a prompt, get a response, stream it to a frontend, let the model call tools. This is a different integration shape entirely — no terminal, no file system access, just HTTPS requests.
This is where SubToAPI fits. It takes the Claude access you already have and exposes it as a standard HTTPS API with application-scoped keys, so you can integrate Claude into a backend, a CI job, or a customer-facing feature without re-plumbing your authentication every time.
curl https://api.subtoapi.app/v1/messages \
-H "Authorization: Bearer $SUBTOAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4",
"max_tokens": 1024,
"messages": [
{"role": "user", "content": "Review this diff for security issues: <diff here>"}
]
}'
The same code-review use case from the git hook above becomes an API call with a scoped key, usage metadata per request, and no dependency on an interactive CLI session. If you're building the CI check example properly for a team — with multiple repos calling it in parallel — this is usually the more stable approach than shelling out to claude -p from a runner.
Streaming works the same way for cases where you want token-by-token output in a UI, like a live code-review widget:
const response = await fetch("https://api.subtoapi.app/v1/messages", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.SUBTOAPI_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
model: "claude-sonnet-4",
max_tokens: 1024,
stream: true,
messages: [{ role: "user", content: "Explain this stack trace." }]
})
});
Full request and response formats are in the docs, streaming details in the streaming guide, and the fastest way to get a working call is the quickstart.
Choosing the right path
A quick way to decide:
- Writing code interactively with a human reviewing each step → Claude Code CLI in your terminal.
- Automated checks on every commit or PR, low volume → Claude Code in a git hook or CI step, accepting the auth and rate-limit tradeoffs.
- Backend feature, high volume, multiple team members or services calling Claude → a proper API integration with scoped keys and usage tracking, which is what SubToAPI is built for.
Many teams end up using two of these at once: Claude Code for the actual day-to-day coding work, and an API integration for the automated, always-on pieces like PR summaries, changelog generation, or internal tools that need Claude but shouldn't depend on someone's individual terminal session being logged in.
questions
Can I use Claude Code without the terminal CLI? Not for its core coding features — those depend on filesystem and shell access. For non-interactive use cases like backend automation, use the API directly instead of trying to run Claude Code headless.
How do I integrate Claude Code into a CI pipeline? Install the CLI in your runner, pipe diffs or logs into claude -p with a prompt, and parse the output to gate the build. For higher-volume or multi-repo setups, an API-based approach with scoped keys is usually more reliable.
What's the difference between Claude Code and the Claude API? Claude Code is an interactive CLI tool for editing code in your repo with human oversight. The API is a raw HTTPS interface for sending prompts and getting responses, meant for building into your own applications and services.