Back to Commands

/commit

🌿Version & Control & Git

Create well-formatted git commits with conventional commit messages and emoji

Allowed Tools: Bash, Read, Glob

Quick Actions

Installation

Option A: Install as User Command (available in all projects)

macOS/Linux:

cp commit.md ~/.claude/commands/

Windows:

copy commit.md %USERPROFILE%\.claude\commands\

Option B: Install as Project Command (current project only)

macOS/Linux:

mkdir -p .claude/commands && cp commit.md .claude/commands/

Windows:

mkdir .claude\commands 2>nul && copy commit.md .claude\commands\

Note: After installation, restart Claude Code to load the new command.

Usage

Slash command:

/commit

Command Instructions


Claude Command: Commit


This command helps you create well-formatted commits with conventional commit messages and emoji.


Usage


To create a commit, just type:

```

/commit

```

Or with options:

```

/commit --no-verify

```

What This Command Does


  • Unless specified with `--no-verify`, automatically runs pre-commit checks:
  • - Detect package manager (npm, pnpm, yarn, bun) and run appropriate commands

    - Run lint/format checks if available

    - Run build verification if build script exists

    - Update documentation if generation script exists

  • Checks which files are staged with `git status`
  • If 0 files are staged, automatically adds all modified and new files with `git add`
  • Performs a `git diff` to understand what changes are being committed
  • Analyzes the diff to determine if multiple distinct logical changes are present
  • If multiple distinct changes are detected, suggests breaking the commit into multiple smaller commits
  • For each commit (or the single commit if not split), creates a commit message using emoji conventional commit format

  • Best Practices for Commits


  • **Verify before committing**: Ensure code is linted, builds correctly, and documentation is updated
  • **Atomic commits**: Each commit should contain related changes that serve a single purpose
  • **Split large changes**: If changes touch multiple concerns, split them into separate commits
  • **Conventional commit format**: Use the format `<type>: <description>` where type is one of:
  • - feat: A new feature

    - fix: A bug fix

    - docs: Documentation changes

    - style: Code style changes (formatting, etc)

    - refactor: Code changes that neither fix bugs nor add features

    - perf: Performance improvements

    - test: Adding or fixing tests

    - chore: Changes to the build process, tools, etc.

  • **Present tense, imperative mood**: Write commit messages as commands (e.g., "add feature" not "added feature")
  • **Concise first line**: Keep the first line under 72 characters
  • **Emoji**: Each commit type is paired with an appropriate emoji:
  • - ✨ feat: New feature