Zum Inhalt springen
Skillpedia
Allgemeines Programmieren40k · #7330

poka-yoke

Was er macht

Poka-yoke ist eine Technik, um Systeme (zum Beispiel Computercode) so zu bauen, dass Fehler gar nicht erst passieren können. Statt vor einem Fehler zu warnen, verhindert sie ihn von vornherein.

Wann du ihn nutzt

  • ✓Wenn du eine neue Oberfläche oder ein neues System entwirfst.
  • ✓Wenn du alten Code durchsiehst, um Schwachstellen zu finden.
  • ✓Wenn du sicherstellen willst, dass Nutzer das System nicht in einen ungültigen Zustand bringen können.

Link zum Skill

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

Kopiere ihn und füge ihn in deine KI ein (Claude, ChatGPT oder Cursor) mit der Bitte, den Anweisungen zu folgen.

So nutzt du ihn

Am einfachsten: Kopiere die Nachricht und füge sie in deine KI ein. Sie liest den Skill und folgt den Anweisungen.

Fertige Nachricht zum Einfügen

Nutze diesen Skill, um mir zu helfen: https://github.com/github/awesome-copilot/blob/main/skills/poka-yoke/SKILL.md Lies die SKILL.md unter diesem Link und folge ihren Anweisungen für meine Aufgabe.
Soll deine KI Skills wie diesen selbst finden?Installiere den kostenlosen Skillpedia-MCP: eine Zeile, und sie durchsucht vor jeder Aufgabe 15.000+ Skills.In 1 Minute installieren →

Beispielanfrage an deine KI

“Wie kann ich dieses Formular so bauen, dass es nicht abgeschickt werden kann, wenn Angaben fehlen?”

5 neue Skills pro Woche. 1 Minute Lesezeit.

So funktioniert es

Sie funktioniert, indem Regeln oder Strukturen geschaffen werden, die falsche Aktionen praktisch unmöglich machen. Stell dir ein USB-Kabel vor, das nur auf eine Weise passt: Du kannst es nicht falsch herum einstecken.

Technischer Inhalt (originale SKILL.md)

Originaltext des Autors, auf Englisch, direkt von 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

…

Häufige Fragen

Was ist der Unterschied zwischen einer Warnung und einem Poka-yoke?

Eine Warnung sagt: „Pass auf, hier könnte etwas schiefgehen.“ Ein Poka-yoke verhindert dagegen, dass du etwas falsch machst, so wie ein Kabel, das nur auf eine Weise passt.

Warum ist es besser, Fehler zu verhindern, als vor ihnen zu warnen?

Menschen vergessen Warnungen oder überlesen sie. Ein fehlersicheres System sorgt dafür, dass der Fehler nicht passiert, egal wie aufmerksam die Person gerade ist.

Gilt das nur für Computercode?

Nein, die ursprüngliche Idee stammt aus der Industrie, wo Fertigungsfehler vermieden werden sollten. Das Konzept lässt sich aber auf jedes System anwenden, in dem Fehler passieren können.

Details

Originalbeschreibung des Autors

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

Beliebtheit

GitHub-Sterne
40k
Platz im Ranking
#7330
Lizenz
MIT
Aktualisiert
15.10.2026

Ist dieser Skill nützlich?

0

Anmelden um abzustimmen.

Kommentare

  • …

Weitere Skills aus diesem Repository

Ähnliche Skills