Skip to content
Skillpedia
General coding40k · #5273

poka-yoke

Helps your agent create code that is hard to misuse. This prevents common errors and makes using the code safer and easier.

What it does

Poka-yoke is a technique for creating systems (like computer code) that make mistakes impossible. Instead of warning about an error, it prevents the error from happening.

When to use it

  • ✓When designing a new interface or system.
  • ✓When reviewing old code to find failure points.
  • ✓When you want to ensure users cannot put the system into an invalid state.

Example of what to ask your AI

“How can I make this form impossible to submit with missing information?”

Want more? Open the sections below.

How to use

The easiest way: copy the message below and paste it into Claude, ChatGPT, Cursor or any AI. It reads the skill and follows the instructions.

Skill link

https://github.com/github/awesome-copilot/blob/main/skills/poka-yoke/SKILL.md

Ready-to-paste message

Use this skill to help me: https://github.com/github/awesome-copilot/blob/main/skills/poka-yoke/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
How it works

It works by creating rules or structures that physically prevent incorrect actions. Think of a USB cable that only fits one way: you can't get it wrong.

Installation

Easiest way: copy the skill link and paste it into Claude, ChatGPT or Cursor asking it to follow the instructions.

In the terminal (Claude Code, Codex, Cursor), in your project folder:

npx skills add github/awesome-copilot --skill poka-yoke

Or download just the file:

curl -L https://raw.githubusercontent.com/github/awesome-copilot/main/skills/poka-yoke/SKILL.md -o SKILL.md
Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

Poka-Yoke: Make the Mistake Unsayable

People will always make mistakes. That is not the problem worth solving. The problem is letting a mistake become a defect.

Shigeo Shingo, a Japanese industrial engineer, worked this out on a switch assembly line in 1961. Workers kept forgetting a spring. The fix was not a reminder: the job was split so the worker first laid both springs in a dish, then fitted them from the dish. A spring left over was the error announcing itself, before the unit could move on.

The dish is a device. "Please remember the spring" is not.

The line that does most of the work

A comment, a docstring, a wiki page, a review checklist, or a line in an instructions file saying "don't do X" is not a poka-yoke. It is training, and training degrades. A device does not. If your fix relies on someone remembering something, keep going.

This applies to your own instructions too. A rule written into a config file competes for attention with every other rule there and loses a little more as the file grows. A check that fails the build does not.

What this changes about the output

Given a design, models will readily list what to fix. They rarely state what the fix makes impossible, and that is the difference between advice you agree with and a constraint you can rely on. That habit is most of what this skill is for.

The other half is refusing to accept a non-device as a fix. "Add validation", "be careful with this function", "document the invariant" are all rung zero. Each has a real device behind it, and naming that device is the work.

Axis 1: what happens when the mistake occurs

Rank every finding on this ladder, and say which rung the current code sits on and which rung your fix reaches.

Rung Name Meaning
1 Control The wrong action cannot be performed. Type error, database constraint, missing permission.
2 Warning It is possible, but announces itself as it happens. A linter, a runtime assertion, a confirmation you cannot skip.
3 Detection It happens, and you find out afterwards. Tests, logging, monitoring, code review.
0 rung zero Telling people to be careful. Docs, comments, "please remember to".

Detection is not failure; sometimes it is all that is available. But a plan that stops at Detection should say so, rather than presenting it as prevention.

Axis 2: how the device notices

Shingo's three inspection lenses. They are a checklist for finding hazards, not decoration:

  • Contact — can the wrong thing physically fit? Two adjacent parameters of the same type can be swapped silently. A string that should be one of four values. Money as a float.
  • Fixed-value — is the set complete? A switch with no exhaustiveness check. A config where a missing key silently means "off". An enum handled in three of five places.
  • Motion-step — is the order right, and did every step happen? A two-phase write with no transaction. A retry with no idempotency key. A resource acquired on one path and released on another.

Inspect at the source

The cheapest place to catch a mistake is where it is made, not where it surfaces. A validation that runs three layers below the input has already let the bad value travel, and the stack trace will point at the wrong module. Push the check to the boundary the value crosses.

Designing something new

Mistake-proofing is cheapest before the code has callers. Once it has them, every device is a migration; before it has them, a device is free.

Work from the call site. A signature that reads fine in isolation often reads terribly where it is used:

# the mistake is expressible: nothing stops refunding an order that was never paid
def refund(order: dict) -> Refund:
    return payments.refund(order["payment_id"])

# the mistake is no longer expressible
def refund(order: PaidOrder) -> Refund: ...

The moves, roughly in order of how often they apply:

Make invalid states unrepresentable. A bag of optional fields where only certain combinations are legal becomes a discriminated union where the illegal ones cannot be constructed.

Parse, don't validate. Convert unstructured input into a type that carries proof at the boundary, once, rather than re-checking the same string in nine places.

Distinguish concepts that share a primitive. transfer(from: str, to: str) accepts its

…

FAQ

What's the difference between a warning and a poka-yoke?

A warning says 'be careful, this might go wrong.' A poka-yoke physically prevents you from doing something wrong, like a cable that only fits one way.

Why is it better to prevent errors than to warn about them?

People forget or ignore warnings. An error-proof system ensures the mistake doesn't happen, regardless of human attention.

Is this only for computer code?

No, the original idea comes from industrial engineering to prevent manufacturing errors. But the concept applies to any system where mistakes can occur.

Details

Original description by the author

Mistake-proof code so misuse cannot be expressed, rather than warning against it. Use when designing an interface, schema, or state machine and the user wants it hard to get wrong ("make invalid states unrepresentable", "so callers cannot screw it up", "type-safe API", "pit of success"); when auditing existing code for footguns ("what could bite us here", "what is easy to misuse", "poka-yoke this

repo: github/awesome-copilot

Popularity

GitHub stars
40k
Ranking position
#5273
License
MIT
Updated
10/15/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills