Connect OpenAI Codex to Capsule Security for complete visibility into AI coding assistant activity, including prompts, tool execution, and session lifecycle.
This integration uses Codex's hooks system to capture AI coding assistant activity. Hooks are shell commands that execute at specific points in Codex's lifecycle, providing automated workflows and audit capabilities.
The integration is delivered through Codex's managed configuration - a requirements.toml that registers the Capsule hooks. Because the configuration is managed, the hooks are trusted by policy, apply to every user, and cannot be disabled or removed by users. No per-user trust approval is required.
The following hooks are configured:
| Hook Event | Description |
|---|---|
| SessionStart | Session initialization and context with MCP tools definitions |
| UserPromptSubmit | User prompts before submission to the model |
| PreToolUse | Tool execution requests (before execution) |
| PostToolUse | Tool execution results (after completion) |
| Stop | Agent stop events when the agent finished responding |
Before you begin, ensure you have:
- Codex CLI installed
- A Capsule Security account with admin access
- A device management tool (Jamf, Intune, Kandji, ...) to deploy files to your fleet
Log in to the Capsule Security portal
Navigate to Settings > Integrations and locate Codex
In the wizard, select your platform to download the managed configuration. Capsule generates it for you, including an embedded authentication token scoped to your organization:
- Mac / Linux: a single
requirements.tomlfile - Windows: a
capsule-codex-managed.ziparchive containingrequirements.tomland theCapsuleCodexHook.ps1companion script
- Mac / Linux: a single
Deploy the files to the following locations via your MDM:
Platform requirements.tomlCompanion script macOS / Linux /etc/codex/requirements.tomlNot required Windows %ProgramData%\OpenAI\Codex\requirements.tomlC:\ProgramData\Capsule\CodexHooks\CapsuleCodexHook.ps1On macOS, the configuration can alternatively be delivered as an MDM configuration profile in the
com.openai.codexpreference domain, with the file's content base64-encoded into therequirements_toml_base64key
See the platform guides for step-by-step MDM instructions:
The managed configuration is loaded at session start. Exit any running Codex sessions and start a new one for the configuration to take effect.
Start a new Codex CLI session
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 Codex agent appears
Click on the agent and review the audit logs to verify events are captured:
- Session start event
- User prompt
- Tool execution
- Session activity
If events are not appearing:
Verify
requirements.tomlis in the correct location for your platform (see Step 2), and that its content was deployed intactRun
/hooksin Codex - the Capsule hooks should be listed as managed; if nothing is listed, the configuration is not being loadedWindows: verify the companion script -
CapsuleCodexHook.ps1must exist atC:\ProgramData\Capsule\CodexHooks\, where the managed configuration invokes itCheck for conflicting managed configuration sources - Codex resolves managed configuration in precedence order (macOS MDM preference-domain profiles override the
/etc/codex/requirements.tomlfile), so another policy may be taking precedence or disabling hooksContact Capsule Security support if issues persist
Codex hooks execute with your current environment credentials. Before deploying the configuration:
- Review all hook commands in the generated configuration
- Verify the endpoint URL matches your organization's Capsule instance
- Protect authentication tokens embedded in the configuration (never commit
requirements.tomlto version control)
For help with this integration:
- Email: support@capsule.security
- Include: Your organization ID, integration status, and any error messages