Agent skill · Documentation

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.

Nick44,086★ · +407/wk · 1 repos on radarProfile →
claude-codecodexcursorMIT
Install
npx skills add sickn33/agentic-awesome-skills --skill invariant-guard --agent claude-code

Same command for any agent — swap --agent for codex, cursor, copilot.

Facts
Files in the skill folder: 1
SKILL.md size: 18 KB
Bundled scripts: none
Declared author: morsechimwai
Path: skills/invariant-guard/SKILL.md
Open the folder on GitHub →
Where it comes from
Stars: 44,414 · +328 this week
Language: Python
Read our review of the source →

Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.

From the SKILL.md

# 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

What's inside
Steps it walks through
  1. When to Use This Skill
  2. The Iron Law
  3. Non-negotiable rules
  4. The pre-write protocol
  5. Worked trap — Boyer–Moore majority vote
  6. Canonical example — binary search for the leftmost match
  7. Without the protocol — returns any match
  8. With the protocol — contract-driven leftmost
  9. Common invariant patterns to reach for
  10. Edge case table — defaults to consider
  11. Output discipline
  12. When to escalate or redirect
  13. Rationalizations to watch for
  14. Red flags — STOP and write the invariant first
More from agentic-awesome-skills
All skills →
About this skill
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.

Keep going