Home › Agent workflows › /commit slash command (Claude Code)
/commit slash command (Claude Code)
A Claude Code /commit slash command that reviews staged changes and writes a Conventional Commits message.
Claude Code (CLAUDE.md)Agent workflows
How to use
Save this as .claude/commands/commit.md in your repository root, commit it, and your agent will pick it up automatically. Edit the commands to match your project.
.claude/commands/commit.mdDownload ---
description: Review staged changes and create a Conventional Commits commit
allowed-tools: Bash(git status:*), Bash(git diff:*), Bash(git log:*), Bash(git commit:*)
argument-hint: [optional summary or scope]
---
## Context
- Status: !`git status --short`
- Staged diff: !`git diff --cached`
- Recent commits (for style): !`git log --oneline -10`
## Task
1. If nothing is staged, stop and tell me which files have changes; do not stage files yourself.
2. Check the staged diff for problems before committing: secrets or `.env` contents, debug logs, `.only`/focused tests, large generated files, unrelated changes mixed together. If you find any, stop and list them.
3. Write one commit message in Conventional Commits format:
- `type(scope): summary`, imperative, lowercase, ≤ 72 chars, no period.
- Types: feat, fix, refactor, perf, test, docs, build, ci, chore. Use `!` plus a `BREAKING CHANGE:` footer for breaking changes.
- Body (wrapped at 72) explaining why, if the change isn't obvious.
- Use this hint from me if given: $ARGUMENTS
4. Commit with `git commit -m "<summary>" -m "<body>"`.
5. Show the resulting `git log --oneline -1`.
Never use `--no-verify`, `--amend`, or push.