AGENT SKILL

using-git-worktrees-lite

Use when creating an isolated git worktree from the current branch for parallel development and only a build/compile check is required (no tests)

License 许可
Apache-2.0
最近更新
2026-11-14
Stars
★ 1.6k
Forks
490

01 前言 Front Matter

name
using-git-worktrees-lite
description
Use when creating an isolated git worktree from the current branch for parallel development and only a build/compile check is required (no tests)

03 SKILL.md 正文

Using Git Worktrees Lite

Overview

Create an isolated worktree from the current branch with a build/compile check instead of running tests.

Core principle: Confirm base branch + safe worktree directory + compile-only verification.

Announce at start: "I'm using the using-git-worktrees-lite skill to set up an isolated workspace."

The Process

Step 0: Normalize to Repo Root (Avoid CWD Pitfalls)

Worktrees are very sensitive to your current working directory (CWD) when you use relative paths like .worktrees/....

Always capture the repo root and ensure you are operating from there before creating worktrees:

repo_root=$(git rev-parse --show-toplevel)
cd "$repo_root"

Step 1: Capture Base Branch (Merge Target)

base_branch=$(git branch --show-current)

Confirm with the user that this is the branch to merge back into. Do not assume main or master.

Step 2: Select Worktree Directory

Follow this priority order:

ls -d .worktrees 2>/dev/null
ls -d worktrees 2>/dev/null

If neither exists, check AGENTS.md for a preferred location. If still unknown, ask the user.

Step 3: Verify Directory is Ignored (Project-Local Only)

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

If not ignored, add the directory to .gitignore and commit. If you cannot commit now, stop and ask.

Step 4: Create Worktree From Base Branch

Use a naming convention to preserve the base branch in the worktree branch name:

<base-branch>__wt__<worktree-branch>

Example:

feature/auth__wt__login
# Example: git worktree add .worktrees/feature-auth__wt__login -b feature-auth__wt__login "$base_branch"
git worktree add "$path" -b "$branch_name" "$base_branch"
cd "$path"

Step 5: Run Project Setup (Auto-detect)

# Node.js
if [ -f package.json ]; then npm install; fi

# Rust
if [ -f Cargo.toml ]; then cargo fetch; fi

# Python
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
if [ -f pyproject.toml ]; then poetry install; fi

# Go
if [ -f go.mod ]; then go mod download; fi

# Java (Maven)
# No dependency install step needed here

Step 6: Build/Compile Check (No Tests)

  1. Check AGENTS.md for project build/compile commands. If present, follow it.
  2. Otherwise use default build/compile commands:
# Node.js (requires build script)
if [ -f package.json ]; then npm run -s build; fi

# Rust
if [ -f Cargo.toml ]; then cargo build; fi

# Go
if [ -f go.mod ]; then go build ./...; fi

# Python
if [ -f pyproject.toml ] || [ -f requirements.txt ]; then python -m compileall .; fi

# Java (Maven)
if [ -f pom.xml ]; then mvn -q clean compile; fi

If no build command is available (e.g., no npm build script), ask the user for the correct command.

If the build fails, report the failure and ask whether to proceed or investigate.

Step 7: Report Result

Worktree ready at <path>
Base branch: <base-branch>
Build/compile: <result>

Step 8: Return to Repo Root (Important)

Unless the user explicitly asks you to stay in the worktree to debug, return to the repo root at the end.

This prevents follow-up commands from accidentally running in the last worktree (and prevents creating nested worktrees due to relative paths).

cd "$repo_root"

Quick Reference

Step Action
Base branch Use current branch, confirm with user
Directory Prefer .worktrees/, then worktrees/, else ask
Safety git check-ignore for project-local directories
Build Follow AGENTS.md or defaults; no tests
CWD Normalize to repo root; return at end
Merge Merge from the base-branch worktree, not the worktree branch

Common Mistakes

Assuming main/master as base branch

  • Problem: Merges into the wrong branch
  • Fix: Capture and confirm current branch as base

Skipping ignore verification

  • Problem: Worktree files show up in git status
  • Fix: git check-ignore before creating worktree

Running tests instead of compile-only

  • Problem: Violates the lite workflow
  • Fix: Only run build/compile checks

Skipping build because no obvious command

  • Problem: Misses required compilation verification
  • Fix: Ask for the project-specific build command

Merging from the worktree branch directory

  • Problem: Base branch is already checked out elsewhere; merge fails
  • Fix: Merge from the base-branch worktree directory

Staying in the last worktree directory

  • Problem: Follow-up tasks run in the wrong directory; relative worktree paths can create nested worktrees
  • Fix: Always cd "$repo_root" after setup/build unless debugging is needed

Rationalization Table

Excuse Reality
"I'll just merge this into main later" Base branch is the current branch; confirm it now
"Tests are easier than a build" Lite workflow requires build/compile only
"No build command, so I'll skip it" Ask for the correct build command

Red Flags

  • "I'll just merge this back to main"
  • "Tests are faster than figuring out the build"
  • "No need to confirm the base branch"

Example

base_branch=$(git branch --show-current)
# Confirm base_branch with user
repo_root=$(git rev-parse --show-toplevel)
cd "$repo_root"
mkdir -p .worktrees
path=.worktrees/feature-x
branch_name=feature-x

git worktree add "$path" -b "$branch_name" "$base_branch"
cd "$path"

npm install
npm run -s build

cd "$repo_root"

04 同仓库更多 Skills

hashgraph-online
hashgraph-online/awesome-codex-plugins

migrate-to-e2e

Moves an existing Playwright, Cypress, Selenium, Appium, Detox, Maestro, or TesterArmy suite to e2e one slice at a time, with the old suite running beside the new one until each ported test is proven. Keeps a MIGRATION.md progress file so any later session resumes where the last stopped. Optionally plants a defect to show both suites catch it. Use for /migrate-to-e2e, "migrate our tests to e2e", "port these Maestro flows", "move our TesterArmy tests", or when a project has an e2e config and an older suite still running.

★ 1.6k
hashgraph-online
hashgraph-online/awesome-codex-plugins

e2e

Writes, runs, and debugs end-to-end tests for web and mobile apps with e2e, the agentic test runner, which mixes agent.act goals with exact locator assertions on a Playwright browser or an iOS or Android device. Also drives a project's running app live over the e2e MCP server to look at a screen, check a UI change, take a screenshot or record a video, and try a locator; and runs bug bashes, parallel e2e explore runs with each bug proven by a repro test. Use when a project depends on e2e or has an e2e.config.ts, when asked for end-to-end, browser, mobile, or agentic UI tests, to check a change in the running app, to QA or bug bash an app or branch, or when an e2e run fails.

★ 1.6k
hashgraph-online
hashgraph-online/awesome-codex-plugins

create-verification-skill

Generate a project-local verify-<app> skill on top of e2e, so any coding agent can launch the app, check it is worth driving, exercise a feature the way a user does, keep evidence, and bug bash it. Writes the skill, a feature map with one explore charter per feature, and proves it once. Use for /create-verification-skill, "make a verification skill for this repo", or when a project has no scripted way to prove UI behavior.

★ 1.6k
hashgraph-online
hashgraph-online/awesome-codex-plugins

deja-search

deja-vu memory — search the user's past AI coding sessions with the deja CLI. Holds what they already settled and never wrote into the repo (naming rules, banned or already-tried tools, required checks before merge, preferred values, who owns what). Use before your first edit in a task, before you call a change done or ready to merge, before you recommend a tool, library, design or reviewer, before re-debugging an error that may already be solved, when they say 'didn't we fix this before', 'what did we decide about X' or 'I already have that', and before telling them something on this machine does not exist.

★ 1.6k
hashgraph-online
hashgraph-online/awesome-codex-plugins

deja-reflect

End-of-session reflection and memory curation with deja-vu. Review what was decided, what commands broke and what repaired them, and record durable project rules or decisions with deja remember so the next session starts with them.

★ 1.6k
hashgraph-online
hashgraph-online/awesome-codex-plugins

revid

Make, edit, export and post AI videos with Revid (revid.ai) through the Revid MCP server. Use whenever the user wants a short-form or long-form video made (from an idea, a script, a URL, an article, a PDF, a tweet, a product page, their own clips, or a song), wants to find what is going viral on TikTok, YouTube, Instagram or X before making something, wants to edit or re-export an existing Revid project, generate a standalone AI image or clip, make a series episode, or publish and schedule a finished video to connected social accounts. Covers setup (hosted MCP with OAuth, or an API key), the 36 tools, credits, polling and the rules for publishing. Routes to the more specific revid-* skills when one fits.

图像与多媒体Skill与智能体开发
★ 1.6k