Skip to lesson

AnthropicClaude Certified Architect – Foundations2026-103.6 Integrate Claude Code into CI/CD pipelines

Choose context loading for each CI job

Completed by the knowledge check

Learning objective

Retain project instructions in ordinary -p runs; recognize that --bare intentionally skips automatic CLAUDE.md, hooks, skills, plugins, and MCP discovery.

Core idea

Non-interactive execution and automatic context discovery are different decisions. An ordinary claude -p invocation loads the same configured context as an interactive session, including project instructions. Adding --bare deliberately changes that startup contract.

Choose the contract from the job’s dependencies. A team review that relies on checked-in conventions needs those conventions in context. A portable script that should ignore host customizations can use bare mode, but must supply the instructions and integrations it actually requires. Neither mode is a substitute for the permission policy in 3.6.1.

How it works

Keep ordinary project instructions available

For ordinary print runs, check out the repository and launch from the intended working directory. Project instructions can live in ./CLAUDE.md or ./.claude/CLAUDE.md. Claude Code loads instruction files in the directory hierarchy above the working directory at launch; instruction files in subdirectories load on demand.

This loading behavior matters in a monorepo. A job launched at the repository root should not assume every package’s nested instructions are already in context. Direct the reviewer to the relevant package files so its investigation reaches the applicable guidance. See 3.1.1 for instruction scope and 3.1.4 for diagnosing loading.

Ordinary -p also loads configured context from ~/.claude. A reusable runner can therefore supply personal instructions or customizations that a clean runner lacks. “It works on a developer machine” does not establish the context received by the CI invocation. Inspect the working directory, checked-out instructions, runner configuration, and launch flags together.

CLAUDE.md is guidance the model reads, not an enforced permission boundary. Writing “never deploy” there does not replace tool denials. Keep required operational gates in the job’s permissions or hooks; use the instruction file for project knowledge and review criteria.

Understand what bare mode skips

--bare skips automatic discovery of hooks, skills, custom commands, subagents, installed plugins, MCP servers, auto memory, and CLAUDE.md. The CLI reference states that it sets CLAUDE_CODE_SIMPLE; setting CLAUDE_CODE_SIMPLE=1 can therefore explain bare behavior even when the visible command lacks the flag.

A bare run still has Bash, file-read, and file-edit tools. Skipping configuration discovery does not mean that no tools exist or that all tool operations are approved. Continue to configure permissions and the tool menu explicitly.

There is a documented exception to the broad discovery rule: a directory supplied through --add-dir can contribute skills from its .claude/skills/ folder even in bare mode. Its .claude/commands/ and .claude/agents/ folders remain skipped. Bare mode skips automatic discovery; it does not make every skill unavailable.

Bare mode also changes authentication. It does not read OAuth credentials or the system keychain. For the Anthropic API, supply ANTHROPIC_API_KEY in the environment or an apiKeyHelper through --settings. The documented cloud providers continue to use their own provider credentials. A job that stops authenticating after adding --bare needs an explicit supported credential path, not a larger turn budget.

Supply bare-mode dependencies explicitly

The documented flags let you choose what a bare invocation receives:

DependencyExplicit mechanism
Extra system instructions--append-system-prompt or --append-system-prompt-file
Settings--settings
MCP servers--mcp-config
Custom agents--agents
A plugin--plugin-dir or --plugin-url

For example, a bare review can receive the repository’s standing instructions through a file flag:

claude --bare -p "Review the supplied diff against the project criteria" \
  --append-system-prompt-file ./CLAUDE.md < pr.diff

The file flag supplies its contents as system-prompt additions. It does not restore automatic discovery of every other CLAUDE.md, hook, skill, or integration. If the job depends on separate package instructions, supply those deliberately too. Do not assume loading one text file recreates the complete ordinary session.

Appending preserves Claude Code’s default system prompt. --system-prompt and --system-prompt-file replace that prompt instead. Choose an append flag when you need project-specific additions while retaining the default coding-assistant guidance.

Account for hooks and MCP startup

Without bare mode, a -p session runs project hooks from .claude/settings.json and connects project MCP servers from .mcp.json, even in a folder it has never trusted. Print mode shows neither a workspace trust dialog nor a per-server approval prompt.

This is a load boundary, not a claim that each subsequent MCP tool call bypasses permissions. It explains why the job’s startup can differ when it reads different repository or host configuration. For a script intended to discover nothing implicitly, bare mode removes those dependencies; explicitly supplied MCP configurations or plugins remain intentional inputs.

Bare mode also prevents background tasks and omits system reminders normally supplied alongside tool results. If your workflow relies on those behaviors, treating bare mode as a performance-only flag is incorrect. Select the startup contract before tuning the job’s timing.

Key distinctions and trade-offs

Ordinary print mode reduces explicit setup when the repository already holds the required instructions and integrations. It also inherits configured context from the working directory and host. Bare mode makes dependencies more deliberate, but moves responsibility for supplying them into the invocation.

A fresh conversation is not an empty configuration. Ordinary print mode can load project instructions and auto memory into a fresh context window. Conversely, a bare invocation can receive substantial explicit context through prompts and flags. Distinguish conversation history from startup inputs; see 3.6.5 for review isolation.

Architecture / decision scenario

A CI test generator follows fixture rules in the repository’s CLAUDE.md. The first implementation uses ordinary -p from the checkout root and reads the relevant test files. After an optimization adds --bare, it starts proposing tests that ignore fixture conventions.

The team verifies the launch flags and finds that the instruction file is no longer discovered. It can retain ordinary print mode, or keep bare mode and supply --append-system-prompt-file ./CLAUDE.md plus any package guidance the assignment needs. It also supplies API authentication explicitly if bare mode removed reliance on subscription credentials. The decision restores the context dependency; repeating “follow project standards” without the standards does not.

Common exam traps

  • Assuming -p alone disables CLAUDE.md loading.
  • Treating --bare as a startup-speed change with no behavioral consequences.
  • Assuming a supplied root instruction file restores all automatic discovery.
  • Confusing MCP connection at startup with approval of every MCP tool call.
  • Forgetting CLAUDE_CODE_SIMPLE=1 when diagnosing bare behavior.
  • Expecting bare mode to use subscription OAuth credentials.

Where the exam guide differs

Note:

The exam guide names CLAUDE.md as the project-context mechanism for CI-invoked Claude Code without describing bare mode. Ordinary -p retains that behavior; --bare intentionally skips automatic instruction loading. Read an exam item about CLAUDE.md as an ordinary configured run unless it supplies a mode that disables discovery. The product documentation recommends bare mode for scripted calls, so check the invocation before relying on automatic project-context loading.

What to remember

Choose ordinary discovery or bare mode deliberately. Ordinary -p loads configured context; --bare skips it and requires explicit dependencies. Preserve project guidance through discovery or file-based prompt additions, then apply permissions independently. A missing context dependency is repaired by supplying that dependency, not by increasing retries.

Knowledge check

References