verify-worktree-plugins

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Verify Worktree Plugin Patches

验证Worktree插件补丁

After plugin updates, the worktree skills (compound-engineering
git-worktree
, superpowers
using-git-worktrees
) lose custom patches that tell Claude Code to launch new instances in worktree directories.
插件更新后,worktree技能(compound-engineering的
git-worktree
、superpowers的
using-git-worktrees
)会丢失自定义补丁,这些补丁用于告知Claude Code在worktree目录中启动新实例。

What This Checks

验证内容

ComponentWhat's Verified
compound-engineering SKILL.md"Claude Code + Worktree Working Directory" section
compound-engineering worktree-manager.sh"Open a NEW Claude Code instance" banner after create
superpowers SKILL.md"Launch Claude Code" in step 5 report
PreCompact hook
getWorktreeContext
function for compaction survival
Both marketplace and latest cache versions are checked.
组件验证内容
compound-engineering SKILL.md"Claude Code + Worktree工作目录"章节
compound-engineering worktree-manager.sh创建后显示“打开新的Claude Code实例”提示
superpowers SKILL.md第5步报告中的“启动Claude Code”部分
PreCompact钩子确保
getWorktreeContext
函数在压缩后仍能正常工作
会检查市场版本和最新缓存版本。

Instructions

操作步骤

1. Run the verification script

1. 运行验证脚本

bash
bash ~/.claude/scripts/verify-worktree-plugins.sh
bash
bash ~/.claude/scripts/verify-worktree-plugins.sh

2. If any checks fail, re-apply patches

2. 若任何检查失败,重新应用补丁

bash
bash ~/.claude/scripts/verify-worktree-plugins.sh --patch
bash
bash ~/.claude/scripts/verify-worktree-plugins.sh --patch

3. If the PreCompact hook is missing worktree detection

3. 若PreCompact钩子缺少worktree检测功能

The
--patch
flag cannot auto-fix the TypeScript hook. Regenerate it manually:
The hook at
~/.claude/hooks/context-compression-hook.ts
needs a
getWorktreeContext()
function that:
  1. Runs
    git rev-parse --git-dir
    to detect if CWD is a worktree (path contains
    /worktrees/
    )
  2. If yes, outputs branch, worktree path, and main repo path
  3. This output gets injected as a
    <system-reminder>
    during compaction
Regenerate it with this structure:
typescript
import { execSync } from "node:child_process";

function getWorktreeContext(): string | null {
  // Check git-dir for "/worktrees/" to detect worktree
  // Return formatted context string with branch, path, main repo
  // Return null if not in a worktree
}

// In main(): call getWorktreeContext() and console.log if non-null
--patch
标志无法自动修复TypeScript钩子,需手动重新生成:
位于
~/.claude/hooks/context-compression-hook.ts
的钩子需要一个
getWorktreeContext()
函数,该函数需实现:
  1. 执行
    git rev-parse --git-dir
    以检测当前工作目录是否为worktree(路径包含
    /worktrees/
  2. 若是,输出分支、worktree路径和主仓库路径
  3. 该输出会在压缩过程中作为
    <system-reminder>
    注入
按以下结构重新生成:
typescript
import { execSync } from "node:child_process";

function getWorktreeContext(): string | null {
  // 检查git-dir是否包含"/worktrees/"以检测worktree
  // 返回包含分支、路径和主仓库的格式化上下文字符串
  // 若不在worktree中则返回null
}

// 在main()中:调用getWorktreeContext(),若结果非空则console.log

4. Report results to the user

4. 向用户报告结果

Show the verification output and note any files that needed patching.
显示验证输出,并记录所有需要打补丁的文件。

Background

背景信息

Claude Code's statusline, git context, and system prompt are set at launch time. Running
cd
in a Bash tool call does NOT change the process CWD. After auto-compact, Claude reverts to the launch directory's context. Each worktree needs its own Claude Code instance launched from that directory (
cd /path && claude
).
The worktree plugin patches ensure Claude always tells the user to open a new terminal and launch Claude Code from the worktree directory after creation.
Claude Code的状态栏、git上下文和系统提示在启动时设置。在Bash工具调用中运行
cd
不会改变进程的当前工作目录。自动压缩后,Claude会恢复到启动目录的上下文。每个worktree都需要从该目录启动独立的Claude Code实例(
cd /path && claude
)。
worktree插件补丁确保Claude始终告知用户在创建worktree后打开新终端并从worktree目录启动Claude Code。

When to Run

运行时机

  • After updating the
    compound-engineering
    plugin
  • After updating the
    superpowers
    plugin
  • If worktree creation stops showing the "launch Claude Code" instructions
  • Periodically as a sanity check
  • 更新
    compound-engineering
    插件后
  • 更新
    superpowers
    插件后
  • 当worktree创建后不再显示“启动Claude Code”说明时
  • 定期作为健康检查