/pmstack:pmstack-find-failuresfrom pmstack: Eval Studio for product managers
Guides a reviewer through analyzing AI product failures using Eval Studio. Sets up trace projects, runs the local studio, suggests failure modes and groupings, and tracks coverage until no new failure modes appear.
Ships in pmstack: Eval Studio for product managers. 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.
Read when SKILL.md points to them.
The reviewer reads traces and writes notes. You organize: set up the project, keep Eval Studio running, watch reviews arrive, and suggest failure modes, flags, and the next traces to read. The reviewer accepts or dismisses every suggestion. Work through the phases in order. Before and after each phase, tell the reviewer in one line what you did and what comes next.
Words used here:
experience.userLabel (patient, customer, employee). Default "customer".Examples use the Maple Dental booking assistant: patients book, move, or cancel appointments by text, web chat, or phone, and the assistant calls tools such as find_slots, book_appointment, and transfer_to_staff.
Locate the pmstack command line. Replace <skill-dir> with this skill's base directory (Claude Code shows it as "Base directory for this skill" when the skill loads) and keep the quotes, since paths often contain spaces:
PMSTACK=""
for p in "<skill-dir>/../../../.pmstack/bin/pmstack.mjs" "<skill-dir>/../../bin/pmstack.mjs" "$HOME/.pmstack/bin/pmstack.mjs"; do
[ -f "$p" ] && PMSTACK="$p" && break
done
node --version must report 20 or newer. If PMSTACK stays empty or Node is older, ask:
pmstack's command line is not on this computer. How do you want to review? A. Use Eval Studio in your browser at https://ryanalberts.github.io/pmstack/studio/ (recommended: nothing to install) B. Download pmstack with
git clone https://github.com/RyanAlberts/pmstack(needs Node 20 or newer), then continue here
On A, the reviewer loads traces in Set up. When they open the AI help drawer ("Ask AI to find more", "Group my notes with AI") and paste its prompt into this chat, answer with only the JSON the prompt asks for. Never install npm packages.
On B, clone it in the current directory, then set PMSTACK="$PWD/pmstack/bin/pmstack.mjs" (the paths above do not look there) and continue.
Set FOLDER to the directory that holds the trace file; the project lives in $FOLDER/pmstack/. Save the helper at the end of this file as pmstack-helper.mjs in a temporary directory outside $FOLDER, and set HELPER to its path.
$FOLDER/pmstack/.studio.json names a live process. Check before any write:
node -e 'try{const s=JSON.parse(require("fs").readFileSync(process.argv[1],"utf8"));process.kill(s.pid,0);console.log("running "+s.url)}catch(e){console.log(e.code==="EPERM"?"running":"stopped")}' "$FOLDER/pmstack/.studio.json"
While it runs, the only file you write is $FOLDER/pmstack/suggestions.json, through the helper. Reading the project is always safe.experience.gate and experience.groupGate (defaults 10 and 30): flags wait until gate traces are reviewed; mode suggestions wait until groupGate. Reviewed means verdict pass or fail. "Not sure yet" (skip) and label-only reviews (verdict: null) do not count.Look before asking: find . -maxdepth 3 \( -name "*.jsonl" -o -name "*.csv" -o -path "*pmstack/project.json" \) -not -path "*/node_modules/*". An existing pmstack/project.json means the project exists: set FOLDER to the directory that contains that pmstack/ folder and go to Phase 3.
pmstack reads JSONL (preferred), JSON arrays, and CSV, in the common shapes: OpenAI or Anthropic chat messages, OpenAI Responses items, question and answer pairs, step logs, plain text. Only id is expected. Format guide: https://github.com/RyanAlberts/pmstack/blob/main/guides/trace-format.md. Traces kept in a tracing vendor (LangSmith, Langfuse, Phoenix, Braintrust) come out through its export, one row per conversation or task.
No traces yet: ask
There are no traces yet. How should we get some? A. Add trace logging to the app, then collect real sessions (recommended when the product has users) B. Generate test conversations now (recommended before launch)
On B, load pmstack-make-traces. On A, give this brief to the coding agent that owns the app (you, when you have its code):
Save every AI session in this app as one trace. A trace holds the user's input, the system instructions, every model call, every tool call with its arguments and result, any documents retrieved, and the final output the user saw. Keep any logging the app already sends to a tracing vendor. Also append one JSON object per session, on one line, to
traces/traces.jsonl, withid,metadata(channel such as sms, web, or voice; persona; user feedback; app version),messages(role, content, tool calls with name and arguments, tool results),stepsfor work outside the chat (retrieved documents with id, title, and text), andoutputwhen the result is not a chat reply (an email, an answer with citations, a list). Leave out passwords, payment details, and government ids.
One Maple Dental trace (a single line in the file):
{"id":"t-0042","metadata":{"channel":"sms","persona":"existing patient"},"messages":[{"role":"system","content":"You are the scheduling assistant for Maple Dental..."},{"role":"user","content":"can I move my cleaning to friday"},{"role":"assistant","content":"","tool_calls":[{"id":"call_a1","name":"find_slots","arguments":{"date":"2026-09-25"}}]},{"role":"tool","tool_call_id":"call_a1","name":"find_slots","content":"{\"slots\":[\"09:30\",\"14:00\"]}"},{"role":"assistant","content":"Friday has 9:30 AM or 2:00 PM open. Which works?"}]}
Put the channel in metadata.channel (sms, voice or phone, web): the chat view uses it to show texts on a phone-width screen with formatting symbols shown literally, calls as a timed transcript, and web chat with formatting rendered.
Done when a trace file holds at least 20 traces (100 or more is better) and the reviewer confirms they may read them.
Read 5 to 10 traces spread across the file: start, middle, end, and each channel or persona. Note where the {userLabel}'s words and the AI's reply live, which steps happen behind the scenes, which tools appear, and which details vary.
Create the project, using the real trace file name (add --view <id> or --pattern <id> when step 1 settled them):
node "$PMSTACK" import "$FOLDER/traces.jsonl" --out "$FOLDER/pmstack/project.json" --name "Maple Dental booking assistant"
The command guesses the view, pattern, stages, and filters. Correct experience in project.json directly (the studio is not running yet):
| Field | Decide | Maple Dental |
|---|---|---|
userLabel | The user word: customer, patient, employee, developer, shopper, prospect, or another | patient |
customerGoal | One sentence: what the {userLabel} is trying to get done | Book, move, or cancel a dental appointment without waiting for the front desk. |
renderer | How the {userLabel} saw the output: chat (text, web chat, calls), email, document, answer (with sources), agent (steps), code-review, fields, list, layout, auto | chat |
rendererBy | Only when some traces look different: { "key": "channel", "map": { "email": "email" } } | not needed |
pattern | How the AI works: single, augmented (one call with tools), chain, routing, parallel, orchestrator, evaluator, agent | augmented |
stages | 3 to 6 steps of the funnel of an AI experience, in order, named in the {userLabel}'s terms | below |
filters | Details with 2 to 12 values worth filtering on | ["channel", "persona"] |
Stage rules: id is lowercase and never changes after creation (unknown and start are reserved). label is what the reviewer sees. column is one of ask understand gather plan act check answer outcome. match says which steps belong to the stage; any listed key can match: tools (exact tool names found in the traces), kinds (user, assistant, tool_call, tool_result, retrieval, llm, tool, handoff, guardrail, note), roles, namePattern (a case-insensitive pattern on the step name), last: "assistant" (the final reply). {} matches no step, so only the reviewer sets that stage. The first matching stage in order wins.
"stages": [
{ "id": "understand", "label": "Understand the request", "column": "understand", "match": {} },
{ "id": "handoff", "label": "Hand off when needed", "column": "plan", "match": { "tools": ["transfer_to_staff"], "kinds": ["handoff"] } },
{ "id": "lookup", "label": "Check the calendar", "column": "gather", "match": { "tools": ["find_slots", "get_patient"] } },
{ "id": "act", "label": "Book or change", "column": "act", "match": { "tools": ["book_appointment", "cancel_appointment", "reschedule_appointment"] } },
{ "id": "reply", "label": "Reply to the patient", "column": "answer", "match": { "last": "assistant" } }
]
When no view shows the output the way the {userLabel} saw it, set "renderer": "layout" with panels such as "layout": [{ "label": "Patient's request", "path": "input", "as": "text" }] (as: text, markdown, chat, cards, table, details, json), or load pmstack-custom-view for a view written in code.
Run node "$PMSTACK" validate "$FOLDER/pmstack/project.json" and fix every error it prints until it exits 0.
Tell the reviewer your choices in 3 to 5 lines (user word, view, stages, filters), then ask:
A. Looks right: open Eval Studio (recommended: every choice can change later in Set up) B. Change who the user is or what they are trying to do C. Change the stages D. Change how traces look
Done when validate exits 0 and the reviewer picked A.
run_in_background), adding --traces <file> when the trace file is not traces.jsonl:
node "$PMSTACK" studio "$FOLDER" --port 0 --open
It prints one line, Eval Studio: http://127.0.0.1:<port>/, and writes the same URL to .studio.json, which it removes on exit.project.batch is null, suggest the first set of 20 (Phase 6, breadth).Done when the reviewer confirms the studio is open.
Run node "$HELPER" "$FOLDER/pmstack/project.json" "$PMSTACK" watch. It re-reads the project every 3 seconds and prints one line whenever the review count changes or a failure mode is added or redefined. In Claude Code, run it with the Monitor tool (description "reviews in ", timeout_ms 1800000) and re-arm it each time it expires while the reviewer is still working. Elsewhere, run it in the background, append its output to a log, and read new lines at the start of each turn.
On each line:
node "$HELPER" "$FOLDER/pmstack/project.json" "$PMSTACK" status. It prints counts, the saturation hint, re-check count, notes waiting to be grouped, coverage per detail value, the priority table, and a suggested next set, all computed by pmstack's own engine so the numbers match the studio.groupGate is reached and notes are waiting (Phase 5); the next set when the current one is done (Phase 6); a report every 20 reviews (Phase 7).Done when the reviewer stops for the day, or the saturation level is stop and the reviewer agrees to move on.
gate)Flags need a failure mode. Until the reviewer creates one ("+ New failure mode from this note" in the judgment panel), stay with breadth (Phase 6). Scan for a failure mode when it first appears and whenever its definition changes. The scan covers every trace not already tagged with the mode, reviewed and unreviewed: flags on traces the reviewer marked Good are the main defense against criteria drift, where the reviewer's idea of good sharpens as they read.
node "$HELPER" "$FOLDER/pmstack/project.json" "$PMSTACK" scan <modeId> "$OUT" (OUT is a temporary directory).{ "modeId": "...", "flags": [ { "traceId", "quote", "reason" } ] }.{ "kind": "flag", "traceId", "modeId", "quote", "reason" }.A Problem review whose note fits an existing failure mode but carries none gets { "kind": "assign", "traceId", "modeId", "quote": "<words from the note>", "reason" }.
groupGate)node "$HELPER" "$FOLDER/pmstack/project.json" "$PMSTACK" group failure "$OUT" (group success for Good notes). Answer it yourself. It lists the notes without a mode, the existing modes, and the stage ids.handoff). "Booked 9:30 before she chose a time" and "Offered 3:30, already booked" look alike but need different fixes, so they become "Books before the patient confirms" (act) and "Offers a time that is taken" (lookup).ignore named "Not a product problem".{ "kind": "mode", "mode": { "name", "definition", "stage", "kind": "failure" }, "traceIds": [...], "reason": "<which notes, and why they belong together>" }. The reviewer unticks notes that do not belong before accepting.Write new suggestions as a JSON array to a temporary file, then run node "$HELPER" "$FOLDER/pmstack/project.json" "$PMSTACK" append <file>. The helper keeps every existing entry unchanged, skips any trace and mode pair or mode name already suggested (dismissed ones included) or already a mode, fills id (sg-<YYYYMMDDHHmmss>-<n>), status, from, createdAt, and reviewed, and replaces the file in one step. The studio polls the file and shows new suggestions with a dashed purple border.
project.batch.items) has a review, suggest the next 20. Start from nextSet in the status output, which mixes detail values and lengths and keeps at least 30% random picks. Swap in up to 5 targeted picks for gaps in coverage (a channel with few reviews, negative feedback, the longest conversations), keeping at least 6 random picks. Append { "kind": "batch", "items": [ { "traceId", "reason" } ], "reason" } with item reasons such as "voice, not reviewed yet", "Has feedback = thumbs_down", "Random pick".recheck is 5 or more, tell the reviewer: " Good traces were reviewed before newer failure modes existed. Filter Review traces to Re-check to confirm them."After every 20 reviews, and whenever asked, report from the status output in 3 to 5 lines:
Reviewed 42 of 170 (sms 25 of 102, web 12 of 54, voice 5 of 14). 17 problems across 5 failure modes. New in your last 20: "Books before the patient confirms". Next set leans on phone calls.
The aim is 100 reviewed traces, or until new failure modes stop appearing. Saturation level group means the latest notes need grouping first. Level stop (20 reviews in a row added no new failure mode, and nothing was renamed or redefined in that span) means say so and suggest Phase 8.
Priority is traces x severity weight (Blocks 3, Hurts 2, Annoys 1); ties go to the earlier stage. The most common failure mode is not always the first to fix. The reviewer decides and records choices in the Funnel tab ("What to fix first") and on the Failure modes cards. For each of the top failure modes, up to 5:
How badly does "Offers a time that is taken" hurt the patient? A. Blocks the patient (recommended: 3 notes say the patient arrived for a slot that was not theirs) B. Hurts the patient or the business C. Annoys the patient
impact field once the studio has stopped.Hand off in one line each: Build a check with an AI judge: pmstack-build-judge (code checks are built in the Checks tab). An answer bot whose failures start at the look-up stage: pmstack-check-sources. Fixes shipped: pmstack-regression-checks.
With nobody to answer (claude -p, codex exec, a scheduled job): run Phases 1 and 2 taking the recommended option at every question, and list each choice. Smoke-test the studio: start it with --port 0 in the background, read the URL, confirm curl -s "<url>api/info" returns "mode":"folder", stop the process, and confirm .studio.json is gone. Print the command that starts it later. Report that no review has happened: the review loop needs a person.
project.json by hand while the studio runs.gate, or suggest failure modes before groupGate.Save as pmstack-helper.mjs outside $FOLDER. It needs Node 20 and the pmstack command line.
// pmstack-helper.mjs: status, watch, AI help prompts, and safe writes to suggestions.json.
// node pmstack-helper.mjs <project.json> <pmstack.mjs> status | watch | scan <modeId> <outDir>
// | group failure|success <outDir> | append <new-suggestions.json>
import { existsSync, readFileSync, renameSync, writeFileSync } from "node:fs";
import { dirname, join } from "node:path";
import { pathToFileURL } from "node:url";
const [projectPath, cliPath, command, arg, outDir] = process.argv.slice(2);
const readJson = (file, empty) => (existsSync(file) ? JSON.parse(readFileSync(file, "utf8")) : empty);
const isReviewed = (r) => r?.verdict === "pass" || r?.verdict === "fail";
if (command === "watch") {
// Read-and-compare loop: one line per change in reviews, or when a failure mode is added or redefined.
let last = "";
setInterval(() => {
let p;
try { p = JSON.parse(readFileSync(projectPath, "utf8")); } catch { return; }
const done = Object.entries(p.reviews ?? {}).filter(([, r]) => isReviewed(r));
const modes = (p.modes ?? []).filter((m) => m.kind === "failure");
const modesEdited = modes.map((m) => m.definitionUpdatedAt ?? m.createdAt ?? "").sort().at(-1) ?? "none";
const state = `reviewed=${done.length} problems=${done.filter(([, r]) => r.verdict === "fail").length} failureModes=${modes.length} modesEdited=${modesEdited}`;
if (state === last) return;
last = state;
const newest = done.sort(([, a], [, b]) => (a.at < b.at ? 1 : -1))[0]?.[0] ?? "none";
console.log(`${state} lastEdited=${newest}`);
}, 3000);
} else if (command === "append") {
// Keep existing entries untouched; skip anything already suggested, dismissed, or already a mode.
const project = readJson(projectPath, {});
const file = join(dirname(projectPath), "suggestions.json");
const current = readJson(file, { suggestions: [] });
const key = (s) => (s.kind === "batch" ? null : s.kind === "mode" ? `mode:${s.mode.name.toLowerCase()}` : `${s.traceId}:${s.modeId}`);
const seen = new Set([...(project.suggestions ?? []), ...current.suggestions].map(key).filter(Boolean));
for (const m of project.modes ?? []) seen.add(`mode:${m.name.toLowerCase()}`);
const stamp = new Date().toISOString().replace(/\D/g, "").slice(0, 14);
const createdAt = new Date().toISOString();
const before = current.suggestions.length;
for (const s of readJson(arg, [])) {
const k = key(s);
if (k && seen.has(k)) continue;
if (k) seen.add(k);
const reviewed = s.traceId ? { reviewed: isReviewed(project.reviews?.[s.traceId]) } : {};
current.suggestions.push({ ...s, ...reviewed, id: `sg-${stamp}-${current.suggestions.length + 1}`, status: "open", from: "agent", createdAt });
}
writeFileSync(`${file}.tmp`, JSON.stringify(current, null, 2));
renameSync(`${file}.tmp`, file); // one-step replace, so the studio never reads half a file
console.log(`Added ${current.suggestions.length - before} suggestion(s).`);
} else {
const { loadProjectFile } = await import(pathToFileURL(cliPath).href);
const lib = await import(new URL("../docs/studio/lib/index.mjs", pathToFileURL(cliPath)).href);
const p = await loadProjectFile(projectPath);
if (command === "status") {
const s = lib.reviewStats(p);
console.log(JSON.stringify({
reviewed: s.reviewed, total: s.total, problems: s.fail, notSure: s.skip, needsNote: s.needsNote,
saturation: lib.saturationHint(p), recheck: lib.recheckQueue(p).length, notesToGroup: lib.unassignedNotes(p).length,
coverage: lib.coverage(p),
priority: lib.priorityTable(p).map((r) => ({ id: r.mode.id, name: r.mode.name, stage: r.mode.stage, traces: r.traces, severity: r.mode.severity ?? null, priority: r.priority })),
nextSet: lib.nextBatch(p, { size: 20, strategy: "mix" }),
}, null, 2));
} else {
const parts = command === "scan" ? lib.scanPrompt(p, arg) : lib.groupingPrompt(p, { kind: arg });
parts.forEach((text, i) => writeFileSync(join(outDir, `${command}-${arg}-${i + 1}.txt`), text));
console.log(`${parts.length} part(s) written to ${outDir}`);
}
}
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub ryanalberts/pmstack --plugin pmstack12 skills in this plugin
/pmstack-build-judgeBuilds an AI judge (a prompt that asks a model for Pass or Fail) for one failure mode found while reviewing traces, and saves it as a check in the pmstack project. Checks the prerequisites (at least 20 Problem and 20 Good labels, no simple rule that could decide it, the product's instructions already ask for the behavior), turns the failure mode's definition into Pass and Fail rules, picks 2 to 4 examples from the examples split only, puts the critique before the result, limits what the judge sees, pins an exact model version, and runs it on the tuning set. Use when a failure mode is marked Build a check and needs judgment a simple rule cannot make, or when someone asks to write, draft, or improve a judge prompt./pmstack-check-sourcesChecks an answer bot that searches documents by testing the search and the answer separately. Reviews full traces first, has the reviewer mark the sources each answer needed, measures the search with Recall@k and mean reciprocal rank, fixes search before the answer step, then builds one judge for answers backed by their sources and another for answers that address the question. Use when a product answers questions from a document collection, knowledge base, help center, or search results, when its answers cite sources, or when someone mentions RAG.Other plugins' skills for the same job