
branch-and-pr
Reusable git workflow for creating branches, commits, and pull requests. Handles branch naming with
提供方 Plabrum|开源
Branch, Commit, and Pull Request Workflow
Shared workflow for creating feature branches, committing changes, and opening pull requests.
When to use this skill
- After completing implementation work that needs to be submitted
- When you need to create a branch, commit, and PR in one flow
- From other commands/skills like
/submitor/linear-ticket
Workflow Steps
-
Determine engineer's initials
- Run
git config user.nameto get full name - Extract initials from the name (e.g., "Phil Labrum" → "pl")
- Convert to lowercase for consistency
- Run
-
Generate branch name
- Use format:
<initials>/<feature-description-in-kebab-case> - For Linear tickets:
<initials>/<ticket-id>/<feature-description> - Examples:
pl/add-user-authenticationpl/ARI-36/fix-campaign-validationsk/refactor-api-client
- Use format:
-
Create and checkout branch
git checkout -b <branch-name> -
Stage all relevant changes
git add .Or stage specific files as needed
-
Create commit
- Generate descriptive commit message:
- For general work: Use imperative mood (e.g., "add user authentication")
- For Linear tickets:
<TICKET-ID>: <description>(e.g., "ARI-36: add user authentication")
- Create commit with Claude Code attribution:
git commit -m "$(cat <<'EOF' <commit-message> 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> EOF )" - Generate descriptive commit message:
-
Handle pre-commit hooks
- If commit fails due to pre-commit hooks:
- Check if hooks auto-formatted files (e.g., ruff, prettier)
- If so, stage the reformatted files:
git add -u - Retry the same commit command (commit never happened, so just create it fresh)
- Continue until commit succeeds
- If commit fails due to pre-commit hooks:
-
Push to remote
git push -u origin <branch-name> -
Create pull request
- Use
gh pr createwith detailed description - PR title should match commit message
- PR body should include:
## Summary [2-3 bullet points describing changes] ## Test plan [Bulleted markdown checklist of verification steps] 🤖 Generated with [Claude Code](https://claude.com/claude-code) - For Linear tickets, also include:
Closes https://linear.app/arive/issue/<TICKET-ID>
- Use
-
Return PR URL
- Display the PR URL so it can be used by calling command
- For Linear tickets, the URL will be used to update the ticket
Parameters (Conceptual)
This skill can be adapted based on context:
- Feature name: Generated from work done or provided explicitly
- Ticket ID: Optional, if working on a Linear ticket
- Commit message: Generated from changes or provided explicitly
- PR description: Generated from context or provided explicitly
Best Practices
- Branch naming: Always use
<initials>/prefix followed by kebab-case - Initials: Always lowercase (e.g., "pl" not "PL")
- Commit messages: Use imperative mood (e.g., "add feature" not "added feature")
- PR descriptions: Be thorough but concise - focus on the "why" and "what"
- Base branch: Always use
main(verify withgit status)
Error Handling
- Pre-commit hooks fail: Re-stage files and retry (don't skip)
- Push fails: Check if branch already exists remotely
- PR creation fails: Verify gh CLI is authenticated (
gh auth status) - Merge conflicts: Stash or commit changes before switching branches
Integration with Other Commands
This skill is designed to be called from:
/submit- For general feature work/linear-ticket- For Linear ticket workflow- Other custom commands that need git workflow
The calling command should:
- Complete all implementation and quality checks first
- Prepare context (feature name, ticket ID if applicable)
- Invoke this skill to handle git operations
- Use the returned PR URL for any follow-up actions (e.g., updating Linear)
Notes
- Don't commit lockfiles, env files, or generated artifacts (pre-commit hooks will catch these)
- Run
make check-allbefore using this skill if changes are significant - The PR will automatically include Claude Code attribution footer
- Git user config must be set (
git config user.name)