Skip to main content
Skill Claude

Skill Commit Message untuk Claude Code

Membaca staged diff lalu menulis commit message yang menjelaskan apa yang berubah dan kenapa. Tidak pernah meng-commit untuk Anda.

Oleh Matthews WongDiperbarui Dicek dengan Claude Code 2.1.323 docs

Poin utama

Masukkan folder ini ke direktori skills Anda dan Claude menulis commit message dari apa yang benar-benar di-stage. Skill ini membaca git diff --staged, mengikuti gaya riwayat commit terakhir Anda, menjaga satu perubahan logis per commit, dan menulis subject imperatif dengan body yang menjelaskan apa dan kenapa. Ia tidak mengarang alasan, dan tidak commit atau push kecuali Anda minta.

2 file

File-filenya

Persis isi unduhannya. Baca dulu, lalu salin atau unduh.

commit-message/SKILL.md3.2 KB
commit-message/SKILL.md
---
name: commit-message
description: Writes a git commit message from the staged diff, with an imperative subject line and a body that explains what changed and why. Use when the user asks to write a commit message, describe staged changes, "what should I call this commit", or prepare a commit.
allowed-tools: Bash(git status *) Bash(git diff *) Bash(git log *)
---

# Commit message

Write a commit message for the changes that are staged right now. The message
describes only what the diff shows.

## Steps

1. Run `git status --short` to see what is staged and what is not.
2. Run `git diff --staged` and read all of it. If it is long, run
   `git diff --staged --stat` first, then read the diff file by file.
3. If nothing is staged, say so and stop. Do not stage files yourself.
4. Run `git log -n 10 --oneline` and match the style the repository already
   uses (prefixes such as `feat:` or `fix:`, capitalization, language).
5. Decide whether the staged diff is one logical change. If it mixes
   unrelated changes, say which files belong together and propose one
   message per group. Do not hide two changes behind one subject.
6. Write the message in the format below and show it in a code block.

## Format

```text
<subject line>

<body>

<footer, only if needed>
```

Subject line:

- Imperative mood, as if completing "This commit will ...". Write
  "Add retry to webhook sender", not "Added" or "Adds".
- 50 characters or fewer when possible, never more than 72.
- No period at the end.
- Name the thing that changed, not the file list.
- Keep the prefix style found in step 4. If the history has none, add none.

Body:

- One blank line after the subject.
- Wrap lines at 72 characters.
- Say what changed and why. The diff already shows how.
- State the reason only if the diff, the code comments or the user gave it.
  If the reason is not known, describe the change and ask the user for the
  reason instead of making one up.
- Leave the body out for a change that the subject fully explains, such as
  a typo fix.

Footer:

- Issue references or `BREAKING CHANGE:` notes, only when the user or the
  diff provides them. Never invent an issue number.

## Rules

- Describe only changes present in `git diff --staged`. Unstaged and
  untracked files are not part of this commit.
- Never claim that tests pass, that a bug is fixed or that performance
  improved unless the conversation contains the output that shows it.
- Do not run `git add`, `git commit`, `git commit --amend` or `git push`
  unless the user asks for that action in plain words. Writing the message
  is the whole job.
- If the diff contains something that looks like a secret, a key or a
  password, stop and tell the user before writing anything else.
- No marketing words. "Improve", "enhance" and "refactor" need an object and
  a reason, or a more exact verb.

## What to report

1. The proposed message, in a code block, ready to copy.
2. One line listing the staged files it covers.
3. Any warning: mixed changes, unstaged files that look related, a missing
   reason, or a suspected secret.

## Additional resources

- For good and bad messages side by side, see [examples.md](examples.md).
  Read it when the right wording is not obvious.
commit-message/examples.md2.3 KB
commit-message/examples.md
# Commit message examples

Each pair shows a message to avoid and the message to write instead.

## 1. Vague subject

Bad:

```text
Update files
```

Good:

```text
Reject empty email in signup form

The form accepted a blank email and the API answered with a 500.
Validate the field on the client and return a 422 with a field
error from the API, so the user sees which input to fix.
```

Why: the subject names the behavior that changed, and the body gives the
reason a reader will look for in a year.

## 2. Past tense and a file list

Bad:

```text
Changed user-service.ts and user-service.test.ts
```

Good:

```text
Cache user lookups for the length of a request

The order page loaded the same user once per line item. Keep the
result in a request-scoped map so each user is read once.
```

Why: imperative mood, and the files are already listed by git.

## 3. Two changes in one commit

Bad:

```text
Fix date parsing and add export button
```

Good: say that the staged diff holds two unrelated changes, then propose two
commits.

```text
Parse ISO dates without a timezone as UTC
```

```text
Add CSV export button to the orders table
```

Why: one logical change per commit keeps a revert or a bisect clean.

## 4. An invented reason

Bad:

```text
Increase timeout to 30s to fix the flaky production outage
```

The diff only shows a number changing from 10 to 30. Nothing in it mentions
an outage.

Good:

```text
Raise HTTP client timeout from 10s to 30s
```

Then ask the user for the reason and add it to the body once they give it.

## 5. A claim nobody checked

Bad:

```text
Fix login bug, all tests pass
```

Good:

```text
Compare session tokens in constant time

Replace the string equality check in verifySession with
timingSafeEqual, so the comparison time does not depend on how
many leading characters match.
```

Why: "all tests pass" belongs in the message only when the test output is
in the conversation.

## 6. Matching the repository's prefix style

When `git log` shows prefixes such as these:

```text
feat(blog): add reading time to post cards
fix(api): return 404 for unknown slugs
```

write the new message in the same style:

```text
fix(search): keep the query when the dialog reopens
```

When the history has no prefixes, do not add them.

## 7. A change that needs no body

```text
Fix typo in README install step
```
Cara memakainya

Dari unduh sampai jalan

Pakai saat

  • Anda punya perubahan yang sudah di-stage dan ingin message yang dipahami reviewer tanpa membuka diff.
  • Riwayat commit Anda penuh subject seperti update atau fix dan Anda ingin satu gaya yang konsisten.
  • Anda ingin Claude menulis message-nya tetapi commit-nya tetap Anda yang lakukan.
  • Anda sering men-stage perubahan yang tidak berhubungan sekaligus dan ingin diperingatkan sebelum semuanya masuk satu commit.
  1. Ekstrak ke folder skills Anda

    Arsipnya berisi satu folder, commit-message. Ekstrak ke .claude/skills/ di proyek Anda sehingga filenya berada di .claude/skills/commit-message/SKILL.md, atau ke ~/.claude/skills/ untuk memakainya di semua proyek di mesin Anda.

  2. Periksa apakah terdaftar

    Di Claude Code, tanyakan What skills are available? atau buka /skills dan cari commit-message. Bila folder skills belum ada saat sesi dimulai, jalankan /reload-skills lebih dulu.

  3. Stage satu perubahan, lalu minta

    Jalankan git add pada file untuk satu perubahan logis. Lalu ketik /commit-message, atau minta Claude menulis commit message. Skill ini membaca staged diff dan log terakhir Anda sebelum menulis apa pun.

  4. Baca message dan peringatannya

    Anda mendapat message dalam code block, daftar file yang dicakup, dan peringatan bila ada: perubahan campur aduk, file terkait yang belum di-stage, atau alasan yang tidak ditemukan. Lengkapi alasan yang kurang, lalu commit sendiri atau minta Claude melakukannya.

  5. Sesuaikan format dengan tim Anda

    Sunting bagian Format di SKILL.md bila tim Anda memakai panjang subject lain, prefix wajib, atau footer tiket. Tambahkan pasangan contoh Anda sendiri ke examples.md agar skill mengikuti gaya kalimat Anda.

Isinya

Kenapa ditulis seperti ini

Berangkat dari staged diff, bukan dari ingatan

Langkah pertamanya menjalankan git status dan git diff --staged. Message hanya menjelaskan apa yang ditampilkan keduanya, jadi pekerjaan yang dibahas tetapi tidak di-stage tidak ikut masuk.

Format yang jelas dengan angka

Subject dalam bentuk imperatif, 50 karakter bila memungkinkan dan tidak pernah lebih dari 72, tanpa titik. Body dibungkus pada 72 karakter dan menjelaskan apa serta kenapa. Batas yang tertulis lebih mudah diikuti daripada perintah tulis message yang bagus.

Aturan melawan isi karangan

Tidak ada alasan kecuali berasal dari diff, komentar, atau Anda. Tidak ada nomor issue kecuali diberikan. Tidak ada klaim tes lolos tanpa output-nya di percakapan. Bila alasannya tidak ada, skill akan bertanya.

Perintah git read-only sudah disetujui lebih dulu

Baris allowed-tools memuat git status, git diff, dan git log, sehingga Claude bisa menjalankannya tanpa prompt izin selama giliran yang memanggil skill. git add, git commit, dan git push tidak ada di daftar itu.

Contoh di file terpisah

examples.md berisi tujuh pasangan contoh baik dan buruk. SKILL.md menautkannya, dan Claude membukanya hanya saat pilihan katanya tidak jelas, jadi contoh itu tidak dimuat di setiap pemakaian.

Perhatikan

Yang sering salah

  • Skill hanya melihat apa yang di-stage. Bila Anda lupa git add sebuah file, message tidak akan menyebutnya, jadi baca daftar file yang dicakup.
  • Skill adalah panduan, bukan kunci. Untuk benar-benar memblokir commit atau push, pakai aturan deny pada permission atau hook.
  • Skill bisa menjelaskan apa yang berubah dari diff, tetapi alasannya sering hanya ada di kepala Anda. Bersiaplah ditanya, dan jawablah alih-alih menerima tebakan.
Pertanyaan

Yang sering ditanyakan

Jawaban singkat sebelum Anda mengunduhnya.

Apakah skill ini menjalankan git commit untuk saya?

Tidak. Instruksinya meminta Claude tidak menjalankan git add, git commit, atau git push kecuali Anda memintanya secara jelas, dan baris allowed-tools hanya menyetujui git status, git diff, dan git log. Tugasnya hanya menulis message.

Bagaimana cara memicu skill commit message ini?

Ketik /commit-message, atau minta dengan kalimat biasa, misalnya tulis commit message untuk perubahan yang di-stage. Claude mencocokkan permintaan dengan skill lewat description-nya, dan description skill ini memuat frasa yang biasa dipakai untuk tugas tersebut.

Apakah skill ini mengikuti Conventional Commits?

Skill ini mengikuti repository Anda. Ia membaca sepuluh commit terakhir dan mempertahankan gaya prefix yang ditemukan, seperti feat: atau fix:. Bila riwayatnya tanpa prefix, ia tidak menambahkannya. Untuk mewajibkan prefix, sunting bagian Format di SKILL.md.

Apa yang terjadi bila saya men-stage dua perubahan yang tidak berhubungan?

Skill akan menyampaikannya, menyebut file mana yang satu kelompok, dan mengusulkan satu message per kelompok. Ia tidak meng-unstage apa pun; Anda sendiri yang memecah commit-nya. Satu perubahan logis per commit membuat revert di kemudian hari tetap bersih.

Pelajari lebih dalam

Pelajari apa yang dikemas file ini

Pelajaran dan artikel gratis di situs ini yang menjelaskan gagasan di baliknya.

Sumber

Sumber primer yang diperiksa pada tanggal riset. Ikuti tautannya untuk versi terbaru.

Lainnya dari toolkit

Ambil ini juga

Skill ClaudeGratis

Template Skill Claude (SKILL.md)

SKILL.md beranotasi yang tinggal diisi, plus file referensi yang menunjukkan cara menjaga file utama tetap pendek.

  • Claude Code
  • Agent Skills format

2 file3.2 KB.zip

Skill ClaudeGratis

Skill Deskripsi Pull Request untuk Claude Code

Membaca diff branch lalu mengisi template PR: kenapa, apa yang berubah, hasil tes nyata, risiko, dan rollback.

  • Claude Code
  • Git

2 file5.8 KB.zip

TemplateGratis

Template CLAUDE.md untuk Repository Apa Pun

CLAUDE.md awal 70 baris: proyek, stack, perintah, aturan keras, cara memverifikasi pekerjaan, dan yang tidak boleh dilakukan.

  • Claude Code

1 file2.1 KB.md

Semua item toolkit