Connect Claude Code to Capsule Security for complete visibility into AI coding assistant activity, including prompts, tool execution, session lifecycle, and MCP tool usage.
This integration uses Claude Code's hooks system to capture AI coding assistant activity. Hooks are shell commands that execute at specific points in Claude Code's lifecycle, providing automated workflows and audit capabilities.

The following hooks are configured:
| Hook Event | Description |
|---|---|
| SessionStart | Session initialization and context with MCP tools definitions |
| UserPromptSubmit | User prompts, with their pasted images, before submission |
| PreToolUse | Tool execution requests (before execution) |
| PostToolUse | Tool execution results (after successful completion) |
| Stop | Agent stop events when the agent finished responding |
| SessionEnd | Session termination and cleanup |
| SubagentStart | A subagent was spawned by the agent |
| SubagentStop | A subagent finished, with its final message |
Images pasted or attached to a prompt are analyzed together with that prompt before Claude receives it, so a prevention policy can block a prompt because of what its image shows. Each image is also stored and shown with its message in the session log.
- Formats and size: PNG, JPEG, GIF and WebP, up to 5 MB per image. Beyond 10 MB of images in one prompt, the remaining images are analyzed after Claude responds and cannot block that prompt.
- What leaves the machine: only images that are part of a submitted prompt. In the terminal, an image pasted and then removed before submitting is not sent.
- Non-interactive runs: images in prompts sent with
claude -pare analyzed after Claude responds. - Older configurations: a
managed-settings.jsongenerated before image analysis was available still sends images, but only after Claude responds, so they cannot block the prompt. Redeploy the current configuration to analyze images before submission.
Before you begin, ensure you have:
- Claude Code installed
- A Capsule Security account with admin access
Log in to the Capsule Security portal
Navigate to Integrations and locate Claude Code
Click Install - Capsule automatically generates a
managed-settings.jsonfile containing:- Hook commands for all lifecycle events
- An embedded authentication token scoped to your organization
- Platform-specific scripts (bash for macOS/Linux, PowerShell for Windows)
Select your target platform (macOS, Linux, or Windows) to download the configuration file
Deploy the configuration to every developer machine with your Mobile Device Management (MDM) tool.
Setup:
- Deploy the downloaded
managed-settings.jsonfile to the appropriate path for your platform:
| Platform | Path |
|---|---|
| macOS | /Library/Application Support/ClaudeCode/managed-settings.json |
| Linux / WSL | /etc/claude-code/managed-settings.json |
| Windows | C:\Program Files\ClaudeCode\managed-settings.json |
Use your organization's device management solution (Jamf, Intune, SCCF, etc.) to distribute the file to all developer machines. Set appropriate file permissions (read-only recommended).
Include the hooks configuration provided by Capsule Security in the deployed file
Set appropriate file permissions (read-only recommended to prevent user modifications)
Limitations:
- Users can potentially override or disable hooks with project-level settings (
.claude/settings.json) - Users can add local overrides via
.claude/settings.local.json - Requires MDM infrastructure capable of deploying user-level configuration files
- Manual updates required when hooks configuration changes
Key Considerations:
- Centrally managed by your IT or security team
- Your organization is responsible for deployment and updates
For step-by-step, platform-specific instructions, see the dedicated MDM guides:
For the hooks to take effect:
- Exit Claude Code by pressing Ctrl+C or typing
/exit - Restart Claude Code
Run
/hooksin Claude Code to confirm all hooks are listedStart a session and execute a simple task to generate activity:
Create a new file called test.txt with the content "Hello World"Log in to the Capsule Security portal
Navigate to Inventory > Agents and confirm your Claude Code agent appears
Click on the agent and review the audit logs to verify events are captured:
- Session start event
- User prompt
- Tool execution (Write tool)
- Session activity
To view the full conversation, navigate to Observability and filter by Activity Type - Session
If events are not appearing:
Verify the managed-settings.json is in the correct path for your platform (see Step 2)
Check file permissions - the file must be readable by the user running Claude Code
Verify settings file syntax - ensure the file contains valid JSON:
cat "/Library/Application Support/ClaudeCode/managed-settings.json" | python3 -m json.toolRun
/hooksin Claude Code - if no hooks are listed, the file is not being loadedCheck Claude Code logs for hook execution errors
Contact Capsule Security support if issues persist
Claude Code hooks execute with your current environment credentials. Before deploying hooks:
- Review all hook scripts provided by Capsule Security
- Verify the endpoint URL matches your organization's Capsule instance
- Protect authentication tokens used by hooks (never commit to version control)
- Use
.claude/settings.local.jsonfor sensitive configuration values - Ensure
.claude/settings.local.jsonis in.gitignore
For help with this integration:
- Email: support@capsule.security
- Include: Your organization ID, integration status, and any error messages