SkilVaultSign inStart free

Catalogue / draft-commit-messages

draft-commit-messages

Older skill: source not recordedSignedGuides the agent through reading staged git changes and turning them into a well-structured commit message, covering conventional-commit type selection, subject and body drafting, ticket references, and handling of lock files, generated code, and oversized diffs. Use when the user asks to write, dra…
---
name: draft-commit-messages
description: >-
  Guides the agent through reading staged git changes and turning them into a
  well-structured commit message, covering conventional-commit type selection,
  subject and body drafting, ticket references, and handling of lock files,
  generated code, and oversized diffs. Use when the user asks to write, draft,
  review, refine, or create a commit for already-staged changes, or wants a
  diff summarized as a commit message. Not for pull-request descriptions,
  changelogs, release notes, or work that has not been staged yet.
---

Drafting commit messages from staged changes

Turn whatever sits in the git staging area into a commit message the user has approved, then create the commit. You perform the analysis yourself by reading the diff — no external tool, model, or installer is involved. This skill does not cover installing third-party AI commit utilities, configuring model providers, or network proxies from the original workflow; everything is done locally by you.

Step 1 — Survey the staging area

Before reading content, get the shape of the change:

  • Run git status --short to separate staged files from unstaged ones. Only staged files matter.
  • Run git diff --cached --stat for a per-file size overview.

The point of this step is scoping: if the diff is three lines you can read it in one go, but if it is ninety files you need a strategy before diving in.

If nothing is staged, stop. Tell the user the staging area is empty and ask which files they want included. Do not stage files on your own initiative.

Step 2 — Read the diff

Read git diff --cached. For large changesets, read file by file with git diff --cached -- <path>, starting with the biggest source files from the stat output.

Read enough to answer two questions: what changed, and why would a reasonable person have made this change? The "why" usually lives in a few key files; imports and call-site updates only confirm the story.

Step 3 — Check the repository's own conventions

Run git log --oneline -15 to see how this project writes history. Mirror whatever precedent exists: conventional-commit prefixes, plain imperative subjects, ticket keys in subjects, trailers, or a dominant language other than English. If a CONTRIBUTING file or commit-lint config exists, it outranks the log.

Step 4 — Classify the change

Pick the single dominant type:

| Type | Use when the staged change... | |------|-------------------------------| | feat | adds or extends user-facing behavior | | fix | corrects a defect in existing behavior | | docs | touches documentation only | | refactor | restructures code without changing behavior | | perf | improves speed or resource usage | | test | adds or adjusts tests only | | build | changes the build system or dependencies | | ci | modifies pipeline configuration | | chore | routine maintenance with no production-code effect |

When a change plausibly fits two types, choose the one describing the outcome a user of the software would notice.

Step 5 — Write the message

Subject line:

  • Format: type(scope): summary — scope is optional and names the module or package touched.
  • Imperative mood, lowercase after the prefix, no trailing period, aim for 72 characters or fewer.
  • Describe the change, not the list of files.

Body, only when the subject cannot carry the full meaning:

  • Leave a blank line after the subject and wrap lines near 72 characters.
  • Explain motivation and any notable design decision. Do not narrate the diff line by line.
  • If lock files, minified bundles, or generated code were part of the staged set, give them at most one sentence.

Step 6 — Ticket references and language

  • If the branch name contains a tracker key (an uppercase letters-then-number pattern such as NIMBUS-88), offer to attach it — as a subject prefix, trailer, or body line, following the repo's own precedent.
  • If no convention is detectable, simply ask the user for a ticket number before inventing any placement.
  • Default to English. Write the message in another language only when the user asks or the recent log is consistently in one.

Step 7 — Confirm, then commit

  • Show the complete proposed message to the user and ask for approval. Adjust on feedback; do not commit an unreviewed message.
  • After approval, create the commit with git commit using the approved text (a multi-line heredoc keeps formatting intact).
  • Amending rewrites the most recent commit in local history. Only amend when the user explicitly asks for it, and confirm the replacement message first.

Guardrails

These follow directly from what this skill does:

  • Never run a command that pushes, syncs, or otherwise publishes the repository to a remote. Creating the commit is local; sharing it is the user's decision.
  • Never stage or commit files beyond what the user staged and approved. Unstaged work stays out of the commit.
  • If the staged diff contains secrets — API keys, tokens, passwords, connection strings — stop, do not commit, warn the user, and suggest unstaging the offending file. Do not copy the secret into the message or repeat it in conversation.

Handling noise and mixed changes

  • Lock files, minified bundles, generated API clients, and snapshot churn: exclude from your analysis entirely; base the message on the meaningful source edits.
  • If the staged files span unrelated concerns (for example a bug fix plus a dependency bump), propose splitting into separate commits, draft one message per group, and let the user decide.

Examples

Example 1 — new feature. Staged: src/notifications/sms.go, internal/messaging/twilio.go.

feat(notifications): deliver order updates over SMS

Route shipping and delivery events through the messaging
provider's SMS channel. Reuses the existing retry queue so
transient provider errors do not drop notifications.

Example 2 — bug fix. Staged: src/cart/checkout.ts.

fix(cart): stop double-applying discounts on payment retry

The discount was applied a second time when the payment
confirmation webhook arrived after a client retry. Apply it
only when the cart has no recorded discount yet.

Example 3 — ticket detected from branch feature/NIMBUS-88-s3-multipart, staged storage code.

feat(storage): stream large uploads via S3 multipart

Split uploads above 100 MB into multipart requests so the
app avoids holding whole files in memory.

Refs: NIMBUS-88

Edge cases

  • Nothing staged — report it and ask what the user wants staged; do not guess.
  • Enormous diff — read the stat first, then the five largest source files individually, and infer the remainder from file paths and the log.
  • Only generated files staged — say so plainly and propose an honest minimal message such as a chore entry; never invent detail you did not observe.
  • Subject keeps overflowing — tighten the wording and move specifics into the body rather than truncating meaning.