抄送安全设置
- 作者仓库星标 29
- 作者仓库 cc-safe-setup
- 领域
- 安全
- 作者声明的智能体
- 未找到明确声明;不据此推断已兼容或已测试
- 静态检查
- 88 / 100 · 启发式扫描,不代表运行安全
- 运行环境证据
- 未执行;当前没有隔离运行测试证据
- 作者 / 版本 / 许可证
- @yurukusa · 未声明许可证
- 上下文用量评级
- 低消耗
- 接入复杂程度
- 需简单配置
- 是否需要外部接口密钥
- 不需要
- 兼容的系统
- macOS · Linux · Windows
- 运行环境要求
- 未检出明确要求
- 检测到的文件与系统行为
-
- 只读
- 命令执行
- 读取环境变量
- 网络行为
- 仅限本地
- 安装命令数
- 无(仅作为资料)
需要注意: 未声明工具权限范围;实际权限由运行环境决定。
npx cc-safe-setup
# cc-safe-setup
Safety-first configuration for Claude Code. Prevents the accidents that happen when AI writes code autonomously.
## What it does
Installs pre-built safety hooks into your Claude Code environment. These hooks run automatically before/after tool calls to block dangerous operations.
**Categories:**
- **File protection**: Block `rm -rf`, prevent overwriting files outside project
- **Git safety**: Prevent force-push to main, block `reset --hard`
- **Credential guards**: Stop `.env` files from being committed or read by AI
- **Token optimization**: Warn on large file reads, limit subagent spawning
- **Quality gates**: Detect lazy rewrites, verify claims before committing
## Quick start
```bash
npx cc-safe-setup
```
This runs an interactive wizard that configures hooks based on your risk profile.
## Install individual hooks
```bash
npx cc-safe-setup --install-example large-read-guard
npx cc-safe-setup --install-example prevent-rm-rf
npx cc-safe-setup --install-example git-force-push-block
```
## Why hooks instead of CLAUDE.md rules
Rules in CLAUDE.md are suggestions — Claude can forget them. Hooks are enforced at the system level. A hook that blocks `rm -rf` cannot be overridden by the AI.
From 800+ hours of autonomous operation: the hooks that matter most are the ones you don't notice until something goes wrong.
## Resources
- Repository: https://github.com/yurukusa/cc-safe-setup
- Hook Selector (find hooks for your setup): https://yurukusa.github.io/cc-safe-setup/hook-selector.html
- Token Checkup (diagnose waste): https://yurukusa.github.io/cc-safe-setup/token-checkup.html
章节与文件索引
按说明文件中的顺序排列。
它的作用
快速启动
为什么使用 hooks 而不是 CLAUDE.md 规则
资源
文件/命令 -> rm -rf · reset --hard · .env · before/after · CLAUDE.md · github.com/yurukusa/cc-safe-setup · yurukusa.github.io/cc-safe-setup/hook-selector.html · yurukusa.github.io/cc-safe-setup/token-checkup.html
内容校验值 -> b46f196ae6ac
当前原文的自动摘译,尚未人工审校。
它的作用
将预构建的安全挂钩安装到您的 Claude Code 环境中。这些挂钩在工具调用之前/之后自动运行以阻止危险操作。类别: 文件保护:阻止
rm -rf,防止覆盖项目外的文件 Git 安全:防止强制推送到主目录,阻止reset --hard凭证防护:阻止.env文件被 AI 提交或读取快速启动
这会运行一个交互式向导,根据您的风险状况配置挂钩。
为什么使用 hooks 而不是 CLAUDE.md 规则
CLAUDE.md 中的规则是建议——Claude 可以忘记它们。挂钩是在系统级别强制执行的。阻止
rm -rf的钩子不能被AI覆盖。从 800 多个小时的自主运行来看:最重要的钩子是那些直到出现问题时您才注意到的钩子。资源
存储库:https://github.com/yurukusa/cc-safe-setup 挂钩选择器(查找适合您的设置的挂钩):https://yurukusa.github.io/cc-safe-setup/hook-selector.html 令牌检查(诊断浪费):https://yurukusa.github.io/cc-safe-setup/token-checkup.html