CertPrep
Domain 7 · Lesson 7.2 · 7 min read

Configuring the Agent SDK and Claude Code

Exam skillAgent SDK and Claude Code Configuration

Configuring the Claude Agent SDK or Claude Code (permission modes such as default, acceptEdits, plan, auto, dontAsk, and bypassPermissions; hooks; subagent definitions; headless or CI operation) to support a team workflow within stated safety and automation guardrails.

Configure Claude Code and the Agent SDK for a team workflow (permission modes, deny rules, hooks, subagent definitions and headless or CI runs) so it stays inside its safety guardrails, including when nobody is watching.

What you need to know

Claude Code and the Agent SDK share one model of control: permission modes decide how much runs without asking, rules allow or deny specific tools and paths, hooks run your own code at points in the loop, and subagents get their own instructions and tools. This skill asks you to combine them so a team workflow runs as freely as it safely can.

Permission modes

ModeBehaviourFits
default (Manual)Reads run; edits, commands and network access ask firstSensitive work, unfamiliar code
acceptEditsFile edits in the working directory run without asking; other actions keep their rulesWorking with changes reviewed afterwards in the diff
planClaude explores and writes a plan; source edits wait until the plan is approvedUnderstanding a codebase before changing it
autoA classifier reviews actions before they run and blocks those that look risky or driven by hostile contentLong interactive tasks with fewer prompts; reduces prompts, does not guarantee safety
dontAskAnything not pre-approved by a rule is denied; the session never waits for inputLocked-down CI and scripts
bypassPermissionsPermission prompts and safety checks are skippedIsolated containers or VMs only

Two facts matter in many items. Deny rules block in every mode, including bypassPermissions, so they are the hard limit. And administrators can disable bypassPermissions and auto through managed settings, which users and projects cannot override.

Hooks

Hooks run your code at points such as before a tool call (PreToolUse), after it (PostToolUse) or when a session ends. A PreToolUse hook can inspect the command or file path and block it, which makes a rule like "never push to main" deterministic. Hooks also run formatters and linters after edits, and record what the agent did for audit.

Subagent definitions

A subagent is defined with its own prompt and its own restricted tool list. A review subagent that only reads files cannot change them, whatever it is asked. Defining subagents per role keeps the main session's context lean and limits what each part of a workflow can do.

Headless and CI operation

Claude Code runs non-interactively with -p, returning structured output that a pipeline can parse. In CI, pair it with dontAsk, an explicit allow list (for example the test command and file edits), deny rules for secrets and protected branches, and hooks for anything that needs checking in code. The Agent SDK offers the same controls in code, including a permission callback that decides each tool request.

In the exam

Configuration items describe a team workflow with safety and automation requirements (interactive or unattended, what must never happen, how much can run without review) and ask which mode, rules, hooks or subagent definitions fit. Use dontAsk with allow and deny rules for CI, plan before large changes, acceptEdits when edits are reviewed afterwards, deny rules and hooks for hard limits, restricted tool lists for subagents, and managed settings to forbid risky modes. Distractors use bypassPermissions outside an isolated environment, rely on instructions, or leave an unattended run waiting for approval.

Check your understanding

Question 1

A CI job runs Claude Code to fix lint errors on every pull request. It must never wait for input, may only edit files and run the linter, and must never read .env files. Which configuration fits?

Show answer

Answer: A. dontAsk denies anything not pre-approved, so the job never waits, and the deny rule is a hard limit. Bypassing removes protection, acceptEdits would leave the linter waiting, and nobody approves CI steps live.

Question 2

Which statement about deny rules is correct?

Show answer

Answer: D. Deny rules are the hard limit in every permission mode, which is why they carry the rules that must never be broken.

Question 3

A team wants a review subagent that can read the codebase and comment, but can never modify files. How should it be defined?

Show answer

Answer: B. A restricted tool list makes editing impossible for that subagent. A prompt can be ignored, and reverting edits afterwards is cleanup, not prevention.

Apply it: Configure Northgate's nightly migration bot

Exercise · about 20 minCase: Northgate Software

Northgate wants a nightly job that uses Claude Code to migrate one service at a time to the new logging library, run the tests and open a draft pull request. It runs on a CI runner with no one watching. Security requires: no secrets read into context, no pushes to protected branches, no production access, and SOC 2 evidence of what the job did.

  1. Choose the permission mode and justify it.
  2. Write the allow rules, deny rules and hooks.
    Done when: every security requirement is enforced by a rule or a hook, not an instruction.
  3. Define one subagent the job uses, with its tool list.
  4. Say what is set centrally in managed settings and what is set in the repository.
Check your work
Show model answer

1. Mode. dontAsk: the job never waits for input, and anything not pre-approved is denied.

2. Rules and hooks

TypeSetting
AllowEdit files in the service directory; run the build and test commands; git commit and push to migration/* branches; open a draft pull request
DenyRead .env*, key files and the secrets directory; push to main or release branches; any production hostnames
PreToolUse hookBlocks any shell command that pushes outside migration/* or reaches production hosts, and logs the attempt
PostToolUse hookRuns the secrets scanner on changed files and the linter after edits
Session-end hookWrites a record of tool calls, files changed and test results to the audit store for SOC 2 evidence

3. Subagent. A "usage finder" subagent with read and search tools only, which lists the old library's call sites before the main session edits anything.

4. Central versus repository. Managed settings: bypassPermissions and auto disabled, the secrets deny rules, the approved marketplace for plugins. Repository settings: the service's build and test commands and the migration/* branch rule.

Key termsClaude Agent SDKHookPermission mode

Sources