/microscope:compare-jfrfrom microscope
Compares two JVM profiles (before/after) using differential flamegraphs to detect performance regressions or improvements. Use when evaluating code changes, benchmarks, or branches.
Ships in microscope. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Two recordings of the same application — one from before a change, one from after — subtracted frame by frame. The primary is the run under examination and the baseline is what it is measured against; a positive delta always means the primary spends more.
Tool names below omit the prefix your client puts in front of them — mcp__plugin_microscope_jeffrey__ in Claude Code with the microscope plugin, mcp__jeffrey__ in Codex or wherever the server is registered by hand as jeffrey, mcp_jeffrey_ in Gemini CLI; the rest of the name is exact camelCase: compare_movements, not compare_movements_list.
Any two recordings can be subtracted, and the result always looks like a finding. Whether it is one depends on facts the deltas do not show: that both runs did the same kind of work, for a comparable length of time, with the same profiler settings. Nothing inside a JFR file proves any of that.
So compare_list is not a warm-up call, and compare_quality after it is not one either. Between
them they decide whether the rest means anything, and their answer is a finding in its own right —
"these two runs are not comparable" is a real, reportable result, and a far better one than a
confident regression that was really a recording twice as long, or a sampler that dropped a third
of its samples on one side.
profileIdsprofiles_list shows every analysed profile with its name, recording time and duration. Pick the
baseline (before) and the primary (after) from it.
The user named two files (before.jfr and after.jfr) — call recordings_analyzeFile with the
absolute path for each; recordings_analyzeFile returns the existing profile for a file with
the same name and size as one already imported; after re-recording to the same path, pass
force=true.
Jeffrey opens those paths itself, so both files must be on the machine Jeffrey runs on. If no
recordings_ tool is advertised, this Jeffrey has ingestion switched off — upload both in the UI
first.
Getting the direction right matters: pass the after run as profileId and the before run
as baselineProfileId. Backwards, every regression reads as an improvement.
compare_list reports both recordings' span and length (durationMs, null for a side that
carries no span), the event types they have in common with each side's totals, and the types only
one of them recorded. Its uiLink opens the pair's differential grid in Microscope, for the user.
Read its notes, and stop to think when:
comparable is empty (status: EMPTY). There is nothing to compare — different formats,
one is a heap dump, or wholly different profiler settings. Say so and stop.Then call compare_quality with the same two ids before quoting a delta. It returns evidence,
not a single comparability verdict. Assess the question using these fields:
samplingConfiguration, matchingSettings and findings: samplingConfiguration lists only the
common types whose stored settings are MISMATCH or UNKNOWN — their event volumes need
qualification — and matchingSettings counts the ones that match, which supports comparing them.
Check each side's samplerHealth for sample loss too. A matching snapshot does not prove
unchanged settings throughout either recording.commonEventTypes, onlyInPrimary and onlyInBaseline: compare shared evidence. A type absent
on one side is not evidence that the application stopped doing that work.durationNormalization.available: recording-exposure scaling is possible when true. It does
not establish equal workload or request rate; filtered graph exports use the selected window,
while this tool describes whole recordings.workloadNormalization.available: currently false because observed server events do not
establish complete operation counts. This prevents per-request efficiency or speed claims from
these counts alone. It does not prevent comparing observed hotspot shares or qualified
duration-normalized movements. State the denominator and the limitation.truncation: omitted evidence is unknown, not a clean bill of health.Open the report with your assessment of what can be compared and its limitations. That assessment is about the recordings: matching settings, lengths and sampler health show the two were recorded the same way, never that the runs did the same work. Say both in one sentence — "recorded the same way (30.5 s against 30.4 s, all 89 shared types' settings match); whether both did the same work is not shown" — unless the user or the workload states it. Never write "the runs are comparable" on its own. If no shared event type supports the requested comparison, report that gap and stop. Otherwise compare the supported dimensions, and keep a workload regression claim separate from an observed movement.
If the two runs came from different machines, different load levels or different JVM flags, say so before anything else. No amount of arithmetic recovers that, and the numbers will look just as precise either way.
compare_movements with the eventType from compare_list. This is the main tool. It returns the
methods that grew and the ones that shrank, ranked by how much work moved with them.
jdk.ExecutionSample, or jdk.CPUTimeSample for a recording made with JDK 25's
CPU-time sampler turned on (the JDK's settings leave it off) — take whichever compare_list reports
in commonjdk.ObjectAllocationSample with useWeight: true, so the ranking is by bytes
rather than by allocation countjdk.JavaMonitorEnter with useWeight: true (weight is nanoseconds blocked)Movements are attributed by self weight, so a change is charged to the method that actually moved rather than to every caller above it. That is why the ranked list is the first read and the tree is the second.
The document opens with its own comparability section and an explanation of every column. Follow that preamble; it is written against the code that produced the numbers.
A window narrows both sides: startEpochMs/endEpochMs are instants on the primary's clock,
applied at the same offset into the baseline, and the answer's window reports where it landed on
each recording. The uiLink opens the differential flamegraph with the same event type, filters,
window and baseline; its uiLinkNote says what the page shows differently from the ranking.
compare_flamegraph exports the merged call tree, so a movement can be followed to the call paths
it travelled through — which caller started spending more, whether the work is new or grew in
place.
Pruning is by movement, not by size: a subtree in which nothing changed is dropped however
large it is. Absence in this tree means "did not move", not "not present" — the opposite of the
single-profile flamegraph_export. Lower thresholdPct to chase one path; raise it for the shape
of the change.
[NEW] and once as [GONE], often of near-identical
size. Both documents list such pairs as candidate renames. They are suspicions; you have the
source diff and the profile does not, so check it before reporting either half as a real change.compare_movements ranks nothing above the pruning
threshold, report exactly that — "no movement above the threshold on this event type" — and not
that the two builds perform identically: a change smaller than run-to-run variance is invisible
to this method, and the report says so.Write the result in the report skill's shape: the comparability assessment first, worded as in
§2, then each movement with the compare_movements call and its figures, the confidence the
comparability notes allow, and the two profile ids with which one was the baseline.
The profile says where, never why. With the repository open alongside, read the real source for each moved method before naming a file or a line — never infer them from a frame name — and map the movements onto the actual diff. A regression that lines up with a hunk in the change is a finding; one that does not is a lead, and often a rename or an unrelated shift in load.
Ask about the diff directly. Read recordingCommit with profiles_get on both profiles first —
a commit is never assumed missing — then which change to read:
recordingCommit (profiles_get): the change is
<baseline commit>..<primary commit> — never HEAD~1..HEAD. When git rev-parse HEAD is past the
primary's commit, say so in one line ("profiled at abc1234, HEAD is def5678, one commit later") and
read the source at the primary's commit (git show <commit>:<path>) before naming a line.git log -1 --stat and git show <that commit>, and say the pairing is the user's word — nothing
in the profiles ties them to those commits.git diff --stat over that range names the changed files; read each hunk and write down the
methods it changed — the method a hunk sits in, and each method it adds a call to — as
Class#method, in source spelling. compare_methods with
those methods, the same eventType and window as the ranking, and your framePrefixes answers
for each of them on both sides — movement (NEW, GONE, MORE, LESS, UNCHANGED), the change
scaled onto the primary's length, the callees that appeared or vanished below it, and the runtime
names matched on each side. Read unlistedMovers before concluding: a method of yours outside the
diff that moved as much is the finding the diff did not predict. UNCHANGED is below 0.1 % of the
primary, inside the noise of a sampled profile — say so rather than "no effect".
optimize-code carries the full profile-to-code-change workflow once the regression is located.
Comparison documents are large, and answering well often takes several. A jfr-analyst
agent — microscope:jfr-analyst from the Claude Code plugin, or the Codex custom agent from
codex/agents/jfr-analyst.toml — runs a sequence and returns only the findings. Give it both
profile ids, which is the baseline, and the one question. Delegate when more than one event type is
in play or the chase runs deep; read here when there is exactly one document and it will be
discussed turn by turn. A document the client saved to a file the analyst cannot open comes back under
Saved, not read, with its call: read those files here before answering.
You are usually running inside the repository of the application that was profiled, so a finding
can become a change to its code. When it can, offer that as an option labelled exactly
Implement fixes — not "I can propose a change" in passing — beside the follow-ups that close the
answer. In Claude Code close with AskUserQuestion whenever this option is on offer, a named area's
answer included: the follow-ups, Implement fixes, and "Stop here". Elsewhere, one line that
starts "Implement fixes:". Offer it, never take it: nothing is edited until the user picks it.
Before you send a reply whose findings name code this repository holds, check its close: the option
reads Implement fixes, word for word. "Fix count(): I can propose changes" is the same offer
without its name, and the user cannot pick it.
Offer it only when both hold, or it is noise — and when they do not, leave it out without a word: no "Implement fixes: not on offer", no sentence on why there is nothing to fix. Run both checks before you write the offer: one that says it has not yet checked whether the class is here is not offered.
.git there (Glob), or git rev-parse --show-toplevel answering;gcRootPath names the field, or the thread and stackFrame that hold it), the configuration file
(logback.xml, application.yml, a pool's settings): Grep or Glob for it finds a file there,
not only JDK, framework or library code.Then say how the code relates to the profile in the option's description: profiles_get's
recordingCommit against git rev-parse HEAD — "profiled at abc1234, HEAD is def5678" when they
differ, "commit not recorded" when recordingCommit is null (a heap dump carries none). That
qualifies the offer; it never removes it.
The option's description names what it would change, at most two findings by place (say, logback.xml's caller data, the pricing class's line formatter, or the audit log's unbounded list). When the user asks what else there is, or the analysis winds down, the ledger's Covered findings that pass the same check become one multi-select Implement fixes for: question.
Picked, it hands over to the optimize-code skill with what this conversation already established —
the profile id, each finding's frame or setting, its figures and its link — so it starts at reading
the source rather than choosing evidence again, and keeps its own gate: the proposed change per
finding first, then which to apply, and only the accepted ones are edited. A setting (a JVM flag, a
pool size) is proposed as a value to change, not as an edit to code. After the build and the tests,
offer Re-profile and compare — profile-run records the changed code, compare-jfr puts it
against this profile — so the fix is measured rather than assumed. A heap finding is measured by a
second dump taken under the same load and put against this one with heap_diff, the earlier dump as
the baseline.
Jeffrey never reads this repository, so it is told which code is the application's own: the root
packages of the source tree you are in, passed as framePrefixes. Work them out once and reuse them
for every call:
Glob for **/src/main/java/**/*.java and **/src/main/kotlin/**/*.kt and take the shortest
package roots shared by the files (usually two or three segments: com.acme.orders.). Fall back to
the groupId in pom.xml or the group in build.gradle(.kts). In a multi-module repository
where the question is about one service, take that module's packages and the shared ones it uses.com.acme. does not also match com.acmecorp..java., org.springframework.):
library and JDK work is already charged to the own method that called it. What a library costs on
its own is read from flamegraph_export.com.acme.orders." — so the user can correct you before
anything depends on it. code_hotspots called without them answers with the profile's busiest
non-library packages as suggestedFramePrefixes; one that differs from yours means the profile is
of another application, or the code was shaded or relocated.A frame comes back by its runtime name, and source and runtime spell code differently: a lambda body
runs as Outer#lambda$method$1, a nested class is Outer$Inner at runtime and Outer.Inner in
source, a Kotlin top-level function lives on FileKt, a Kotlin lambda or coroutine is a class named
after its function (Outer$method$1). code_method takes the source spelling and lists every runtime
name it merged in matchedFrames — read them before you name a line of source for a figure. A row of
code_hotspots or code_callSites, and each of compare_methods' unlistedMovers, carries its
reference in that spelling: pass it on as it is, never the row's runtime methodName. A hotspot that
is your own wrapper — a database client, an HTTP helper, a generic executor — is charged everything
below it, so the change is rarely in it: its calledFrom names the code of yours in another class that
asked for the cost (the repository method behind a query, the service behind a call), and that is where
a fix lands. Name both. A method compare_methods answers NOT_SEEN lists
nearestReferences — most often the same method with its nested class or package spelled out
(com.acme.Checkout.PriceCalculator#formatLine for Checkout#formatLine). A NOT_SEEN method has
no figures: if the answer's first nextTools entry is compare_methods, make that call before you
read, report or compare any figure of that method. It respells the methods Jeffrey can match without
doubt. Never stand in an unlistedMovers row for a listed method: its charged cost leaves out the
own methods it calls, so it hides the very change a diff added below it. With no such entry, the
candidates are ambiguous or live in another class; check their classes in the source before you pass
one yourself.
Whenever a reply names something Microscope can open — the profile, a flamegraph, an operation, a
trace, an endpoint, a statement group, a GC, JIT or thread page, a heap class or object, a
differential, a catalogue row, a ledger entry — make the name a Markdown link marked with ↗:
[trace 7e34c5994dc96208 ↗](<its uiLink>), and in a table a column of [↗ open](<its uiLink>).
Every link carries the mark — every profile named too, the analysed one and its baseline alike, and
a page named in passing ("the exceptions page"), a profile named under Not assessed or Open
leads, and a figure's source given as the page it was read off ([slowest traces ↗](<its uiLink>)) — the
links most often left bare: [checkout candidate ↗](<its uiLink>) — and never the bare URL. The ↗ is what makes it a link the
user sees: a terminal that renders links shows the text alone, clickable, with the URL behind it,
and an unmarked name reads as plain words. That holds in every reply, not only in a written report:
a finding, a ranked list, a follow-up offer, a sentence in passing. Before you send a reply, check
it: every ]( closes a link text that holds ↗.
uiLink — a trace, an
operation, an exemplar — links with that one; otherwise the answer's uiLink is the page that
shows the row. Quote the uiLinkNote beside it when there is one.profiles_viewLink, one cheap call; the profile itself → profiles_link.[GC page ↗](<its uiLink>) — and
a tool stays in backticks beside it, plain. A tool you did not call — a follow-up on offer, a check under
Not assessed — is named that way and not linked at all: `jvm_safepoints` alone, never
[`jvm_safepoints`](<a link>) and never the profile's own link in place of a page you have no link for.profileId and baselineProfileId are the same profile → pick two different runs.no event type in common → the two profiles cannot be compared; profiles_features on each
shows what they actually hold.compare_list before reporting it.compare_list first, then the
candidate renames, before believing it.Related skills: analyze-jfr for a single profile, optimize-code to turn a located regression into
an edit, jfr-sql for raw SQL against either profile, report for the shape the result is written
in.
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub petrbouda/jeffrey --plugin microscope13 skills in this plugin
/analyze-connectorFinds and analyses JVM recordings that live on the connector (the recording volume on an Azure file share, or in a local directory) rather than in a file the user has — the JFR recordings, heap dumps, application logs, GC logs and crash files a deployed application produced. Use whenever the user asks about what an environment recorded or wrote rather than about a file they have: production, staging, a named service, "the last hour", "since the deploy", "what the connector has", "why was prod slow this morning", "why did the pod's JVM die", "the exceptions in the service log". It locates the session, asks which interval matters, pulls in that part of the recording — or the one file that matters — and hands off to analyze-jfr or analyze-heap, or reads the log itself. For a recording file already on this machine, analyze-jfr applies directly./analyze-exceptionsAnalyses the exceptions an application threw in a Jeffrey profile and traces each one to the code in the current repository that caused it — separates the application's throws (libraries included, so timeouts and connection resets stay) from the JVM's own class-loading and linking noise, finds where the application's code entered each throw, reads that source and recommends the smallest fix. Use whenever the user asks to analyse the exceptions or errors of an application, service or recording, why an application throws so much, what an exception storm or a burst of timeouts in a profile is caused by, whether exceptions are used as control flow, or names an exception class seen in a JFR recording or Microscope's Exceptions page./analyze-heapAnalyses a heap dump held by a running Jeffrey Microscope — what is holding the memory, what is leaking, which class loader survived a redeploy, where the waste is — starting from the catalogue or from a .hprof file Jeffrey has not seen yet. Use whenever the user asks what is holding memory, why the heap keeps growing, why the JVM ran out of memory, what is leaking, or mentions retained size, a dominator tree, GC roots, a heap dump or an .hprof file./analyze-jfrAnalyses a JVM profile held by a running Jeffrey Microscope — CPU, wall-clock, allocation, lock contention, trace latency, and the machine underneath: garbage collection, safepoints, JIT compilation, threads, native memory, the container and the JVM's configuration. Starts from the catalogue or from a .jfr file Jeffrey has not seen yet. Use whenever the user asks why something is slow, where the time goes, what is allocating, why GC pauses are long, what is pausing the JVM, what the JIT compiler or deoptimisation is doing, which threads are burning CPU, why memory grows outside the heap, whether the container is throttling, what a JFR recording or flamegraph shows, or mentions a Jeffrey profile, a .jfr file or async-profiler output. For a heap dump or .hprof file, analyze-heap applies instead./code-insightAnswers questions about the code in the current repository from a Jeffrey profile, asked by the names in the source - whether a method or class is hot, who calls it at runtime, which of its lines the time goes to, what it calls into, which exceptions are thrown under it, which requests run it, which of the repository's own methods a profile's cost is charged to, which lines issue a SQL statement or call and how often one request does (N+1), and what the application did at runtime - its operations, statements, attributes and own events - tied back to the code. Use whenever the user asks about the runtime behaviour of code they are reading or editing - "is this method hot", "who calls this in production", "what does this class cost", "which endpoint runs this", "where does our code spend its time", "which line issues this query", "is there an N+1", "what does this service actually do at runtime" - and a profile of that code exists or can be recorded./heap-sqlLoad before the first heap_executeQuery call, whichever skill is driving the analysis: the schema of a Jeffrey heap-dump index (class, instance, outbound_ref, class_instance_field, string_content, gc_root, dominator, retained_size) and the traps that return a wrong answer without an error — the string table is the name pool, not the String contents; outbound_ref.field_id counts the whole field layout; retained sizes need the current tree. Use for what the purpose-built heap tools do not answer: what objects' fields or strings hold across a class, a count or join they do not shape.Other plugins' skills for the same job