Skip to main content
ClaudeWave
Slash Command894 repo starsupdated 2d ago

commit

The /commit slash command analyzes staged git changes using `git diff --cached` and generates a Semantic Commit message following Conventional Commits standards. It determines the appropriate commit type (feat, fix, docs, refactor, chore), creates a concise subject line under 50 characters, and writes a structured body detailing added, modified, and deleted resources to `.git/COMMIT_EDITMSG`. Use this command when ready to commit staged changes and needing an automatically formatted commit message.

Install in Claude Code
Copy
mkdir -p ~/.claude/commands && curl -fsSL https://raw.githubusercontent.com/guanyang/open-agent-hub/HEAD/commands/commit.md -o ~/.claude/commands/commit.md
Then start a new Claude Code session; the slash command loads automatically.

commit.md

# Slash Command: /commit

## Core Objective
Analyze staged git modifications and generate/write a high-quality Semantic Commit message.

## Steps for the Agent
1. **Analyze Staged Changes**: Run `git diff --cached` to inspect what changes have been staged.
2. **Determine Conventional Commit Type**:
   - `feat`: New features (e.g., new skill, agent, command, utility).
   - `fix`: Bug fixes.
   - `docs`: Documentation updates.
   - `refactor`: Code restructurings.
   - `chore`: Maintenance, dependencies, config updates.
3. **Format Subject & Body**:
   - Write a concise summary line (subject) under 50 characters.
   - Formulate a structured commit message body detailing Added, Modified, and Deleted resources.
4. **Action**: Write the generated message directly to `.git/COMMIT_EDITMSG`.
5. **Output**: Output the commit message for the user to review, and tell them they can run `git commit -F .git/COMMIT_EDITMSG` to finalize the commit.