worktree-pr-and-clean

Push a git worktree branch, create a PR to main, and clean up.

13|Updated Feb 21, 2026
One-click install
npx skills add https://github.com/phenobarbital/antigravity-config --skill worktree-pr-and-clean
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: worktree-pr-and-clean
Source: https://github.com/phenobarbital/antigravity-config/tree/main/backend/.agent/skills/worktree-pr-and-clean
Command: npx skills add https://github.com/phenobarbital/antigravity-config --skill worktree-pr-and-clean

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Automate end-to-end management of temporary git worktrees: push the selected branch, open a PR to main after explicit user approval, and remove the worktree to keep the repository clean.

Core Features & Use Cases

  • Locate the active worktree by reading .worktrees/_active.json (if present) or by running git worktree list and selecting a non-primary worktree.
  • Verify state: ensure the worktree has a clean status and the current branch matches the expected branch.
  • Push to origin: push the branch associated with the active worktree.
  • Create a PR: if GitHub CLI is available and authenticated, open a PR to main; otherwise provide manual PR steps.
  • Clean up: remove the worktree, prune stale metadata, and clear the active-worktree indicator when appropriate.
  • Report: provide PR link, commands executed, and any remaining manual steps.

Quick Start

After user approval, push the active worktree branch, open a PR to main, and clean up the worktree.

Frequently Asked Questions about worktree-pr-and-clean

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

FAQPage Schema
How do I automate git worktree cleanup after pushing a branch and opening a PR?▼

To automate git worktree cleanup after a PR, use a workflow that locates the active worktree, verifies a clean state, pushes the branch to origin, creates a PR via GitHub CLI, and then removes the worktree and prunes metadata.

Can I create a GitHub pull request directly from a temporary git worktree?▼

Yes, you can create a GitHub pull request directly from a temporary git worktree if the GitHub CLI is installed and authenticated; otherwise, the workflow provides manual PR creation steps.

What is the safest way to push a feature branch from a git worktree to main?▼

The safest way to push a feature branch from a git worktree is to first verify the worktree has a clean status and the expected branch is active, then push to origin and open a PR to main only after explicit user approval.

Does the worktree PR and cleanup workflow require the GitHub CLI?▼

The worktree PR and cleanup workflow does not strictly require the GitHub CLI, but it uses the CLI to automatically open a PR to main; without it, the workflow outputs manual PR creation steps.

How does the worktree cleanup process handle stale git metadata?▼

The worktree cleanup process handles stale git metadata by removing the temporary worktree, running git worktree prune to clear stale references, and clearing the active-worktree indicator file.

What happens if my git worktree has uncommitted changes before PR creation?▼

If a git worktree has uncommitted changes before PR creation, the workflow's state verification step fails because it requires a clean worktree status and the current branch to match the expected branch before pushing.