← ClaudeAtlas

integrate-arcjet-guard-claude-agent-sdk-pylisted

Integrate Arcjet Guard into the Python Claude Agent SDK — wrap authored @tool with guard_tool, and use guard_hooks for UserPromptSubmit inbound plus PreToolUse on unwrapped built-ins / MCP. Use when asked to add Arcjet to claude-agent-sdk, rate limit those tools, screen inbound prompts, or block prompt injection / PII. This is Python claude-agent-sdk, not the JS adapter and not Claude Managed Agents hosted sessions.
arcjet/arcjet-plugin · ★ 1 · AI & Automation · score 80
Install: claude install-skill arcjet/arcjet-plugin
# Integrate Arcjet Guard into the Python Claude Agent SDK `arcjet.guard.claude_agent_sdk` wraps the agent's existing Arcjet client. It never talks to the Arcjet API itself. Shared Guard fundamentals (client, rules, labels, decisions, capture, registration) live in [../arcjet/references/guards_python.md](../arcjet/references/guards_python.md). Load that reference for anything that is not Claude Agent SDK-specific. Official `claude-agent-sdk>=0.2.127,<1` only — not the JS `@anthropic-ai/claude-agent-sdk` adapter (`@arcjet/guard/claude-agent-sdk/v0`, docs https://docs.arcjet.com/guards/claude-agent-sdk/), not Vercel AI, not community forks, and not Claude Managed Agents hosted `client.beta.sessions` (`arcjet.guard.claude_managed_agents`). Importing `arcjet.guard.claude_agent_sdk` does not load LangChain, CrewAI, or the JS adapter. The extra is safe (no chromadb). Exports: `guard_tool`, `guard_hooks`, `claude_agent_context`. Authored `@tool` + `create_sdk_mcp_server` for tools you own; `guard_hooks` for inbound `UserPromptSubmit` and unwrapped built-ins / MCP `PreToolUse`. There is no inbound helper and no `guard_can_use_tool`. Three surfaces, one decision rule: - **An authored `@tool`** → `guard_tool`. Denial is JSON-in-content + `is_error: True`. Python does **not** forward `structuredContent` (that is the JS adapter). Do **not** raise. - **Inbound text** → `guard_hooks` `UserPromptSubmit` (`decision: "block"`). That is the only place a turn can be declined before th