# Hook formats, tested: what goes in and what comes back

Tested 2026-11-14 (America/Panama time), karmadue-guard 0.3.0, live KarmaDue answers. Each row is one real run: the hook JSON below was piped to `node ~/.karmadue/guard/karmadue-guard.js hook <client>` and the reply is what came out (reason text shortened with …). The guard was not run inside Cursor, Cline or the Docker MCP Gateway; payloads follow each client's published hook format. Setup for every client: https://karmadue.expo.app/docs/hooks.md

Install the guard (every file is SHA-256 pinned): `curl -fsSL https://karmadue.expo.app/guard/install.sh | KARMADUE_NO_SHIMS=1 sh`

| Client | Command tested | Result |
| --- | --- | --- |
| Claude Code | npm install event-stream@3.3.6 | deny |
| Codex CLI | pip install ctx==0.2.6 | deny |
| Cursor | npm install event-stream@3.3.6 | deny |
| Cursor | npm install is-number@7.0.0 | allow |
| Cline | npm install event-stream@3.3.6 | cancel |
| Docker MCP Gateway | npm install event-stream@3.3.6 | isError block |
| generic | npm install event-stream@3.3.6 | block |

## Claude Code (`hook claude-code`)

In:
```json
{"hook_event_name":"PreToolUse","tool_name":"Bash","tool_input":{"command":"npm install event-stream@3.3.6"}}
```
Out:
```json
{"systemMessage":"KarmaDue block: event-stream@3.3.6 (npm)","hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"KarmaDue blocked this command.\n- event-stream@3.3.6 (npm) -> BLOCK: Do not install event-stream@3.3.6: malicious-package report GHSA-mh6f-8j2x-4483 …"}}
```

## Codex CLI (`hook codex`)

In (`tool_input.command` is a string):
```json
{"session_id":"t","cwd":"/tmp","hook_event_name":"PreToolUse","tool_name":"Bash","tool_use_id":"1","tool_input":{"command":"pip install ctx==0.2.6"}}
```
Out:
```json
{"systemMessage":"KarmaDue block: ctx==0.2.6 (pypi)","hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"KarmaDue blocked this command.\n- ctx==0.2.6 (pypi) -> BLOCK: Do not install ctx==0.2.6: malicious-package report GHSA-67r3-h899-9w95 …"}}
```
Known limit: if `tool_input.command` arrives as an argument array instead of a string, the guard answers NOT CHECKED and allows (fail-open by default; use `--fail closed` to block instead).

## Cursor (`hook cursor`)

In:
```json
{"hook_event_name":"beforeShellExecution","command":"npm install event-stream@3.3.6","cwd":"/tmp"}
```
Out:
```json
{"permission":"deny","user_message":"KarmaDue block: event-stream@3.3.6 (npm)","agent_message":"KarmaDue blocked this command.\n- event-stream@3.3.6 (npm) -> BLOCK: … GHSA-mh6f-8j2x-4483 …"}
```
Clean package (`npm install is-number@7.0.0`): `{"permission":"allow"}`

## Cline (`hook cline`)

In:
```json
{"preToolUse":{"toolName":"execute_command","parameters":{"command":"npm install event-stream@3.3.6"}}}
```
Out:
```json
{"cancel":true,"contextModification":"KarmaDue blocked this command.\n- event-stream@3.3.6 (npm) -> BLOCK: …","errorMessage":"KarmaDue block: event-stream@3.3.6 (npm)"}
```

## Docker MCP Gateway interceptor (`hook docker`)

In:
```json
{"method":"tools/call","params":{"name":"run_command","arguments":{"command":"npm install event-stream@3.3.6"}}}
```
Out (an empty reply means let it through):
```json
{"content":[{"type":"text","text":"BLOCKED by KarmaDue.\nKarmaDue blocked this command.\n- event-stream@3.3.6 (npm) -> BLOCK: …"}],"isError":true}
```

## Generic (`hook generic`)

In: `{"command":"npm install event-stream@3.3.6"}`

Out: `{"level":"block","decision":"block","text":"KarmaDue blocked this command. …","targets":[{"target":"npm:event-stream@3.3.6","level":"block","decision":"deny","checked":true, …}]}`

## Limits

- A check is not a safety guarantee; it does not watch what code does when it runs.
- Latency measured the same day from us-east: 0.7–1.9 s per check (most of it server work), so allow a hook timeout of at least 10 s.
- Seed records are labeled "Founder-operated assessment, not independent".

Questions or a client that doesn't work: https://karmadue.expo.app/forum · Knowledge trees: https://karmadue.expo.app/trees.md
