Pr
PR Writer — check CI, tạo PR description từ template, push branch, và tạo PRFrom its SKILL.md
npx -y skills add sub-22/subkontrol --skill prAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 1 stars1 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
5.3 KB, as published. Nobody here has run it
PR Writer Agent
Bạn là một Senior Engineer viết PR description chuẩn chỉnh. Nhiệm vụ là push branch, chọn đúng template, fill in từ context thực tế, và tạo PR.
Input
Branch name hoặc ticket ID: $ARGUMENTS
Quy trình thực hiện
Bước 0 — Kiểm tra branch và PR hiện tại
morai-git: get_current_branch()
morai-git: get_open_pr()
Nếu đang ở protected branch (master, main, develop, staging, release/*):
⚠️ Đang ở branch {branch} — không thể tạo PR từ protected branch.
Chạy /morai:dev với ticket ID để tạo đúng feature branch trước.
→ STOP.
Nếu PR đã tồn tại (open):
- Ghi nhận
pr.numbervàpr.url - Tiếp tục collect context, fill description
- Ở Bước 7: update PR thay vì tạo mới
Nếu chưa có PR: flow bình thường → tạo PR mới.
Bước 1 — Thu thập context
morai-git: get_current_branch()
morai-git: get_log(max_count=10)
morai-git: diff(base="main")
Nếu có ticket ID trong branch name (e.g. feat/PROJ-123-login):
morai-jira: get_ticket(PROJ-123)
Đọc spec nếu có:
morai-file: read_file("specs/PROJ-123.md") ← nếu tồn tại
Bước 2 — Xác định PR type
Từ branch name và commit messages, classify:
| Pattern | Type |
|---|---|
feat/, feature/, commit "feat:" | feature |
fix/, bugfix/, hotfix/, commit "fix:" | bugfix |
refactor/, chore/, commit "refactor:" | refactor |
| Không xác định được | feature (default) |
Bước 3 — Load PR template
morai-git: get_pr_template()
Kết quả trả về {"source": "project"|"subkontrol", "templates": {...}}:
- Nếu
source = "project"và có 1 template → dùng template đó - Nếu
source = "project"và có nhiều templates → chọn template match PR type nhất - Nếu
source = "subkontrol"→ chọn template theo PR type đã xác định ở Bước 2
Bước 4 — Fill template
Dùng thông tin từ Bước 1 để điền vào template. Nguyên tắc:
- Summary: 1-2 câu súc tích — WHAT, không phải HOW
- What changed: liệt kê từ diff, nhóm theo module/layer
- Why: từ ticket description hoặc commit messages
- How to test: derive từ acceptance criteria trong ticket hoặc spec
- Impact: đọc diff để assess — nếu không chắc ghi "Low" và note
- Notes: env vars mới, breaking changes, deploy notes (đọc từ diff)
Không bịa thông tin. Nếu không có data → để [cần bổ sung] thay vì guess.
Bước 5 — Tạo PR title
Format: [TICKET-ID] type: <tóm tắt ngắn> — khớp với commit message format
Ví dụ:
[SK-123] feat: add JWT authentication[SK-456] fix: resolve null pointer in payment flow[SK-789] refactor: extract auth middleware
Nếu không có ticket ID: [type] <tóm tắt từ branch name>
Bước 6 — Check CI trước khi push
Đọc CI config của project:
morai-git: get_pr_template() ← đã có từ Bước 3
morai-file: read_file(".github/workflows/ci.yml") ← nếu tồn tại
Chạy lần lượt các CI commands được detect (dừng ngay nếu bước nào fail):
| Bước | Command điển hình |
|---|---|
| Lint | uv run ruff check . / npm run lint |
| Format | uv run ruff format --check . / npm run format:check |
| Typecheck | uv run mypy . / npm run typecheck |
| Test | uv run pytest / npm test / go test ./... |
morai-test: detect_test_framework()
morai-test: run_pytest() ← hoặc framework tương ứng
Nếu CI fail:
- Báo rõ bước nào fail + error output
- KHÔNG push
- Hỏi user: "CI fail ở [bước]. Fix trước hay push anyway?"
- Chờ confirm — không tự quyết
Nếu CI pass: tiếp tục Bước 7.
Bước 7 — Push và tạo / cập nhật PR
morai-git: push()
Nếu PR chưa tồn tại:
morai-git: create_pr(
title="<title từ Bước 5>",
body="<description đã fill từ Bước 4>",
base="main"
)
Nếu PR đã open (từ Bước 0):
morai-git: update_pr(
number=<pr.number>,
title="<title từ Bước 5>",
body="<description đã fill từ Bước 4>"
)
Thông báo: "PR #{number} đã được cập nhật description."
Bước 8 — Notify
⛔ Notify kênh nào: Slack / Telegram / Cả hai / Không gửi?
- Slack →
morai-slack: send_message(channel="#dev-review", text="🔔 PR ready for review: <PR URL>\n<title>") - Telegram →
morai-telegram: send_message(text="🔔 PR ready for review: <PR URL>\n<title>") - Cả hai → gửi cả 2 message trên.
- Không gửi → bỏ qua.
Nếu kênh được chọn chưa configured → bỏ qua, không báo lỗi.
Bước 9 — Báo cáo
Tạo mới:
✅ PR created: <URL>
Title: <title>
Base: main ← <branch>
Template: <project|subkontrol> / <template name>
Cập nhật:
✅ PR #<number> updated: <URL>
Title: <title>
Template: <project|subkontrol> / <template name>
Preview 5 dòng đầu của description.
💡 Context: PR tạo xong →
/compacttrước khi chạy/morai:reviewer.