use-sparse-set

use-sparse-set is a skill for Claude Code, Codex from jimmc414/claude-code-plugin-marketplace. It costs 29 tokens per session (638 once invoked), scanned A, original, MIT.

A way to represent sparse data with a Python set that stores only active coordinates or states, rather than every possible position.

In plain words
What is it for?
Use it for infinite grids, active-cell tracking, sparse matrices, coordinate sets, and simulations such as Conway's Game of Life.
Why use it?
It avoids wasting memory on huge spaces where most locations are empty and provides fast membership checks. It is not suited to dense matrices or array slicing.

Skill for Claude CodeCodex

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

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.

agentmods
npx agentmods add skills/jimmc414/claude-code-plugin-marketplace/use-sparse-set
Any agent
npx skills add jimmc414/claude-code-plugin-marketplace --skill use-sparse-set
Clone the repo
git clone --depth 1 https://github.com/jimmc414/claude-code-plugin-marketplace

Made for: Claude Code, Codex.

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 use-sparse-set

README.md
[![agentmods](https://agentmods.dev/badge/skills/jimmc414/claude-code-plugin-marketplace/use-sparse-set.svg)](https://agentmods.dev/skills/jimmc414/claude-code-plugin-marketplace/use-sparse-set)
Your own site
<a href="https://agentmods.dev/skills/jimmc414/claude-code-plugin-marketplace/use-sparse-set"><img src="https://agentmods.dev/badge/skills/jimmc414/claude-code-plugin-marketplace/use-sparse-set.svg" alt="Measured on agentmods" height="20"></a>
Per session 29 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 638 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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.00029 $0.00638
Opus 5 $0.00015 $0.00319
Sonnet 5 $0.00006 $0.00128
Haiku 4.5 $0.00003 $0.00064

Measured yesterday against content hash 5d78249d74e9, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, from the pricing page.

Security

Grade A, and why

use-sparse-set 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 yesterday.

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/use-sparse-set/SKILL.md · 77 lines

How it starts

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

use-sparse-set

When to Use

  • Infinite or very large coordinate spaces
  • Only a few elements are "active" at any time
  • Need O(1) membership testing
  • Natural union/intersection operations apply
  • Game of Life, sparse matrices, active cell tracking

When NOT to Use

  • Dense data where most cells have values
  • Need array indexing or slicing
  • Matrix operations (use numpy)

The Pattern

Use Python sets to represent sparse collections. Only store elements that exist/matter.

# Instead of 2D array:
# grid = [[0]*1000 for _ in range(1000)]  # Wastes memory

# Use set of coordinates:
active_cells = {(3, 5), (10, 20), (100, 200)}

# Operations are natural
(5, 5) in active_cells  # O(1) membership
active_cells.add((7, 7))  # O(1) add
active_cells |= other_set  # Union
active_cells &= valid_region  # Intersection

Example (from pytudes Life.ipynb)

Cell = Tuple[int, int]
World = Set[Cell]  # Only live cells stored

# Initial state - just the active cells
glider = {(1, 0), (2, 1), (0, 2), (1, 2), (2, 2)}

def neighbors(cell):
    """All 8 neighbors of a cell."""
    x, y = cell
    return [(x+dx, y+dy)
            for dx in [-1, 0, 1]
            for dy in [-1, 0, 1]
            if (dx, dy) != (0, 0)]

def neighbor_counts(world):
    """Count neighbors for all relevant cells."""
    from collections import Counter
    return Counter(n for cell in world for n in neighbors(cell))

def next_generation(world):
    """Game of Life: 3 neighbors = born, 2-3 = survive."""
    counts = neighbor_counts(world)
    return {cell for cell, count in counts.items()
            if count == 3 or (count == 2 and cell in world)}

# Can handle any size - sparse representation!
huge_world = {(1000000, 1000000), (1000001, 1000000)}
next_gen = next_generation(huge_world)  # Works fine

Key Principles

  1. Only store what exists: Empty cells don't consume memory
  2. Infinite space is free: No bounds needed
  3. Set operations map to problems: Union = combine, intersection = overlap
  4. Tuples are hashable: Coordinates work as set elements
  5. Counter for aggregation: Count "votes" from neighbors

Read the full file on GitHub · 77 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. yesterday First seen · 77 lines · 29 tokens per session scan A 5d78249d74e9

Subscribe to this mod's changes

use-sparse-set is a skill published in the GitHub repository jimmc414/claude-code-plugin-marketplace (4 stars, last pushed today), licensed MIT. It adds 29 tokens to every session and 638 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.