Agent SkillsTerry-Mao/AICodingFlow › git-worktree

git-worktree

GitHub

用于创建隔离的Git工作区以并行处理分支,规范命名、基线选择及安全校验,支持Issue关联与状态检查。

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

Trigger Scenarios

需要并行开发多个功能分支 基于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

inicio - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-16 23:42
浙ICP备14020137号-1 $mapa de visitantes$