Borrowing it
Nothing to install: this file belongs to SegfaultSorcerer/heap-seance. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.
curl -O https://raw.githubusercontent.com/SegfaultSorcerer/heap-seance/main/.claude/commands/leak-scan.mdgit clone --depth 1 https://github.com/SegfaultSorcerer/heap-seanceWrote 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.
[](https://agentmods.dev/commands/segfaultsorcerer/heap-seance/leak-scan)<a href="https://agentmods.dev/commands/segfaultsorcerer/heap-seance/leak-scan"><img src="https://agentmods.dev/badge/commands/segfaultsorcerer/heap-seance/leak-scan/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.
<a href="https://agentmods.dev/commands/segfaultsorcerer/heap-seance/leak-scan"><img src="https://agentmods.dev/badge/commands/segfaultsorcerer/heap-seance/leak-scan.svg" alt="Reviewed on agentmods" width="80" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00060 | $0.01225 |
| Opus 5 | $0.00030 | $0.00613 |
| Sonnet 5 | $0.00012 | $0.00245 |
| Haiku 4.5 | $0.00006 | $0.00122 |
Grade A, and why
leak-scan 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.
How it starts
The opening of the file, as written. The whole thing — 95 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Run a conservative Java leak scan for $ARGUMENTS.
Interpret $ARGUMENTS as either a PID (integer) or a process name/pattern (string).
Step 1: Resolve target process
- If
$ARGUMENTSis an integer, use it directly as PID. - If
$ARGUMENTSis empty, calljava_list_processes()and list all discovered JVMs so the user can choose. Do not pick one silently. - If
$ARGUMENTSis a string, calljava_list_processes()and match by substring against each processdisplayfield (case-insensitive). If exactly one process matches, use it. If multiple match, list them and ask the user to narrow down. If none match, report this and stop.
Step 2: Collect 3 histogram samples
Call java_class_histogram(pid, live_only=true) three times. Between each sample, ask the user to perform the suspected leaking action in their application (e.g., open/close a view, send requests, load/discard data) and confirm when done. This is critical — without exercising the app between snapshots, leaks stay invisible because no new objects are created along the leaking path.
Prompt the user like this:
- After sample 1: "Histogram sample 1 collected. Please perform the action you suspect is leaking (e.g., open/close views, trigger requests), then let me know when you're done."
- After sample 2: "Histogram sample 2 collected. Please repeat the same action once more, then confirm."
- After sample 3: proceed to Step 3.
Why 3 samples: detecting monotonic growth requires at least 3 data points. The live_only=true flag triggers a GC before each snapshot, so only reachable objects are counted — this filters out garbage that would skew the signal.
Step 3: Collect GC pressure snapshot
Call java_gc_snapshot(pid, interval_s=2, samples=6).
This samples jstat -gcutil over ~12 seconds to capture old-gen utilization trend and Full GC activity.
Step 4: Evaluate signals
Two independent signals determine whether escalation is warranted:
Monotonic growth candidate: a class whose retained bytes are non-decreasing across all 3 histogram samples AND whose total growth is >= 1,000,000 bytes. Classes that shrink between any two samples are not candidates — the threshold filters noise from normal allocation churn.
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.
- 9d ago First seen · 95 lines · 60 tokens per session scan A 593f40a978b4
leak-scan is a command published in the GitHub repository SegfaultSorcerer/heap-seance (4 stars, last pushed 5mo ago), licensed Apache-2.0. It adds 60 tokens to every session and 1,225 once invoked, about $0.0003 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.
Other commands, from other repositories
java-debug
Debug Java applications - analyze errors, memory issues, performance.
profile
Coordinate a reproducible Java profiling and optimization lifecycle.
resolve-deps
Diagnose and resolve Swift Package Manager dependency conflicts (launches spm-conflict-resolver agent).
profile-performance
Profile Julia code to find performance bottlenecks — CPU hot spots, runtime dispatch, GC pressure, allocations, and type instabilities — using a fully headless (no-GUI) workflow.
lint:explain
(Ruff) Explain a ruff error and show the PROPER solution (without noqa!).
savant-node
Node.js performance optimization with Node.js Developer agent.