kosa8 hooks install
Install kosa8's hook into a coding agent (Claude Code, Cursor, Codex, Gemini CLI, Copilot CLI)
Usage#
kosa8 hooks install claude-code|cursor|codex|gemini|copilot
Adds kosa8's hook to the agent's settings, keeping everything else in the file as it was (other hooks included). The file is backed up to ~/.kosa8/hooks/backups first; installing again replaces kosa8's entries, and uninstall takes them out.
claude-code --scope user ~/.claude/settings.json --scope project .claude/settings.local.json (not committed) cursor --scope user ~/.cursor/hooks.json --scope project .cursor/hooks.json codex --scope user ~/.codex/hooks.json --scope project .codex/hooks.json gemini --scope user ~/.gemini/settings.json --scope project .gemini/settings.json copilot --scope user ~/.copilot/hooks/kosa8.json --scope project .github/hooks/kosa8.json
Claude Code: PreToolUse on Bash, PowerShell, Monitor, Read, Edit, MultiEdit, Write, NotebookEdit, WebFetch, WebSearch and every MCP tool, with "onFailure": "block" (Claude Code 2.1.295 or later); SessionStart, Stop and SessionEnd are recorded. Cursor: beforeShellExecution, beforeMCPExecution, beforeReadFile and preToolUse (Write, Delete) with "failClosed": true; afterFileEdit, sessionStart, stop and sessionEnd are recorded. Codex: PreToolUse on Bash, apply_patch and MCP tools; SessionStart, Stop and SessionEnd recorded. Codex runs a new hook only after you trust it (/hooks), and cannot ask from a hook, so a call kosa8 would ask about is refused. Gemini CLI: BeforeTool on shell, file, web and MCP tools; SessionStart and SessionEnd recorded. Asks are refusals here too. Copilot CLI: preToolUse on every tool (a crash refuses the call); sessionStart and sessionEnd recorded.
--mode sandbox runs the agent's shell commands in a kosa8 sandbox with the project mounted at /work (Claude Code's Bash; Cursor's Shell).
--org decides with your kosa8 Cloud organization's hook policy (owners and admins set it in Cloud: rules turned off, the org's own rules, fail closed or open). It is cached in ~/.kosa8/hooks/org-policy.json, refreshed when older than its TTL, and used offline. --forward-audit (with --org) has kosa8d send each decision to the organization's Cloud audit log, and so to its SIEM export: the agent, tool, the command or path (clipped to 300 characters), a SHA-256 of the arguments, the decision, its reason and rule ids, the session id and folder. Never file contents or command output.
Plans: Solo and up; --cloud and --org need Team and up.
Options#
| Flag | Type | What it does | Default |
|---|---|---|---|
--cloud | bool | send each decision to kosa8 Cloud's audit log and webhooks (Team plan and up) | — |
--forward-audit | bool | with --org: forward each decision's metadata to the organization's Cloud audit log and SIEM | — |
--image | string | the image sandbox mode runs shell commands in (default node:22-slim) | — |
--mode | string | check (decide each call) or sandbox (also run shell commands in a kosa8 sandbox) | check |
--org | bool | decide with your kosa8 Cloud organization's hook policy (Team plan and up) | — |
--print | bool | print the settings file as it would be written, and write nothing | — |
--project | string | the project folder, for --scope project and sandbox mode (default: current directory) | — |
--scope | string | user (every project) or project (this folder) | user |
--trust | bool | codex: also trust kosa8's hooks in Codex (what /hooks does), so they run from the next session | — |
Example#
kosa8 hooks install claude-code kosa8 hooks install cursor --scope project --project . kosa8 hooks install codex --mode sandbox kosa8 hooks install claude-code --print