test-structural-invariants

test-structural-invariants is a skill for Claude Code from jimmc414/claude-code-plugin-marketplace. It costs 27 tokens per session (795 once invoked), scanned A, original, MIT.

A testing pattern that checks properties a data structure must always satisfy, such as its size, keys, relationships, or coverage. These properties are called invariants.

In plain words
What is it for?
Use it to validate graphs, lookup tables, Sudoku structures, precomputed data, and other complex collections.
Why use it?
It catches incorrectly built or initialized structures even when individual values look valid. This helps detect broken relationships between connected data.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the norvig-patterns plugin — 54 skills shipped together

Good fit Use it to validate graphs, lookup tables, Sudoku structures, precomputed data, and other complex collections.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/jimmc414/claude-code-plugin-marketplace/test-structural-invariants
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 jimmc414/claude-code-plugin-marketplace --skill test-structural-invariants
Clone the repo
git clone --depth 1 https://github.com/jimmc414/claude-code-plugin-marketplace

Made for: Claude Code.

Or install norvig-patterns, the plugin that ships this one along with the rest of its 54 skills.

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 test-structural-invariants

README.md
[![agentmods](https://agentmods.dev/badge/skills/jimmc414/claude-code-plugin-marketplace/test-structural-invariants/github.svg)](https://agentmods.dev/skills/jimmc414/claude-code-plugin-marketplace/test-structural-invariants)
Your own site
<a href="https://agentmods.dev/skills/jimmc414/claude-code-plugin-marketplace/test-structural-invariants"><img src="https://agentmods.dev/badge/skills/jimmc414/claude-code-plugin-marketplace/test-structural-invariants/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 test-structural-invariants

Your own site · 80×15
<a href="https://agentmods.dev/skills/jimmc414/claude-code-plugin-marketplace/test-structural-invariants"><img src="https://agentmods.dev/badge/skills/jimmc414/claude-code-plugin-marketplace/test-structural-invariants.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 27 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 795 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.
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.00027 $0.00795
Opus 5 $0.00014 $0.00398
Sonnet 5 $0.00005 $0.00159
Haiku 4.5 $0.00003 $0.00080

Measured 4d ago against content hash c6b9d71eff7c, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

test-structural-invariants 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 4d 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.

plugins/norvig-patterns/skills/test-structural-invariants/SKILL.md · 93 lines

How it starts

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

test-structural-invariants

When to Use

  • After building complex data structures
  • Verifying precomputed relationships
  • Checking initialization is correct
  • Invariants that should always hold

When NOT to Use

  • Simple data
  • No structural constraints
  • Runtime performance critical

The Pattern

Assert properties that must be true about your data structures.

# After building structure, verify invariants
def test_structure():
    # Size invariants
    assert len(items) == EXPECTED_SIZE

    # Relationship invariants
    assert all(condition(item) for item in items)

    # Coverage invariants
    assert set(keys) == expected_keys

    # Bidirectional relationship
    for a, bs in graph.items():
        for b in bs:
            assert a in graph[b]  # Symmetric

Example (from pytudes)

# sudoku.py - Sudoku structure invariants
def test():
    """A set of tests that must pass."""
    # Size invariants
    assert len(squares) == 81       # 9x9 grid
    assert len(unitlist) == 27      # 9 rows + 9 cols + 9 boxes

    # Relationship invariants
    assert all(len(units[s]) == 3 for s in squares)   # Each square in 3 units
    assert all(len(peers[s]) == 20 for s in squares)  # Each square has 20 peers

    # Specific structure verification
    assert units['C2'] == [
        ['A2', 'B2', 'C2', 'D2', 'E2', 'F2', 'G2', 'H2', 'I2'],  # Column
        ['C1', 'C2', 'C3', 'C4', 'C5', 'C6', 'C7', 'C8', 'C9'],  # Row
        ['A1', 'A2', 'A3', 'B1', 'B2', 'B3', 'C1', 'C2', 'C3']   # Box
    ]
    assert peers['C2'] == set([...20 peers...])

    print('All tests pass.')

# beal.py - mathematical structure tests
def tests():
    assert make_Apowers(6, 10) == {
        1: [1],
        2: [8, 16, 32, 128],
        3: [27, 81, 243, 2187],
        ...
    }
    assert make_Czroots(make_Apowers(5, 8)) == {1: 1, 8: 2, 16: 2, ...}
    assert 3 ** 3 + 6 ** 3 in Czroots
    assert 99 ** 97 in Czroots
    assert 101 ** 100 not in Czroots

# spell.py - corpus statistics invariants
def unit_tests():
    assert len(WORDS) == 32198
    assert sum(WORDS.values()) == 1115585
    assert WORDS.most_common(10) == [
        ('the', 79809), ('of', 40024), ('and', 38312), ...
    ]

Read the full file on GitHub · 93 lines

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. 4d ago First seen · 93 lines · 27 tokens per session scan A c6b9d71eff7c

Subscribe to this mod's changes

test-structural-invariants is a skill published in the GitHub repository jimmc414/claude-code-plugin-marketplace (4 stars, last pushed yesterday), licensed MIT. It adds 27 tokens to every session and 795 once invoked, about $0.0001 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-04.

Related

Other skills, from other repositories

phpunit-migration-test-reviewing

Internal sub-skill. Do not auto-activate. Use only when explicitly invoked by name by another skill or agent.

shopwareLabs/ai-coding-tools · 32 tokens

phpunit-test-adversarial-reviewing

Internal sub-skill. Do not auto-activate. Use only when explicitly invoked by name by another skill or agent.

shopwareLabs/ai-coding-tools · 33 tokens

phpunit-test-team-reviewing

Use this skill when the user asks for a team-based, consensus, multi-reviewer, or red-team review of Shopware PHPUnit tests — trigger phrases like "team review these tests", "consensus review the tests in PR.

shopwareLabs/ai-coding-tools · 52 tokens

phpunit-unit-test-reviewing

Internal sub-skill. Do not auto-activate. Use only when explicitly invoked by name by another skill or agent.

shopwareLabs/ai-coding-tools · 31 tokens

phpunit-integration-to-unit-migrating

Use this skill ONLY when the user explicitly requests an audit, migration, or evaluation of whether a Shopware integration test belongs in the unit suite — trigger phrases like "audit integration tests", "migrate integration tests to unit", "is this an integration test or a unit test", "evaluate integration tests for…

shopwareLabs/ai-coding-tools · 152 tokens

phpunit-unit-test-writing

Use this skill when the user asks to write, generate, create, or add PHPUnit unit tests for a Shopware 6 source class — phrases like "write unit tests for X", "generate tests for ClassName", "create PHPUnit tests", "add test coverage", "test this class", "cover this with tests", "I need tests for", "unit test this"…

shopwareLabs/ai-coding-tools · 187 tokens