Skip to lesson

AnthropicClaude Certified Architect – Foundations2026-100 Prerequisites

Make command runs reproducible in CI

Completed by the knowledge check

Learning objective

Apply essential CLI, Git, and CI/CD concepts: flags, exit codes, shared versus personal configuration, and environment variables

Core idea

A reproducible automated run depends on more than its prompt. The command line selects a mode and options, Git decides which content is recorded, configuration files and environment variables reach the process, and the exit status tells the caller whether the process succeeded. In CI/CD, a successful agent invocation is one step, not proof that the code passes tests or that a release ran.

How it works

Flags and task text

A flag changes how a command runs. In claude -p "Review the authentication module", claude is the program, -p (long form --print) selects non-interactive execution, and the quoted text is the task. Long flags can take values: --output-format json selects machine-readable output. --tools and --allowedTools look alike but differ; 0.6 separates them. The flags and GitHub Actions inputs for unattended jobs are taught in 3.6.1, the JSON envelope and --json-schema in 3.6.2, and --bare context loading in 3.6.3.

Exit status

Claude Code exits with code 0 on success and a non-zero code when the run fails, so scripts can branch on it. An invalid flag is reported to stderr before the run starts; a failure inside the run, such as missing authentication, is printed as the result on stdout. GitHub Actions sets a check-run status from an action’s exit code: 0 is success, anything else failure.

Working tree, index, commit

Git separates the working tree, the index (staging area) and commits. Editing changes the working file; git add snapshots it into the index; git commit records the staged snapshot. Edit the file again after git add and the two differ. git status shows pending state and git diff --cached compares staged changes with the last commit. CI evaluates recorded content, so a local run that passed against an unstaged file says nothing about the revision CI checks.

Shared and personal configuration

FileAudience
~/.claude/settings.jsonYou, across projects
.claude/settings.jsonEveryone on the project; committed
.claude/settings.local.jsonYou, in this project only

Claude Code keeps .claude/settings.local.json out of Git when it creates the file; create it by hand and you add it to .gitignore yourself. The same shared-versus-personal split for MCP servers — .mcp.json against ~/.claude.json — is taught in 2.4.1.

Environment variables

Environment variables are values the execution environment gives a process, separate from the prompt and from the repository. In GitHub Actions, env can be set at workflow, job or step scope, and secrets are stored apart from ordinary configuration variables, so a credential reaches the step that needs it without being committed. Referencing credentials as ${VAR} in shared MCP configuration is taught in 2.4.2.

Key distinctions and trade-offs

  • Flag versus prompt: asking for JSON in prose is not --output-format json.
  • Exit status versus output: output carries data; the exit status carries success.
  • Working tree versus commit: a check covers only the content it inspects.

Architecture / decision scenario

A CI job runs claude -p "Summarize the authentication change" --output-format json on a pull request after passing locally. In CI it fails: the developer’s terminal credentials do not exist there. The wrapper preserves the non-zero exit code although a result was printed, and the team supplies the API key to that step from GitHub Actions secrets instead of committing it to .claude/settings.json. Then git status shows a supporting file was edited but never staged, so the local success described different content.

Common exam traps

  • Treating non-empty stdout as success.
  • Assuming a successful agent run proves the code passes CI.
  • Confusing --allowedTools with tool availability.
  • Assuming edits after git add update the staged snapshot.
  • Relying on personal settings or terminal credentials in CI.
  • Committing a secret because the job needs it.

What to remember

Read flags apart from the task, preserve the exit status, and know which Git content is being evaluated. Commit shared configuration deliberately, keep personal overrides local, and supply environment values to the step that needs them.

Knowledge check

References