Single logo
  • Courses
  • Blog
  • About
Join free on SkoolJoin free 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

Lab: Three Planted Bugs in a Claude Code CI Repo, a Permission Mode, a Plugin Path and an MCP Token Variable

A headless Claude Code job fails on three valid-looking JSON files: bypassPermissions in a project settings file, a plugin command path without ./, and an MCP header that reads a misspelled variable and gets a 401.

Chaand Sheikh

·27 November 2026Claude Code

What you will learn

  • Pick a permission mode and allow rules for headless Claude Code in CI
  • Fix a plugin manifest component path so validation passes
  • Authenticate an HTTP MCP server with a bearer header that reads an environment variable
  • Check all three files before merge with a small script

Before you start

  • CLAUDE.md, settings.json and plugins
  • Deploying and authenticating an MCP server

The refund app is ready to ship, and its CI job fails. Three configuration files hold one bug each. Every file is valid JSON. Each one is still wrong for the tool that reads it.

The job runs Claude Code in headless mode, the claude -p command. Nobody is there to approve a prompt. Think of a night shift with no manager: the night rules must be complete (the settings file), the badge must have the right format or the gate refuses it (the plugin manifest), and the door code is held in memory, never painted on the door (the MCP config).

Three files, one headless job .claude/settings.json what it may do without asking .claude-plugin/plugin.json what it loads, and if it is valid .mcp.json how it signs in to the server CI job claude -p orders server wants a bearer token
A bug in any one of them turns the job red.

Bug 1: a permission mode the project file can't set

{
  "permissions": {
    "defaultMode": "bypassPermissions",
    "deny": ["Read(./.env)"]
  }
}

Someone thought: nobody can approve a prompt in CI, so skip them all. But per the Claude Code docs on permission modes, a project settings file can't set bypassPermissions; it doesn't take effect there. The job starts in the default, manual mode instead, and in headless mode every call that needs approval is denied. Even in user settings, bypassPermissions is meant for isolated containers only.

The fix is dontAsk with explicit allow rules for the two things the job needs. Anything not allowed is denied, quietly, and the job never waits.

{
  "permissions": {
    "defaultMode": "dontAsk",
    "allow": ["Read", "Bash(python run_all.py)"],
    "deny": ["Read(./.env)"]
  }
}

The deny rule was fine all along: it keeps the .env file out of reach. The wider picture of these files is in CLAUDE.md, settings.json and plugins.

Bug 2: a plugin path without ./

{
  "name": "refund-tools",
  "version": "0.1.0",
  "description": "Refund helpers for the support team",
  "author": {"name": "Support Team"},
  "commands": "commands/refund.md"
}

The manifest lives in a folder named .claude-plugin. name is the one required field, in kebab-case. version pins the plugin to that release. The problem is the command path: the plugins reference says every component path must start with ./. Without it, validation fails and the job stops before it starts. The fix is one change:

  "commands": "./commands/refund.md"

Bug 3: a token variable with a typo

{
  "mcpServers": {
    "orders": {
      "type": "http",
      "url": "http://127.0.0.1:8765/mcp",
      "headers": {
        "Authorization": "Bearer ${ORDERS_TOKN}"
      }
    }
  }
}

.mcp.json sits at the repo root so the whole team shares it. type: "http" marks a remote server reached by a URL, and the header carries the sign-in. The good part: the header reads a variable, so the token is never in the file. The bad part: the name is ORDERS_TOKN, missing an E. Per the Claude Code MCP docs, an unset variable stays as written. So the server receives the literal text ${ORDERS_TOKN} and answers 401. Fix the name to ORDERS_TOKEN; the CI secret store sets its value.

The server side is a small gate that checks the bearer token:

"""The bearer check in front of the orders server."""
import hmac
import http.server
import os
import threading


class Gate(http.server.BaseHTTPRequestHandler):
    def do_POST(self):
        want = "Bearer " + os.environ["ORDERS_TOKEN"]
        got = self.headers.get("Authorization", "")
        if hmac.compare_digest(got, want):
            self.reply(200, '{"tools": ["get_order"]}')
        else:
            self.reply(401, '{"error": "unauthorized"}')

    def reply(self, code, body):
        self.send_response(code)
        self.end_headers()
        self.wfile.write(body.encode())

    def log_message(self, *args):
        pass

The expected token comes from the environment, not the code, and hmac.compare_digest compares in constant time so timing gives nothing away. More on this in deploying and authenticating an MCP server.

One check before every merge

Nothing here breaks loudly until the job runs, so the lab adds ci_check.py, our own script with three checks. The settings check fails a mode a project file can't set and wants dontAsk plus allow rules. The plugin check runs claude plugin validate, the real validator from Claude Code, and reports its error line. The MCP check expands the header variables the way the docs describe and names any unset one. Here it is on both folders:

repo
  FAIL settings: bypassPermissions in project file is ignored
  FAIL plugin: commands: Invalid input
  FAIL mcp: ${ORDERS_TOKN} is not set, server answered 401
repo_fixed
  ok   settings: dontAsk, 2 allow rules
  ok   plugin: Validation passed
  ok   mcp: server answered 200
1 of 2 repos blocked

Only the plugin line comes from Claude Code; the other two are our script's words. The token in this run is a test value set by the run script. A real token comes from the CI system's secret store.

A server that needs a token, in CI

OptionWhy it fails
Paste the token into .mcp.jsonIt lands in git, for everyone
Turn off auth on the server for CIThen anyone can call it
Commit one config file per environmentEvery file still holds a secret
Header reads a variable, CI secret store fills itThe file names the variable; the store holds the value

Recap

FileBugFix
.claude/settings.jsonbypassPermissions in a project file is ignoreddontAsk plus two allow rules
plugin.jsoncommands/refund.md has no ././commands/refund.md
.mcp.json${ORDERS_TOKN} is unset, server says 401${ORDERS_TOKEN}, set by the secret store

Read each config the way its tool reads it, and run the check before every merge. For keys outside MCP, see API keys, proxies, rotation and scope.

Previous: lab: prompt, schema and stream bugs. Next: lab: planted bugs in the judge, the retry path and the guardrail.

Keep going in Claude · 9 of 66

Previous
A Claude Code Review Bot in CI: Headless -p, JSON Findings, Team Rules in Git and a Person on the Merge
Next post
Configuring MCP Servers in Claude Code: A Command or a URL, Three Scopes, and Three Moves When One Breaks
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)

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

  • Bug 1: a permission mode the project file can't set
  • Bug 2: a plugin path without ./
  • Bug 3: a token variable with a typo
  • One check before every merge
  • A server that needs a token, in CI
  • Recap
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.