c/agents › command
0votes

Claude Code slash command: /commit

TemplateLow risk Tested
submitted by CommandVault editors to c/agents

Save as .claude/commands/commit.md for clean, conventional commit messages from your staged changes.

Template · 1 variable
---
description: Write a commit message for the staged changes and commit
argument-hint: [optional context]
allowed-tools: Bash(git diff:*), Bash(git status:*), Bash(git commit:*)
---

1. Run `git status` and `git diff --staged`. If nothing is staged, stop and tell me.
2. Write a commit message:
   - First line: {{commit_style}} format, imperative, under 72 characters (e.g. "fix: handle empty cart on checkout").
   - Blank line, then 1–3 short bullets on why, not what.
   - Extra context from me: $ARGUMENTS
3. Show me the message and wait for my OK before committing. If you can't ask (for example a non-interactive run), stop after showing it.
Never use --no-verify and never amend existing commits.
0 commentsreport

Guide

What you get: Typing /commit writes a Conventional Commits style message for your staged changes and makes one local commit. Best for Developers using Claude Code (or Codex via a skill) who want consistent commit messages without writing them by hand..

Before you start

  • A git repository with staged changes
  • Claude Code: save as .claude/commands/commit.md (its allowed-tools line covers git diff, git status and git commit)
  • Codex: save as .agents/skills/commit/SKILL.md with name and description front matter, and let Codex write to .git (its workspace-write sandbox blocks this by default)

Worked example (Oct 17, 2026, Claude Code 2.1.296; Codex 0.151.0 (gpt-5.6-sol))

Input

Staged change to src/app/layout.tsx: title 'Create Next App' -> 'Acme Notes', new description. Ran /commit in Claude Code and $commit in Codex. {{commit_style}} = Conventional Commits.

Result

Claude Code commit: "chore: rename app metadata to Acme Notes". Codex commit (second run): "feat: brand app metadata for Acme Notes"

Claude Code: one local commit, subject plus one 'why' bullet; it also added a Co-Authored-By trailer (Claude Code's default attribution, not from the template). Codex run 1 with -s workspace-write FAILED: git could not create .git/index.lock because the sandbox keeps .git read-only, so no commit was made. Codex run 2 with --add-dir <repo>/.git succeeded: one commit, subject plus two 'why' bullets. No push in any run; untracked files were left out. After this test step 3 waits for your OK before committing (in the test it committed straight away). Codex needed write access to .git for the commit (run 2 used --add-dir .git).

How to check it worked

  • git log -1 shows exactly one new commit
  • The subject line matches the staged diff and is under 72 characters
  • git status shows nothing left staged, and untracked files were not committed

Common problems

  • Codex in its default workspace-write sandbox cannot write to .git, so the commit fails until you allow it
  • In headless (-p) mode you only see the final reply, so the 'show me the message' step is not a real chance to approve it
  • Claude Code may append its own Co-Authored-By trailer

Install this command in your AI tool

Converted for each tool's format. Fill in the blanks above first; your answers are included.

One command
npx commandvault add claude-code-slash-command-commit-584b2474 --tool claude
Save as .claude/commands/commit.md
---
description: Write a commit message for the staged changes and commit
argument-hint: [optional context]
allowed-tools: Bash(git diff:*), Bash(git status:*), Bash(git commit:*)
---

1. Run `git status` and `git diff --staged`. If nothing is staged, stop and tell me.
2. Write a commit message:
   - First line: {{commit_style}} format, imperative, under 72 characters (e.g. "fix: handle empty cart on checkout").
   - Blank line, then 1–3 short bullets on why, not what.
   - Extra context from me: $ARGUMENTS
3. Show me the message and wait for my OK before committing. If you can't ask (for example a non-interactive run), stop after showing it.
Never use --no-verify and never amend existing commits.

Use it: Type /commit and what you want, e.g. /commit add password reset. Your text replaces $ARGUMENTS.

The same file also works as a skill at .claude/skills/commit/SKILL.md.

From Claude Code's docs , checked Oct 17, 2026.

More from c/agents

See all of c/agents →
0 comments

Log in to join the discussion.