Agent SkillsTerry-Mao/AICodingFlow › git-worktree

git-worktree

GitHub

创建隔离的Git工作树以并行处理分支任务。支持基于Issue命名、自动选择基准分支及安全检查。避免覆盖现有资源,排除未提交更改,并生成cd命令以便切换目录。

.agents/skills/git-worktree/SKILL.md Terry-Mao/AICodingFlow

Trigger Scenarios

需要并行开发不同功能或修复bug 用户明确要求创建新的Git工作树 涉及Issue编号的任务分支初始化

Install

npx skills add Terry-Mao/AICodingFlow --skill git-worktree -g -y
More Options

Non-standard path

npx skills add https://github.com/Terry-Mao/AICodingFlow/tree/main/.agents/skills/git-worktree -g -y

Use without installing

npx skills use Terry-Mao/AICodingFlow@git-worktree

指定 Agent (Claude Code)

npx skills add Terry-Mao/AICodingFlow --skill git-worktree -a claude-code -g -y

安装 repo 全部 skill

npx skills add Terry-Mao/AICodingFlow --all -g -y

预览 repo 内 skill

npx skills add Terry-Mao/AICodingFlow --list

SKILL.md

Frontmatter
{
    "name": "git-worktree",
    "description": "Create isolated Git worktrees for parallel branch work with efficient naming, base selection, and safety checks."
}

git-worktree

Create a separate worktree without disturbing the current one, then use the new directory for subsequent Codex tool calls. This does not change the user's existing shell; report the cd command.

Naming And Path

  • Branch names follow git-branch.
  • Issue-backed: <type>/<short-desc>-<issueID>.
  • Worktree path preserves the branch path: .worktrees/<branch-name>, for example .worktrees/feat/search-123.
  • Do not copy current uncommitted changes.
  • Do not overwrite existing branches, worktrees, or directories.

Fetch issue metadata only when an issue ID is given:

gh issue view <issueID> --json title,body,number

Validate:

git check-ref-format --branch <branch-name>

Efficient Checks

Use one tool call for local state:

git status --short
git branch --show-current
git worktree list --porcelain
git branch --list <branch-name>
test -e .worktrees/<branch-name>

Add remote/freshness checks only when they matter:

git branch --remotes --list '*/<branch-name>'
git fetch origin <base>
git rev-list --left-right --count <base>...origin/<base>

Base policy:

  • Default <base> to main unless repo guidance or the user names another base.
  • Same-repo work prefers origin/<base>, then local <base>.
  • Use upstream/<base> only for fork workflows or explicit guidance.
  • If local <base> is stale but origin/<base> is selected, proceed and report that local <base> was not updated.

Stop only if branch/worktree/path exists, base selection is unsafe or stale for the work, or dirty current changes make intent ambiguous. Otherwise report that dirty current changes, if any, are excluded.

Create And Verify

Create the parent directory when the branch name contains /, then add the worktree:

mkdir -p .worktrees/<type>
git worktree add --no-track -b <branch-name> .worktrees/<branch-name> <base-ref>

For same-repo work, <base-ref> is normally origin/main when available. Keep --no-track; git-push sets the branch upstream when published.

Verify in one call:

git worktree list --porcelain
git -C .worktrees/<branch-name> branch --show-current
git -C .worktrees/<branch-name> status --short
pwd

Run pwd from inside the new worktree.

Report branch, path, base ref, whether dirty changes were excluded, current directory, and the user's cd .worktrees/<branch-name> command.

Guardrails

  • No git worktree remove, git worktree prune, rm, git reset, git stash, git push, or force commands unless explicitly asked.
  • Do not create protected/shared base branches as target branches unless explicitly asked.
  • Keep .worktrees/ ignored by Git.

Version History

  • e53c5ac Current 2026-07-24 11:35

Same Skill Collection

.agents/skills/bootstrap-issue-config/SKILL.md
.agents/skills/create-issue/SKILL.md
.agents/skills/create-pr/SKILL.md
.agents/skills/diagnose-ci-failures/SKILL.md
.agents/skills/git-branch/SKILL.md
.agents/skills/git-commit/SKILL.md
.agents/skills/git-push/SKILL.md
.agents/skills/pr-walkthrough/SKILL.md
.agents/skills/resolve-merge-conflicts/SKILL.md
.agents/skills/review-pr-local/SKILL.md
.agents/skills/review-spec-local/SKILL.md
.agents/skills/spec-driven-implementation/SKILL.md
.agents/skills/write-product-spec/SKILL.md
.agents/skills/write-tech-spec/SKILL.md
.github/skills/check-impl-against-spec/SKILL.md
.github/skills/create-product-spec/SKILL.md
.github/skills/create-tech-spec/SKILL.md
.github/skills/dedupe-issue-repo/SKILL.md
.github/skills/dedupe-issue/SKILL.md
.github/skills/implement-issue/SKILL.md
.github/skills/implement-specs/SKILL.md
.github/skills/product-change-report/SKILL.md
.github/skills/product-docs-sync/SKILL.md
.github/skills/product-wiki/SKILL.md
.github/skills/review-pr-repo/SKILL.md
.github/skills/review-pr/SKILL.md
.github/skills/review-spec-repo/SKILL.md
.github/skills/review-spec/SKILL.md
.github/skills/security-review-pr/SKILL.md
.github/skills/security-review-spec/SKILL.md
.github/skills/triage-issue-repo/SKILL.md
.github/skills/triage-issue/SKILL.md
.github/skills/update-dedupe/SKILL.md
.github/skills/update-pr-review/SKILL.md
.github/skills/update-triage/SKILL.md

Metadata

Files
0
Version
e53c5ac
Hash
16f4b10f
Indexed
2026-07-24 11:35

Главная - Вики-сайт
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-06 17:36
浙ICP备14020137号-1 $Гость$