Home / CCA-F / Claude Code / Hooks, SDK & CI/CD — Detail & Examples
DWG 3.4 — DETAIL & EXAMPLES

Hooks, SDK & CI/CD — Detail & Examples

Part of Claude Code · overview: domain-3.html
In this page

A before/after fix for a hanging CI job, the difference between an instruction and a hook-enforced rule, and where the Agent SDK fits in.

3.4aA CI job, before and after

WORKED EXAMPLE · FIXING A HANGING CI JOB
BEFOREA GitHub Actions step runs: claude "Review this PR for security issues"
  1. Claude Code defaults to interactive mode, which expects keyboard input.
  2. The CI runner has no keyboard attached — there's nothing to type.
  3. The job hangs indefinitely waiting for input that will never come, and eventually times out.
AFTER:claude -p "Review this PR for security issues" --output-format json — runs non-interactively, writes the result to stdout, and exits; JSON output lets a downstream CI step parse findings automatically.

3.4bA hook enforcing a rule programmatically

Instruction vs. enforcement
  • Writing "never run destructive shell commands" into CLAUDE.md is a request — a strong one, but still just an instruction the model follows probabilistically.
  • A pre-tool-use hook that inspects the proposed shell command and blocks execution if it matches a destructive pattern (e.g. a recursive delete) is enforcement — it happens outside the model's own judgment, so it can't be talked out of it.
  • Hooks are the right tool specifically when a rule needs to be guaranteed, not just requested.

3.4cSDK: same loop, different home

The Claude Agent SDK is what you'd reach for to build a custom application with the same act/observe/decide loop Claude Code uses in the terminal — for example, embedding an agent directly into an internal support tool rather than asking support staff to use the Claude Code CLI itself.


Claude Certified Architect — Study NotesDWG 3.4