AgentSkillsCN

aico-worktree

为功能开发创建隔离的 Git 工作树。负责目录选择、Gitignore 验证、项目设置以及基准测试验证。 当满足以下条件时,可使用此技能: - 开始需要与当前工作区隔离的功能开发; - 在新分支上执行实施计划之前; - 希望同时在多个分支/功能上开展工作; - 用户要求“创建工作树”、“隔离这项工作”、“分离分支”; - 在开始重大变更之前,需要先清理基准环境。 安全提示:在创建工作树之前,务必确认工作树目录已被 Gitignore 忽略。 流程:检查目录 → 验证是否被忽略 → 创建工作树 → 执行设置 → 验证基准测试。

SKILL.md
--- frontmatter
name: aico-worktree
description: |
  Create isolated git worktree for feature development. Handles directory selection, gitignore verification, project setup, and baseline test verification.

  Use this skill when:
  - Starting feature work that needs isolation from current workspace
  - Before executing implementation plans on a new branch
  - Want to work on multiple branches/features simultaneously
  - User asks to "create worktree", "isolate this work", "separate branch"
  - Need clean baseline before starting major changes

  Safety: ALWAYS verify worktree directory is gitignored before creating.
  Process: Check directory → Verify ignored → Create worktree → Run setup → Verify baseline tests

Git Worktree

Process

  1. Check existing directories: .worktrees/ or worktrees/
  2. Verify gitignored: MUST verify before creating
  3. Create worktree: git worktree add <path> -b <branch>
  4. Run project setup: Auto-detect (npm/pip/go/cargo)
  5. Verify baseline tests: Run tests, report status

Directory Selection

PriorityCheck
1Existing .worktrees/
2Existing worktrees/
3Project config/docs
4Ask user

Safety Verification

For project-local directories:

bash
git check-ignore -q .worktrees 2>/dev/null

If NOT ignored → Add to .gitignore first.

Creation Steps

bash
# Create worktree with new branch
git worktree add ".worktrees/$BRANCH_NAME" -b "$BRANCH_NAME"
cd ".worktrees/$BRANCH_NAME"

# Run project setup (auto-detect)
if [ -f package.json ]; then npm install; fi
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi

# Verify baseline tests
npm test / pytest / go test ./...

Report Format

code
Worktree ready at <full-path>
Branch: <branch-name>
Tests: <N> passing
Ready to implement <feature-name>

Worktree Management

bash
git worktree list          # List all
git worktree remove <path> # Remove after merge
git worktree prune         # Clean stale

Key Rules

  • ALWAYS verify directory is gitignored for project-local
  • MUST run baseline tests before reporting ready
  • If tests fail → Report failures, ask whether to proceed
  • ALWAYS auto-detect and run project setup

Common Mistakes

  • ❌ Skip ignore verification → ✅ Always verify gitignored
  • ❌ Skip baseline tests → ✅ Verify clean starting point
  • ❌ Proceed with failing tests → ✅ Ask user first
  • ❌ Leave stale worktrees → ✅ Remove after merge