Scores knowledge graph quality across extraction, resolution, structure, query, and operations. Runs a ratchet loop that keeps only metric-improving changes. Use for tuning extraction prompts, ontology, or detecting regressions.
Ships in karpathy-graph. 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.
The evaluation harness has the same shape as Karpathy's autoresearch loop. The
artifact being optimized is not train.py — it is the extraction prompt, the
ontology, the resolution policy, or the query serializer.
Read current extraction prompt and score history
-> Propose ONE motivated change
-> Run extraction on the gold set
-> Compute precision, recall, F1, cost, latency
-> If improved: keep. If worse: revert.
-> Record and continue.
One change at a time. A batch of five changes that improves the metric teaches you nothing about which of the five worked.
Without one you are guessing. Take 10–30 representative units of context and hand-label the entities and relations that should be extracted. Include adversarial cases deliberately:
A gold set of only easy cases certifies a system that fails on the hard ones.
Each layer has a metric and a way it misleads you. Track both.
| Layer | Metric | How it misreads |
|---|---|---|
| Extraction | entity/relation precision, recall, F1 | high precision hides missing entities |
| Resolution | pairwise precision/recall, false-merge rate | compression alone rewards over-merging |
| Graph | components, density, isolated nodes | one component is not always desirable |
| Query | answer accuracy, cited-path validity | fluent answers can cite irrelevant edges |
| Workflow | task success, cost, latency | more agents can raise activity without value |
| Operations | recovery rate, corrections | average success hides catastrophic cases |
Also track schema-valid response rate and cost per document. An extraction prompt that gains two F1 points and triples cost is usually a regression.
KG="${CLAUDE_PLUGIN_ROOT:-plugins/karpathy-graph}/scripts/kgraph.py"
python3 "$KG" --name "<graph>" stats
python3 "$KG" --name "<graph>" validate
Read the trend, not the snapshot:
| Movement | Reads as |
|---|---|
| Isolated nodes jump | resolution regressed, or extraction produced orphans |
| Isolated nodes drop sharply | possible over-merging |
| Components rising | fragmented corpus, or under-merging |
| Components → 1 | check for false merges before calling it success |
| Density falling | relations are being missed |
| Any violation | malformed write — this is a bug, not a metric |
Four conditions make this loop work. Preserve all four:
BEST=$(score_against_gold_set) # baseline
# propose exactly one change
NEW=$(score_against_gold_set)
if better "$NEW" "$BEST"; then
keep; BEST=$NEW
else
revert
fi
# record the trial either way — failures are evidence
Record reverted trials. A change that failed tells the next iteration where not to go; discarding it means rediscovering the same dead end.
Before an artifact ships, verify that every claim in it traces to a graph path.
python3 "$KG" --name "<graph>" path <source_entity> <target_entity>
Unsupported claim → return structured feedback naming the missing evidence, not
a free-form critique. Template: references/grounding.md.
Record the gate itself in the graph, so the evaluation is auditable:
python3 "$KG" --name "<graph>" --run-id "$RUN" add-node \
--type Evaluation --name "grounding gate $RUN" \
--attr rubric="every claim cites a supported edge" \
--attr result="pass"
python3 "$KG" --name "<graph>" --run-id "$RUN" add-edge \
--predicate EVALUATES --source <eval_id> --target <artifact_id>
Invariant I3 requires the rubric. An evaluation without stated criteria is an opinion.
A ratchet improves the metric it can see. It will happily raise F1 while tripling cost, or raise compression while corrupting the graph with false merges.
Hold constraints alongside the objective: cost ceiling, latency ceiling, false-merge rate ceiling, minimum component count. Optimizing extraction quality at the price of resolution precision is not an improvement.
Track trends over time, not isolated scores: extraction rate by document type, schema failure rate, resolution compression, connected-component changes, query latency, subgraph size, cited-edge validity, token cost, stale entity count, graph write failures, agent retry rates.
A sudden rise in isolated nodes signals a resolution regression. A sudden drop signals over-merging. Both need a human before the next build.
What SKILL.md sets; muted values are Claude Code's defaults
7 skills in this plugin
/karpathy-graph-buildStage 3 of the karpathy-graph pipeline, and the end-to-end entry point. Create a graph, assemble validated writes with provenance, and produce the machine and human artifacts. Use when the user asks to build or create a knowledge graph from a context, to add facts to an existing graph, or when running the whole extract-resolve-assemble-query pipeline in one go./karpathy-graph-extractStage 1 of the karpathy-graph pipeline. Turn unstructured context — documents, source files, incident timelines, chat logs, research notes — into typed entities and subject-predicate-object relations that fit the graph ontology. Use when the user asks to extract entities, pull relations out of documents, map a codebase into a graph, or when building a knowledge graph and no nodes exist yet./karpathy-graph-queryStage 4 of the karpathy-graph pipeline. Answer multi-hop questions from a knowledge graph by retrieving a bounded subgraph with edge citations, and ground or refute claims against actual graph paths. Use when the user asks a question that spans several facts, asks how two things connect, asks to verify or ground a claim, or when an agent needs task-specific context from an existing graph./karpathy-graph-resolveStage 2 of the karpathy-graph pipeline. Collapse duplicate surface forms into canonical entities using context as evidence, reversibly and with a recorded rationale. Use after extraction when the graph contains aliases, abbreviations, or spelling variants of the same thing, when isolated-node count is high, or when the user asks to deduplicate or merge entities./karpathy-graph-swarmFan the karpathy-graph pipeline out across parallel agents that share the graph as memory instead of copying transcripts. Use when the context is too large for one pass — hundreds of documents, a whole codebase, many independent hypotheses — or when the user asks to parallelize graph construction, run a swarm, or use multiple agents to build a graph./karpathy-graph-visualizeRender a karpathy-graph for humans — an interactive HTML explorer, a Mermaid diagram for docs and PRs, and a health report — then explain what the picture actually shows. Use when the user asks to see, visualize, draw, or open the graph, wants a diagram for documentation, or asks what the graph looks like./karpathy-graph:karpathy-graph-evaluatefrom karpathy-graph
npx claudepluginhub andersonlimahw/lemon-ai-hub --plugin karpathy-graphOther plugins' skills for the same job