editing-agents-md
Skill này làm gì
Skill này giúp bạn chọn nội dung cho các file hướng dẫn mà công cụ lập trình AI đọc khi bắt đầu mỗi phiên làm việc. Nó dành cho người duy trì các file này và muốn chúng ngắn gọn, hữu ích.
Khi nào nên dùng
- ✓Khi bạn muốn thêm một quy tắc mới vào file AGENTS.md hoặc CLAUDE.md.
- ✓Khi một quy tắc liên tục bị vi phạm và có người đề nghị ghi nó xuống.
- ✓Khi một file hướng dẫn đã dài và cần cắt gọt.
Liên kết skill
https://github.com/PostHog/posthog/blob/master/.agents/skills/editing-agents-md/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Giúp tôi xem quy tắc này nên nằm trong file CLAUDE.md của tôi không, và viết lại để AI làm theo.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Trước tiên, skill hỏi xem một cơ chế khác, chẳng hạn linter hoặc bài kiểm thử, có thể áp dụng quy tắc không. Skill chỉ giữ quy tắc trong file khi không có cách nào tốt hơn, và viết lại cho rõ ràng.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
Editing AGENTS.md
The root AGENTS.md loads in full at the start of every session, in every tool that reads it.
A line you add is paid for by every task in the repo, forever, whether or not that task touches the subject.
So the question is never "is this true?" — it is "is this worth loading into every session?"
Two findings set the frame:
- Adding a context file raises inference cost by over 20% on average, and does not reliably raise task success (2602.11988). A second study measured the opposite sign on runtime and tokens (2601.20404). The evidence is mixed, which argues for a small sharp file rather than no file.
- File size, instruction position, file architecture, and contradictions between adjacent files each produced no detectable effect on whether an agent follows a rule, across 1,650 sessions (2605.10039).
Read the second one carefully, because it kills a whole class of proposals. Moving a section higher "so the agent sees it" is churn against a null result. Do not reorder for attention. Reorder only when a heading makes a rule easier for a human to find or cite.
1. Does this belong in the file at all?
Work down this ladder and stop at the first rung that fits. It is the same ladder AGENTS.md states for itself.
| Rung | Mechanism | Use when |
|---|---|---|
| 1 | Linter — ruff, oxlint, semgrep (.semgrep/rules/devex/) |
The violation is a code pattern a matcher can see |
| 2 | lint-staged / pre-commit | It needs the file list or the working tree, not the AST |
| 3 | Skill (.agents/skills/) |
It applies to one kind of task, not every task |
| 4 | A rule in AGENTS.md | None of the above can carry it |
Rung 4 is the last resort, not the default.
A convention that a semgrep rule could catch belongs in .semgrep/rules/devex/ — read its README for the severity choice and the WARNING-to-ERROR ratchet.
Put the migration playbook in the rule's message: field, because that is what an author actually reads when it fires.
Rung 3 is the one people skip most. If a rule only matters while merging a PR, writing a migration, or building a workflow, it belongs in that skill, where it loads on demand and can be ten times longer.
2. Check the six smells
Measured across 100 popular repositories (2606.15828). Prevalence in brackets.
- Lint leakage [62%] — the rule restates what a linter already blocks. This is the most common failure by a wide margin. Do not delete the reasoning, but cut it to the reason plus the rule id, and tag it. CI is the check; the prose is only the why.
- Context bloat [42%] — content that does not apply to most sessions. Environment-specific setup, product documentation, anything a
docs/page should hold. Target is under 200 lines. - Skill leakage [35%] — task-specific instructions sitting in the always-loaded file instead of a skill.
- Conflicting instructions [28%] — two rules that disagree, often because one aged. Grep for the other statement before you add yours.
- Init fossilization [24%] — text nobody has reviewed since it was generated. If you are editing near a stale rule, verify it still holds and fix it in the same diff.
- Blind references [16%] — a link with no statement of what it holds and when to read it. Every link needs a "read this when …" clause, or an agent has no basis to spend a tool call on it.
3. Write the rule as an invariant, not an instruction
The file is read by authors and reviewers alike. An invariant serves both; an instruction has to be translated.
- Say what must be true: "Every tenant-data model must have
team_id." - Not what to do: "Remember to add
team_idwhen you make a model."
Be specific and imperative. A vague preference changes nothing.
"Use uv pip, never pip" works. "We prefer uv" does not.
Name the trigger the rule fires on, so a reader scanning a diff knows when it applies.
Keep to the repo's prose conventions: ASD-STE100 Simplified Technical English, active voice, one
Câu hỏi thường gặp
Tại sao không đưa mọi quy tắc vào file?
Mỗi dòng được nạp vào mọi phiên làm việc, nên file dài làm tăng chi phí và không phải lúc nào cũng giúp AI làm theo quy tắc. File ngắn, rõ ràng hoạt động tốt hơn.
Lời khuyên này có áp dụng cho file CLAUDE.md không?
Có. Cùng lời khuyên áp dụng cho AGENTS.md và CLAUDE.md, vì cả hai đều được nạp khi bắt đầu mỗi phiên.
Có nên đưa một quy tắc lên đầu file để AI thấy rõ hơn không?
Thường là không. Nghiên cứu đứng sau skill này cho thấy vị trí không ảnh hưởng đáng tin cậy đến việc agent có làm theo quy tắc hay không, nên chỉ nên sắp xếp lại để người đọc dễ tìm mục.
Chi tiết
Mô tả gốc của tác giả
Decide whether a rule belongs in an AGENTS.md / CLAUDE.md file, and write it so it holds. Use before adding, editing, or removing any instruction in a root or nested AGENTS.md, when a convention keeps getting broken and someone proposes documenting it, when reviewing a diff that touches one, or when a file has grown and needs a trim. Carries the enforcement-tag convention (`[lint: <id>]` / `[review]`), the six configuration smells to check against, and the size budget. Trigger terms: AGENTS.md, CLAUDE.md, agent instructions, context file, add a rule, document this convention, the file is too l
repo: PostHog/posthog
Độ phổ biến
- Sao GitHub
- 41k
- Vị trí xếp hạng
- #6813
- Giấy phép
- —
- Cập nhật
- 2/11/2026
Bình luận
- …
Thêm skill từ kho mã này
depot-ci
41kGiúp agent của bạn thiết lập và chạy quy trình Depot CI, một lựa chọn thay thế GitHub Actions, gồm chuyển các quy trình hiện có và đọc nhật ký chạy.
depot-container-builds
41kGiúp agent của bạn build image Docker trên các builder từ xa của Depot, gồm image đa nền tảng, đẩy lên registry và sửa lỗi build.
depot-github-runners
41kGiúp agent của bạn chuyển các job GitHub Actions sang runner do Depot quản lý, chọn kích thước và nhãn runner, và xử lý lỗi thiết lập runner.
formatting-slack-messages
41kGiúp agent của bạn tạo tin nhắn, modal và màn hình chính trên Slack rõ ràng, đúng bố cục, và kiểm tra theo quy tắc hiện hành của Slack.
Skill tương tự
add-model-provider
394kGiúp agent của bạn kết nối nhà cung cấp mô hình AI mới với OpenClaw bằng lệnh an toàn, giữ API key khỏi văn bản thuần và chạy thử.
acp-router
394kGiúp agent của bạn gửi một tác vụ đến trợ lý lập trình như Claude Code hoặc Cursor qua OpenClaw, để công việc chạy ngay trong công cụ đó.
browser-automation
394kHướng dẫn agent của bạn điều khiển trang web từng bước, gồm đăng nhập, tab và cách khôi phục khi trang ngừng phản hồi.