Anthropic ant, claude -p, Agent SDK compared
AI engineer Daniel San maps out when to use Anthropic's ant CLI, headless claude -p, or the Claude Agent SDK by testing all three on the same real repository security audit. The visual architecture guide contrasts single-shot API calls against local Claude Code agent loops and exposes costly permission, prompt-caching, and CI security pitfalls.
Anthropic's programmatic stack looks redundant on paper until you ship to CI or production, where picking the wrong layer quietly 10x's your token bill or executes untrusted repository hooks.
- –Single-shot vs. agent loop is the core split: ant hits the Claude API directly (one request, one response) for predictable batch jobs and evals, whereas claude -p and the Agent SDK both run the multi-turn Claude Code harness with file I/O, CLAUDE.md, and MCP.
- –claude -p permission flags have sharp edges: --allowedTools only pre-approves listed tools instead of removing the rest, so truly locking down headless runs requires --tools, --strict-mcp-config, and --permission-mode default—a prefix change that broke prompt caching and jumped his test run from $0.21 to $2.10.
- –Running claude -p against untrusted PRs without --bare is a CI security footgun because headless mode loads repo hooks and MCP servers without a trust dialog; Anthropic's docs indicate --bare will become the default.
- –The Claude Agent SDK bundles its own Claude Code binary (decoupled from your local terminal install) for embedding policies in Python or TypeScript apps, though its canUseTool callback skips auto-approved read-only calls—meaning strict auditing still requires a PreToolUse hook or explicit tools allowlist.
DISCOVERED
1h ago
2026-12-03
PUBLISHED
1h ago
2026-12-03
RELEVANCE
AUTHOR
dani_avila7
