技能 using-git-worktrees
📦

using-git-worktrees

安全 ⚙️ 外部命令📁 檔案系統存取

為功能開發建立隔離的 git 工作區

也可從以下取得: Cycleaddict,Cygnusfear,Doyajin174,ZhanlinCui,davila7,DYAI2025,CodingCossack,obra

開發者在多個分支之間工作時難以切換上下文。此技能會建立隔離的 git worktree,讓您可以平行處理多個功能,同時保留當前工作區的狀態。

支援: Claude Codex Code(CC)
📊 70 充足
1

下載技能 ZIP

2

在 Claude 中上傳

前往 設定 → 功能 → 技能 → 上傳技能

3

開啟並開始使用

測試它

正在使用「using-git-worktrees」。 Create a worktree for the new payment feature

預期結果:

I'm using the using-git-worktrees skill to set up an isolated workspace.

Worktree ready at /projects/myapp/.worktrees/feature/payments
Tests passing (47 tests, 0 failures)
Ready to implement payment feature

正在使用「using-git-worktrees」。 Set up a workspace to review the api-v2 branch

預期結果:

I'm using the using-git-worktrees skill to set up an isolated workspace.

Detected existing .worktrees directory
Verified directory is git-ignored
Created worktree: git worktree add .worktrees/api-v2 -b api-v2
Installed dependencies: npm install
Baseline tests: 23 passing

Worktree ready at /projects/myapp/.worktrees/api-v2

安全審計

安全
v1 • 2/25/2026

All 43 static findings evaluated as false positives. External commands are standard git and build tools with hardcoded or trusted arguments. Filesystem operations are legitimate directory checks. No command injection vectors, credential exposure, or malicious patterns detected.

1
已掃描檔案
223
分析行數
2
發現項
1
審計總數
審計者: claude

品質評分

38
架構
100
可維護性
87
內容
23
社群
100
安全
91
規範符合性

你能建構什麼

功能開發隔離

開始在新的功能分支上工作,不會遺失未提交的變更或破壞當前工作區狀態

程式碼審查準備

建立乾淨的隔離工作區來審查和測試 pull request 變更,不影響本地開發

Bug 修復重現

在獨立 worktree 中隔離 bug 調查工作,同時維持穩定的開發環境

試試這些提示

基本 Worktree 設定
Set up an isolated workspace for the feature/auth-improvements branch using git worktrees
自訂目錄 Worktree
Create a worktree for bugfix/memory-leak in the .worktrees directory and run the project setup
PR 審查工作區
Create an isolated worktree from the pull-request-123 branch so I can review changes without affecting my current work
多分支開發
I need to work on the experimental/caching branch while keeping my current changes intact. Set up a worktree and verify tests pass

最佳實務

  • 在建立前務必驗證 worktree 目錄已加入 git ignore,防止意外提交
  • worktree 建立後立即執行基礎測試,建立乾淨的起始點
  • 遵循目錄優先順序:現有目錄 > CLAUDE.md 偏好設定 > 詢問使用者

避免

  • 未驗證 git ignore 狀態就建立 worktree,導致版本控制中的工作區混亂
  • 跳過基礎測試驗證,無法區分新 bug 和既有問題
  • 硬編碼目錄位置,而非先檢查現有目錄和使用者偏好設定

常見問題

什麼是 git worktree,為什麼要使用它?
git worktree 是連結至同一倉庫的工作目錄。它讓您可以同時在多個分支上工作而無需切換,保持每個工作區隔離並保留未提交的變更。
Worktree 會建立在哪裡?
Worktree 會建立在 .worktrees/(專案本地)、worktrees/(替代專案本地)或 ~/.config/superpowers/worktrees/<project>/(全域位置)。此技能遵循優先順序,若不存在偏好設定則會詢問。
我需要在每個 worktree 中安裝依賴套件嗎?
是的,每個 worktree 都有自己的工作目錄。此技能會自動偵測您的專案類型(npm、cargo、pip、poetry、go)並執行相應的安裝命令。
如果基礎測試失敗會怎樣?
此技能會回報測試失敗情況,並詢問您是否要繼續調查或繼續進行。這確保您在進行新變更前了解起始狀態。
我可以同時擁有多個 worktree 嗎?
是的,git 支援多個 worktree。每個 worktree 獨立運作,讓您可以使用獨立的終端工作階段平行處理不同分支。
完成後如何清理 worktree?
使用 finishing-a-development-branch 技能或執行 'git worktree remove <path>' 來刪除 worktree。主倉庫和其他 worktree 不受影響。

開發者詳情

檔案結構

📄 SKILL.md