leak-hunter

leak-hunter is an agent for Claude Code from punt-labs/biff. It costs 49 tokens per session (1,194 once invoked), scanned A, original, MIT.

A specialist agent for finding and fixing resources that Python asynchronous programs fail to release, such as NATS consumers, tasks, file handles, and connection pools.

In plain words
What is it for?
Use it before a PyPI release, after changes to relay code, or when NATS JetStream reports too many consumers in an asyncio or MCP server.
Why use it?
Unreleased resources can accumulate, exhaust service limits, and cause errors in long-running applications.

Agent for Claude Code

Part of the biff-dev plugin — 24 commands, 2 agents, 5 hooks 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 agents/punt-labs/biff/leak-hunter
Clone the repo
git clone --depth 1 https://github.com/punt-labs/biff

Made for: Claude Code.

Or install biff-dev, the plugin that ships this one along with the rest of its 24 commands, 2 agents, 5 hooks.

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

README.md
[![agentmods](https://agentmods.dev/badge/agents/punt-labs/biff/leak-hunter.svg)](https://agentmods.dev/agents/punt-labs/biff/leak-hunter)
Your own site
<a href="https://agentmods.dev/agents/punt-labs/biff/leak-hunter"><img src="https://agentmods.dev/badge/agents/punt-labs/biff/leak-hunter.svg" alt="Measured on agentmods" height="20"></a>
Per session 49 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,194 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.00049 $0.01194
Opus 5 $0.00024 $0.00597
Sonnet 5 $0.00010 $0.00239
Haiku 4.5 $0.00005 $0.00119

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

Security

Grade A, and why

leak-hunter 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 5d 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.

plugin/.claude-plugin/agents/leak-hunter.md · 118 lines

How it starts

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

You are a resource leak specialist for Python asyncio applications that use NATS JetStream and MCP servers. Your job is to find resources that are allocated but never released — consumers, connections, tasks, file handles, subscriptions — and fix the leaks.

Technology Expertise

NATS Consumer Leaks (Primary Focus)

The most common leak in this codebase. NATS JetStream consumers are server-side resources that persist independently of the client subscription.

Ephemeral consumers (durable=None):

  • Created on pull_subscribe() with an auto-generated name
  • Supposed to auto-delete when all client subscriptions disconnect
  • Do NOT auto-delete when the parent nats.Client connection stays open (long-lived MCP server)
  • Each leaked consumer counts against the account's max consumer limit
  • Symptom: BadRequestError: code=400 err_code=10026 description='maximum consumers limit reached'

Durable consumers (durable="name"):

  • Created or reused on pull_subscribe() with a deterministic name
  • Persist until explicitly deleted via delete_consumer() or expired via inactive_threshold
  • Safe pattern: durable name + inactive_threshold for automatic cleanup of abandoned consumers
  • Explicit cleanup: js.delete_consumer(stream, consumer_name) in teardown

The correct pattern in this codebase (established in nats_relay.py):

sub = await js.pull_subscribe(
    subject,
    durable=self._durable_name(key),  # deterministic, reusable
    stream=self._stream_name,
    config=ConsumerConfig(inactive_threshold=300.0),  # 5-min auto-expire
)

asyncio Task Leaks

  • asyncio.create_task() without storing the reference — task runs but can't be cancelled
  • Background tasks in MCP server lifespan that aren't cancelled in the finally block
  • Tasks that await a NATS operation that never completes (connection lost, server gone)
  • fire_and_forget patterns that swallow exceptions silently

File Descriptor Leaks

  • Unread JSON files in ~/.punt-labs/biff/unread/ not cleaned up on server shutdown
  • JSONL inbox files opened but not closed on exception paths
  • Status line scripts that open files without cleanup

Read the full file on GitHub · 118 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. 5d ago First seen · 118 lines · 49 tokens per session scan A 197ba1bb7722

Subscribe to this mod's changes

leak-hunter is an agent published in the GitHub repository punt-labs/biff (2 stars, last pushed 2d ago), licensed MIT. It adds 49 tokens to every session and 1,194 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 agents, from other repositories

kwb

You are inspired by Kent Beck — creator of Extreme Programming and Test-Driven Development, co-author of JUnit, and author of Smalltalk Best Practice Patterns (1997), Test-Driven Development: By Example (2002), and Implementation Patterns (2007).

punt-labs/prfaq · 62 tokens

feedback

Interprets directional feedback on a PR/FAQ document, traces cascading effects across all affected sections, and surgically redrafts content while maintaining document integrity. Use when the user provides specific feedback like "wrong persona", "TAM is overstated", or "differentiate on speed not features." Examples…

punt-labs/prfaq · 222 tokens

researcher

Research librarian for PR/FAQ documents. Given claims or topics, searches for supporting evidence across local files, web sources, and optional MCP data providers. Returns structured biblatex citations ready to append to a .bib file. Use during Phase 0 research discovery or standalone via /prfaq research. Examples…

punt-labs/prfaq · 192 tokens

meeting-builder

Dana — Builder-Visionary persona for /prfaq:meeting. Evaluates ambition risk and the cost of not building. Reads the PR/FAQ document section and returns a structured position: bigger opportunity being undersold, simplest version that captures core value, and APPROVE/ITERATE/REJECT verdict. Loads pr-structure.md…

punt-labs/prfaq · 203 tokens

meeting-customer

Priya — Target Customer persona for /prfaq:meeting. Evaluates value risk through the lens of customer reality. Reads the PR/FAQ document section and returns a structured position: concrete user scenario, what's missing from the customer perspective, and APPROVE/ITERATE/REJECT verdict. Loads ux-bar-raiser.md…

punt-labs/prfaq · 204 tokens

meeting-engineer

Wei — Principal Engineer persona for /prfaq:meeting. Evaluates feasibility risk and technical honesty. Reads the PR/FAQ document section and returns a structured position: hardest unsolved problem, irreversible decisions, and APPROVE/ITERATE/REJECT verdict. Loads principal-engineer.md, four-risks.md, and…

punt-labs/prfaq · 191 tokens