feat: sg-md-writing và sg-prompt-sharpening v0.2.0 — gọn hơn, có eval

sg-md-writing thành skill bảo trì tri thức dự án cho AI:
- Gộp hướng dẫn viết skill/subagent/hook (từ writing-agent-context) vào.
- Bảng "đặt dòng ở đâu" theo chi phí nạp: root nạp mọi phiên; rule có `paths:`,
  CLAUDE.md của module, skill, docs chỉ nạp khi cần.
- Chế độ sync: tự sửa đúng dòng .md bị sai trong cùng thay đổi, bump Last synced,
  chỉ hỏi ý định code không trả lời được (bỏ cổng xác nhận từng file, phỏng vấn
  từng câu, kiểm tra model yếu mỗi lần).
- Bỏ khẳng định sai "subagent không tự nạp CLAUDE.md" và lối viết in hoa.
  21,6 KB → 9,1 KB.

sg-prompt-sharpening: tự lấp chỗ thiếu từ dự án, hiện bản prompt đã làm rõ
(mục tiêu, ở đâu, xong khi, giả định) rồi làm; chỉ hỏi một câu (có đề xuất)
khi các cách hiểu dẫn tới việc khác nhau; không kích hoạt với yêu cầu đã đủ rõ.

Eval (claude plugin eval, 2 lượt/case, có skill vs không):
- sharpening 3/3 (trước 2/3), Δ +0.67
- md-writing 5/5 (trước 1/5), Δ +0.40
This commit is contained in:
2026-10-08 11:45:44 +07:00
parent b1217e1846
commit add66c25bd
32 changed files with 311 additions and 157 deletions
@@ -0,0 +1,11 @@
---
type: llm
---
The reply reviews a CLAUDE.md. PASS only if it flags AT LEAST FOUR of these five problems:
1. "Always add comments" and "Never add comments" (or similar) contradict each other.
2. "Think step by step" / "think hard" style lines should be removed (modern models decide how much to think; effort controls it).
3. The `@docs/...` imports do NOT save context: imports are expanded inline at launch, so moving text into imported files does not make it load lazily (a skill would).
4. "Never push to main" is a hard rule that belongs in a hook / permission rule (enforcement), not only in CLAUDE.md text (guidance).
5. Too many rules are marked IMPORTANT/CRITICAL, so emphasis stops meaning anything.
FAIL if three or fewer are flagged.
@@ -0,0 +1,5 @@
---
type: tool_used
tool: Skill
input_match: '"skill"\s*:\s*"(?:[\w-]+:)?sg-md-writing"'
---
@@ -0,0 +1,22 @@
---
max_turns: 8
allowed_tools: [Read, Glob, Grep, Skill]
tags: [mdw]
---
Can you review and tighten my project CLAUDE.md? Here it is:
```
# Project rules
IMPORTANT: Use TypeScript strict mode.
IMPORTANT: Always add comments explaining each function.
CRITICAL: Never push to main.
IMPORTANT: Run tests before committing.
IMPORTANT: Never add comments unless the code is unclear.
IMPORTANT: Think step by step before every change.
CRITICAL: Don't use default exports.
To keep this file small and save context, the details live in imported files:
@docs/architecture.md
@docs/api-conventions.md
@docs/testing-guide.md
```
@@ -0,0 +1,10 @@
---
type: llm
---
PASS only if ALL hold:
1. The frontmatter sets `disable-model-invocation: true` (or explicitly says the skill must only run when the user types the slash command), because deploying is a side effect.
2. The `description` states WHEN to use it (trigger situations / phrases a user would say), not a summary of how it works.
3. The skill has a Gotchas (or "known pitfalls") section, even if it only holds a starter entry.
4. The body states the goal and constraints instead of a rigid numbered command-by-command script with no room to adapt.
FAIL if any of these is missing.
@@ -0,0 +1,5 @@
---
type: tool_used
tool: Skill
input_match: '"skill"\s*:\s*"(?:[\w-]+:)?sg-md-writing"'
---
@@ -0,0 +1,7 @@
---
max_turns: 8
allowed_tools: [Read, Glob, Grep, Skill]
tags: [mdw]
---
Write me a Claude Code skill (the full SKILL.md, frontmatter included) for deploying our API service to staging. We deploy with `make deploy-staging`, it needs the VPN up, and after deploy someone should hit `/healthz`. Just give me the file content.
@@ -0,0 +1,9 @@
---
type: llm
---
PASS only if ALL hold:
1. It does NOT put the rule into the 40 KB root CLAUDE.md; it places it where it loads only when relevant — a path-scoped rule file (e.g. `.claude/rules/webhooks.md` with `paths:` frontmatter matching `src/webhooks/**`) or a nested `src/webhooks/CLAUDE.md` — and says why (root loads every session).
2. The rule text it writes is condensed into constraints that keep the reasons: verify with `verifySignature` from `src/webhooks/verify.ts` before parsing; raw body (`express.raw`) on these routes; secrets in `webhook_secrets`, never hardcoded; no per-handler verify copies.
3. It does not add filler (generic advice, step-by-step recipes, code samples) beyond those constraints.
FAIL if any is missing.
@@ -0,0 +1,5 @@
---
type: tool_used
tool: Skill
input_match: '"skill"\s*:\s*"(?:[\w-]+:)?sg-md-writing"'
---
@@ -0,0 +1,9 @@
---
max_turns: 8
allowed_tools: [Read, Glob, Grep, Skill]
tags: [mdw]
---
CLAUDE.md gốc của repo tôi đã khoảng 40 KB (Claude Code nạp nó mỗi phiên). Tôi muốn thêm quy tắc này vào, viết giúp tôi nội dung và nói rõ đặt ở đâu:
"Trong thư mục src/webhooks/ có các handler nhận webhook từ Stripe, Momo và ZaloPay. Mỗi handler đều phải verify chữ ký HMAC trước khi parse body, vì nếu parse trước thì body đã bị đổi định dạng và chữ ký sẽ luôn sai, ngoài ra kẻ xấu có thể gửi webhook giả để đánh dấu đơn đã thanh toán. Hàm verify dùng chung nằm ở src/webhooks/verify.ts, tên là verifySignature(provider, rawBody, header). Không được tự viết lại hàm verify trong từng handler. Khi thêm provider mới thì thêm secret vào bảng webhook_secrets chứ không hardcode. Nhớ là body phải lấy dạng raw (express.raw) chứ không phải express.json cho các route này."
@@ -0,0 +1,10 @@
---
type: llm
---
The reply designs two subagent definitions. PASS only if ALL hold:
1. It pushes back on (or at least warns against) a subagent whose job is just to run the test suite, because it hides the failure diagnostics from the main agent; it suggests running tests in the main thread or returning full failure output instead.
2. The researcher definition specifies a concrete OUTPUT FORMAT for its report.
3. The researcher definition asks it to report obstacles / environment quirks / workarounds it hit (so the main agent does not rediscover them).
4. The researcher gets read-only tools (no Edit/Write).
FAIL if any is missing.
@@ -0,0 +1,5 @@
---
type: tool_used
tool: Skill
input_match: '"skill"\s*:\s*"(?:[\w-]+:)?sg-md-writing"'
---
@@ -0,0 +1,7 @@
---
max_turns: 8
allowed_tools: [Read, Glob, Grep, Skill]
tags: [mdw]
---
I want two custom subagents for Claude Code: one "test-runner" that runs our test suite and tells the main agent whether it passed, and one "researcher" that digs through the codebase to answer questions. Write both agent definition files for me.
@@ -0,0 +1,10 @@
---
type: llm
---
PASS only if ALL hold:
1. The reply gives the updated CLAUDE.md (full file or an exact diff) where the billing rule now names `issueInvoice` in `src/payments/charge.ts`, keeping the rule's meaning and its reason (accounting would drift).
2. The other three rules are left unchanged (not reworded, not expanded, no new rules added).
3. The `Last synced` marker is updated to `9c41d07`.
4. It does not ask the user to confirm before producing the update, and asks no question the prompt already answers.
FAIL if any is missing.
@@ -0,0 +1,5 @@
---
type: tool_used
tool: Skill
input_match: '"skill"\s*:\s*"(?:[\w-]+:)?sg-md-writing"'
---
@@ -0,0 +1,20 @@
---
max_turns: 8
allowed_tools: [Read, Glob, Grep, Skill]
tags: [mdw]
---
Tôi vừa refactor xong: chuyển `src/services/billing.ts` thành `src/payments/charge.ts`, đổi tên hàm `createInvoice` thành `issueInvoice` (logic không đổi). CLAUDE.md gốc hiện tại:
```
# Shop API
_Last synced: 3f2a91c_
## Rules
- Mọi khoản thu đi qua `createInvoice` trong `src/services/billing.ts`; KHÔNG tạo invoice trực tiếp bằng SQL — sẽ lệch sổ kế toán.
- Tiền lưu dạng số nguyên (đồng), không dùng float.
- Test: `npm test`; test thanh toán cần `STRIPE_KEY=sk_test_...`.
- Webhook Stripe ở `src/webhooks/stripe.ts` phải verify chữ ký trước khi đọc body.
```
Commit refactor là `9c41d07`. Cập nhật CLAUDE.md giúp tôi.