Skip to content

Conventional Commits

Conventional Commits

Format

<type>(<scope>): <description>

[optional body]

[optional footer]

Types

TypeKhi nào dùng
featThêm tính năng mới
fixSửa bug
docsChỉ thay đổi documentation
styleFormat, whitespace (không đổi logic)
refactorRefactor code (không feat, không fix)
testThêm hoặc sửa tests
choreBuild process, dependencies

Ví dụ thực tế

feat(auth): add Google OAuth login
fix(payment): handle timeout in Stripe webhook
docs(api): add rate limiting documentation
refactor(user): extract profile validation to service layer

Tự động hóa với commitlint

pnpm add -D @commitlint/cli @commitlint/config-conventional
echo "export default { extends: ['@commitlint/config-conventional'] };" > commitlint.config.js

Kết hợp với Husky để enforce trên mọi commit.