lean-comments
Skill này làm gì
Công cụ này giúp mã chương trình gọn gàng và dễ hiểu. Nó kiểm tra xem các chú thích có thật sự cần thiết không và có giải thích “vì sao” không, thay vì chỉ lặp lại điều mã đã thể hiện.
Khi nào nên dùng
- ✓Khi bạn thêm chú thích mới vào mã.
- ✓Khi bạn xem lại các chú thích hiện có để đảm bảo chúng hữu ích.
- ✓Khi mã khó hiểu và cần một lời giải thích rõ ràng.
Liên kết skill
https://github.com/github/awesome-copilot/blob/main/skills/lean-comments/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
“Hãy xem lại các chú thích trong đoạn mã này để đảm bảo chúng thật sự cần thiết và giải thích được 'vì sao'.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Công cụ xem xét liệu một lập trình viên có kinh nghiệm có mất thông tin quan trọng nếu chú thích không có mặt hay không. Nó ưu tiên xóa những chú thích chỉ lặp lại mã hoặc quá hiển nhiên.
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.
Lean Comments
Goal
Keep the smallest amount of high-value commentary necessary to make a codebase easier and safer to understand and maintain.
The default is no comment.
A comment must preserve meaningful information that a competent maintainer cannot reasonably recover from the code, names, types, signatures, structure, tests, configuration, or nearby context.
Comments are not labels, narration, decoration, declaration summaries, change logs, or substitutes for clear code.
Reader model
Write for a competent maintainer reading the repository at HEAD months later, without access to the current conversation, prompt, diff, pull request, issue discussion, review discussion, or implementation process.
Document the durable state, contract, constraint, or rationale of the code as it exists. Do not assume the reader knows what changed, what came before, or what was discussed unless that context is deliberately preserved in a reliable project source.
Authority and evidence
Use this skill as the comment-policy authority when it is active.
Use language, framework, library, or infrastructure skills to determine whether a non-obvious constraint is real, not to override this skill's necessity test.
Honor explicit current repository requirements, public API documentation requirements, tooling contracts, and generated-source rules. Do not infer a documentation requirement merely from existing comment density or precedent.
Base retained or newly written rationale on evidence from the repository, tests, configuration, official API behavior, project documentation, issue tracker, ADRs, specifications, or another reliable source.
Never invent a security reason, performance reason, business rule, compatibility requirement, API constraint, historical reason, architectural rationale, or external limitation to justify commentary.
If no supported non-obvious reason exists, remove or omit it.
Core decision rule
Before retaining or adding ordinary commentary, mentally remove it and ask:
Would a competent maintainer lose meaningful, non-obvious information if this comment did not exist?
If no, remove or omit it.
If uncertain, prefer no comment unless repository evidence demonstrates that the information matters.
If yes, retain only the minimum information necessary.
Never preserve a comment merely because it is correct, harmless, already present, grammatically polished, written as a warning, related to security or validation, related to internal or public state, or attached to an exported declaration.
The information itself must justify the comment.
Decision order
Evaluate existing and proposed commentary in this order:
- Delete or omit if the information is already clear without it
- Express through code if a tiny behavior-preserving readability improvement removes the need for it
- Shorten if it is necessary but contains unnecessary information or words
- Rewrite if it is necessary but unclear, inaccurate, stale, awkward, or inconsistent
- Use declaration documentation if the information belongs to the declaration's contract, semantics, or intended usage
- Keep unchanged only if it is already necessary, minimal, accurate, durable, and correctly styled
Always decide necessity before wording.
Do not polish an unnecessary comment or convert one into documentation.
What deserves an implementation comment
Use an implementation comment when it preserves non-obvious information such as:
- Why intentionally surprising code exists
- An external constraint or compatibility requirement
- An important invariant or subtle edge case
- A meaningful tradeoff or required workaround
- Non-obvious coupling
- An ordering, timing, lifecycle, concurrency, performance, or security constraint
- A reason an apparently simpler implementation would be incorrect
Prefer comments that explain why something matters.
Comments that merely explain what the code does should normally be removed.
Remove low-value commentary
Remove comments that merely:
- Restate or translate the code into prose
- Narrate the next statement or obvious control flow
- Explain an obvious guard clause, return, assignment, or branch
- Describe an obvious fetch, validation, transformation, mapping, filtering, creation, update, or deletion
- Repeat a declaration name, property name, type, signature, parameter, or return type
- Label or summarize a declaration
…
Câu hỏi thường gặp
“Mã nguồn” là gì?
Đó là văn bản do lập trình viên viết, cho máy tính biết phải làm gì. Nó giống như công thức nấu ăn cho máy tính.
“Chú thích” trong mã là gì?
Đó là các ghi chú trong mã mà lập trình viên dùng để giải thích phần khó hiểu hoặc lý do của một quyết định. Máy tính bỏ qua chúng.
Vì sao chú thích tốt lại quan trọng?
Chú thích tốt giúp các lập trình viên khác (hoặc chính bạn trong tương lai) hiểu mã nhanh hơn, từ đó dễ bảo trì và sửa lỗi hơn.
Chi tiết
Mô tả gốc của tác giả
Audits, writes, and refines maintained first-party source-code comments and declaration-level documentation across languages. Use when adding, editing, reviewing, cleaning up, or auditing comments, doc comments, docstrings, TODO, FIXME, NOTE, suppressions, or other source commentary, including while modifying code and deciding whether a comment is warranted at all. Defaults to no comment unless it
repo: github/awesome-copilot
Độ phổ biến
- Sao GitHub
- 40k
- Vị trí xếp hạng
- #7268
- Giấy phép
- MIT
- Cập nhật
- 15/10/2026
Bình luận
- …
Thêm skill từ kho mã này
acquire-codebase-knowledge
40kGiúp agent của bạn hiểu và ghi tài liệu cho một dự án mã nguồn có sẵn. Hữu ích khi đón thành viên mới hoặc nắm tổng quan về kiến trúc.
acreadiness-assess
40kGiúp agent của bạn đánh giá mức độ sẵn sàng cho AI của dự án và tạo báo cáo. Hữu ích để biết dự án đã sẵn sàng dùng công cụ AI đến đâu.
acreadiness-generate-instructions
40kGiúp agent của bạn tạo hướng dẫn cho công cụ AI dựa trên kết quả đánh giá. Hữu ích để cải thiện cách AI làm việc với mã và khắc phục các khoảng trống.
acreadiness-policy
40kGiúp agent của bạn xác định hoặc áp dụng chính sách đánh giá dự án bằng AI. Hữu ích để chuẩn hóa cách đánh giá dự án và đảm bảo tuân thủ.
Skill tương tự
technical-documentation
394kGiúp agent của bạn viết và rà soát tài liệu kỹ thuật cùng file hướng dẫn cho agent, rõ ràng để mọi người và công cụ AI đều dễ làm theo.
architecture-decision-records
280kGiúp agent của bạn ghi lại các quyết định quan trọng về cấu trúc dự án, giúp hiểu lý do đằng sau các lựa chọn và giữ lịch sử thay đổi rõ ràng.
code-tour
280kGiúp agent của bạn tạo các hướng dẫn đọc code từng bước, có tham chiếu chính xác đến file và dòng, hữu ích cho phần giới thiệu, giải thích và rà soát.