# Referensi Cepat Conventional Commits

*Format pesan commit, tipe, scope, breaking change*

> Source: Conventional Commits (conventionalcommits.org) · MIT

## Format

### Struktur Pesan Commit

```
<type>[optional scope]: <description>
[optional body]
[optional footer(s)]
```

### Penjelasan Bagian

| Command | Description |
|---------|-------------|
| `type` | Kategori perubahan (feat, fix, dll.) |
| `scope` | Bagian codebase yang terpengaruh (opsional) |
| `description` | Ringkasan singkat dalam bentuk imperatif |
| `body` | Penjelasan detail (opsional, setelah baris kosong) |
| `footer` | Metadata seperti BREAKING CHANGE atau referensi issue |

### Aturan

| Command | Description |
|---------|-------------|
| `Bentuk imperatif` | "add feature" bukan "added feature" |
| `Tipe huruf kecil` | feat: bukan Feat: |
| `Tanpa titik` | Deskripsi tidak diakhiri dengan "." |
| `Baris kosong` | Pisahkan body/footer dari deskripsi |

## Tipe

### Tipe Inti (Relevan SemVer)

| Command | Description |
|---------|-------------|
| `feat` | Fitur baru (memicu kenaikan versi MINOR) |
| `fix` | Perbaikan bug (memicu kenaikan versi PATCH) |

### Tipe Tambahan (Konvensi Umum)

| Command | Description |
|---------|-------------|
| `build` | Sistem build atau dependensi eksternal |
| `chore` | Tugas pemeliharaan (tanpa perubahan src/test) |
| `ci` | Konfigurasi dan script CI |
| `docs` | Perubahan dokumentasi saja |
| `perf` | Peningkatan performa |
| `refactor` | Perubahan kode yang tidak memperbaiki atau menambah fitur |
| `revert` | Membalikkan commit sebelumnya |
| `style` | Pemformatan, whitespace (bukan styling CSS) |
| `test` | Menambah atau memperbaiki test |

## Scope

### Penggunaan Scope

```
feat(auth): add OAuth2 login flow
fix(parser): handle empty input gracefully
docs(readme): update installation steps
refactor(api): extract validation middleware
```

### Panduan Scope

| Command | Description |
|---------|-------------|
| `Nama modul` | feat(auth):, fix(parser): |
| `Nama layer` | feat(api):, fix(db): |
| `Area fitur` | feat(search):, fix(checkout): |
| `Dependensi` | build(deps):, chore(npm): |
| `Tidak perlu scope` | Gunakan tanpa scope untuk perubahan lintas-modul |

## Breaking Change

### Menandai Breaking Change

```
feat!: remove deprecated login endpoint
feat(api)!: change response format to JSON:API
fix!: drop Node 14 support
```

### Breaking Change Gaya Footer

```
feat(api): change user endpoint response
BREAKING CHANGE: response now returns array
instead of object. Update client parsing.
```

### Aturan

| Command | Description |
|---------|-------------|
| `! setelah type/scope` | Penanda breaking change singkat |
| `BREAKING CHANGE:` | Token footer (selalu huruf besar) |
| `BREAKING-CHANGE:` | Juga valid (bentuk tanda hubung) |
| `Dampak SemVer` | Memicu kenaikan versi MAJOR |
| `Tipe apapun` | Breaking change bisa berlaku untuk tipe apapun |

## Contoh

### Commit Sederhana

```
feat: add email notifications
fix: prevent race condition in checkout
docs: correct typo in contributing guide
style: format with prettier
refactor: simplify error handling logic
```

### Dengan Scope

```
feat(blog): add comment threading
fix(auth): refresh token before expiry
test(api): add missing edge case coverage
ci(github): add Node 20 to test matrix
```

### Dengan Body dan Footer

```
fix(parser): handle nested quotes correctly

Previously, nested quotes caused the parser
to enter an infinite loop. This adds a depth
counter to prevent unbounded recursion.

Closes #234
```

## Footer

### Token Footer

| Command | Description |
|---------|-------------|
| `BREAKING CHANGE:` | Mendeskripsikan perubahan API yang breaking |
| `Closes #123` | Auto-close issue saat merge |
| `Fixes #456` | Auto-close issue (referensi fix) |
| `Refs #789` | Referensi issue tanpa menutupnya |
| `Reviewed-by: name` | Atribusi reviewer |
| `Co-authored-by: name` | Atribusi co-author |

### Beberapa Footer

```
feat(api)!: redesign authentication flow

Migrate from session-based to JWT auth.

BREAKING CHANGE: /auth endpoints changed
Closes #101
Refs #98, #99
```

## Tooling

### Commit Linting

```
npm install -D @commitlint/cli \
  @commitlint/config-conventional
echo "module.exports = { extends: \
  ['@commitlint/config-conventional'] }" \
  > commitlint.config.js
```

### Tool Populer

| Command | Description |
|---------|-------------|
| `commitlint` | Lint pesan commit sesuai konvensi |
| `husky` | Git hooks (jalankan commitlint saat commit) |
| `commitizen (cz)` | Builder pesan commit interaktif |
| `standard-version` | Changelog otomatis + kenaikan versi |
| `semantic-release` | Pipeline rilis otomatis penuh |
| `release-please` | Alat otomasi rilis dari Google |

### Setup Commitizen

```
npm install -D commitizen \
  cz-conventional-changelog
npx commitizen init cz-conventional-changelog
# Use: npx cz (or git cz with alias)
```

## Pola Umum

### Pemetaan Kenaikan Versi

| Command | Description |
|---------|-------------|
| `fix:` | PATCH (1.0.0 → 1.0.1) |
| `feat:` | MINOR (1.0.0 → 1.1.0) |
| `BREAKING CHANGE` | MAJOR (1.0.0 → 2.0.0) |
| `docs:, style:, dll.` | Tidak ada kenaikan versi |

### Pengelompokan Changelog

```
## [1.2.0] - 2026-03-27
### Features
- add email notifications (abc1234)
### Bug Fixes
- prevent race condition (#123) (def5678)
```

### Format Revert

```
revert: feat(blog): add comment threading
This reverts commit abc1234def5678.
```
