The user wants to create a new worktree with a new branch based on a GitHub issue. The issue number (e.g. #72 or 72) is provided as the argument: $ARGUMENTS.
If no issue number argument was provided, ask the user which issue they want.
Follow these steps:
- •
Fetch the GitHub issue using
gh issue view <number>to get the issue title and body. - •
Look at existing branch names by running
git branch -r --sort=-committerdateto understand the repo's naming conventions. - •
Think of a good branch name that:
- •Starts with the issue number (e.g.
72-descriptive-name) - •Uses kebab-case
- •Is concise but clearly describes what the issue is about
- •Matches the style of existing branch names in the repo
- •Has no "/" prefix
- •Starts with the issue number (e.g.
- •
Verify that the branch and worktree path (
../<repo-name>-<branch-name>) aren't already in use by checkinggit branch -randgit worktree list. If either already exists, pick a different name and repeat untill you find one that is free. - •
Present the branch name to the user and ask for confirmation before proceeding. For example:
codeIssue #72: "Add export functionality for datasets" Proposed branch name: 72-dataset-export
Wait for the user to approve or suggest a different name.
- •
Once approved, fetch latest from remote by running
git fetch origin. - •
Create the worktree from master:
codegit worktree add ../<repo-name>-<branch-name> -b <branch-name> origin/master
- •
Tell the user how to start working there. Print a message like:
codeWorktree ready! To start Claude in the worktree, run: cd ../<repo-name>-<branch-name> && claude