build-priority-queue

build-priority-queue is a skill for Claude Code, Codex from jimmc414/claude-code-plugin-marketplace. It costs 32 tokens per session (642 once invoked), scanned A, original, MIT.

A Python pattern for a priority queue, which always processes the item with the smallest priority value first. It uses a heap, a data structure designed for efficient access to the next item.

In plain words
What is it for?
Use it for Dijkstra or A* pathfinding, event simulations, priority-based task scheduling, merging sorted streams, and finding top-K results.
Why use it?
It avoids sorting the whole list after every change when work must be handled in priority order.

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/build-priority-queue
Any agent
npx skills add jimmc414/claude-code-plugin-marketplace --skill build-priority-queue
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 build-priority-queue

README.md
[![agentmods](https://agentmods.dev/badge/skills/jimmc414/claude-code-plugin-marketplace/build-priority-queue.svg)](https://agentmods.dev/skills/jimmc414/claude-code-plugin-marketplace/build-priority-queue)
Your own site
<a href="https://agentmods.dev/skills/jimmc414/claude-code-plugin-marketplace/build-priority-queue"><img src="https://agentmods.dev/badge/skills/jimmc414/claude-code-plugin-marketplace/build-priority-queue.svg" alt="Measured on agentmods" height="20"></a>
Per session 32 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 642 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 $0.00032 $0.00642
Opus 5 $0.00016 $0.00321
Sonnet 5 $0.00006 $0.00128
Haiku 4.5 $0.00003 $0.00064

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

Security

Grade A, and why

build-priority-queue 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/build-priority-queue/SKILL.md · 96 lines

How it starts

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

build-priority-queue

When to Use

  • A* or Dijkstra pathfinding
  • Event-driven simulation
  • Task scheduling by priority
  • Any "process best/smallest first" pattern
  • Merging sorted streams
  • Top-K problems

When NOT to Use

  • FIFO order (use deque)
  • LIFO order (use list as stack)
  • Need to update priorities frequently (use indexed heap)

The Pattern

Use heapq for O(log n) push/pop of minimum element.

import heapq

# Basic usage
heap = []
heapq.heappush(heap, 3)
heapq.heappush(heap, 1)
heapq.heappush(heap, 2)
heapq.heappop(heap)  # Returns 1 (minimum)

# With tuples for priority ordering
tasks = []
heapq.heappush(tasks, (priority, task_id, task_data))
_, _, task = heapq.heappop(tasks)

# heapify existing list
data = [3, 1, 4, 1, 5]
heapq.heapify(data)  # In-place, O(n)

Example (from pytudes AdventUtils.ipynb)

import heapq

class PriorityQueue:
    """A queue where the item with minimum key is always popped first."""

    def __init__(self, items=(), key=lambda x: x):
        self.key = key
        self.items = []  # Heap of (score, item) pairs
        for item in items:
            self.add(item)

    def add(self, item):
        """Add item to the queue."""
        pair = (self.key(item), item)
        heapq.heappush(self.items, pair)

    def pop(self):
        """Pop and return the item with minimum key."""
        return heapq.heappop(self.items)[1]

    def top(self):
        """Peek at minimum item without removing."""
        return self.items[0][1]

    def __len__(self):
        return len(self.items)

# Usage in A* search
def astar_search(problem, h):
    frontier = PriorityQueue([Node(problem.initial)],
                             key=lambda n: n.path_cost + h(n))

    while frontier:
        node = frontier.pop()
        if problem.is_goal(node.state):
            return node
        for child in expand(problem, node):
            frontier.add(child)

    return None

Key Principles

  1. Heap property: Parent <= children (for min-heap)
  2. Tuple ordering: (priority, tiebreaker, data) for stable ordering
  3. heapify is O(n): Faster than n pushes for initial data
  4. No decrease-key: Python heapq doesn't support it; add duplicates instead
  5. Wrap for clarity: PriorityQueue class hides heap details

Read the full file on GitHub · 96 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 · 96 lines · 32 tokens per session scan A 70b168581a9d

Subscribe to this mod's changes

build-priority-queue is a skill published in the GitHub repository jimmc414/claude-code-plugin-marketplace (4 stars, last pushed today), licensed MIT. It adds 32 tokens to every session and 642 once invoked, about $0.0002 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-08-31.

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-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

structuring-documentation

Use when writing, editing, auditing, splitting, or measuring Markdown documentation surfaces — README.md, AGENTS.md, CLAUDE.md, and docs/ siblings. Triggers include "is this doc too long", "split this README", "measure the docs", "where does this documentation belong", "audit the documentation", and any request to…

shopwareLabs/ai-coding-tools · 89 tokens

phpunit-integration-test-generation

Use this skill when the user asks to generate, write, or create integration tests for a Shopware 6 source class whose contract requires wired-up code — phrases like "generate integration tests for X", "write an integration test for this controller", "test this indexer", "create an integration test for the message…

shopwareLabs/ai-coding-tools · 184 tokens

phpunit-unit-test-generation

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

shopwareLabs/ai-coding-tools · 30 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