using-git-worktrees

Create isolated Git worktrees with directory selection and safety validation.

Updated Apr 15, 2026
One-click install
npx skills add https://github.com/YangYuS8/dev-2026-grading --skill using-git-worktrees-yangyus8
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: using-git-worktrees
Source: https://github.com/YangYuS8/dev-2026-grading/tree/main/.opencode/skills/using-git-worktrees
Command: npx skills add https://github.com/YangYuS8/dev-2026-grading --skill using-git-worktrees-yangyus8

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

这项技能在需要与当前工作区分离进行功能开发或实验时,提供可自动化选择工作目录并进行安全性验证的隔离 Git 工作树。

Core Features & Use Cases

  • 智能目录选择:优先使用现有本地工作树目录 (.worktrees, worktrees),若两者都存在则优先 .worktrees;若无则参考 CLAUDE.md 的偏好并在必要时询问用户。
  • 安全性校验:在创建工作树前检查忽略规则,防止工作树内容被意外提交到仓库,必要时将条目添加到 .gitignore 并提交。
  • 自动化项目设置:创建工作树后自动检测项目类型并执行相应的安装/编译/测试步骤(如 Node、Rust、Python、Go 等项目)。
  • 使用场景:在需要独立分支进行特性开发或实验时,创建隔离工作树以避免影响主工作区,并对基线测试进行验证。

Quick Start

使用智能目录选择和安全校验,创建一个用于新特性的隔离 Git 工作树。

Frequently Asked Questions about using-git-worktrees

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create an isolated Git worktree for feature development without affecting my main workspace?

To create an isolated Git worktree, use smart directory selection that prioritizes existing local paths like .worktrees, references CLAUDE.md preferences, and validates safety rules before branching. This isolates feature development safely without modifying your main workspace.

What is the best way to prevent Git worktree directories from being accidentally committed to the repository?

Preventing accidental commits of Git worktree directories requires checking ignore rules before creation. This process validates .gitignore entries and automatically adds the worktree path to prevent accidental commits, ensuring repository safety during feature isolation.

How does Git worktree directory selection work when multiple worktree paths already exist?

Git worktree directory selection prioritizes existing local paths by checking for a .worktrees folder first, then a standard worktrees directory. If neither exists, it reads CLAUDE.md preferences or prompts the user to specify the desired isolation workspace location.

Does Git worktree setup automatically handle project installation and baseline testing?

Git worktree setup automatically handles project installation by detecting the project type after isolation and executing relevant build or test commands. It supports Node, Rust, Python, and Go environments, running baseline validation tests to ensure the new branch works correctly.

Can I use automated Git worktrees for experimental branches that need project-specific compilation steps?

Automated Git worktrees support experimental branches by isolating the workspace and automatically detecting the project type to execute necessary installation, compilation, or testing steps. This ensures your isolated feature branch has a validated baseline before development begins.

When do I need to manually configure .gitignore before creating a Git worktree?

You rarely need to manually configure .gitignore before creating a Git worktree because safety validation automatically checks ignore rules and adds necessary entries. This automated check prevents worktree contents from being accidentally committed to your main repository.