Token导航 LogoToken导航TokenDH.com
开发执行命令github未标认证来源可访问许可证需确认审计通过

forkfork 搜索

Agent Skill

fork 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

245

周安装

10

GitHub Stars

1

下载量

78
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:fork(fork 搜索)
来源仓库:https://github.com/fairchild/dotclaude
仓库路径:skills/fork
安装命令:
npx skills add https://github.com/fairchild/dotclaude --skill fork
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/fairchild/dotclaude --skill fork

简介

用于会话分支管理,支持新建终端、协同队友或后台自主代理等多种模式。

  • 适用于需要并行开发、任务交接或上下文延续的工作流场景。
  • 通过 --base、--team 等参数控制分支起点与协作方式。
  • 安装命令:npx skills add https://github.com/fairchild/dotclaude --skill fork。
  • 涉及代码合并时应先核对冲突与测试状态,防止破坏主分支稳定性。

SKILL.md

Fork Session

Fork the current session, carrying context for continuity.

Usage

/fork <branch>                     # Default: open new terminal tab with interactive claude
/fork <branch> --base <ref>        # Fork from a specific base branch/ref
/fork <branch> --move              # Move this session into the worktree
/fork <branch> --team              # Spawn a coordinated teammate in the worktree
/fork <branch> --background        # Spawn autonomous fire-and-forget agent
/fork --local                      # Write handoff for manual pickup
/fork <branch> --dry-run              # Preview what would happen without creating anything

Modes

ModeInteractive?Coordinated?User stays here?Best for
Terminal (default)YesNoYesExploratory/uncertain work
MoveYesN/ANoFully switching focus
TeamNoYesYesDelegated work with oversight
BackgroundNoNoYesWell-defined autonomous tasks
LocalManualN/AYesWhen other modes aren't available

Critical: Invoking wt

wt is a shell function loaded by .zshrc. It is NOT available in Claude Code's Bash tool. Always invoke the script directly:

WT_SCRIPT="$HOME/.claude/skills/git-worktree/scripts/wt.sh"
bash "$WT_SCRIPT" <branch> [options]

Never use bare wt, $_WT_SCRIPT, or source wt.zsh. These all fail in non-interactive shells.

Instructions

Step 1: Determine Mode and Options

Check the user's input:

InputMode
/fork <branch>Terminal (default)
/fork <branch> --moveMove
/fork <branch> --teamTeam
/fork <branch> --backgroundBackground
/fork --localLocal
/fork (no args)Ask: "Branch name for new worktree, or --local for same directory?"

Options (combine with any worktree mode):

  • --base <ref> — Create the worktree from a specific branch, tag, or commit instead of main. Passed through to wt as --base <ref>.
  • --dry-run — Preview what would happen (worktree path, mode, base branch, handoff size) without creating anything. Compatible with all modes.

Step 1.5: Pre-flight Checks (all worktree modes)

Skip this step for --local mode.

Before generating the handoff, verify prerequisites:

  1. Git repo check: git rev-parse --git-dir 2>/dev/null If this fails → tell user "Not in a git repository. Use /fork --local for non-git contexts."
  2. wt.sh available: test -x "$HOME/.claude/skills/git-worktree/scripts/wt.sh" If missing → tell user: "git-worktree skill not installed. Install it or use /fork --local."
  3. Branch collision: REPO_NAME=$(basename "$(git remote get-url origin 2>/dev/null || basename "$(git rev-parse --show-toplevel)")".git) test -d "$HOME/.worktrees/$REPO_NAME/<branch>" If exists → ask: "Worktree <branch> already exists. Resume with wt cd <branch>, or pick a different name?"
  4. claude CLI (for --open and --background modes only): command -v claude If missing → fall back to --local mode and explain why.

If all checks pass, proceed silently. Only report failures.

Step 1.7: Dry Run (if --dry-run)

If --dry-run was specified, report what would happen and stop:

Run the same pre-flight checks from Step 1.5, plus gather additional info, then report:

# Determine values for the report
REPO_NAME=$(basename "$(git remote get-url origin 2>/dev/null || basename "$(git rev-parse --show-toplevel)")" .git)
WORKTREE_PATH="$HOME/.worktrees/$REPO_NAME/<branch>"

# Branch existence
if [ -d "$WORKTREE_PATH" ]; then
  BRANCH_STATUS="yes — would reuse existing worktree"
else
  BRANCH_STATUS="no — would create new branch from $BASE"
fi

# Uncommitted changes
DIRTY_COUNT=$(git status --porcelain 2>/dev/null | wc -l | tr -d ' ')

# claude CLI
CLAUDE_AVAILABLE=$(command -v claude >/dev/null 2>&1 && echo "available" || echo "NOT available — would fall back to --local")

Print the report:

Dry run for `/fork <branch>`:
  Mode: {terminal|move|team|background}
  Worktree: {WORKTREE_PATH}
  Base: {base_branch}
  Branch exists: {BRANCH_STATUS}
  Uncommitted changes: {DIRTY_COUNT} files would be carried as patch
  claude CLI: {CLAUDE_AVAILABLE}
  Terminal: {TERM_PROGRAM or "Terminal"} (for --open/--launch-cmd)
  All pre-flight checks passed ✓

Do not create the worktree, handoff, or spawn any agents. Return after printing the report.

Step 2: Generate Context Summary

Create a handoff document summarizing:

  1. Current Task - what we're working on
  2. Progress - what's been done so far
  3. Git State - current branch, dirty files, recent commits
  4. Key Decisions - important choices made
  5. Next Steps - what the new session should tackle
  6. Relevant Files - files we've been working with
  7. Open Questions - unresolved issues
  8. When Done - how to merge back and clean up

Use this template:

# Session Handoff

## Current Task
{Brief description of what we're working on}

## Progress
- {What's been completed}
- {What's in progress}

## Git State
- Source branch: `{current branch}`
- Base for fork: `{base_branch or "main"}`
- Dirty files: {list of modified/untracked files, or "clean"}
- Recent commits (last 3):
  - `{short hash}` {message}
  - `{short hash}` {message}
  - `{short hash}` {message}

## Key Decisions
| Decision | Choice | Why |
|----------|--------|-----|
| {topic} | {choice} | {rationale} |

## Next Steps
1. {Immediate next action}
2. {Following action}

## Relevant Files
- `path/to/file.ts` - {why it matters}

## Open Questions
- {Unresolved question or blocker}

## When Done
1. Commit your work with conventional commits
2. Apply to main: `wt apply --push --archive`
3. Or return to parent: `cd {original_path}`

---
*Forked from `{repo}@{branch}` on {date}*
*Parent directory: `{original_path}`*

Step 3: Capture Uncommitted Changes (all worktree modes)

Before creating the worktree, check for uncommitted changes and save them as a patch. The worktree is created from a clean base — changes don't travel automatically.

# Check for changes
PATCH=""
if ! git diff --quiet HEAD 2>/dev/null || ! git diff --cached --quiet 2>/dev/null; then
    PATCH=$(mktemp)
    git diff HEAD > "$PATCH"
fi

Skip this step if there are no changes to carry.

Step 4: Create Worktree + Transition

All worktree modes use wt.sh directly. Determine the repo name for the worktree path:

WT_SCRIPT="$HOME/.claude/skills/git-worktree/scripts/wt.sh"
REPO_NAME=$(basename "$(git remote get-url origin 2>/dev/null || basename "$(git rev-parse --show-toplevel)")" .git)

Terminal mode (default)

HANDOFF=$(mktemp)
cat > "$HANDOFF" << 'EOF'
{generated handoff content}
EOF

bash "$WT_SCRIPT" <branch> --no-editor --context "$HANDOFF" --open  # add --base <ref> if specified

The --open flag opens a new terminal tab in the worktree with an interactive claude session. Since --context places a handoff file, --open automatically tells claude to read it.

Move mode

Move mode uses Claude Code's EnterWorktree tool, which is the only way to actually relocate the session's working directory. The Bash tool resets cwd after every call — cd does not persist.

HANDOFF=$(mktemp)
cat > "$HANDOFF" << 'EOF'
{generated handoff content}
EOF

bash "$WT_SCRIPT" <branch> --no-editor --context "$HANDOFF"  # add --base <ref> if specified

After the worktree is created:

  1. Apply the patch if changes were captured:
WORKTREE_PATH="$HOME/.worktrees/$REPO_NAME/<branch>"
if [ -n "$PATCH" ] && [ -s "$PATCH" ]; then
    git -C "$WORKTREE_PATH" apply "$PATCH"
    rm "$PATCH"
fi
  1. Restore the original working directory to clean state:
git checkout -- .
  1. Use EnterWorktree tool to switch the session:
EnterWorktree(name: "<branch>")

Note: EnterWorktree creates its own worktree in .claude/worktrees/. If you already created one with wt.sh, the session will have two worktrees. To avoid this, you can skip wt.sh and use only EnterWorktree — but you lose --base, --context, and conductor setup. Choose based on what the session needs:

  • Needs --base, conductor, or --context: Use wt.sh, then work via absolute paths (don't use EnterWorktree). Set WT_PATH and prefix all subsequent file operations with it.
  • Just needs session relocation: Skip wt.sh, use EnterWorktree directly.

When using absolute paths without EnterWorktree:

WT_PATH="$HOME/.worktrees/$REPO_NAME/<branch>"
# All subsequent Read/Edit/Write calls use $WT_PATH/path/to/file

Tell the user: "Working in ~/.worktrees/<repo>/<branch> via absolute paths. All file operations target the worktree."

Team mode

HANDOFF=$(mktemp)
cat > "$HANDOFF" << 'EOF'
{generated handoff content}
EOF

bash "$WT_SCRIPT" <branch> --no-editor --context "$HANDOFF"  # add --base <ref> if specified

# Apply patch if changes were captured
WORKTREE_PATH="$HOME/.worktrees/$REPO_NAME/<branch>"
if [ -n "$PATCH" ] && [ -s "$PATCH" ]; then
    git -C "$WORKTREE_PATH" apply "$PATCH"
fi

After the worktree is created:

  1. Create or reuse team:
TeamCreate(team_name: "fork-<branch>", description: "Forked work: <branch>")
  1. Create task from handoff:
TaskCreate(
  subject: "<task from handoff Next Steps>",
  description: "<full handoff content>",
  activeForm: "Working on <branch>"
)
  1. Spawn teammate in worktree:
Task(
  team_name: "fork-<branch>",
  name: "<branch>-worker",
  subagent_type: "general-purpose",
  prompt: "You are working in a forked worktree at ~/.worktrees/<repo>/<branch>.
    Use absolute paths for all file operations.
    Read .context/handoff.md at that path for full context.

    Work through the task list (TaskList). Update tasks as you progress (TaskUpdate).
    When blocked or done, message the team lead via SendMessage.
    Commit changes with conventional commits."
)
  1. Assign task to teammate:
TaskUpdate(taskId: "<id>", owner: "<branch>-worker", status: "in_progress")

The main session stays active. Teammate messages arrive automatically when idle. The user can:

  • Check progress: TaskList
  • Send instructions: SendMessage to <branch>-worker
  • Shut down: SendMessage(type: "shutdown_request", recipient: "<branch>-worker")

Rollback on failure:

If any step above fails, clean up what was created:

Failed atClean up
TeamCreateNothing to clean — abort and report error
TaskCreateTeamDelete(team_name: "fork-<branch>")
Task spawnCancel task, then TeamDelete
TaskUpdateTeammate is running but unassigned — send shutdown, then cancel task and delete team

Report what happened: "Fork to <branch> failed at [step]. Cleaned up [resources]. Worktree exists at ~/.worktrees/<repo>/<branch> — you can use it manually."

Background mode

HANDOFF=$(mktemp)
cat > "$HANDOFF" << 'EOF'
{generated handoff content}
EOF

bash "$WT_SCRIPT" <branch> --no-editor --context "$HANDOFF"  # add --base <ref> if specified

# Apply patch if changes were captured
WORKTREE_PATH="$HOME/.worktrees/$REPO_NAME/<branch>"
if [ -n "$PATCH" ] && [ -s "$PATCH" ]; then
    git -C "$WORKTREE_PATH" apply "$PATCH"
fi

After the worktree is created, run claude in the background with structured logging:

All paths must be absolute (use $HOME, not ~). WORKTREE_PATH is built from $HOME so LOG_DIR inherits that.

WORKTREE_PATH="$HOME/.worktrees/$REPO_NAME/<branch>"  # absolute via $HOME
LOG_DIR="$WORKTREE_PATH/.context"
mkdir -p "$LOG_DIR"

cd "$WORKTREE_PATH" && \
  claude --print 'Read .context/handoff.md and complete the work described there. Commit with conventional commits.' \
  > "$LOG_DIR/fork.log" 2>&1 &
FORK_PID=$!
echo "$FORK_PID" > "$LOG_DIR/fork.pid"

# Write completion marker when done
(wait $FORK_PID; echo $? > "$LOG_DIR/fork.exit") &

Use run_in_background: true on the Bash tool call.

Local mode

mkdir -p .context
cat > .context/handoff.md << 'EOF'
{generated handoff content}
EOF

No worktree created. User opens a new terminal and runs claude.

Step 5: Confirm

Mode-specific confirmation messages:

  • Terminal: "Forked to <branch>. New terminal tab opened with interactive Claude session. Handoff at ~/.worktrees/<repo>/<branch>/.context/handoff.md."
  • Move: "Moved into worktree <branch>. To return: cd <original_path>" (or if using absolute paths: "Working in ~/.worktrees/<repo>/<branch> via absolute paths.")
  • Team: "Forked to <branch>. Teammate <branch>-worker is working in the worktree. Messages will arrive here when they need input or finish."
  • Background: "Forked to <branch>. Background agent running (PID in .context/fork.pid).

- Monitor: tail -f ~/.worktrees/<repo>/<branch>/.context/fork.log - Check status: test -f ~/.worktrees/<repo>/<branch>/.context/fork.exit && cat it - Kill: kill $(cat ~/.worktrees/<repo>/<branch>/.context/fork.pid)"

  • Local: "Context written to .context/handoff.md. Open a new terminal here and run claude."

If --base was used, include it in the confirmation: "Based on <ref>."

Examples

Terminal Fork (default)

User: /fork feature-dark-mode

Claude: I'll fork this session to a new worktree with an interactive Claude session.

[Generates handoff summary]
[Runs: bash $WT_SCRIPT feature-dark-mode --no-editor --context /tmp/handoff.md --open]

Forked to `feature-dark-mode`. New terminal tab opened with interactive Claude session.
Handoff at ~/.worktrees/dotclaude/feature-dark-mode/.context/handoff.md

Move with uncommitted changes

User: /fork fix-timeout --move

Claude: I'll fork and move this session into the worktree, carrying your changes.

[Captures git diff as patch]
[Runs: bash $WT_SCRIPT fix-timeout --no-editor --context /tmp/handoff.md]
[Applies patch in worktree]
[Restores original working directory]
[Works via absolute paths to ~/.worktrees/myapp/fix-timeout/]

Moved into worktree `fix-timeout`. Working via absolute paths.
Changes from main applied. To return: work in /original/path.

Fork from a specific base

User: /fork fix-auth-bug --base release/v2.1

[Runs: bash $WT_SCRIPT fix-auth-bug --base release/v2.1 --no-editor --context /tmp/handoff.md --open]

Forked to `fix-auth-bug` based on `release/v2.1`. New terminal tab opened.

Team Fork

User: /fork feature-auth --team

[Creates worktree, applies any patches, creates team, spawns teammate]

Forked to `feature-auth`. Teammate `feature-auth-worker` is working in the worktree.
Messages will arrive here when they need input or finish.

Local Fork

User: /fork --local

[Writes to .context/handoff.md]

Context written to `.context/handoff.md`.
Open a new terminal here and run `claude`.

Troubleshooting

SymptomCauseFix
wt: command not found or permission deniedUsed bare wt or $_WT_SCRIPTUse bash $HOME/.claude/skills/git-worktree/scripts/wt.sh
compdef: assignment to invalid subscriptSourced wt.zsh in non-interactive shellUse wt.sh (bash), not wt.zsh
Changes missing in worktreeWorktree created from clean base branchCapture git diff HEAD as patch before creating worktree, apply after
cd doesn't persist after Bash callClaude Code Bash tool resets cwd per invocationUse absolute paths or EnterWorktree tool
EnterWorktree uses wrong locationIt creates in .claude/worktrees/, not ~/.worktrees/Use wt.sh + absolute paths if you need ~/.worktrees/ convention

Notes

  • Worktree naming: <repo> is derived from git remote get-url origin (e.g., ~/.claude with remote dotclaude.git~/.worktrees/dotclaude/<branch>)
  • Requires: git-worktree skill for all modes except --local
  • The handoff is a snapshot — it won't update if you continue working here
  • Use /chronicle if you want persistent cross-session memory instead
  • Worktree mode runs setup scripts from conductor.json if present
  • Terminal mode uses wt --open which requires macOS (osascript)
  • --base defaults to main if not specified (same as wt default)

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

33.8%
按下载量换算26

Claude

29.28%
按下载量换算23

Cursor

19.36%
按下载量换算15

Gemini CLI

9.01%
按下载量换算7

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

执行命令

安装流程涉及命令执行,可能通过 npx skills add https://github.com/fairchild/dotclaude --skill fork 联网下载 Skill 或依赖。用户安装前应确认命令来源、仓库内容和执行环境。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills