invariant-inference

invariant-inference is a skill for Claude Code, Codex from ArabelaTso/Skills-4-SE. It costs 95 tokens per session (3,228 once invoked), scanned A, original, Apache-2.0.

A code-analysis tool that infers loop invariants: facts that remain true during every pass through a loop. It can turn those facts into assertions for checking code correctness.

In plain words
What is it for?
Use it to analyse loops in Python, Java, C, or C++ and support correctness proofs or verification.
Why use it?
It helps developers reason about loops without having to discover and write every repeated condition by hand.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it to analyse loops in Python, Java, C, or C++ and support correctness proofs or verification.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/arabelatso/skills-4-se/invariant-inference
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add ArabelaTso/Skills-4-SE --skill invariant-inference
Clone the repo
git clone --depth 1 https://github.com/ArabelaTso/Skills-4-SE

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for invariant-inference

README.md
[![agentmods](https://agentmods.dev/badge/skills/arabelatso/skills-4-se/invariant-inference/github.svg)](https://agentmods.dev/skills/arabelatso/skills-4-se/invariant-inference)
Your own site
<a href="https://agentmods.dev/skills/arabelatso/skills-4-se/invariant-inference"><img src="https://agentmods.dev/badge/skills/arabelatso/skills-4-se/invariant-inference/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for invariant-inference

Your own site · 80×15
<a href="https://agentmods.dev/skills/arabelatso/skills-4-se/invariant-inference"><img src="https://agentmods.dev/badge/skills/arabelatso/skills-4-se/invariant-inference.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 95 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,228 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00095 $0.03228
Opus 5 $0.00048 $0.01614
Sonnet 5 $0.00019 $0.00646
Haiku 4.5 $0.00010 $0.00323

Measured 9d ago against content hash 836250f1b331, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-12, from the pricing page.

Security

Grade A, and why

invariant-inference scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 9d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/invariant-inference/SKILL.md · 498 lines

How it starts

The opening of the file, as written. The whole thing — 498 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Invariant Inference

Overview

Analyze loops and automatically infer invariants—properties that remain true throughout loop execution. Generate these as code assertions for verification and correctness proofs.

Workflow

1. Identify the Loop

First, locate and understand the loop to analyze:

Loop types to recognize:

  • for loops with index variables
  • while loops with conditions
  • do-while loops
  • Iterator-based loops
  • Recursive functions (treated as implicit loops)

Extract key information:

  • Loop variable(s) and their initial values
  • Loop condition (when it terminates)
  • Loop body (what happens each iteration)
  • Variables modified in the loop
  • Variables read but not modified

2. Analyze Loop Structure

Understand what the loop does:

Categorize the loop:

  • Accumulation: Building up a sum, product, or collection
  • Search: Looking for an element or condition
  • Transformation: Modifying elements in a data structure
  • Generation: Creating new data based on input
  • Traversal: Visiting all elements
  • Sorting/Partitioning: Rearranging elements

Identify patterns:

  • Array/list iteration with bounds
  • Counter increments/decrements
  • Pointer advancement
  • Collection building
  • Flag-based early termination

3. Infer Invariant Categories

Generate invariants for each applicable category. See invariant-patterns.md for comprehensive patterns.

Bounds Invariants

Properties about variable ranges:

# Loop: for i in range(n)
assert 0 <= i < n

# Loop: while i < len(arr)
assert 0 <= i <= len(arr)

# Loop: two pointers
while left < right:
    assert 0 <= left <= right < len(arr)
Relationship Invariants

Properties relating variables:

Sum/Accumulation:

total = 0
for i in range(len(arr)):
    assert total == sum(arr[0:i])  # Invariant before update
    total += arr[i]
assert total == sum(arr)  # Post-condition

Max/Min:

max_val = arr[0]
for i in range(1, len(arr)):
    assert max_val == max(arr[0:i])
    if arr[i] > max_val:
        max_val = arr[i]

Read the full file on GitHub · 498 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 9d ago First seen · 498 lines · 95 tokens per session scan A 836250f1b331

Subscribe to this mod's changes

invariant-inference is a skill published in the GitHub repository ArabelaTso/Skills-4-SE (252 stars, last pushed 22d ago), licensed Apache-2.0. It adds 95 tokens to every session and 3,228 once invoked, about $0.0005 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.

Related

Other skills, from other repositories

112-java-maven-plugins

Use when you need to add or configure Maven plugins in your pom.xml — including quality tools (enforcer, surefire, failsafe, jacoco, pitest, spotbugs, pmd), security scanning (OWASP), code formatting (Spotless), version management, container image build (Jib), build information tracking, and benchmarking (JMH) …

jabrena/plinth · 149 tokens

111-java-maven-dependencies

Use when you need to add or evaluate Maven dependencies that improve code quality or domain modeling — including nullness annotations (JSpecify), static analysis (Error Prone + NullAway), functional programming (VAVR), architecture testing (ArchUnit), or money and currency support (JavaMoney) — and want a…

jabrena/plinth · 133 tokens

057-design-feature-toggles

Use when designing, implementing, reviewing, testing, or cleaning up feature toggles, feature flags, kill switches, runtime configuration gates, canary controls, staged rollouts, experiments, or temporary compatibility switches in Java enterprise systems. This should trigger for requests such as Design a feature…

jabrena/plinth · 103 tokens

130-java-testing-strategies

Use when you need to apply testing strategies for Java code — RIGHT-BICEP to guide test creation, A-TRIP for test quality characteristics, or CORRECT for verifying boundary conditions. This should trigger for requests such as Review Java code for testing strategies; Apply RIGHT-BICEP testing strategies in Java code…

jabrena/plinth · 96 tokens

133-java-testing-acceptance-tests

Use when you need to implement acceptance tests from maintainer-sanitized Gherkin scenario facts for framework-agnostic Java (no Spring Boot, Quarkus, Micronaut) — confirming @acceptance scenarios before coding, happy path with RestAssured, DB/Kafka test fixtures, WireMock for external REST only, and AT classes run by…

jabrena/plinth · 142 tokens

152-java-performance-gatling

Use when you need to set up Gatling performance testing for a Java Maven project — including adding Gatling dependencies and the Gatling Maven plugin, creating Java simulations, running gatling:test, configuring a simulation class, and reviewing generated reports. This should trigger for requests such as Add Gatling…

jabrena/plinth · 99 tokens