pr-and-cleanup

Create a GitHub pull request from a feature worktree and remove the worktree.

64|1|Updated Jan 8, 2026
One-click install
npx skills add https://github.com/shikajiro/claude-code-skill-example --skill pr-and-cleanup-shikajiro
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pr-and-cleanup
Source: https://github.com/shikajiro/claude-code-skill-example/tree/main/.claude/skills/pr-and-cleanup
Command: npx skills add https://github.com/shikajiro/claude-code-skill-example --skill pr-and-cleanup-shikajiro

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

This Skill prevents wasted time and clutter by automating the end-of-work flow: creating a pull request and then removing the associated Git worktree when development is finished.

Core Features & Use Cases

  • Auto-detect worktree context and validate state: Ensures you’re inside a worktree, checks for uncommitted changes, and warns about push status before creating the PR.
  • Create a PR with configurable inputs: Supports interactive or provided PR title/body, optional draft PRs, and a selectable base branch.
  • Safely clean up after success: Removes the worktree and returns you to the base branch (while keeping local/remote branches intact).
  • Use case: You complete feature implementation inside a worktree, then want a one-shot command that opens the PR and immediately frees disk space by removing the worktree.

Quick Start

Run the skill from inside .worktrees/<feature-name> to create a PR for your current feature branch and delete that worktree automatically.

Frequently Asked Questions about pr-and-cleanup

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

FAQPage Schema
How do I automatically create a pull request and delete a git worktree afterwards?

To create a pull request and delete a git worktree, you can run an automation script from inside the worktree that opens the PR via gh CLI and then removes the worktree directory. This automates the end-of-work flow to reduce local repository clutter.

Can I open a draft pull request from a feature worktree and return to the base branch?

Yes, you can open a draft pull request from a feature worktree and return to the base branch. The automation creates the draft PR and automatically checks out your specified base branch after removing the worktree.

Does the worktree cleanup script guard against uncommitted changes before opening a PR?

Yes, the worktree cleanup script guards against uncommitted changes before opening a PR. It validates the worktree state and warns you, requiring an optional force flag if you want to proceed with the pull request creation despite local changes.

Do I need the gh CLI to automate pull request creation and repository cleanup?

Yes, you need the gh CLI installed to automate pull request creation and repository cleanup. The tooling depends on both bash and git to detect the worktree context and execute the GitHub pull request commands.

Can I run only the pull request creation without removing the worktree directory?

Yes, you can run only the pull request creation without removing the worktree directory by using a pr-only mode. This allows you to isolate PR creation from the cleanup step if you want to keep the worktree for further development.

What is the best way to manage git worktree clutter after finishing a feature branch?

The best way to manage git worktree clutter after finishing a feature branch is to automate the cleanup process. By combining pull request creation with worktree removal, you immediately free disk space and return to the base branch without leaving stale directories.