Extracts typed entities and subject-predicate-object relations from documents, codebases, incident timelines, and research notes into a structured graph ontology. Stage 1 of a pipeline.
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.
Replace the classical NLP pipeline with one schema-constrained pass per document. There is no trained NER model here — the schema is the training data, and the ontology is the contract.
One unit of context at a time. A "unit" is whatever fits comfortably in one pass with room for reasoning:
| Context | Unit |
|---|---|
| Documents | one document, or one section of a long one |
| Codebase | one module or package, not one file |
| Incident | one timeline, one postmortem |
| Research | one paper, one thread |
Never batch unrelated documents into one extraction call. Provenance gets blurred and you cannot tell which source supported which claim.
Emit exactly this shape. Nothing else — no prose, no markdown fence commentary.
{
"nodes": [
{
"type": "Source",
"name": "incident-2026-03-11.md",
"uri": "./docs/incidents/incident-2026-03-11.md"
},
{
"type": "Entity",
"name": "Vendor X",
"description": "component supplier named in the incident report",
"aliases": ["VendorX Ltd", "Vendor-X"]
},
{
"type": "Claim",
"name": "Vendor X supplied Component Z",
"description": "stated in the parts inventory section"
}
],
"edges": [
{
"predicate": "SUPPORTS",
"source": "incident-2026-03-11.md",
"target": "Vendor X supplied Component Z",
"source_doc": "incident-2026-03-11.md#parts-inventory",
"confidence": 0.92
},
{
"predicate": "MENTIONS",
"source": "Vendor X supplied Component Z",
"target": "Vendor X"
}
]
}
Edges may reference nodes by name or by id. Names resolve against the nodes
in the same payload first, then against the existing graph — so you can extract
without knowing what ids the engine will assign.
Always emit a Source node first. Every document you read becomes one.
Every claim you extract must connect back to it. A payload with claims and no
source will fail validate.
Separate entities from claims. An entity is a thing (Vendor X,
AuthMiddleware, val_bpb). A claim is a statement about things
(Vendor X supplied Component Z). Do not encode a statement as an entity name.
Capture aliases as you see them. Abbreviations, former names, spelling variants, casing differences. Resolution (stage 2) depends on this — an alias you drop here is a merge that cannot happen later.
Write descriptions that disambiguate. Resolution uses descriptions as contextual evidence. "Vendor X" is useless. "Component supplier named in the 2026-03-11 incident report" lets a later stage tell it apart from a different Vendor X.
Set honest confidence. Explicitly stated in the text → 0.9–1.0. Strongly implied → 0.7–0.9. Inferred across sentences → 0.5–0.7. Below 0.5, do not emit it. Never round everything to 0.95 to look decisive.
Mark inference explicitly. A claim you reasoned to rather than read gets
"inference": true and no Source edge. Anything else is fabrication.
Precision beats recall here. A missed entity is a gap; a fabricated one contaminates every traversal that touches it.
When the context is source code, map it like this:
| Code concept | Node |
|---|---|
| Module, service, package | Entity |
| The file itself | Source |
| Architectural fact ("auth runs before routing") | Claim |
| Build output, generated report | Artifact |
| Test suite, benchmark | Evaluation |
| Latency, coverage, bundle size | Metric |
Imports and calls become DEPENDS_ON. Derivation and forks become
DERIVED_FROM. Do not create an edge type for every code relationship — the
ontology is fixed.
Write the payload to a file and pass it to the engine:
KG="${CLAUDE_PLUGIN_ROOT:-plugins/karpathy-graph}/scripts/kgraph.py"
python3 "$KG" --name "<graph>" --run-id "$RUN_ID" ingest @extraction.json
The response reports nodes_added, edges_added, and any
invariant_violations. A non-empty violations list means your payload was
malformed — fix the extraction, do not proceed to resolution.
Next stage: karpathy-graph-resolve.
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-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-extractfrom karpathy-graph
npx claudepluginhub andersonlimahw/lemon-ai-hub --plugin karpathy-graphOther plugins' skills for the same job