heap-seance: Command for Claude Code

.claude/commands/leak-deep.md

leak-deep is a command for Claude Code from SegfaultSorcerer/heap-seance. It costs 82 tokens per session (1,346 once invoked), scanned A, original, Apache-2.0.

A command for investigating suspected Java memory leaks with runtime recordings, heap snapshots, and analysis tools. A memory leak is retained data that keeps using memory after it is no longer needed.

In plain words
What is it for?
Use it for deep leak investigations, heap-dump analysis, or known out-of-memory problems. It accepts a process ID or process-name pattern and gathers class histograms, Java Flight Recorder data, and related evidence.
Why use it?
It collects evidence about what is growing and which objects keep other objects alive. This is useful when a Java process gradually consumes memory or ends with an out-of-memory error.

Command for Claude Code

Written for Claude Code: allowed-tools in frontmatter.

This is SegfaultSorcerer/heap-seance's own configuration. It tells Claude Code how to work on heap-seance itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything heap-seance configures →

Reuse

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.

Copy the file
curl -O https://raw.githubusercontent.com/SegfaultSorcerer/heap-seance/main/.claude/commands/leak-deep.md
Clone the repo
git clone --depth 1 https://github.com/SegfaultSorcerer/heap-seance

Made for: Claude Code.

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

README.md
[![agentmods](https://agentmods.dev/badge/commands/segfaultsorcerer/heap-seance/leak-deep/github.svg)](https://agentmods.dev/commands/segfaultsorcerer/heap-seance/leak-deep)
Your own site
<a href="https://agentmods.dev/commands/segfaultsorcerer/heap-seance/leak-deep"><img src="https://agentmods.dev/badge/commands/segfaultsorcerer/heap-seance/leak-deep/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 leak-deep

Your own site · 80×15
<a href="https://agentmods.dev/commands/segfaultsorcerer/heap-seance/leak-deep"><img src="https://agentmods.dev/badge/commands/segfaultsorcerer/heap-seance/leak-deep.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 82 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,346 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.00082 $0.01346
Opus 5 $0.00041 $0.00673
Sonnet 5 $0.00016 $0.00269
Haiku 4.5 $0.00008 $0.00135

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

Security

Grade A, and why

leak-deep 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.

.claude/commands/leak-deep.md · 95 lines

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 full deep Java leak forensics for $ARGUMENTS.

Interpret $ARGUMENTS as either a PID (integer) or a process name/pattern (string).

This command runs deep evidence collection unconditionally — it does not wait for scan signals to justify escalation. Use it when you already suspect a leak or want comprehensive evidence.

Step 1: Resolve target process

  • If $ARGUMENTS is an integer, use it directly as PID.
  • If $ARGUMENTS is empty, call java_list_processes() and list all discovered JVMs so the user can choose. Do not pick one silently.
  • If $ARGUMENTS is a string, call java_list_processes() and match by substring against each process display field (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: Capture baseline signals

These establish the growth and GC context that deep tools will corroborate or refute.

  1. Collect 3 histogram samples with java_class_histogram(pid, live_only=true). 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. Without exercising the app between snapshots, leaks stay invisible. This gives the monotonic growth baseline — classes whose retained bytes rise across all 3 snapshots are candidates.
  2. Collect GC snapshot with java_gc_snapshot(pid, interval_s=2, samples=6). This reveals whether old-gen is under pressure and Full GCs are occurring.

Step 3: Deep evidence collection

Run all of these unconditionally, in sequence:

  1. JFR recording: java_jfr_start(pid, profile="profile", duration_s=45) — captures allocation events, GC activity, and object count data over 45 seconds.
  2. JFR summary: java_jfr_summary(jfr_file) — extracts event types and counts. Look for jdk.ObjectCountAfterGC events and whether growth candidate classes appear in allocation-heavy events.
  3. Heap dump: java_heap_dump(pid, live_only=true) — full reachable-object snapshot. live_only=true triggers GC first so the dump contains only retained objects, making dominator analysis cleaner.
  4. MAT leak suspects: java_mat_suspects(heap_dump_file) — runs Eclipse MAT's automated leak suspect analysis. This is the strongest signal: it identifies dominator holders, accumulation points, and retained byte chains.
  5. Allocation profile: java_async_alloc_profile(pid, duration_s=30) — flame graph of allocation hot spots. Only if async-profiler is available. Useful as tie-breaker when MAT and JFR are ambiguous.

Read the full file on GitHub · 95 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. 9d ago First seen · 95 lines · 82 tokens per session scan A 7f5eb789e813

Subscribe to this mod's changes

leak-deep is a command published in the GitHub repository SegfaultSorcerer/heap-seance (4 stars, last pushed 5mo ago), licensed Apache-2.0. It adds 82 tokens to every session and 1,346 once invoked, about $0.0004 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.