|
| 1 | +# Commit Message Guidelines |
| 2 | + |
| 3 | +## Format |
| 4 | + |
| 5 | +```bash |
| 6 | +type(scope)!: Capitalized subject |
| 7 | +``` |
| 8 | + |
| 9 | +- **type** – see list below |
| 10 | +- **scope** – affected area (lowercase; kebab-case if needed) |
| 11 | +- **!** – include if the change is **breaking** |
| 12 | +- **subject** – imperative, ≤ 72 characters, no trailing period |
| 13 | + |
| 14 | +--- |
| 15 | + |
| 16 | +## Types |
| 17 | + |
| 18 | +- **feat** – new user-facing feature |
| 19 | +- **fix** – user-facing bug fix |
| 20 | +- **refactor** – code change without altering behavior |
| 21 | +- **perf** – performance improvement |
| 22 | +- **docs** – documentation changes only |
| 23 | +- **test** – tests only |
| 24 | +- **build** – build system, packaging, tooling |
| 25 | +- **ci** – CI/CD configuration changes |
| 26 | +- **deps** – add/update/remove dependencies |
| 27 | +- **chore** – maintenance tasks (formatting, renaming, non-prod scripts) |
| 28 | +- **release** – version tags and changelog updates |
| 29 | +- **revert** – revert a previous commit |
| 30 | + |
| 31 | +> Use **deps** instead of **chore** when the main change is dependency-related. |
| 32 | +
|
| 33 | +--- |
| 34 | + |
| 35 | +## Scopes |
| 36 | + |
| 37 | +Keep scopes consistent within a project. |
| 38 | +Examples: |
| 39 | +`ui | api | db | infra | docs | mobile | tests` |
| 40 | + |
| 41 | +--- |
| 42 | + |
| 43 | +## Subject Rules |
| 44 | + |
| 45 | +- Use imperative mood: “Add” / “Fix” / “Refactor” (not “Added” or “Adds”) |
| 46 | +- No trailing period |
| 47 | +- Keep concise; use the body for details |
| 48 | + |
| 49 | +--- |
| 50 | + |
| 51 | +## Body (Optional but Recommended) |
| 52 | + |
| 53 | +Explain **what** changed and **why**, not file-by-file changes. |
| 54 | +Wrap text at ~72 characters. |
| 55 | +Consider including: |
| 56 | + |
| 57 | +- Context and reasoning for the change |
| 58 | +- Risks or follow-up actions |
| 59 | +- Migration or rollout notes |
| 60 | + |
| 61 | +--- |
| 62 | + |
| 63 | +## Footers |
| 64 | + |
| 65 | +Common footers: |
| 66 | + |
| 67 | +- `Fixes #123` / `Closes #123` / `Refs #456` |
| 68 | +- `BREAKING CHANGE: <impact + migration>` |
| 69 | +- `Co-authored-by: Name <email>` |
| 70 | +- `Security: <impact or CVE>` |
| 71 | +- `Signed-off-by: Name <email>` |
| 72 | + |
| 73 | +If breaking changes exist and `!` is not used, include a `BREAKING CHANGE:` footer. |
| 74 | + |
| 75 | +--- |
| 76 | + |
| 77 | +## Examples |
| 78 | + |
| 79 | +```bash |
| 80 | +feat(api): Add refresh token endpoint |
| 81 | +fix(ui): Correct button alignment in modal (Fixes #42) |
| 82 | +refactor(db): Move RLS policies to separate schema file |
| 83 | +perf(web): Defer data sync until window idle |
| 84 | +deps(core): Upgrade framework to v2.5.0 |
| 85 | +``` |
| 86 | +
|
| 87 | +Breaking change example: |
| 88 | +
|
| 89 | +```bash |
| 90 | +feat(auth)!: Require MFA for all login endpoints |
| 91 | +BREAKING CHANGE: Users must configure MFA before logging in. |
| 92 | +``` |
| 93 | +
|
| 94 | +--- |
| 95 | +
|
| 96 | +## When to Split a Commit |
| 97 | +
|
| 98 | +Split commits when: |
| 99 | +
|
| 100 | +- Mixing multiple **types** (e.g., `feat` + `fix`) |
| 101 | +- Changes affect unrelated **scopes** |
| 102 | +- A dependency bump includes unrelated refactors |
| 103 | +
|
| 104 | +--- |
| 105 | +
|
| 106 | +## Revert Template |
| 107 | +
|
| 108 | +```bash |
| 109 | +revert: Revert "<original commit subject>" |
| 110 | + |
| 111 | +This reverts commit <sha>. |
| 112 | +Reason: <explanation>. |
| 113 | +``` |
0 commit comments