$ recombobulate _
home / tips / run-claude-code-in-cicd-pipelines
run-claude-code-in-cicd-pipelines

Claude Code doesn't need a terminal — you can run it headlessly in CI/CD pipelines using the -p flag with --output-format stream-json.

claude -p "Review this diff for security issues" \
  --output-format stream-json \
  --max-turns 1 \
  < <(git diff main...HEAD)

This runs Claude non-interactively and streams structured JSON output, making it easy to parse in CI scripts. Set the ANTHROPIC_API_KEY environment variable in your CI secrets and you're good to go.

A practical GitHub Actions example:

- name: AI Code Review
  run: |
    npm install -g @anthropic-ai/claude-code
    git diff ${{ github.event.pull_request.base.sha }}...HEAD \
      | claude -p "Review for bugs, security issues, and style problems. Be concise." \
      --output-format stream-json
  env:
    ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}

You can also use it for automated changelog generation, migration safety checks, or enforcing conventions that are hard to express as lint rules:

# Check migrations are reversible
claude -p "Check if all pending migrations have a working down() method" --max-turns 3

# Generate changelog from recent commits
git log --oneline v1.0..HEAD | claude -p "Write a user-facing changelog from these commits"

The key principle: anything you'd ask Claude interactively, you can automate in a pipeline.

~/recombobulate $ tip --comments --count=0

Log in to leave a comment.

~/recombobulate $ tip --related --limit=3
0
Scan Pending Changes for Security Issues with /security-review

The /security-review command scans your uncommitted changes for injection vectors, auth gaps, hardcoded secrets, and other common vulnerabilities.

bagwaa @bagwaa · 1 hour ago
0
Run Setup Scripts on Every Session with the SessionStart Hook

The SessionStart hook fires when any session begins or resumes, making it ideal for loading environment variables and running one-time setup scripts.

bagwaa @bagwaa · 1 hour ago
0
Write Property-Based Tests with fast-check and Claude

Ask Claude to write property-based tests for your functions using fast-check — it identifies the mathematical invariants in your code and generates tests that cover inputs you'd never enumerate by hand.

bagwaa @bagwaa · 2 hours ago