setup

A command for initializing a Claude Code project and configuring its hooks, which are actions triggered at specific points in the agent's work. It supports project-wide and user-wide settings.

In plain words
What is it for?
Use it to perform initial setup, configure hooks globally or for one project, verify hook settings, or walk through an interactive setup.
Why use it?
It reduces manual setup and helps diagnose incorrect hook paths, timeouts, matchers, or lifecycle events.

Command

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/xiaobei930/cc-best/setup
Clone the repo
git clone --depth 1 https://github.com/xiaobei930/cc-best
Per session 10 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 2,901 The whole file, excluding the scripts and references it only reads on demand.
Security scan B 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00010 $0.02901
Opus 5 $0.00005 $0.01451
Sonnet 5 $0.00002 $0.00580
Haiku 4.5 $0.00001 $0.00290

Measured 2d ago against content hash 09b6ed8b61a8, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade B, and why

setup scanned grade B with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Reads agent configuration directoriesmediumAgent snooping

.claude/, .codex/, .gemini/ hold keys, settings and other credentials a mod has no legitimate need for.

| `--global` | 配置到全局 `~/.claude/settings.json` |
commands/setup.md · 373 lines

How it starts

The opening of the file, as written. The whole thing — 373 lines — stays where its author put it; the contents beside it link to each section on GitHub.

/setup - 项目初始化

初始化 Claude Code 项目配置。支持 Plugin 模式Clone 模式

使用方式

# 完整初始化(默认)
/cc-best:setup

# 仅配置 hooks(修复插件 hooks 问题)
/cc-best:setup --hooks

# 配置 hooks 到全局
/cc-best:setup --hooks --global

# 配置 hooks 到项目
/cc-best:setup --hooks --project

# 验证 hooks 配置是否正确
/cc-best:setup --verify

# 交互式配置向导
/cc-best:setup --interactive

参数说明

参数 说明
--hooks 仅配置 hooks,跳过其他初始化步骤
--global 配置到全局 ~/.claude/settings.json
--project 配置到项目 .claude/settings.local.json
--verify 验证 hooks 配置是否正确(诊断模式)
--interactive 交互式配置向导,按需选择安装组件

执行步骤

0. 检查 --verify 参数

如果使用 --verify 参数,执行验证模式:

# 运行 hooks 验证脚本
node <SCRIPT_PATH>/verify-hooks.js

验证脚本会检查:

  • ✅ 脚本路径是否存在
  • ✅ timeout 是否在合理范围 (1ms - 10min)
  • ✅ matcher 语法是否正确
  • ✅ 生命周期事件是否有效

验证完成后输出诊断报告和修复建议,然后退出。

1. 检测运行模式

如果存在 scripts/node/hooks/ 目录:
  → Clone 模式
否则:
  → Plugin 模式,定位插件缓存目录

2. 运行初始化脚本

使用 Node.js 脚本(跨平台兼容)执行初始化:

# 检测并运行初始化脚本
# Plugin 模式:脚本位于插件目录
# Clone 模式:脚本位于项目目录

# 优先使用 Node.js(跨平台)
if command -v node &> /dev/null; then
    # 查找脚本位置(Plugin 或 Clone 模式)
    if [ -f "scripts/node/init.js" ]; then
        node scripts/node/init.js
    fi
else
    # 回退到 Bash(仅 Unix)
    if [ -f "scripts/shell/init.sh" ]; then
        bash scripts/shell/init.sh
    fi
fi

初始化脚本会自动:

  • 检测运行模式(Plugin/Clone)
  • 创建 .claude/settings.local.json
  • 创建必要目录结构
  • 初始化 Memory Bank 文件
  • Plugin 模式下从插件目录复制模板
  • Clone 模式下创建 Hookify 规则文件

3. 清理旧版本 Hooks 配置

⚠️ v0.6.3 升级: 如果从旧版本升级,全局 settings.json 可能有冗余的 hooks 配置需要清理。

检查并清理

  1. 读取全局配置 ~/.claude/settings.json
  2. 检查是否存在 hooks 字段,且包含 ${CLAUDE_PLUGIN_ROOT}/scripts/node/hooks/ 路径
  3. 如果存在,这是旧版本遗留配置,应该删除 hooks 字段
  4. 告知用户:「已清理旧版本 hooks 配置,现在通过插件内置 hooks/hooks.json 自动生效」
// 清理逻辑示例
const settingsPath = path.join(os.homedir(), ".claude/settings.json");
const settings = JSON.parse(fs.readFileSync(settingsPath, "utf8"));

if (settings.hooks) {
  const hasOldHooks = JSON.stringify(settings.hooks).includes(
    "scripts/node/hooks/",
  );
  if (hasOldHooks) {
    delete settings.hooks;
    fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2));
    console.log("✅ 已清理旧版本 hooks 配置");
  }
}

Read the full file on GitHub · 373 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 373 lines · 10 tokens per session scan B 09b6ed8b61a8

Subscribe to this mod's changes

setup is a command published in the GitHub repository xiaobei930/cc-best (50 stars, last pushed 2mo ago), licensed MIT. It adds 10 tokens to every session and 2,901 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it B with 1 finding (reads agent configuration directories). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.