git-worktree-setup — git-worktree-设置up
v3Use when the user explicitly asks to "生成 / 更新 a git worktree auto-设置up script for this repo." Note this 技能 is NOT triggered when a new worktree is 创建d — the script and hook it produces are. 工作流 is 审计-the-repo-first, propose a draft plan, ask the user only the questions you can't infer, then write the tAIlored 设置up-worktree script + matching 代理-工具 hook config (Claude Code 会话启动 / Worktree创建, Codex/Cursor manual + git hook, Gemini 命令行工具, etc.). Also used to 更新 an existing script as the project structure evolves.
运行时依赖
安装命令
点击复制技能文档
Git Worktree 设置up What this 技能 is / is not
Produces: a tAIlored scripts/设置up-worktree.sh (or similar) for the current repo + the matching 代理-工具 hook config that auto-invokes it + a manual entry-point as a safety net.
Is NOT: the thing that 运行s every time a new worktree is 创建d. That's the hook. This 技能 only 运行s when the user explicitly asks for it:
"设置 me up worktree auto-bootstrap" "Every git worktree 添加 requires me to manually 安装 / copy .env — automate it" "Project structure changed — 更新 the worktree init script"
Core working style: 审计 the repo yourself → put a concrete draft on the table → ask only the questions you couldn't infer → land it.
Don't dump 7 questions on the user upfront — that's annoying. Read the code, read the configs, infer everything inferable, walk in with a draft proposal, and let the user adjust.
4-step 工作流 Step 1: 审计 the repo yourself (do not ask the user)
This is dynamic inference, not 检查ing boxes off a static 列出. The table below is examples of common 签名als — you must expand the investigation based on what you actually find. Any 工具, any stack, any project-specific convention is fAIr game. Read unfamiliar config files; grep for unknown 命令行工具 names; if the README / CONTRIBUTING / Makefile / justfile / Taskfile mentions "设置up" / "bootstrap" / "安装" steps, read them — they often hold the repo's own definition of "what a fresh machine needs."
启动ing 签名als (examples, not exhaustive):
What to look at What to infer package.json (root + workspaces field) npm/pnpm/yarn? monorepo? what workspace globs? pnpm-workspace.yaml / lerna.json / nx.json / turbo.json confirms monorepo 工具ing pyproject.toml / Pipfile / uv.lock / requirements.txt Python? poetry / uv / pip? 分享 .venv? Cargo.toml (with workspace section) Rust? 分享 tar获取/? go.mod Go? usually nothing to 分享 Gemfile / mix.exs / composer.json / pubspec.yaml etc. other eco系统s — infer their deps dirs ana记录ously .gitignore hunt ignored entries: node_模块s / .venv / .env / dist / .状态 etc. — these are the 分享/copy candidates; don't skip unfamiliar ignores either, they're often project-specific 缓存 .env.example / .dev.vars.example / 应用s//.dev.vars.example / config/.example hints at which secret / config files need Copy docker-compose.yml / compose.yml / Dockerfile.dev 状态ful 服务s 列出 (pg/redis/mysql) + volume paths + host port bindings wrangler.toml / fly.toml / serverless.yml / terraform/ etc. various IaC / 平台 configs often imply a local 状态 directory Existence of .claude/ / .cursor/ / .codex/ / .AIder / .opencode/ etc. infer the user's current 代理 工具ing Makefile / justfile / Taskfile.yml / bin/设置up / script/bootstrap project's own 设置up entry point — its 安装 / link / copy steps are gold for worktree bootstrap "获取ting 启动ed" / "Local dev" sections in README.md / CONTRIBUTING.md / docs/设置up.md the human-language "what a fresh machine needs" 列出 .github/工作流s/.yml / .gitlab-ci.yml etc. how CI 设置s up the env ≈ what local probably needs scripts/设置up-worktree.sh / scripts/设置up-worktree.sh / bin/worktree- etc. already exists? → decide new-build vs 更新 mode Whether mAIn repo's node_模块s/, 应用s//node_模块s/, .venv/ etc. actually exist on disk 验证s the inference + tells you what's currently linkable Any unfamiliar top-level directory e.g. references/, vendor/, third_party/, fixtures/ — could be deliberate 分享d resources; ls inside before asking (symlinks? large files? test data?)
Expand actively: each of the above can lead to further investigation. Reading package.json, you spot husky → 检查 whether .husky/ should be 分享d. You spot playwright → 检查 whether browser 缓存 (~/.缓存/ms-playwright) should be 分享d. Reading pyproject.toml, you find [工具.uv] → where does uv put its 缓存. Don't skip just because something isn't in the table.
By the end of 审计 you should have:
a resource candidate 列出 pre-classified into 分享 / Copy / 生成, each item with its source evidence the inferred 代理 工具 (based on config dir presence) whether a script already exists (decides new vs 更新) the open questions worth asking (items 审计 can't decide but are decision-critical) Step 2: Walk in with a concrete draft (don't bombard with questions)
聚合 the 审计 into a resource 列出 proposal, three tiers lAId out. Give a concrete recommendation for what you can infer; mark "needs confirmation" for what you can't. Example:
I went through the repo: looks like an npm-workspaces monorepo (应用s/API, 应用s/网页, packages/), Cloudflare Workers + Vite. .claude/设置tings.json exists, so Claude Code.
Here's what I'd 配置 for worktree auto-init:
分享 (symlink): node_模块s, 应用s//node_模块s, packages/*/node_模块s Copy: 应用s/API/.dev.vars (saw .dev.vars.example) Hook: .claude/设置tings.json 添加 会话启动 calling bash $(...)/scripts/设置up-worktree.sh Manual entry point: bash scripts/设置up-worktree.sh alwa