Chuyển đến nội dung
Skillpedia
Lập trình chung12k · #11523

pit-of-success

Skill này làm gì

Skill hướng dẫn AI tìm các lệnh gọi API, setter và prop có thể bị dùng sai, rồi chuyển hành vi cần thiết vào mã dùng chung. Dành cho lập trình viên review hoặc tái cấu trúc mã.

Khi nào nên dùng

  • ✓Khi một API, setter hoặc prop của thành phần có bẫy mà lệnh gọi tự nhiên có thể rơi vào.
  • ✓Khi bạn tái cấu trúc mã để đường đi an toàn trở thành mặc định.
  • ✓Khi bạn muốn thay các hàm trợ giúp hoặc wrapper trùng lặp bằng một triển khai dùng chung duy nhất.

Liên kết skill

https://github.com/trycompai/crm/blob/release/.agents/skills/pit-of-success/SKILL.md

Sao 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

Hãy dùng skill này để giúp tôi: https://github.com/trycompai/crm/blob/release/.agents/skills/pit-of-success/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Setter này bị lỗi khi ai đó truyền null. Bạn có thể sửa mã để lệnh gọi thông thường luôn hoạt động không?”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

AI tìm mọi nơi gọi điểm vào công khai, kiểm tra xem lệnh gọi tự nhiên có làm sai hành vi không, rồi chuyển quy tắc vào mã dùng chung.

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.

Pit of Success

Make misuse hard and the obvious call correct.

Steps

  1. Find the public seam being used: exported function, hook return value, setter, component prop, route body, schema, or command. Then search every caller of that seam. Done when you know the natural call a future maintainer would write.
  2. Run the footgun test: “If someone does the obvious thing without knowing the hidden helper or convention, does behavior break?” Examples: setSelection(null) should mean the product’s normal clear behavior; a schema should reject states the UI never wants; a prop should not require sibling props in the right combo.
  3. Move the invariant into the seam. Prefer, in order:
    • make the existing API do the safe thing,
    • narrow the type/schema so bad states cannot be represented,
    • rename/split the API so the dangerous path is explicit,
    • only then add a helper, and only if all natural callers use it.
  4. Delete bypasses and duplicate meanings. Replace local wrappers, parallel helper names, and comments that explain the trap with one shared implementation at the seam.
  5. Prove the pit with one check: a focused test or type/schema assertion showing the obvious call now preserves behavior, plus a grep confirming no caller still uses the old footgun.

Rules

  • Do not fix only the named callsite. If the seam is wrong, fix the seam.
  • Do not rely on “remember to call this helper first” when callers can still call the raw API.
  • Do not add comments as a substitute for making misuse impossible or obvious.
  • Keep the diff boring: one invariant, one owner, no speculative abstraction.
  • If compatibility prevents changing the seam, name the dangerous API accordingly and expose a safe default API beside it.
Câu hỏi thường gặp

Nó chỉ sửa một nơi gọi không?

Không. Khi chính API sai, skill yêu cầu sửa điểm nối dùng chung thay vì một nơi gọi.

Skill ưu tiên thứ tự sửa nào?

Nó ưu tiên làm cho API hiện có an toàn trước, sau đó thu hẹp kiểu, rồi tách API, và thêm hàm trợ giúp cuối cùng.

Làm sao để chứng minh bản sửa?

Nó dùng một bài kiểm thử hoặc kiểm tra kiểu tập trung để chỉ ra lệnh gọi tự nhiên giờ đã hoạt động, cùng một lần tìm kiếm để xác nhận không còn nơi gọi cũ.

Chi tiết

Mô tả gốc của tác giả

Review or refactor code so the correct behavior is the default path; use when APIs, setters, hooks, helpers, or component props have footguns where a natural call bypasses required semantics.

repo: trycompai/crm

Độ phổ biến

Sao GitHub
12k
Vị trí xếp hạng
#11523
Giấy phép
MIT
Cập nhật
1/11/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự