Synthèse automatique
Ce skill guide l'agent pour transformer les états « censés ne jamais arriver » en états impossibles, en définissant des invariants inductifs avec un propriétaire clair et en les faisant respecter aux frontières de parsing, de construction, d'API, de base de données, de verrou et de transaction.
Points forts
- Fournit un modèle conceptuel précis (invariant, inductif, propriétaire, pré/postcondition, sûreté vs vivacité) qui évite les confusions fréquentes
- Propose une échelle de protection graduée, de l'espoir au typage compile-time en passant par la validation aux frontières et les contraintes de persistance
- Impose une démarche par contre-exemple concret (trace d'entrées, transitions, ordonnancement) plutôt que par intuition
- Couvre explicitement les cas difficiles : courses, doublons, événements hors ordre, idempotence, versionnement et correction de boucles
Limites
- Les étapes détaillées du protocole sont tronquées dans le fichier fourni, ce qui rend la procédure complète impossible à suivre telle quelle
- Suppose que l'agent sait déjà identifier le propriétaire de l'état ; en cas d'échec, le skill renvoie vers une phase de clarification sans fournir d'outillage
- S'appuie sur des commandes associées (/tw-fix, /tw-tk) propres à un écosystème, ce qui limite la portabilité
- Aucun exemple de code concret n'est fourni pour illustrer la mise en œuvre des invariants
À utiliser lorsqu'une tâche révèle des états impossibles, une dérive de cache ou d'index, des races, des doublons ou des branches « unreachable » devenues atteignables.
À éviter pour des demandes d'implémentation large sans indice d'invariant ou lorsque le propriétaire de l'état ne peut pas encore être identifié.
Analyse de sécurité
SûrThe skill is purely advisory methodology prose about defining and enforcing invariants. It contains no shell commands, no network calls, no file/credential access, no obfuscated payloads, and it does not instruct the agent to disable safety checks or take destructive actions. No tools are declared, so the listing introduces no meaningful execution risk.
Aucun point d'attention détecté
Comment cette analyse est faiteExemples
Our users table has a denormalized post_count column and it keeps drifting from the posts table; a nightly fix-up job reconciles it. Help me define invariants and make the drift impossible instead of patching it.Retries and out-of-order webhooks sometimes cause double charges and stale writes. Work out the invariants for idempotency keys and version checks, name the owner, and tell me where to enforce them.We keep seeing 'should never happen' errors in the error tracker for our order state machine, and flags produce impossible combinations. Find the counterexample trace and restructure the states so illegal ones can't be built.name: tw-invariant-ace description: "Turn 'should never happen' into 'cannot happen' by defining owned inductive invariants and enforcing them at parse/construct/API/DB/lock/txn boundaries with a verification signal. Use when prompts mention invariants, impossible states, validation sprawl, cache/index drift, idempotency/versioning, retries/duplicates/out-of-order events, race/linearization bugs, loop correctness, or hardening another workflow (for example /tw-fix) with invariant checks first."
Invariant Ace
Mission
Turn "should never happen" into "cannot happen" with minimal, high-leverage changes: pick owned, inductive invariants; enforce them at the strongest cheap boundary; prove via a concrete counterexample trace and a verification signal.
Use When (Signals)
- Null/shape surprises, runtime validation sprawl, or input decoding scattered across the codebase.
- Redundant stored facts drift (cache/index/denormalized columns) or "fix-up" code runs often.
- Flags/states explode; impossible combinations appear; "unreachable" is reachable.
- Races, duplicate/out-of-order events, retries, partial failures, or "exactly once" assumptions.
- Idempotency keys, monotonic version/epoch checks, stale writes, or linearization questions are central.
- Loop/algorithm correctness depends on comments or intuition; tricky indexing/arithmetic/termination.
- "Should never happen" branches show up in logs or error trackers.
Routing Priority
- If a task has invariant/protocol cues and also asks for broad implementation (
/tw-tk,/tw-fix), run this skill first to lock invariants, then execute edits. - If you cannot name state owner + transitions, switch to clarification/discovery before implementation.
Core Model (Fast Definitions)
- Invariant: predicate P(state) intended to hold for all reachable states in a scope.
- Inductive: true initially AND preserved by every allowed transition in that scope.
- Owner: the single module/type/transaction/lock/actor that controls all mutations needed to preserve P.
- Precondition/postcondition: caller obligation vs operation guarantee; do not mislabel these as invariants.
- Derived property: recomputable fact; avoid storing it as "must match" unless you centralize updates.
- Safety vs liveness: invariants are safety ("nothing bad"); keep progress ("eventually") separate.
Immediate Scan
- State owner: where does the truth live (type/module/service/table)?
- State boundary: where does raw data enter (API/DB/file/queue)?
- Allowed transitions: list operations/events that mutate the state (including retries and concurrency).
- Failure today: one concrete trace (inputs + transitions + schedule) that reaches a bad state.
- Protection level: hope -> runtime -> construction-time -> type/compile-time -> persistence/protocol/atomicity.
- Pain tag(s): data | concurrency/protocol | algorithm/loop (often multiple).
Protection Ladder
Choose the cheapest strong layer that makes the violation hard or impossible.
- Hope-based: comments, assumptions, "unreachable".
- Runtime: scattered guards/validators near use sites.
- Construction-time: parse/validate once at boundaries; core code only handles refined values.
- Type/compile-time: illegal states are unrepresentable (ADTs, typestates, opaque wrappers).
- Persistence: schema/constraints/transactions enforce invariants at rest.
- Concurrency boundary: locks/actors/CAS/txns define where invariants must hold (under lock, at commit, at linearization).
Protocol (Counterexample-Driven)
-
Declare scope + owner.
- Write "P holds when/where": always | after construction | under lock | at txn commit | after message apply.
- If you cannot name an owner, the invariant will drift; pick a choke point first.
-
List transitions and try to break P.
- For each transition (and retry/out-of-order variants), attempt a counterexample trace.
- If P fails, decide: bug vs wrong scope vs missing state vs wrong owner.
-
Make P inductive (or downgrade it).
- Weaken P, move it to pre/postconditions, or add auxiliary state (version/epoch/status/idempotency key) until it closes under transitions.
-
Run a coordination check (concurrency/distributed).
- Ask: can two individually-valid concurrent transitions merge into a P-violating state?
- If yes, you need coordination (lock/txn/consensus) OR you must redesign the invariant/operation (partition, escrow, monotone merges, idempotency).
-
Encode enforcement at the strongest cheap boundary.
- Prefer: parser/decoder + smart constructors + narrow/opaque types + centralized mutation.
- Avoid: N scattered validators, duplicated truths without a single writer, and "fix-up" routines on every read.
-
Add observability if full enforcement must be staged.
- Add cheap tripwires (assert/log/metric) and quarantine paths (reject/dead-letter/compensate).
- Record replayable context (transition name, IDs, versions), not raw secrets.
-
Verify with the right harness.
- Data: fuzz/property tests on parsers/constructors.
- State machines: stateful/model-based tests (sequences).
- Concurrency: stress + schedule perturbation; assert at quiescent points.
- Protocols: small model checking/simulation for drops/dupes/reorder.
- Algorithms: invariant assertions in loops + differential tests vs reference.
Compact Mode (Fast Path)
Use this when the task is small or time-boxed.
- Counterexample: one concrete failing trace (<=5 transitions).
- Invariants: 1-2 predicates with explicit owner + scope.
- Enforcement Boundary: one chosen choke point (parse/construct/API/DB/lock/txn).
- Verification: one signal tied to one predicate.
Escalate to full protocol if any of the above is ambiguous or non-inductive.
Invariant Record (Use This Format)
- Predicate: P(state) (precise, checkable)
- Owner: module/type/service/table/lock/txn
- Holds: always | after construction | under lock | at commit | after apply
- Maintained by: transitions that must preserve P
- Enforced at: parse/construct/API/DB/lock/txn/protocol
- Counterexample to avoid: minimal trace that breaks it today
- Verification: property/stateful/stress/model/differential
Patterns by Pain
Data Modeling & Input Validity
- Boundary refinement: raw -> parsed -> validated; only validated enters core.
- Canonicalization: normalize early (case/whitespace/timezone/ID format) so equality and caching are stable.
- Explicit absence: model optionality explicitly; avoid "sometimes null" in the core.
- Cross-field coupling: combine coupled fields into one value to prevent illegal combinations.
- Denormalization discipline: if you store derived facts, centralize writes or make them recomputed.
Concurrency & Protocol Correctness
- Lock/txn invariants: P holds under lock or at commit; define where the linearization point is.
- Monotonic metadata: versions/epochs/counters only increase; reject stale writes.
- Idempotency: retries and duplicates are safe (idempotency keys, dedupe tables, "apply once").
- Explicit state machines: enumerate states + allowed transitions; persist enough metadata to reject out-of-order events.
- Coordination decisions: if P depends on global uniqueness or non-negativity under concurrent debits, choose coordination or redesign (partition/escrow).
Algorithms & Loop-Heavy Code
- Loop invariants: assert what is preserved each iteration (partitioned regions, sorted prefix, conservation laws).
- Variant/termination: name a decreasing measure; if you cannot, expect non-termination edges.
- Representation invariants: hide internal structure behind an API; add a rep-check for tests/debug.
- Differential testing: compare to a simple, slow reference implementation to catch corner cases.
Before/After Sketches (Language-Agnostic)
Boundary Refinement (Data)
Before: functions accept RawInput and validate ad hoc
After: parseRaw(...) -> ValidatedValue | Error
core functions accept ValidatedValue only
Idempotency + Versioning (Concurrency/Protocol)
Before: handle(event) mutates state directly (retries duplicate side effects)
After: if seen(event.id) return
if event.version <= state.version return (or reject)
apply(event) at a single atomic boundary (lock/txn/CAS)
Loop Invariant (Algorithm)
Before: comment says "array left side is partitioned"
After: assert(invariant(state)) inside loop
test: random arrays, shrink failing cases, compare to reference
Verification
Pick at least one signal and tie it to a specific invariant predicate.
- Property/fuzz: parsers, constructors, normalization.
- Stateful/model-based: sequences over operations; check invariants after each step.
- Concurrency stress: N threads + jitter; assert invariants at quiescent points.
- Protocol simulation: reorder/duplicate/drop + crash/restart; assert safety invariants.
- Model checking (optional): small state + exhaustive exploration for protocols.
- Differential/reference: algorithm output equals reference for randomized inputs.
- Runtime tripwires: assertions/logging/metrics for staged rollout.
Research Anchors (Mental Models, Not Requirements)
- Hoare/Floyd/Dijkstra: invariants as proof objects; weakest preconditions.
- ADT/rep invariants (Liskov-style): abstraction function + local reasoning.
- Abstract interpretation: over-approx reachable states; inferred invariants.
- Dynamic invariant mining (Daikon-style): candidate generation; falsify with counterexamples.
- Separation logic / framing: invariants tied to ownership; interference-aware reasoning.
- Rely-guarantee & linearizability: concurrency invariants under schedules.
- TLA+/Alloy mindset: protocols as transitions + invariants; counterexample traces.
- Coordination avoidance / CRDT laws: when invariants require coordination vs merge-safe design.
Output Contract (Required Headings)
Use these exact headings in the final response for this skill:
- Counterexample
- Invariants
- Owner and Scope
- Enforcement Boundary
- Seam (Before -> After)
- Verification
- Observability (optional)
Deliverable Checklist
- Counterexample: minimal breaking trace (include schedule/retry if relevant).
- Invariants: 1-5 predicates with owner + scope ("holds when").
- Enforcement Boundary: boundary/type/API/DB/lock/txn/protocol choice + why.
- Seam (Before -> After): minimal structural change that makes violations hard.
- Verification: property/stateful/stress/model/differential tied to at least one predicate.
- Observability (optional): tripwires/quarantine/metrics if rollout must be staged.
Cross-Coordination
- If broader failures emerge, lean on the Unsoundness checklist.
- If stronger invariants dent ergonomics, reference the Footgun guardrails.
Du fichier au premier essai
Le téléchargement contient exactement le contenu affiché sur cette fiche. Cette copie peut différer de la dernière version du dépôt source.
Consulter la source et ses fichiers annexesCe téléchargement contient uniquement SKILL.md. Les scripts, références, modèles et dépendances éventuels ne sont pas inclus. Récupérez les fichiers nécessaires depuis la source en conservant leur arborescence avant de poursuivre.
1. Télécharger le fichier
Télécharger SKILL.mdDepuis la racine d’un projet de test, enregistrez le fichier sous .skill-downloads/invariant-ace-msh3uubt/SKILL.md, ou utilisez la commande suivante. Ce dossier sert à examiner la skill avant son installation.
Commande pour macOS/Linux ou WSL : un shell POSIX et curl sont nécessaires. Sous Windows sans WSL, utilisez le bouton de téléchargement et créez le dossier manuellement.
mkdir -p '.skill-downloads/invariant-ace-msh3uubt' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/invariant-ace-msh3uubt/download' --output '.skill-downloads/invariant-ace-msh3uubt/SKILL.md.part' && mv '.skill-downloads/invariant-ace-msh3uubt/SKILL.md.part' '.skill-downloads/invariant-ace-msh3uubt/SKILL.md'2. Vérifier les prérequis
Lisez SKILL.md avant de l’utiliser. Si le fichier cite des scripts ou services externes, examinez-les et préparez les accès nécessaires dans votre environnement de test.
Aucune section de prérequis reconnue dans ce fichier. Cela ne signifie pas qu’il est autonome : les bibliothèques, outils et accès peuvent être cités ailleurs dans le contenu ou dans le dépôt source.
Les plateformes de la fiche sont des indications du catalogue. Les chemins ci-dessous suivent la documentation des outils ; ils ne prouvent pas que cette skill y a été exécutée. Aucune version minimale de ces outils n’est attestée pour cette fiche.
3. Charger la skill
Après vérification, copiez le dossier complet dans le projet avec l’une des commandes ci-dessous, puis ouvrez une nouvelle session de l’outil. La commande s’arrête si un dossier du même nom existe déjà : comparez les fichiers avant de le remplacer.
Claude Code
test -f '.skill-downloads/invariant-ace-msh3uubt/SKILL.md' && test -s '.skill-downloads/invariant-ace-msh3uubt/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/tw-invariant-ace' && cp -R '.skill-downloads/invariant-ace-msh3uubt' '.claude/skills/tw-invariant-ace'OpenSkills
OpenSkills doit déjà être installé. La procédure locale install/read est contrôlée avec OpenSkills 1.5.0, qui exige Node.js ≥ 20.6.0. Aucun slug du catalogue n’est résolu automatiquement.
Installation officielle d’OpenSkillsopenskills install './.skill-downloads/invariant-ace-msh3uubt'openskills read 'invariant-ace-msh3uubt'La lecture doit afficher le contenu du fichier installé et son dossier de base. Elle ne lance ni la skill ni ses dépendances.
Pour un agent qui lit AGENTS.md, synchronisez ensuite l’index. Cette commande modifie AGENTS.md : relisez le diff avant de l’utiliser.
openskills syncMode manuel ou autre outil : joignez SKILL.md à une conversation, ou ouvrez-le dans un agent capable de lire les fichiers. Ajoutez les ressources annexes nécessaires. Il n’existe pas de dossier universel reconnu par tous les outils.
4. Faire un premier essai
Utilisez une entrée courte et fictive : un endpoint d’API, un petit document ou un brief d’interface. Dans une nouvelle conversation, joignez le fichier ou donnez son chemin à l’agent, puis adaptez cette demande :
Lis .skill-downloads/invariant-ace-msh3uubt/SKILL.md et applique ses instructions à cet exemple : [décrire une entrée de test]. Indique les fichiers, dépendances ou accès qui manquent. Produis le résultat demandé par la skill sans inventer de données ni exécuter de script non examiné.Résultat attendu : une sortie correspondant aux instructions de la skill, ou une liste précise des prérequis manquants. Une simple confirmation de lecture ne valide pas le premier usage. Si une ressource externe est indisponible, ce parcours reste à tester.
Bonnes pratiques React Hook Form
Developpement
Maîtrisez React Hook Form : évitez les anti-patterns, gérez les abonnements, et traitez correctement reset, dirty state et entrées contrôlées.
Migration Emotion vers Mantine
Developpement
Migrer les styled-components Emotion vers des composants Mantine avec style props et modules CSS. Pour convertir .styled.tsx ou supprimer les imports @emotion.
Détecteur de dérive de périmètre
Developpement
Analyse les diffs git par rapport à une intention pour détecter la dérive de périmètre, fichiers non liés et PR trop larges, puis suggère de garder, diviser ou justifier.