worktree-commit-merge
Overview
You're in a git worktree on a feature branch with uncommitted changes. This skill:
- Commits those changes to the current branch
- Merges the branch into master/main — fast-forward if possible, otherwise a regular merge commit
Step 1: Gather context
Run these in parallel:
git status
git diff HEAD
git branch --show-current
git worktree list
git log --oneline -10
This gives you:
- What files changed and what's staged vs unstaged
- The current branch name (the worktree branch)
- The main worktree path and which branch it has checked out
- Recent commit style so your message fits the project
Step 2: Commit the changes
Stage specific files rather than git add -A, which can accidentally include unintended files like .env or build artifacts:
git add <specific relevant files>
Write a commit message that follows the style from the recent log. Always pass via heredoc to preserve formatting:
git commit -m "$(cat <<'EOF'
<type>(<scope>): <description>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
EOF
)"
Step 3: Identify the merge target
From git worktree list output, the first entry is always the main worktree. Identify:
MAIN_PATH— filesystem path of the main worktreeMAIN_BRANCH— branch checked out there (typicallymasterormain)CURRENT_BRANCH— the branch you just committed to
Step 4: Merge into master/main
Try fast-forward first. If the histories have diverged, fall back to a regular merge commit:
git -C <MAIN_PATH> merge --ff-only <CURRENT_BRANCH> \
|| git -C <MAIN_PATH> merge <CURRENT_BRANCH> --no-edit
Tell the user which path was taken — fast-forward or merge commit — so they know what happened to the history.
Step 5: Sync the worktree branch with master/main
After merging, bring the worktree branch up-to-date so it includes any commits that were already on master/main (e.g., from other merges):
git merge <MAIN_BRANCH>
This runs in the worktree directory (current directory), pulling in the full state of master/main.
Step 6: Confirm
git -C <MAIN_PATH> log --oneline -5
Report what was committed (files + message), how it was merged, and that the worktree branch is now in sync with master/main.
More from kjnez/claude-code-django
pytest-django-patterns
pytest-django testing patterns, Factory Boy, fixtures, and TDD workflow. Use when writing tests, creating test factories, or following TDD red-green-refactor cycle.
24django-extensions
Django-extensions management commands for project introspection, debugging, and development. Use when exploring URLs, models, settings, database schema, running scripts, or profiling performance. Triggers on questions about Django project structure, model fields, URL routes, or requests to run development servers.
12pr-summary
Generate a pull request summary for the current branch changes. Use when the user wants to create a PR description, summarize branch changes, or prepare a PR body. Triggers on requests like "summarize my changes", "write a PR description", "what changed in this branch", "/pr-summary".
4