跳转到正文
报告库
用途分类 / 开发辅助

Using Git Worktrees Skill 安全审计

作者说它能做什么(原文)

Use when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallback

第三方安全检查结论

先别安装或运行

已检查文件
1
发现的风险
3
会不会运行危险命令?检查是否下载程序后直接运行、让他人远程控制电脑,或藏起要运行的命令。发现 1 项风险
高风险

自动安装、构建和测试会执行尚未审查的项目或依赖代码

原文依据:2 处
发现了什么

只要检测到常见清单文件,Skill 就指示运行 npm install、cargo build、pip/poetry install 或 go mod download,随后运行测试。安装生命周期脚本、Rust build.rs、构建逻辑和测试都可能执行仓库或下载依赖提供的任意代码,而且这些步骤没有单独确认或禁用脚本的限制。

为什么需要注意

恶意或被入侵的仓库或依赖可能在代理权限范围内读取或修改可访问文件、调用本机工具,或使用包管理器允许的网络访问。worktree 隔离并不能隔离进程权限、凭据或工作区之外的数据。

该指令会在发现清单文件时自动运行依赖安装或构建,并随后运行项目测试。`npm install` 可能触发生命周期脚本,`cargo build` 可能执行 build.rs,Python 安装及测试也可能执行仓库或依赖代码;这里没有要求在执行前单独确认或禁用脚本。`go mod download` 通常仅下载模块,因此并非列出的每条命令都具有同等执行风险。

SKILL.md:104来自说明文档打开原文件
Auto-detect and run appropriate setup:```bash# Node.jsif [ -f package.json ]; then npm install; fi# Rustif [ -f Cargo.toml ]; then cargo build; fi# Pythonif [ -f requirements.txt ]; then pip install -r requirements.txt; fiif [ -f pyproject.toml ]; then poetry install; fi# Goif [ -f go.mod ]; then go mod download; fi```
查看另外 1 个位置
SKILL.md:123来自说明文档打开原文件
Run tests to ensure workspace starts clean:```bash# Use project-appropriate commandnpm test / cargo test / pytest / go test ./...```
会不会泄露文件和密钥?检查是否发送含密码或密钥的文件,以及代码里是否直接写了密钥。未发现风险
会不会删除文件或一直在后台运行?检查是否大范围删除文件、改写磁盘,或设置自动启动。发现 2 项风险
中风险

目录未被忽略时会自动修改并提交 .gitignore

原文依据:2 处
发现了什么

用户对创建隔离 worktree 的同意会被扩展为修改版本库并创建一次提交;指令没有要求展示变更、确认提交内容或再次征得同意。该提交是持久的历史变更,并非创建临时工作区所必需的无痕操作。

为什么需要注意

用户的分支可能获得计划外的 .gitignore 修改和提交,影响后续合并、审查与共享历史;若代理所处环境或分支判断有误,变更也可能落在用户不希望修改的分支上。

Skill 先就创建隔离 worktree 征求同意,但如果本地 worktree 目录未被忽略,则又强制修改 `.gitignore` 并创建提交。该持久化仓库历史变更没有单独确认,也没有要求用户检查提交内容,因此创建工作区的授权可能被扩展成用户未预期的版本库修改。用户可要求作者将此步骤改为再次确认或选择仓库外目录。

SKILL.md:78来自说明文档打开原文件
#### Safety Verification (project-local directories only)**MUST verify directory is ignored before creating worktree:**```bashgit check-ignore -q .worktrees 2>/dev/null || git check-ignore -q worktrees 2>/dev/null```**If NOT ignored:** Add to .gitignore, commit the change, then proceed.**Why critical:** Prevents accidentally committing worktree contents to repository.
查看另外 1 个位置
SKILL.md:41来自说明文档打开原文件
Has the user already indicated their worktree preference in your instructions? If not, ask for consent before creating a worktree:> "Would you like me to set up an isolated worktree? It protects your current branch from changes."Honor any existing declared preference without asking. If the user declines consent, work in place and skip to Step 2.
中风险

worktree 创建失败后会退回用户当前检出目录

原文依据:3 处
发现了什么

当沙箱拒绝创建 worktree 时,Skill 明确要求在当前目录继续设置和基线测试。此前的同意是针对“隔离 worktree”,而此回退只要求告知,不要求用户批准在原目录执行后续操作。

为什么需要注意

安装、构建或测试产生的文件、锁文件变化和其他副作用可能出现在用户原有工作区中,破坏该 Skill 所承诺的隔离,并可能与未提交工作混合。

如果沙箱拒绝创建 worktree,指令只要求告知用户,随后就在当前检出目录运行设置和测试,并未重新取得同意。由于设置步骤可能安装依赖、运行构建脚本并改变锁文件或生成文件,这会失去用户原先同意的隔离边界。用户可限制为失败后暂停并重新确认。

SKILL.md:100来自说明文档打开原文件
**Sandbox fallback:** If `git worktree add` fails with a permission error (sandbox denial), tell the user the sandbox blocked worktree creation and you're working in the current directory instead. Then run setup and baseline tests in place.
查看另外 2 个位置
SKILL.md:41来自说明文档打开原文件
Has the user already indicated their worktree preference in your instructions? If not, ask for consent before creating a worktree:> "Would you like me to set up an isolated worktree? It protects your current branch from changes."Honor any existing declared preference without asking. If the user declines consent, work in place and skip to Step 2.
SKILL.md:104来自说明文档打开原文件
Auto-detect and run appropriate setup:```bash# Node.jsif [ -f package.json ]; then npm install; fi# Rustif [ -f Cargo.toml ]; then cargo build; fi# Pythonif [ -f requirements.txt ]; then pip install -r requirements.txt; fiif [ -f pyproject.toml ]; then poetry install; fi# Goif [ -f go.mod ]; then go mod download; fi```
会不会绕过安全保护?检查是否跳过网站安全验证、开放过多文件权限,或取消操作前的确认。未发现风险
会不会误导 AI 或隐藏内容?检查工作说明是否要求 AI 忽略你的指令、干扰检查结果,或夹带看不见的文字。未发现风险
会不会偷偷改推广链接或收款方?检查是否强制替换推广链接或收款对象,同时要求隐瞒更改。未发现风险

Skill 逻辑拆解

7 个说明模块

该 Skill 先比较 Git 目录和公共目录,并检查是否位于子模块中,以避免在现有 linked worktree 内再次创建 worktree。

查看原文
SKILL.md:20来自说明文档打开原文件
```bashGIT_DIR=$(cd "$(git rev-parse --git-dir)" 2>/dev/null && pwd -P)GIT_COMMON=$(cd "$(git rev-parse --git-common-dir)" 2>/dev/null && pwd -P)BRANCH=$(git branch --show-current)```
SKILL.md:28来自说明文档打开原文件
```bash# If this returns a path, you're in a submodule, not a worktree — treat as normal repogit rev-parse --show-superproject-working-tree 2>/dev/null```
SKILL.md:33来自说明文档打开原文件
**If `GIT_DIR != GIT_COMMON` (and not a submodule):** You are already in a linked worktree. Skip to Step 2 (Project Setup). Do NOT create another worktree.

若尚未声明偏好,该 Skill 要求先征得用户同意;有原生 worktree 工具时优先使用,否则才执行 git worktree add 并创建新分支。

查看原文
SKILL.md:41来自说明文档打开原文件
Has the user already indicated their worktree preference in your instructions? If not, ask for consent before creating a worktree:> "Would you like me to set up an isolated worktree? It protects your current branch from changes."Honor any existing declared preference without asking. If the user declines consent, work in place and skip to Step 2.
SKILL.md:53来自说明文档打开原文件
The user has asked for an isolated workspace (Step 0 consent). Do you already have a way to create a worktree? It might be a tool with a name like `EnterWorktree`, `WorktreeCreate`, a `/worktree` command, or a `--worktree` flag. If you do, use it and skip to Step 2.Native tools handle directory placement, branch creation, and cleanup automatically. Using `git worktree add` when you have a native tool creates phantom state your harness can't see or manage.Only proceed to Step 1b if you have no native worktree tool available.
SKILL.md:92来自说明文档打开原文件
```bash# Determine path based on chosen locationpath="$LOCATION/$BRANCH_NAME"git worktree add "$path" -b "$BRANCH_NAME"cd "$path"```

创建 worktree 后,该 Skill 会依据项目清单自动安装或构建依赖,并运行相应测试;这不仅是目录隔离检查,也会执行项目及依赖提供的代码。

查看原文
SKILL.md:102来自说明文档打开原文件
## Step 2: Project SetupAuto-detect and run appropriate setup:```bash# Node.jsif [ -f package.json ]; then npm install; fi# Rustif [ -f Cargo.toml ]; then cargo build; fi# Pythonif [ -f requirements.txt ]; then pip install -r requirements.txt; fiif [ -f pyproject.toml ]; then poetry install; fi# Goif [ -f go.mod ]; then go mod download; fi```
SKILL.md:121来自说明文档打开原文件
## Step 3: Verify Clean BaselineRun tests to ensure workspace starts clean:```bash# Use project-appropriate commandnpm test / cargo test / pytest / go test ./...```
从这里开始 · 工作说明SKILL.md
using-git-worktrees
连线表示工作说明包含的模块,不是实际运行顺序。点击模块可查看原文。
文件与检查记录1 个文件

检查范围与遗漏

逐文件查看涉及的内容

下方列出本次涉及的原文范围;纳入检查不代表已查清所有问题。

  • SKILL.md已纳入全文

这份报告只针对上方版本。我们看了拿到的代码和说明文件,没有实际运行 Skill,也没有检查它另外安装的软件包。因此,这不是“保证安全”的承诺;换了版本或使用环境,结果也可能不同。

  • SKILL.md工作说明

代码和说明中提到的操作

运行命令
SKILL.md:20来自说明文档打开原文件
```bashGIT_DIR=$(cd "$(git rev-parse --git-dir)" 2>/dev/null && pwd -P)
SKILL.md:28来自说明文档打开原文件
```bash# If this returns a path, you're in a submodule, not a worktree — treat as normal repo
SKILL.md:70来自说明文档打开原文件
2. **Check for an existing project-local worktree directory:**   ```bash   ls -d .worktrees 2>/dev/null     # Preferred (hidden)
安装其他软件包
SKILL.md:108来自说明文档打开原文件
# Node.jsif [ -f package.json ]; then npm install; fi
SKILL.md:114来自说明文档打开原文件
# Pythonif [ -f requirements.txt ]; then pip install -r requirements.txt; fiif [ -f pyproject.toml ]; then poetry install; fi
读取了多少行
168
文件校验值(用于核对版本)
02921034d1e3608664d3a1fd0fd2c35d3893b14479a3d488870ccb3628e5d356