spacehub

surshar / claude-code

Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.

Built by Anthropic · github.com/anthropics

claude-code / plugins / commit-commands / README.md
225 lines · 5.8 KBPreviewCodeRaw
1# Commit Commands Plugin
2
3Streamline your git workflow with simple commands for committing, pushing, and creating pull requests.
4
5## Overview
6
7The Commit Commands Plugin automates common git operations, reducing context switching and manual command execution. Instead of running multiple git commands, use a single slash command to handle your entire workflow.
8
9## Commands
10
11### `/commit`
12
13Creates a git commit with an automatically generated commit message based on staged and unstaged changes.
14
15**What it does:**
161. Analyzes current git status
172. Reviews both staged and unstaged changes
183. Examines recent commit messages to match your repository's style
194. Drafts an appropriate commit message
205. Stages relevant files
216. Creates the commit
22
23**Usage:**
24```bash
25/commit
26```
27
28**Example workflow:**
29```bash
30# Make some changes to your code
31# Then simply run:
32/commit
33
34# Claude will:
35# - Review your changes
36# - Stage the files
37# - Create a commit with an appropriate message
38# - Show you the commit status
39```
40
41**Features:**
42- Automatically drafts commit messages that match your repo's style
43- Follows conventional commit practices
44- Avoids committing files with secrets (.env, credentials.json)
45- Includes Claude Code attribution in commit message
46
47### `/commit-push-pr`
48
49Complete workflow command that commits, pushes, and creates a pull request in one step.
50
51**What it does:**
521. Creates a new branch (if currently on main)
532. Stages and commits changes with an appropriate message
543. Pushes the branch to origin
554. Creates a pull request using `gh pr create`
565. Provides the PR URL
57
58**Usage:**
59```bash
60/commit-push-pr
61```
62
63**Example workflow:**
64```bash
65# Make your changes
66# Then run:
67/commit-push-pr
68
69# Claude will:
70# - Create a feature branch (if needed)
71# - Commit your changes
72# - Push to remote
73# - Open a PR with summary and test plan
74# - Give you the PR URL to review
75```
76
77**Features:**
78- Analyzes all commits in the branch (not just the latest)
79- Creates comprehensive PR descriptions with:
80 - Summary of changes (1-3 bullet points)
81 - Test plan checklist
82 - Claude Code attribution
83- Handles branch creation automatically
84- Uses GitHub CLI (`gh`) for PR creation
85
86**Requirements:**
87- GitHub CLI (`gh`) must be installed and authenticated
88- Repository must have a remote named `origin`
89
90### `/clean_gone`
91
92Cleans up local branches that have been deleted from the remote repository.
93
94**What it does:**
951. Lists all local branches to identify [gone] status
962. Identifies and removes worktrees associated with [gone] branches
973. Deletes all branches marked as [gone]
984. Provides feedback on removed branches
99
100**Usage:**
101```bash
102/clean_gone
103```
104
105**Example workflow:**
106```bash
107# After PRs are merged and remote branches are deleted
108/clean_gone
109
110# Claude will:
111# - Find all branches marked as [gone]
112# - Remove any associated worktrees
113# - Delete the stale local branches
114# - Report what was cleaned up
115```
116
117**Features:**
118- Handles both regular branches and worktree branches
119- Safely removes worktrees before deleting branches
120- Shows clear feedback about what was removed
121- Reports if no cleanup was needed
122
123**When to use:**
124- After merging and deleting remote branches
125- When your local branch list is cluttered with stale branches
126- During regular repository maintenance
127
128## Installation
129
130This plugin is included in the Claude Code repository. The commands are automatically available when using Claude Code.
131
132## Best Practices
133
134### Using `/commit`
135- Review the staged changes before committing
136- Let Claude analyze your changes and match your repo's commit style
137- Trust the automated message, but verify it's accurate
138- Use for routine commits during development
139
140### Using `/commit-push-pr`
141- Use when you're ready to create a PR
142- Ensure all your changes are complete and tested
143- Claude will analyze the full branch history for the PR description
144- Review the PR description and edit if needed
145- Use when you want to minimize context switching
146
147### Using `/clean_gone`
148- Run periodically to keep your branch list clean
149- Especially useful after merging multiple PRs
150- Safe to run - only removes branches already deleted remotely
151- Helps maintain a tidy local repository
152
153## Workflow Integration
154
155### Quick commit workflow:
156```bash
157# Write code
158/commit
159# Continue development
160```
161
162### Feature branch workflow:
163```bash
164# Develop feature across multiple commits
165/commit # First commit
166# More changes
167/commit # Second commit
168# Ready to create PR
169/commit-push-pr
170```
171
172### Maintenance workflow:
173```bash
174# After several PRs are merged
175/clean_gone
176# Clean workspace ready for next feature
177```
178
179## Requirements
180
181- Git must be installed and configured
182- For `/commit-push-pr`: GitHub CLI (`gh`) must be installed and authenticated
183- Repository must be a git repository with a remote
184
185## Troubleshooting
186
187### `/commit` creates empty commit
188
189**Issue**: No changes to commit
190
191**Solution**:
192- Ensure you have unstaged or staged changes
193- Run `git status` to verify changes exist
194
195### `/commit-push-pr` fails to create PR
196
197**Issue**: `gh pr create` command fails
198
199**Solution**:
200- Install GitHub CLI: `brew install gh` (macOS) or see [GitHub CLI installation](https://cli.github.com/)
201- Authenticate: `gh auth login`
202- Ensure repository has a GitHub remote
203
204### `/clean_gone` doesn't find branches
205
206**Issue**: No branches marked as [gone]
207
208**Solution**:
209- Run `git fetch --prune` to update remote tracking
210- Branches must be deleted from the remote to show as [gone]
211
212## Tips
213
214- **Combine with other tools**: Use `/commit` during development, then `/commit-push-pr` when ready
215- **Let Claude draft messages**: The commit message analysis learns from your repo's style
216- **Regular cleanup**: Run `/clean_gone` weekly to maintain a clean branch list
217- **Review before pushing**: Always review the commit message and changes before pushing
218
219## Author
220
221Anthropic (support@anthropic.com)
222
223## Version
224
2251.0.0