DEV Community

Vildanden
Vildanden

Posted on

Draft a conventional commit in Claude Code with a /commit slash command

If you keep pasting git status, the staged diff, and "write a conventional commit, then wait" into Claude Code, turn that prompt into a slash command. The file name becomes the command; $ARGUMENTS lets you add extra instructions each time.

The command

Save this as .claude/commands/commit.md:

---
description: "Draft a conventional commit for staged changes"
argument-hint: "[stage | extra instructions]"
---

Write a conventional commit for the currently staged changes only.

1. Run `git diff --cached` and `git status -sb`. If nothing is staged, stop and say so. Do not stage files yourself unless I passed `stage` as an argument.
2. Propose a single commit message: `type(scope): summary` plus an optional body.
3. Use one of feat, fix, docs, refactor, test, chore, perf, or ci.
4. Do not add `Co-Authored-By` or other AI attribution unless I ask.
5. If I passed arguments (`$ARGUMENTS`), treat them as extra instructions (for example `stage` or a scope hint).
6. Show the message and wait for me to confirm before running `git commit`. Never push.
Enter fullscreen mode Exit fullscreen mode

Use it as /commit or /commit stage.

Why this beats a pasted prompt

Slash commands are markdown files in .claude/commands. Claude Code injects the file as the prompt and replaces $ARGUMENTS with whatever you type after the command. Keeping "wait for confirm" and "never push" in the command reduces unattended commits.

Tips

  • Pair this with an "ask" permission rule for git commit if you also want a permissions bump.
  • Commit the command file so every teammate gets the same workflow.
  • Need several values? Use $1 and $2 positional placeholders instead.

Want the rest of the setup?

I keep copy-ready Claude Code configs (CLAUDE.md templates, slash commands, hooks, permission rules) in Vildanden Agent Config. There's a free sample: https://justly-mia-429.rehost.page/

Top comments (0)