invariant-guard
Correctness-first: forces writing the function contract, loop invariant, termination argument, and edge cases BEFORE code. Catches Boyer-Moore, leftmost binary search, QuickSelect traps.
npx skills add sickn33/agentic-awesome-skills --skill invariant-guard --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# invariant-guard — Correctness-First Coding The model knows what a loop invariant is. It knows recursion needs a base case. It knows about empty lists, integer overflow, and the difference between `<` and `≤`. It just does not write these down before producing code, so it ships subtle correctness bugs that tests do not catch. invariant-guard fixes the behavior. State the invariants. State the base case. State the termination argument. State the edge cases. Then write the code — and verify that the code maintains what you stated. **Violating the letter of these rules is violating the spirit of the skill.** "I know this algorithm" is the exact rationalization that ships off-by-one and missing-postcondition bugs. ## When to Use This Skill Use **invariant-guard** when writing or reviewing algorithms where the obvious implementation is subtly wrong: - Postcondition stronger than the loop's natural invariant: Boyer–Moore majority, Floyd's cycle detection, leftmost vs any binary search, QuickSelect partition. - In-place mutation with read+write pointers: dedup-in-place, partition, rotate. - Recursion with multiple parameters or accumulator state. - Off-by-one suspects with duplicates, em
- When to Use This Skill
- The Iron Law
- Non-negotiable rules
- The pre-write protocol
- Worked trap — Boyer–Moore majority vote
- Canonical example — binary search for the leftmost match
- Without the protocol — returns any match
- With the protocol — contract-driven leftmost
- Common invariant patterns to reach for
- Edge case table — defaults to consider
- Output discipline
- When to escalate or redirect
- Rationalizations to watch for
- Red flags — STOP and write the invariant first
What does the invariant-guard skill do?
Correctness-first: forces writing the function contract, loop invariant, termination argument, and edge cases BEFORE code. Catches Boyer-Moore, leftmost binary search, QuickSelect traps.
How do I install it?
Run `npx skills add sickn33/agentic-awesome-skills --skill invariant-guard --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From sickn33/agentic-awesome-skills, a repository with 44,414 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.