invariants
БесплатноБез исполняемых скриптовНе проверенFinds the state machines and rules an app relies on but never enforces, then returns a numbered report of where to enforce each one.
от raphaelsalaja★ 74 звезды на GitHubОб этом скилле
Invariants
This skill reads an app for the rules its code assumes but never writes down. It finds flags that only make sense together and assumptions no line checks, then returns one numbered report.
Every rule traced to a line
A rule counts only when a line relies on it, such as a read that breaks if the rule is false. Each finding names that line and the line that enforces the rule, or says none does. A rule inferred from naming alone is Not verified.
The sweep covers interface state: component state, stores, context, refs, URL params and the server data the interface reads. Server code and databases are in scope only when the user names them.
Showing each state on one page belongs to lab. Worst-case values on screen belong to stress. The states of one animation belong to deconstruct. A fallback that hid a broken rule cites restraint-no-fallbacks. A fix that belongs in a shared component cites reuse-fix-in-the-primitive. Opening the result runs in verify.
1. Group the flags that move together
List every boolean, status string and nullable value in scope with the lines that write it. Flags set in the same handler, or read together in one condition, form one group. Reporting isOpen and isClosing as two findings is invariants-group-the-flags.
2. Write the machine each group implies
For each group, write the states it can rest in as a table of state, entered on and left on. Count the combinations the flags allow against the states the table names. "These flags look related" with no count is invariants-count-the-combinations.
Every combination no state names is an impossible state. Give each one the line that produces it, such as an error handler that never clears isLoading. One that no line reaches is still listed, marked unreachable.
Then cross every state with every event the group receives, such as open, close, Escape and a response arriving. Each cell names the next state or says ignored. A blank cell is where impossible states come from, such as open pressed during closing. A table of states with no events is invariants-every-event-in-every-state.
3. Collapse each group into one status
Replace the group with one discriminated union or reducer, so an impossible state cannot be written. isLoading, isError and data kept side by side is invariants-one-status.
Transitions live in one place: the reducer, or the events that call it. A status set directly from five components is invariants-one-writer.
Every switch over a status ends in a never check, so adding a state fails to compile until each branch handles it. default: return null on a union hides the next state someone adds, and is invariants-exhaustive-switch. Without TypeScript, the default throws in development.
Store the source and compute the rest. A value that can be computed from props or other state is computed during render, never kept in state of its own. selectedItem copied out of items goes stale on the next edit, so store selectedId and find the item. A copy kept in sync by an effect is invariants-derive-not-store.
4. Find what the code assumes
Run each search across the scope and list every hit. Reading files by eye for assumptions is invariants-search-every-shape.
| Shape | Search |
|---|---|
| Non-null assertion | \w!\. and \w!\) |
| Cast past the type | rg -nP '^(?!\s*import\b)(?!\s*export\b).* as [A-Z]' and as unknown as, dropping hits inside a multi-line import or export |
| First item read blind | \[0\] and .at(0) |
| Find used as found | .find( with no check before the next read |
| Keys that must be unique | key={ on a field nothing dedupes |
| Order that must hold | An effect or listener that reads what another one sets |
| One of a kind | "only one", "should never" and "always" in comments |
| Default hiding a gap | ?? [], ?? "" and ?? 0 on values that are always set |
| Limits that must match | maxLength and .max( beside the column or schema that stores the field |
| A quiet default | default: in a switch over a union, returning anything but a never check |
| Copied state | useState(props., and an effect whose only line calls a setter |
| Responses that race | fetch( or an awaited call inside an effect with no AbortController and no ignore flag in its cleanup |
| Stored data read blind | JSON.parse(localStorage, searchParams.get( and params. read with no parse |
| IDs as numbers | Number(id), parseInt( and +id on an ID, which lose digits past 9007199254740991 |
The screen shows the answer to the latest request. A search effect with no cleanup lets the response for hel land after hello and replace it. Abort the old request, or ignore its result in the effect's cleanup. A data library that keys each request by its query already does this. A hand-written fetch effect with no cleanup is invariants-latest-request-wins.
A field's input limit matches its storage limit. A
Установить invariants в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл invariants?
Finds the state machines and rules an app relies on but never enforces, then returns a numbered report of where to enforce each one.
Как установить скилл invariants?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл invariants запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
docx
Use this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include…
от AnthropicUse this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple…
от Anthropicxlsx
Use this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing…
от Anthropicpptx
Use this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or…
от Anthropic