niels-kwg/toolkit/claude-code-ci

Claude Code and agent skill by niels-kwg/toolkit

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Running Claude Code in CI pipelines — non-interactive mode, stream-json output, GitHub Actions integration, and PR review automation. Maps to CCA Domain 3.

Install

npx vskill@latest install niels-kwg/toolkit/claude-code-ci

SKILL.md

The same SKILL.md was published earlier as niels-kwg/toolkit/claude-code-ci.

Claude Code in CI

Overview

How to run Claude Code as a non-interactive tool in CI/CD pipelines. Covers the claude -p interface, output parsing, GitHub Actions integration, and common automation patterns like PR review and test generation.

Non-Interactive Mode

Basic Invocation
bash
# Single prompt, streaming JSON output
claude -p "Review this diff for security issues" --output-format stream-json
# Pipe input via stdin
git diff HEAD~1 | claude -p "Review this diff" --output-format stream-json
# With a specific model
claude -p "Generate unit tests for src/auth.ts" --model claude-sonnet-4-20250514
Output Formats
FormatUse Case
textHuman-readable output (default)
jsonSingle JSON object on completion
stream-jsonNewline-delimited JSON events as they arrive
stream-json Event Types
jsonl
{"type": "assistant", "content": "Looking at the diff..."}
{"type": "tool_use", "tool": "Read", "input": {"file_path": "/src/auth.ts"}}
{"type": "tool_result", "output": "...file contents..."}
{"type": "result", "content": "Found 2 issues:\n1. ..."}

Parse the final result event for the actionable output.

GitHub Actions Integration

PR Review Workflow
yaml
name: Claude PR Review
on:
pull_request:
types: [opened, synchronize]
jobs:
review:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Claude Code
run: npm install -g @anthropic-ai/claude-code
- name: Run review
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
run: |
DIFF=$(git diff origin/main...HEAD)
REVIEW=$(echo "$DIFF" | claude -p "Review this PR diff. Focus on: bugs, security issues, missing error handling. Output as markdown." --output-format text)
gh pr comment ${{ github.event.pull_request.number }} --body "$REVIEW"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Test Generation on PR
yaml
- name: Generate missing tests
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
run: |
CHANGED=$(git diff --name-only origin/main...HEAD -- '*.ts' '*.tsx')
claude -p "Generate unit tests for these changed files: $CHANGED. Write tests to the appropriate __tests__ directories." --output-format text

Key Flags for CI

FlagPurpose
-p "prompt"Non-interactive single prompt mode
--output-formatControl output format (text, json, stream-json)
--modelOverride default model
--max-turnsLimit agentic loop iterations (prevents runaway)
--allowedToolsRestrict which tools Claude can use
--disallowedToolsBlock specific tools (e.g., block Bash in review-only jobs)
Safety in CI
bash
# Read-only review: block file writes and shell access
claude -p "Review src/ for bugs" \
--allowedTools "Read,Glob,Grep" \
--output-format json
# Limit iterations to prevent infinite loops
claude -p "Fix the failing test" --max-turns 10

Parsing CI Output

python
import json
import subprocess
result = subprocess.run(
["claude", "-p", "Analyze src/api.ts for N+1 queries", "--output-format", "json"],
capture_output=True, text=True
)
output = json.loads(result.stdout)
# output["result"] contains the final response text
# output["cost"] contains token usage
if "N+1" in output["result"]:
sys.exit(1) # Fail the CI check

When to Use

  • Automated PR review on every push
  • Pre-merge test generation for changed files
  • Migration script validation before deploy
  • Documentation freshness checks
  • Security scanning as a CI gate

Common Mistakes

  1. Missing `--output-format`: Default text output is hard to parse in scripts — use json or stream-json
  2. No `--max-turns` in CI: Without a turn limit, an agentic loop can run indefinitely and burn credits
  3. Exposing API keys: Always use GitHub Secrets, never hardcode keys in workflow files
  4. Not restricting tools: In review-only jobs, block Write/Edit/Bash to prevent accidental modifications
  5. Ignoring exit codes: claude -p returns non-zero on failure — check $? or use set -e
  6. Large diffs as input: Diffs over 100KB may exceed context — filter to relevant files first

Security

  • Security scanPassed, 90 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
0

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/niels-kwg/toolkit/claude-code-ci/badge)](https://verified-skill.com/skills/niels-kwg/toolkit/claude-code-ci)

Something wrong with this skill or its page? Tell us.