> ## Documentation Index
> Fetch the complete documentation index at: https://ccsafetynet.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# hook 命令

> cc-safety-net hook 参考：智能体调用的运行时 hook 入口、各智能体对应的集成选项，以及哪些智能体改为在进程内加载 CC Safety Net。

`hook` 是智能体在运行工具之前调用的命令。它从 stdin 以 JSON 读取智能体的 hook 输入，需要阻止调用时，按该智能体的拒绝格式作答。智能体的插件或配置会替你接好它，通常不需要手动运行。

例如，`install --cursor` 会把下面这条命令写入 Cursor 的 hook 配置，Cursor 每次调用工具都会运行它：

```bash theme={"dark"}
npx -y cc-safety-net hook --cursor
```

## hook 集成选项

`hook` 需要正好一个集成选项，用来指明智能体。没有选项或选项多于一个时，它打印 `hook requires exactly one integration flag. Try: cc-safety-net hook --kimi-code`，显示命令帮助，并退出 `1`。

| 选项 | 智能体 | 旧版选项 |
| - | - | - |
| `-ac`, `--agy-cli` | [Antigravity CLI](/docs/zh-Hans/installation/antigravity-cli.md) | 无 |
| `-cc`, `--coding-cli` | [Coding CLI (Claude Code)](/docs/zh-Hans/installation/claude-code.md) | `--claude-code`；顶层形式 `cc-safety-net -cc` 和 `cc-safety-net --claude-code` 也可用 |
| `-cx`, `--codex` | [Codex](/docs/zh-Hans/installation/codex.md) | 无 |
| `-cu`, `--cursor` | [Cursor](/docs/zh-Hans/installation/cursor.md) | 无 |
| `-dv`, `--devin` | [Devin CLI](/docs/zh-Hans/installation/devin-cli.md) | 无 |
| `-fd`, `--droid` | [Factory Droid](/docs/zh-Hans/installation/factory-droid.md) | 无 |
| `-gc`, `--gemini-cli` | [Gemini CLI](/docs/zh-Hans/installation/gemini-cli.md) | 顶层形式 `cc-safety-net -gc` 和 `cc-safety-net --gemini-cli` |
| `-cp`, `--copilot-cli` | [GitHub Copilot CLI](/docs/zh-Hans/installation/github-copilot-cli.md) | 顶层形式 `cc-safety-net -cp` 和 `cc-safety-net --copilot-cli` |
| `-gb`, `--grok-build` | [Grok Build](/docs/zh-Hans/installation/grok-build.md) | 无 |
| `-ha`, `--hermes-agent` | [Hermes Agent](/docs/zh-Hans/installation/hermes-agent.md) | 无 |
| `-kc`, `--kimi-code` | [Kimi Code](/docs/zh-Hans/installation/kimi-code.md) | 无 |

各智能体的页面说明了它的 hook 检查什么、检查失败时会怎样。在 Claude Code 中，hook 可以改为向你确认，而不是直接阻止。参见 [Claude Code 何时改为询问而不是阻止](/docs/zh-Hans/installation/claude-code.md#when-claude-code-asks-you-instead-of-blocking)。

## 没有 hook 选项的智能体

Amp Code、DeepSeek Harness、OpenClaw、OpenCode 和 Pi 没有 `hook` 选项。它们以插件或扩展的形式，在自己的进程内加载 CC Safety Net。参见[集成模型](/docs/zh-Hans/guides/how-it-works.md#integration-models)。

> [!NOTE]
>
> 没有 `hook install` 或 `hook uninstall` 子命令。请使用顶层的 [`install`](/docs/zh-Hans/reference/cli/install) 和 [`uninstall`](/docs/zh-Hans/reference/cli/uninstall) 命令。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.