Format commit message theo Conventional Commits standard (Conventional Commits v1.0.0). Input là git diff hoặc mô tả thay đổi, output là commit message có ty...
Sinh commit message chuẩn Conventional Commits trong 5 giây, consistent 100% across team.
Kiểm tra loại input user cung cấp:
Nếu là Git diff output (có diff --git, index, lines với +/-):
→ Parse diff để trích xuất thông tin thay đổi
Nếu là mô tả bằng text: → Hỏi clarifying nếu cần:
Nếu không rõ: → Hỏi: "Anh/chị cho em biết: (A) Dùng git diff, (B) Mô tả bằng tay, hay (C) File paths đã thay đổi?"
Dựa trên nội dung thay đổi, chọn type phù hợp:
| Type | Khi dùng |
|---|---|
| feat | Tính năng mới (new feature, new capability) |
| fix | Sửa bug (fix error, fix bug, fix issue) |
| docs | Thay đổi documentation |
| style | Format code, không ảnh hưởng logic (whitespace, semicolon) |
| refactor | Refactor code, không thay đổi hành vi (rename, extract) |
| test | Thêm, sửa, refactor test |
| chore | Việc maintenance (update deps, build config) |
Logic quyết định:
IF có "fix" + "bug" + "error" → type = fix
ELIF có "add" + "new" + "create" + "implement" → type = feat
ELIF có "doc" + "readme" + "comment" → type = docs
ELIF có "format" + "style" + "indent" → type = style
ELIF có "refactor" + "rename" + "extract" → type = refactor
ELIF có "test" + "spec" + "assert" → type = test
ELSE → type = chore
Scope là phần thay đổi cụ thể, ngắn gọn:
Nếu nhiều files khác nhau: → Thường KHÔNG có scope (rủi ro quá dài)
Nếu 1 file hoặc 1 module: → Dùng file/module name kebab-case:
authuser-servicecommit-formatterFormat: <type>(<scope>): <description>
Quy tắc:
Examples:
feat: add user login
fix(auth): resolve session timeout
docs: update API reference
style: format code with prettier
refactor: extract validation logic
test: add unit tests for auth
chore: upgrade to Node.js v22
Khi nào cần body:
Format body:
[blank line]
<explanation>
[optional details]
- Closes #123
- Refs PR #456
Quy tắc body:
Examples body:
Add email verification flow
- Send verification link to user email
- Verify token on click
- Update user status to verified
Closes #45
Kiểm tra commit message vừa tạo:
Nếu FAIL bất kỳ check → Hỏi user sửa input.
Context: Dev vừa hoàn thành feature login, push code lên Git, muốn commit message chuẩn.
Input (Git diff):
diff --git a/index.js b/index.js
index abc123..def456 100644
--- a/index.js
+++ b/index.js
@@ -1,5 +1,6 @@
const express = require('express');
-const app = express();
+const app = express().use(express.json());
Thought Process:
express.json() middleware → Đây là feat (thay đổi behavior)Output:
feat: add express json middleware
Adds JSON body parsing to Express app.
Context: Dev sửa bug trong auth module, chỉ mô tả bằng văn bản.
Input: "Sửa lỗi session timeout trong file auth.js, user bị logout sau 10 phút"
Thought Process:
Output:
fix(auth): resolve session timeout
Set session timeout to 24 hours to prevent users
from being logged out too quickly.
Closes #789
Context: Dev vừa refactor authentication + fix bug trong user service + update docs cho cả hai.
Input (Mô tả): "Refactor auth module, fix user service validation, update docs for both"
Thought Process:
Output:
refactor: refactor authentication system
Extract user validation to separate service and improve
error handling across auth module.
Changes:
- auth.js: extract validation logic
- user-service.js: add validation middleware
- README.md: update auth flow docs
Refs PR #123, #456
Context: Dev thay đổi API signature, breaking change cho clients cũ.
Input (Mô tả): "Thay đổi API /user endpoint, từ email sang userId, breaking change cho clients"
Thought Process:
Output:
feat(user): change user endpoint to use userId
BREAKING CHANGE: Email parameter removed, use userId instead.
Update API clients to use new endpoint format.
- Updated /user GET endpoint
- Removed email parameter
- Added userId parameter
Migration guide: See docs/api-migration.md
Closes #901
Context: Dev chạy prettier, chỉ format code, không thay đổi logic.
Input (Git diff hoặc mô tả): "Format tất cả files với prettier, thêm dấu chấm cuối dòng"
Thought Process:
Output:
style: format code with prettier
feat|fix|docs|style|refactor|test|chore→ Tách thành multiple commits, mỗi commit 1 logical change
→ Dùng type revert, format: revert: <original subject>
→ Không dùng skill này → Git tạo merge commit tự động
Trạng thái: ✅ Active
File: /data/workspace/whitelist.yml
Mô tả: File này điều khiển skill nào được phép tự động thêm vào Gateway hệ thống (auto-add). Khi Hina nhận trigger "tạo skill", "tạo skill mới", Hina sẽ kiểm tra danh sách whitelist này trước khi tự động thêm skill.
Cách hoạt động:
/data/workspace/whitelist.ymlskills_allowed_auto_add khôngCác skill hiện tại trong whitelist:
Cập nhật whitelist:
status: "disabled" hoặc xóa khỏi danh sáchlast_updated timestampLợi ích:
Đây là danh sách types chính thức:
| Type | Description |
|---|---|
| feat | Tính năng mới (new feature, new capability) |
| fix | Sửa bug (fix error, fix bug, fix issue) |
| docs | Thay đổi documentation (README, comments, API docs) |
| style | Format code (whitespace, semicolon, indentation) - không ảnh hưởng logic |
| refactor | Refactor code (rename, extract) - không thay đổi behavior |
| test | Thêm/sửa/refactor test (tests, specs) |
| chore | Maintenance (build config, update deps, script) |
Quy tắc important:
<type>(<scope>): <subject>| ❌ Sai | ✅ Đúng |
|---|---|
| Added user login | feat: add user login |
| Fixed bug | fix: resolve authentication error |
| Update docs | docs: update README |
| Format code | style: format with prettier |
| Refactored code | refactor: extract validation logic |
ZIP package — ready to use