Single logo
  • Courses
  • Blog
  • About
Join on SkoolJoin on Skool

In this topic

Claude
  • CLAUDE.md, settings.json and Plugins: Which Claude Code File Advises, Which Enforces, Which Packages
  • Authoring a Claude Skill: SKILL.md, Frontmatter, Progressive Disclosure and the Description That Triggers It
  • One Change, Four Environments: Where a Claude Config Edit Lands in Dev, Staging, Prod and CI
  • Claude in the SDLC: Prompts in Git, a Change Gate by Path, a Claude Review That Advises and a Person Who Merges
  • Hooks That Block Destructive Actions: a PreToolUse Gate That Allows, Asks or Denies
  • Choosing a Claude Code Extension: Skill, Hook, Rules File, Subagent, Slash Command or Plugin
  • Rolling Out Claude Code to a Team: Settings Precedence, dontAsk in CI, a Hook for Every-Time Rules and a Plugin for Five Repos
  • A Claude Code Review Bot in CI: Headless -p, JSON Findings, Team Rules in Git and a Person on the Merge
  • Lab: Three Planted Bugs in a Claude Code CI Repo, a Permission Mode, a Plugin Path and an MCP Token Variable
  • Configuring MCP Servers in Claude Code: A Command or a URL, Three Scopes, and Three Moves When One Breaks
  • The Claude Messages API: Your First Call, Field by Field
  • Claude Tool Use: How tool_use and tool_result Work in the Messages API
  • Claude Client SDKs Wrap One REST API: Raw HTTP, Python, TypeScript and Async Calls Compared
  • Anthropic SDK Timeouts, Retries and Error Classes: Configure the Client Once, Then Give 429, 529, 400 and Timeouts Their Own Move
  • Claude Streaming Events: The Event Order, message_stop, Tool Arguments, Stop Reasons and a WebSocket Relay
  • Images, PDFs and Thinking Blocks in the Claude Messages API: Typed Blocks In, Typed Blocks Out
  • Getting Data Into Claude: PDF Documents, the Files API, Search Results and Citations
  • Opus, Sonnet or Haiku: Pick the Claude Model per Job, and Test the Request When a New Release Arrives
  • Adaptive Thinking and Effort in Claude: Two Dials, Set per Workload, and the Thinking Block You Must Pass Back
  • Claude Cost Tracking From usage: Count Before, Cap During, Read After, Then Find the Line That Drives the Bill
  • Claude Cache Breakpoints: Where to Put cache_control, How to Move It With the Chat, and Why the Reads Stay at Zero
  • Claude Message Batches or Real Time: Choose by Who Is Waiting, Match by custom_id, Resend Only the Failures
  • Calling Claude Through Amazon Bedrock, Google Cloud and Microsoft Foundry: Same Call, Different Door
  • The Life Cycle of a Claude App: Six Phases, a Model That Retires, and a Release Gate for Every Change
  • Pinning Claude Model IDs and Upgrading Safely: One Change at a Time, a Golden-Set Replay and a Staged Rollout
  • Content Boundaries and Schema Design for Claude: Fence the Input in a Tag, Let the Output Say I Don't Know
  • The Agentic Loop and stop_reason: Keep Turning on tool_use, Stop on end_turn, Cap the Turns
  • The Claude Agent SDK: query(), ClaudeAgentOptions and @tool, in Python and TypeScript
  • Fix the Agent: Four Broken Claude Agent SDK Configs, From the Symptom to the One Wrong Line
  • Claude Managed Agents: Cloud Sandbox, Self-Hosted Sandbox or Self-Hosted Service
  • Agent SDK Hooks for Deterministic Actions: PreToolUse, PostToolUse, and Four Hooks That Fail Silently
  • Memory and Context-Window Patterns for Claude Agents: Context Editing, Compaction and the Memory Tool
  • Reading an Agent Trace: Five Signatures, Five Missing Patterns, and How Long a Fact Must Live
  • Tool Descriptions for Claude: How Claude Picks a Tool, and How to Stop It Picking the Wrong One
  • Tool Input Schemas and Error Responses for Claude: Required Fields, Enums, is_error and a Retry Flag
  • Tool Response Shaping and a Lean Tool Set: Give Claude a Sticky Note, Not the Filing Cabinet
  • Fix the Tool Schema: Read the Trace, Fix the Card, Re-Run (Four Real Schema Bugs)
  • Client Tools, Server Tools and Approval Gates: Who Runs the Tool, and Who Says Yes First
  • Built-in Tool, Custom Tool, Skill or MCP Server? Pick the Lightest One That Fits
  • System Prompt or User Turn: Where Each Instruction Goes, and Output Limits Your Code Enforces
  • Refine the Prompt One Line at a Time, Then Clean and Fence the Customer's Text
  • Prompt Revision Driven by Evals: Name the Cause, Change One Thing, Rerun the Whole Suite
  • Long-Running Sessions: Compact, Prune, Isolate or Start Fresh, Decided by Naming the Failure
  • Context Isolation Through Subagents: Read the Logs Elsewhere, Keep One Line
  • Defensive Parsing of Claude Replies: Check the Stop Reason, Read the Block or the Text, Then Validate the Values
  • Full Context or Retrieval: Choose by Corpus Size, Cost and Freshness
  • Skepticism Toward Confident Output: Check the Quote, the Record and the Sum Before You Send
  • Debugging a Claude App: Three Error Types, the Recovery Each One Earns, and the First Failing Row
  • Six Ways a 200 Can Still Be Wrong: Hallucination, Refusal, Under-Acting, Context Loss, Format Drift and Inconsistency
  • Fix the Cause, Not the Symptom: Four Recovery Drills for an LLM App, Each Checked on a New Input
  • Integration Layer or Model Output? Three Taps and Three Questions to Find Where a Wrong Answer Lives
  • Which Test Layer Owns the Failure? Unit, Functional, Integration and End-to-End Tests for a Claude App
  • Designing an Overnight Document Pipeline on Claude: Batch Lane, Live Lane, a Cached Prefix and a custom_id Reconcile
  • Proving a Model Upgrade Is Ready: A Frozen Golden Set, a Calibrated Judge, the Right Layer and a Release Gate
  • From Requirement to Design for a Claude App: Eight Requirements, Five Elements and a Trace With No Gaps
  • Build a Claude Refund App: the Messages API, Two Tools, an MCP Server and a Hook in One Loop
  • Ship a Claude App: an Eval Gate, Two Guardrail Layers, a Cost Check From usage and a Pinned Model
  • Lab: a 30-Case Golden Set, a Calibrated Judge and a Per-Slice CI Gate on a Claude Refund App
  • Lab: Cut a Claude App's Bill by 62 Percent With Usage Data, Layered Cache Breakpoints and a Batch Job
  • Lab: Three Planted Bugs in a Claude App, a Vague Prompt, a Mistyped Tool Schema and a Broken Stream Handler
  • Lab: Three Planted Bugs in a Claude Code CI Repo, a Permission Mode, a Plugin Path and an MCP Token Variable
  • Lab: Harden a Claude App, an Uncalibrated Judge, a Retry Loop That Retries Everything and a Hook Matcher With a Gap
  • Lab: Turn a Claude App Into a Reusable Template, One Pinned Model Id, No Key in Code and Evals Built From Data
  • Building an MCP Server: Tools, Resources and Prompts in Python and TypeScript
  • MCP Transports: stdio or Streamable HTTP, and Who Starts the Server
  • Deploying and Authenticating an MCP Server: Environment Keys for stdio, Bearer Tokens and Scopes for HTTP
  1. Blog
  2. /
  3. Claude
  4. /
  5. Claude Code

A Claude Code Review Bot in CI: Headless -p, JSON Findings, Team Rules in Git and a Person on the Merge

Design a pull-request review bot with Claude Code: run it headless with -p, ask for JSON findings with a schema, keep review rules in a committed CLAUDE.md, leave the merge to a person and batch the nightly job.

Chaand Sheikh

·27 November 2026Claude Code

What you will learn

  • Run Claude Code in a CI step with -p so it runs once and exits
  • Get findings back in a fixed shape with --output-format json and --json-schema
  • Keep the team's review rules in a project CLAUDE.md committed to git
  • Keep the bot as an advisor, and send work nobody waits on to the Message Batches API

Before you start

  • What Claude Code is
  • Basic CI with GitHub Actions

A developer opens pull request 212 on the shop-app repository: a refund rounding fix. Before any person looks at it, a review bot does. It runs Claude Code inside the CI pipeline and leaves its findings as inline comments.

The bot has three jobs on every pull request: review for bugs and security problems, suggest tests the suite is missing, and post feedback as comments. The goal has two halves. The feedback must be actionable, and there must be few false positives, because noisy comments teach people to ignore all of them, the good ones too.

So most of the design is about the pipeline around the model, not the model. Let's make five decisions.

Where Claude review fits in the wider change process (what goes in git, a change gate by path, the GitHub Action) is in Claude in the SDLC.

The system in one picture

The shop-app review job Pull request starts one job claude -p runs once, exits CLAUDE.md team rules, in git JSON findings file, line, message Inline comments A person approves checks pass, merge Nightly test ideas: Message Batches API read at the next standup, nobody is waiting
The pipeline asks once, gets a fixed shape back, and a person decides.

Decision 1: the job hangs, so run it headless

A workflow step runs claude "Review the changes in this pull request". On the runner it never finishes, and the log ends with Claude Code waiting for input. Nobody is there to answer.

The fix is the print flag, -p. It is the documented non-interactive mode: it runs once, prints the answer and exits.

claude -p "Review the changes in this pull request"

The workarounds people try first all miss the cause:

  • A longer timeout. Nobody will ever answer, so it only hangs longer.
  • Piping yes into it. That guesses at questions and breaks on any question that isn't yes or no.
  • A pseudo-terminal that presses Enter. A fragile copy of what -p already does.

Decision 2: findings must become comments, so ask for a shape

The review comes back as one long paragraph. A script has to post each finding on its own line, at the right file and line. Asking for "a tidy list" and parsing it with a regular expression works until the first time the layout changes, because free text drifts. Running the review twice and keeping the tidier one gives you two unparseable answers instead of one. And describing the layout in CLAUDE.md guides the model, but it doesn't guarantee a shape.

The fix is --output-format json together with --json-schema, where the schema describes one finding. The schema makes the output machine-parseable, so the script can post every finding as an inline comment. The lecture's finding has four fields: file, line, severity and message. As an illustration, a schema for that could look like this:

{
  "type": "object",
  "properties": {
    "findings": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "file": { "type": "string" },
          "line": { "type": "integer" },
          "severity": { "type": "string" },
          "message": { "type": "string" }
        },
        "required": ["file", "line", "severity", "message"]
      }
    }
  },
  "required": ["findings"]
}

The posting script then loops over findings and creates one comment per item. No regex, no guessing. The same idea outside Claude Code is in structured LLM output with Pydantic.

Decision 3: the team's rules live in a committed CLAUDE.md

The team has review rules:

  • Money is stored in cents, never floats.
  • Skip style nitpicks the formatter already handles.
  • Every refund path needs a test.

These rules must apply on the CI runner and on every developer's laptop, and they must change through code review. That points to one place: a CLAUDE.md at the repository root, committed to git. The runner and every teammate load the same rules, and changing a rule is a pull request like any other change.

WhereWhy it fails here
~/.claude/CLAUDE.md on each laptopPersonal, not in git. The runner never sees it.
CLAUDE.local.md in each checkoutPersonal to one checkout, so the team and the runner don't share it.
Pasted into the workflow prompt in every repositoryTen copies drift apart, and no developer's own Claude Code reads them.
CLAUDE.md at the repo root, in gitShared by everyone, reviewed like code.

Decision 4: the bot advises, a person approves

Review time is the bottleneck, and a manager suggests counting the bot's review as the required approval whenever it reports no findings. Don't. Zero findings means the bot found nothing, not that the change is safe. Making the bot stricter so nobody has to look doesn't change that: a stricter bot is still a model and can still miss things. Removing the bot throws away a fast first pass that catches real problems.

Keep the bot as an advisor. Merging still needs passing checks and a person's approval.

Decision 5: the merge check stays synchronous, the nightly job is batched

Claude runs two jobs. One is a check that blocks the merge button until it passes. The other is a nightly job that suggests missing tests across the repository, read at the next morning's standup. The lead wants the lowest cost for both.

The Message Batches API costs less but promises no speed, so use it where nobody is waiting. The nightly job goes through batches. The merge check stays synchronous.

  • Both in batches removes the gate: the check exists so the merge waits for it.
  • Both synchronous gives up the 50 percent saving on work nobody is waiting for.
  • The merge check in batches makes developers wait on a job with no latency promise.

The same "who is waiting decides the lane" rule drives the overnight document pipeline.

Common mistakes

  • Fixing a hang with timeouts instead of -p.
  • Parsing free text with a regex when the CLI can return JSON that matches a schema.
  • Keeping review rules in personal files, so the runner reviews against different rules than the team.
  • Letting "no findings" stand in for an approval.
  • Batching a check that someone is waiting on.

Recap

SymptomFix
The job waits for inputRun it headless with -p
Findings must become comments--output-format json with --json-schema
The team has review rulesA CLAUDE.md in the repo, committed to git
Who decides the mergeChecks pass and a person approves; the bot advises
Nobody is waiting on itMessage Batches; a blocking check stays synchronous

When two fixes both sound sensible, ask what the cause is: the flag, the schema, the file, the approval or the API. Pick the one that fixes that cause.

Try it yourself

Write the CLAUDE.md for your own repository with three review rules, then sketch the schema for one finding in your project. Which field would your posting script need that the four fields above don't cover?

Tried the exercise? Share your answer or ask a question.

The StudyEasy AI Community is free to join, with the lesson files, notebooks and code.

Join free on Skool

Keep going in Claude · 8 of 66

Previous
Rolling Out Claude Code to a Team: Settings Precedence, dontAsk in CI, a Hook for Every-Time Rules and a Plugin for Five Repos
Next post
Lab: Three Planted Bugs in a Claude Code CI Repo, a Permission Mode, a Plugin Path and an MCP Token Variable

Related course on Udemy

Claude Certified Developer - Foundations (CCDV-F) Exam Prep

Build and ship Claude apps: the API, agents, tools and MCP, prompts, evals, security and model choice.View on Udemy ↗: Claude Certified Developer - Foundations (CCDV-F) Exam Prep (paid course, opens in a new tab)

Related posts

CLAUDE.md, settings.json and Plugins: Which Claude Code File Advises, Which Enforces, Which Packages

Three needs in one repo: a test command, a rule that Claude must never read .env, and a shared deploy skill. See which file each belongs in, how the settings layers merge, and what a plugin manifest carries.

Authoring a Claude Skill: SKILL.md, Frontmatter, Progressive Disclosure and the Description That Triggers It

Pack a support team's ticket-triage routine into one skill folder, then watch three requests load one, two or all three levels: the catalog, the SKILL.md body, and a script whose code never enters the context.

One Change, Four Environments: Where a Claude Config Edit Lands in Dev, Staging, Prod and CI

Change one line in a repo and ask where it lands. A small resolver for bookshop-bot shows that a new model id in settings.json reaches only CI, a prompt bump reaches dev and CI, and a prod block edit reaches only prod.

Claude in the SDLC: Prompts in Git, a Change Gate by Path, a Claude Review That Advises and a Person Who Merges

Follow one prompt edit from a branch to a merge: version prompts and the model pin like code, keep the API key in GitHub Secrets, gate changes by path, let Claude review the diff, and leave the merge to a person.

On this page

  • The system in one picture
  • Decision 1: the job hangs, so run it headless
  • Decision 2: findings must become comments, so ask for a shape
  • Decision 3: the team's rules live in a committed CLAUDE.md
  • Decision 4: the bot advises, a person approves
  • Decision 5: the merge check stays synchronous, the nightly job is batched
  • Common mistakes
  • Recap
  • Try it yourself
Community · Free to join
Single logo

StudyEasy AI Community

Hosted onSkool

Learn AI engineering, share what you build, and connect with other learners.

  • Free resources: lesson files, notebooks and code

  • Ask questions and join engineering discussions

  • Meet real people learning and building with AI

Join free on Skool

Related course on Udemy

Claude Certified Developer - Foundations (CCDV-F) Exam Prep

Build and ship Claude apps: the API, agents, tools and MCP, prompts, evals, security and model choice.View on Udemy ↗: Claude Certified Developer - Foundations (CCDV-F) Exam Prep (paid course, opens in a new tab)

Single logo

Empowering Education, One Course at a Time

About
About usContact usFAQs
Legal
Terms of ServicePrivacy Policy

© 2026 StudyEasy Organization. All rights reserved.