vault backup: 2026-06-02 16:37:24
This commit is contained in:
@@ -33,6 +33,46 @@ aliases:
|
|||||||
- PostToolUse
|
- PostToolUse
|
||||||
- MCP:`claude mcp add gitnexus -- cmd /c npx -y gitnexus@latest mcp`
|
- MCP:`claude mcp add gitnexus -- cmd /c npx -y gitnexus@latest mcp`
|
||||||
|
|
||||||
|
# 索引
|
||||||
|
## 项目开发时自动索引方案
|
||||||
|
|
||||||
|
### SessionStart Hook(推荐)
|
||||||
|
Claude Code 会话启动时自动执行增量分析,索引最新时秒级返回。
|
||||||
|
|
||||||
|
`.claude/settings.json`:
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"hooks": {
|
||||||
|
"SessionStart": [{
|
||||||
|
"hooks": [{
|
||||||
|
"type": "command",
|
||||||
|
"command": "npx gitnexus analyze",
|
||||||
|
"timeout": 120
|
||||||
|
}]
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
- **触发时机**:新会话、`/clear` 后
|
||||||
|
- **开销**:增量分析,索引最新时 <1s
|
||||||
|
- **适用**:所有项目,`.claude/settings.json` 可提交 Git 团队共享
|
||||||
|
- **PowerShell 路径含空格**:`cd \"D:\\path\\My Project\" && npx gitnexus analyze`
|
||||||
|
|
||||||
|
### 备选方案
|
||||||
|
|
||||||
|
| 方案 | 触发点 | 优点 | 缺点 |
|
||||||
|
|------|--------|------|------|
|
||||||
|
| **PostToolUse + Bash(git commit)** | commit 后 | 提交即同步 | 每次 commit 等分析耗时 |
|
||||||
|
| **Git post-commit hook** | commit 后 | 不依赖 CC | `.git/hooks/` 不可版本控制 |
|
||||||
|
| **手动 `/gitnexus-cli`** | 用户触发 | 按需 | 易忘,索引滞后 |
|
||||||
|
| **PreToolUse 守卫** | 代码操作前 | 保证安全 | 每次操作额外等待 |
|
||||||
|
|
||||||
|
### 建议组合
|
||||||
|
- 日常:==SessionStart Hook==,零感知保索引新鲜
|
||||||
|
- 大重构后:手动 `npx gitnexus analyze --force` 重建
|
||||||
|
- 团队:Hook 配置放入 `.claude/settings.json` 提交 Git
|
||||||
|
|
||||||
## 提高索引速度
|
## 提高索引速度
|
||||||
|
|
||||||
> [!tip] 适用场景
|
> [!tip] 适用场景
|
||||||
|
|||||||
Reference in New Issue
Block a user