AgentStack
Browse Sign in
Browse Why AgentStack Sell Docs
Sign in
SKILL verified Apache-2.0 Self-run

To Invariants

skill-officialunofficial-skills-to-invariants · by officialunofficial

Distill the invariants — properties that must always hold — out of the current conversation and codebase, and write them to an in-repo doc. Use when the user wants to capture invariants, pin down what must always be true, harden a design, or turn a discussion/spec/PRD into checkable properties.

No reviews yet
0 installs
42 views
0.0% view→install

Install

$ agentstack add skill-officialunofficial-skills-to-invariants

✓ scanned · ✓ verified, works with Claude Code, Cursor, and more.

Security review

✓ Passed

No issues found. Passed automated security review. · v0.1.0 How review works →

  • Prompt-injection patterns
  • Secret / credential exfiltration
  • Dangerous shell & filesystem operations
  • Untrusted network calls
  • Known-malicious package signatures

What it can access

  • Network access No
  • Filesystem access No
  • Shell / process execution No
  • Environment & secrets No
  • Dynamic code execution No

From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.

View the full security report →

Verified badge

Passed review? Show it. Paste this badge into your README, it links to the public security report.

AgentStack Verified badge Links to your public security report.
[![AgentStack Verified](https://agentstack.voostack.com/badges/verified.svg)](https://agentstack.voostack.com/security/report/skill-officialunofficial-skills-to-invariants)

Reliability & compatibility

Security review passed
0 installs to date
no reviews yet
2mo ago

Declared compatibility

Claude CodeClaude Desktop

Compatibility is declared by the source manifest. End-to-end runtime verification is coming, see below.

Preview Execution monitoring

We're building live execution health for every listing: tool-call success rate, median latency, uptime, and last-checked timestamps, measured, not self-reported. It isn't live yet, so we don't show numbers we can't stand behind.

How agent discovery & health will work →
Are you the author of To Invariants? Claim this listing to set pricing, connect Stripe payouts, and keep 70% of every sale.
Sign up to claim

About

Take the current conversation context and codebase understanding and produce a set of invariants: properties that must ALWAYS hold for the system to be correct. Do NOT interview the user — synthesize what you already know. Two audiences, two sections: design-level system invariants and enforceable invariants that map to a concrete check.

An invariant is not a feature, a requirement, or a nice-to-have. It is a condition whose violation means the system is broken. "Users can reset their password" is a feature. "A session token is never valid after logout" is an invariant.

Process

1. Explore (if needed)

If you have not already, skim the code in the area under discussion to ground the invariants in the real data structures, state machines, and boundaries. Use the project's own vocabulary. An invariant you cannot point at a place in the code for is a guess — mark it as one.

2. Discover invariants

Sweep the design through these lenses — each tends to surface a different class of invariant. Aim for coverage, not volume; skip lenses that don't apply.

  • Representation — internal consistency a data structure must always satisfy (no dangling refs, sorted, no duplicates, sums to a stored total, non-null where required).
  • State machine / lifecycle — only valid transitions occur; terminal states are terminal; nothing escapes a state it shouldn't (e.g. "a cancelled order is never fulfilled").
  • Round-trip / inversedecode(encode(x)) == x; save→load, serialize→parse, redo(undo) are identity.
  • Conservation / accounting — a quantity is neither created nor destroyed (money, inventory, reference counts balance before and after).
  • Idempotence — applying an operation twice equals applying it once (retries, upserts, dedup).
  • Ordering / monotonicity — timestamps, versions, sequence numbers never go backwards; causality is preserved.
  • Uniqueness / referential integrity — IDs are unique; every foreign reference resolves; no orphans.
  • Boundary / authority — inputs stay within range; trust/permission boundaries are never crossed (no privilege escalation, no reading another tenant's data).
  • Metamorphic — a relationship between related runs holds (adding an item never decreases the count; sorting twice == sorting once).

3. Classify and locate

For each invariant, decide which section it belongs in, and find where it lives in the code:

  • System invariant — a design-level truth, possibly too broad or too semantic for a single assertion. Capture the property and why it holds.
  • Enforceable invariant — expressible as an assertion, precondition/postcondition, property-based test, type, DB constraint, or runtime check. Find where it is enforced today; if nowhere, mark GAP — an unenforced invariant is a latent bug.

A single invariant can appear in both sections: stated as a system truth, then listed with its concrete check.

4. Write the doc

Write to the path in {{ARGUMENTS}}, or docs/INVARIANTS.md by default. If the file exists, merge — don't clobber invariants already recorded; add, refine, and flag conflicts. Use the template below.

5. Report

Summarize to the user: how many invariants, and — most important — the GAPs (invariants with no enforcement). Ask whether they want the gaps turned into tests or tickets (do not do it unless asked).

Invariants

> Properties that must ALWAYS hold. A violation is a bug, by definition. > Scope:

System invariants

Design-level properties. Each: the property, why it holds, and the blast radius if it breaks.

INV-1:

  • Always:
  • Because:
  • If violated:

Enforceable invariants

Each maps to a concrete check. [x] = enforced today; [ ] = GAP, not enforced.

  • [x] INV-2: — enforced by ` at `.
  • [ ] INV-3:GAP: no current check. Suggested: ``.

Assumptions & non-invariants

What makes an invariant good

  • Absolute. It holds for all valid states, always. If it needs "usually" or "should", it's a heuristic, not an invariant — either tighten it or move it to non-invariants.
  • Falsifiable. You can describe a concrete state that would violate it. If nothing could ever contradict it, it says nothing.
  • Observable / contractual. It constrains behavior or observable state, not an incidental implementation detail that a valid refactor could change.
  • Atomic. One property per invariant. Split conjunctions ("unique AND sorted") so each can be checked and cited independently.
  • Located. It names where it's enforced, or admits it isn't (GAP).

INV: A token presented after its session's logout is always rejected. Absolute, falsifiable (present a post-logout token → must 401), enforceable (auth-middleware test), atomic.

INV: The auth system is secure. Not falsifiable, not atomic, not checkable — it's a wish, not an invariant.

INV: Passwords are hashed with bcrypt cost 12. "bcrypt cost 12" is an implementation detail. The invariant is "passwords are never stored in recoverable form"; the algorithm is a how, not a must-always-hold.

Task: distill the invariants from the current context and write them to the doc. {{ARGUMENTS}}

Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

Install and usage instructions live in the source repository linked above.

Reviews

No reviews yet, be the first.

Versions

  • v0.1.0 Imported from the upstream source.