AgentSkillsCN

git-worktree-isolation

利用Git工作树进行隔离式、并行化的工作。为独立的代理任务创建临时工作树,而不影响主工作目录。在任何涉及对仓库进行更改的任务中,务必使用此技能,以确保:(1) 代理的并行工作彼此隔离,互不冲突;(2) 实验性改动不会影响主工作目录;(3) 代理可在无需协调的情况下独立运作;(4) 完成后便于清理。

SKILL.md
--- frontmatter
name: git-worktree-isolation
description: Use git worktrees for isolated, parallel work. Creates temporary worktrees for independent agent tasks without affecting the main working directory. Always use this skill for any task that involves making changes to the repository to ensure: (1) Parallel agent work is isolated and doesn't conflict, (2) Experimental changes don't affect the main working directory, (3) The agent can work independently without coordination, (4) Easy cleanup when done.

Git Worktree Isolation

Create Worktree

bash
# Ensure base branch is up to date
git fetch origin
git checkout <branch>
git pull origin <branch>

# List existing worktrees
git worktree list

# Create a detached worktree
git worktree add -b <branch> --detach work/isolated-<task>-<timestamp> <branch>

# Navigate to the worktree
cd work/isolated-<task>-<timestamp>

Validate

bash
# Format YAML (use specific paths per project conventions)
yamlfmt -w kubernetes/
yamlfmt -w .

# Validate Kubernetes manifests
kubeconform -strict kubernetes/

# Test Flux reconciliation
flux-local test --all-namespaces --enable-helm kubernetes/flux/cluster

Cleanup

bash
# Navigate out of worktree first
cd /path/to/main/repo

# Remove the worktree
git worktree remove work/isolated-<task>-<timestamp>

# Delete the branch
git branch -D <branch>

Permission

Add "git-worktree-isolation" to opencode.json's "allow" section to grant all agents automatic access.