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.
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).
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
| Option | Why it fails |
|---|---|
Paste the token into .mcp.json | It lands in git, for everyone |
| Turn off auth on the server for CI | Then anyone can call it |
| Commit one config file per environment | Every file still holds a secret |
| Header reads a variable, CI secret store fills it | The file names the variable; the store holds the value |
Recap
| File | Bug | Fix |
|---|---|---|
.claude/settings.json | bypassPermissions in a project file is ignored | dontAsk plus two allow rules |
plugin.json | commands/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.
StudyEasy AI Community
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
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.