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 before submission to Claude |
| 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 |
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
Enterprise organizations with Claude Code Pro can use remote managed settings to centrally control and distribute hooks across the organization.
Overview:
Remote managed settings are configured via the Claude.ai admin console and automatically fetched when users authenticate. This method provides the highest level of security and control by:
- Enforcing organization-wide hook policies that cannot be overridden by users
- Automatically synchronizing configurations to all authenticated team members
- Allowing strict control over which hooks are permitted to run
- Blocking user, project, and plugin hooks when
allowManagedHooksOnlyis enabled
Setup:
Access the Claude.ai admin console with your enterprise administrator account
Navigate to the Settings section
Configure the hooks provided by Capsule Security with
allowManagedHooksOnlyenabled:{ "allowManagedHooksOnly": true, "hooks": { "UserPromptSubmit": [...], "PreToolUse": [...], "PostToolUse": [...], "SessionStart": [...], "SessionEnd": [...] } }Save and publish the configuration
Behavior:
When allowManagedHooksOnly is set to true:
- Managed hooks (configured via admin console) are loaded and executed
- User hooks (
~/.claude/settings.json) are blocked - Project hooks (
.claude/settings.json) are blocked - Plugin hooks are blocked
This ensures only administrator-approved hooks run, preventing users from disabling or circumventing the Capsule Security integration.
Settings Precedence:
Claude Code applies settings in the following order (highest to lowest):
- Remote managed settings - Cannot be overridden
- File-based managed settings (
managed-settings.json) - Ignored when remote managed settings are configured - Command line arguments
- Local project settings (
.claude/settings.local.json) - Shared project settings (
.claude/settings.json) - User settings (
~/.claude/settings.json)
Key Features:
- Centralized management through Claude.ai admin console
- Automatic synchronization to all authenticated team members
- Cannot be overridden by users or project settings
- Enforces enterprise security policies across the organization
- No manual deployment to individual machines required
For organizations without Claude Code Enterprise or those preferring traditional MDM deployment, use Mobile Device Management tools to deploy hooks to user settings files.
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
- Less secure than Option A as users may override settings
- Suitable when remote managed settings are not available
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