poka-yoke
Skill này làm gì
Poka-yoke là kỹ thuật làm cho quy trình hoặc mã không thể mắc lỗi. Thay vì phụ thuộc vào việc con người nhớ làm mọi thứ đúng, hệ thống được thiết kế sao cho lỗi hoặc là không thể xảy ra, hoặc là dễ thấy ngay.
Khi nào nên dùng
- ✓Khi bạn muốn ngăn lỗi xảy ra trong một quy trình hoặc mã.
- ✓Khi thiết kế hệ thống mà lỗi có thể gây hậu quả nghiêm trọng (tiền bạc, dữ liệu quan trọng).
- ✓Khi một lỗi lặp lại, bạn muốn đảm bảo nó không xảy ra nữa.
Liên kết skill
https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/poka-yoke/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
“Làm thế nào để biểu mẫu đăng ký này không cho phép mắc lỗi, để người dùng không thể gửi thông tin không hợp lệ?”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Poka-yoke hoạt động bằng cách tạo ra các “thiết bị” ngăn lỗi. Đó có thể là một kiểu dữ liệu cụ thể, một quy tắc không cho tiếp tục nếu có gì sai, hoặc một cảnh báo rõ ràng ngay tại thời điểm xảy ra lỗi.
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.
Poka-Yoke: Mistake-Proofing for Software
Shigeo Shingo's insight, from the Toyota Production System: people will always make mistakes; that is not the problem worth solving. The problem is letting a mistake become a defect. So you stop trying to make humans more careful and start redesigning the work so the mistake either cannot physically happen or announces itself immediately.
A poka-yoke ("poh-kah yoh-kay", ポカヨケ) is a device: a jig, a shape, a counter: not an instruction. In software: a type, a constraint, a hook, a schema, a state machine. The single most important consequence:
A comment, a docstring, a wiki page, a code review checklist, or a line in CLAUDE.md saying "don't do X" is not a poka-yoke. It is training. Training degrades. A device does not. If your proposed fix relies on someone remembering something, keep going.
When to Use This Skill
- Use when the user says "poka-yoke this", "mistake-proof it", or "make this harder to get wrong".
- Use when designing an interface, schema or state machine and the ask is "make invalid states unrepresentable" or "so callers cannot screw it up".
- Use when auditing existing code for footguns: "what could bite us here", "what is easy to misuse".
- Use after an incident, when the fix must close the class rather than the case: "make sure this never happens again", "this is the third time".
- Especially for money, auth, permissions, deletion, migrations and pipelines, where failure is silent.
The two axes
Every real poka-yoke answers two questions. Use both when you classify a hazard or propose a device. They are the difference between this method and generic code review.
Axis 1, Regulatory function: what happens when the mistake occurs?
This is a strict preference ladder. Always reach for the highest rung you can afford.
| Rung | Name | What it does | Software examples |
|---|---|---|---|
| 1 | Control | The mistake is impossible. The work cannot proceed. | Type won't compile · NOT NULL / CHECK / unique constraint · required function argument · private constructor + smart constructor · PreToolUse hook returns deny · protected branch |
| 2 | Warning | The mistake is possible but announced at the moment it happens. | Lint error in the editor · failing CI gate · runtime assertion that throws · confirmation prompt naming the exact thing being destroyed |
| 3 | Detection | The mistake ships, and something finds it afterward. | Tests · monitoring · alerting · reconciliation job |
| 0 | (not a poka-yoke) | Relies on a human remembering. | Docs · comments · training · "be careful" · review checklists |
Shingo's rule: prefer control over warning, always, and only settle for warning when control is genuinely too expensive, then say why out loud. In software the honest reason is usually "the language can't express it" or "it would break every existing caller," and both are worth stating explicitly so the tradeoff is visible.
Axis 2, Setting function: how does the device notice?
Shingo's three detection methods map cleanly onto software. These are your inspection lenses, run all three over any interface and you will find hazards that a general code review misses.
| Method | Factory floor | The question to ask code | Software devices |
|---|---|---|---|
| Contact | The part physically won't seat unless it's the right shape and orientation | Can the wrong thing fit? | Distinct types instead of shared primitives · branded/newtype IDs · parse-don't-validate at boundaries · units in the type · discriminated unions instead of bags of optionals |
| Fixed-value | A counter says all 6 screws were fitted | Can the wrong count or an incomplete set pass? | Exhaustive match/switch over an enum · required fields · "all migrations applied" check · row-count guard on a bulk write · checksums · config validated as a whole at boot |
| Motion-step | A sensor confirms step 3 happened before step 4 | Can the steps happen in the wrong order, or be skipped? | Typestate · builder that cannot .build() until required steps run · state machines with illegal transitions unrepresentable · idempotency keys · RAII / defer / context managers · transactions |
The third principle: inspect at the source
Shingo separated source inspection from informative inspection, which finds the defect
…
Câu hỏi thường gặp
Điều gì KHÔNG phải là poka-yoke?
Poka-yoke không phải là một chú thích trong mã, một hướng dẫn trong tài liệu hay một danh sách kiểm tra. Những thứ đó phụ thuộc vào trí nhớ con người và có thể bị quên. Poka-yoke là một quy tắc hoặc cấu trúc nằm bên trong chính hệ thống.
Các cấp độ poka-yoke là gì?
Có ba cấp độ: Kiểm soát (lỗi không thể xảy ra), Cảnh báo (lỗi được báo ngay tại thời điểm đó) và Phát hiện (có gì đó tìm ra lỗi sau đó). Lý tưởng là luôn hướng đến cấp Kiểm soát.
Poka-yoke nhận diện lỗi bằng cách nào?
Nó dùng ba phương pháp: Tiếp xúc (phần sai sẽ không lắp vừa), Giá trị cố định (số lượng hoặc tập hợp không đúng), và Bước chuyển động (các bước xảy ra sai thứ tự hoặc bị bỏ qua).
Chi tiết
Mô tả gốc của tác giả
Mistake-proof code, config and process: make the wrong action impossible or self-announcing rather than documented.
Độ phổ biến
- Sao GitHub
- 48k
- Vị trí xếp hạng
- #5461
- Giấy phép
- MIT
- Cập nhật
- 15/10/2026
Bình luận
- …
Thêm skill từ kho mã này
00-andruia-consultant
48kGiúp agent của bạn bắt đầu hoặc cải thiện các dự án AI. Phân tích mã, gợi ý công cụ và lập kế hoạch hành động bằng tiếng Tây Ban Nha.
007
48kCho phép agent của bạn thực hiện kiểm toán bảo mật và mô hình hóa mối đe dọa. Hữu ích để bảo vệ dự án khỏi các cuộc tấn công và lỗ hổng.
10-andruia-skill-smith
48kGiúp agent của bạn tạo hoặc cải thiện các công cụ AI. Xác định cách công cụ hoạt động, viết tài liệu và kiểm tra cấu trúc.
20-andruia-niche-intelligence
48kGiúp agent của bạn tạo bản tóm tắt về một ngành cụ thể. Hữu ích để hiểu bối cảnh, quy tắc, cách người dùng tương tác và rủi ro của dự án.
Skill tương tự
diffs
394kGiúp agent của bạn tạo một diff có thể chia sẻ về các chỉnh sửa, dưới dạng liên kết xem hoặc file ảnh, thay vì một bản tóm tắt viết tay.
coding-agent
394kGiúp agent của bạn giao một việc lập trình lớn cho Codex, Claude Code hoặc OpenCode chạy nền, rồi theo dõi tiến độ của nó.
gh-issues
394kGiúp agent của bạn tìm issue trên GitHub, chọn những issue cần xử lý và mở pull request với bản sửa, kể cả theo dõi nhận xét đánh giá.