Resolves duplicate entities in a knowledge graph by collapsing aliases, abbreviations, and spelling variants into canonical entities using context evidence. Merges are reversible with recorded rationales.
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.
Extraction creates surface forms, not a clean graph. The same thing appears as an abbreviation, an alias, a former name, a spelling variant, or a partial name. Resolution decides which of those are the same entity.
This is a reasoning task, not a string-matching task.
It fails in both directions:
A false merge is the more expensive error. Collapse two entities into one node and every downstream traversal silently combines their relations, dates, and sources. Nothing errors. The graph just becomes confidently wrong.
When uncertain, do not merge. An unmerged duplicate is visible and fixable. A false merge is invisible.
Only ever compare entities of the same type. An Entity never resolves to a
Source, a Metric never resolves to a Claim.
KG="${CLAUDE_PLUGIN_ROOT:-plugins/karpathy-graph}/scripts/kgraph.py"
python3 "$KG" --name "<graph>" query "" --type Entity --max-nodes 200
Before spending reasoning on candidates, group by anything cheap: shared token,
shared acronym, edit distance, one name being a substring of another, shared
source_docs. This is blocking, not deciding — it builds the candidate set.
For each candidate cluster, weigh the evidence that actually discriminates:
| Evidence | Weight |
|---|---|
| Descriptions describe the same thing | strong |
Same source_docs, same section | strong |
| Alias lists overlap | strong |
| Neighbours in the graph overlap | moderate |
| Names look similar | weak on its own |
Ask: would a careful human reading both descriptions conclude these are the same thing? If the honest answer is "probably", that is a no.
python3 "$KG" --name "<graph>" --run-id "$RUN_ID" resolve \
--canonical <canonical_id> \
--alias <alias_id> --alias <other_alias_id> \
--rationale "both describe the component supplier in the 2026-03-11 incident; shared source section"
The engine keeps every alias node addressable and adds a RESOLVED_TO edge
carrying the rationale. Nothing is destroyed. The canonical entity absorbs the
aliases' names and source_docs.
The rationale is mandatory. "duplicate" is not a rationale. Write the evidence that convinced you, so a human — or a later agent — can audit or reverse the decision.
python3 "$KG" --name "<graph>" retract --edge <resolved_to_edge_id>
One edge. That is the whole cost of reversing a merge, which is exactly why the merge must never destroy the alias node.
After resolving, check REPORT.md:
Compression ratio = surface forms ÷ canonical entities.
A high ratio is not automatically good. Over-merging produces a connected graph that is false. Watch the direction of travel:
| Change | Likely cause |
|---|---|
| Isolated nodes jump up | resolution regressed, or extraction produced orphans |
| Isolated nodes drop sharply | possible over-merging |
| Components collapse toward 1 | check for false merges before celebrating |
| Compression ratio > 3 | inspect a sample of merges by hand |
Sample and verify. Do not trust an aggregate that only rewards merging.
Next stage: karpathy-graph-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-evaluateStage 5 of the karpathy-graph pipeline. Score graph quality across extraction, resolution, structure, query, and operations, and run a ratchet loop that keeps only changes which improve the metric. Use when the user asks how good the graph is, wants to tune extraction prompts or the ontology, asks to measure or improve graph quality, or wants to detect resolution regressions./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-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-resolvefrom karpathy-graph
npx claudepluginhub andersonlimahw/lemon-ai-hub --plugin karpathy-graphOther plugins' skills for the same job