pr-and-cleanup

Automate PR creation and cleanup of your Git worktree in one step.

Updated Jan 9, 2026
One-click install
npx skills add https://github.com/f4ah6o/pr-and-cleanup --skill pr-and-cleanup-f4ah6o
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pr-and-cleanup
Source: https://github.com/f4ah6o/pr-and-cleanup/tree/main
Command: npx skills add https://github.com/f4ah6o/pr-and-cleanup --skill pr-and-cleanup-f4ah6o

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires bash, git, gh, grep, sed, make, and includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill solves the hassle of creating a GitHub pull request while forgetting to clean up a local git worktree, which wastes disk space and clutters your development directories.

Core Features & Use Cases

  • Automated PR creation from a feature worktree: Detects the current worktree context and creates a PR using GitHub CLI (gh pr create), optionally with a draft flag.
  • Guardrails against unsafe execution: Checks for uncommitted changes and validates key preconditions before proceeding, with options to limit behavior to PR creation or cleanup only.
  • Automatic worktree cleanup after success: Removes the worktree directory after a successful PR and returns you to the main branch, while keeping local and remote branches intact.

Use Case: After finishing a feature in .worktrees/<feature-name>, run this Skill to open the PR and then automatically delete the temporary worktree to keep your workspace tidy.

Quick Start

Run the PR from your worktree by executing: cd .worktrees/<feature-name> && bash ../../.claude/skills/pr-and-cleanup/scripts/pr_and_cleanup.sh

Frequently Asked Questions about pr-and-cleanup

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

FAQPage Schema
How do I create a GitHub pull request from a git worktree and clean up the directory afterward?

You can automate the pull request creation and worktree cleanup by running a Bash script that uses git and GitHub CLI to validate uncommitted changes, execute gh pr create with your specified options, and remove the worktree upon success.

What happens to uncommitted changes when I run an automated PR creation script?

The PR creation script checks for uncommitted changes as a guardrail before proceeding. It validates key preconditions to prevent unsafe execution, ensuring your local modifications are not lost during the worktree cleanup process.

Does this automated PR and cleanup flow require the GitHub CLI and git installed?

Yes, the workflow requires bash, git, and the GitHub CLI (gh) to execute commands. It also depends on standard Unix utilities like grep, sed, and make to manage the worktree and pull request creation process.

Can I create a draft pull request from a feature branch in a git worktree?

Yes, the automated PR creation supports draft flags and custom PR title, body, and base options. You can execute the workflow to open a draft pull request directly from your local feature branch worktree.

Why should I clean up a git worktree after opening a pull request?

Cleaning up a git worktree after opening a pull request saves disk space and prevents your development directories from becoming cluttered. Automating this step ensures the temporary worktree is removed only after the PR is successfully created.

What is the best way to manage feature branch worktrees without leaving orphaned directories?

Using an automated script to handle the end-to-end flow of PR creation and worktree removal is an effective approach. It creates the pull request via GitHub CLI and safely deletes the worktree while keeping local and remote branches intact.