knowledge-graph-extract
An agent skill that extracts a knowledge graph — subject–relation–object triplets — from a folder of documents, and optionally turns it into Cypher import scripts for Neo4j/Memgraph.
Built for Claude Code, portable to any agent supporting the Agent Skills format.
Features
- Any documents the agent can read — txt, md, pdf, ... The agent does the reading; the bundled scripts never parse documents.
- Optional graph schema — allowed entity types and relation types (with optional subject/object constraints), provided as a JSON file or inline in the prompt.
- Deterministic chunking + progress manifest — large documents are split at recorded
boundaries (line ranges for text, page ranges for PDFs); every chunk's status is tracked in
manifest.jsonand updated atomically. If the agent runs out of context or the session dies, re-invoking the skill on the same output directory resumes exactly where it stopped. - Entity registry — canonical names and aliases are kept in
entities.jsonlso "IBM" and "International Business Machines" become one node, not two. - Salience budget — an optional max-triplets-per-document cap that keeps the graph focused on the most important facts without truncating documents.
- Deterministic validation & Cypher generation — three Python scripts, stdlib only
(zero pip dependencies, no network, no subprocess, no eval/exec, never connect to a
database). Violating triplets are quarantined to
rejected.jsonl, never silently dropped.
Install
As a Claude Code plugin (works with private repos — uses your git credentials):
/plugin marketplace add maddataanalyst/knowledge-graph-extract # or a full git URL
/plugin install knowledge-graph-extract@knowledge-graph-extract
Manually (Claude Code or any Agent Skills–compatible agent): copy or symlink the skill folder into your skills directory:
cp -r skills/knowledge-graph-extract ~/.claude/skills/ # personal, all projects
# or
cp -r skills/knowledge-graph-extract <project>/.claude/skills/ # per-project
claude.ai / API: zip skills/knowledge-graph-extract/ and upload it in
Settings → Capabilities, or via the API skills endpoint.
Quick start
Extract a knowledge graph from ./papers into ./kg_out.
Entity types: Person, Organization, Method, Dataset.
Relations: PROPOSES, USES, EVALUATED_ON, AFFILIATED_WITH.
Max 80 triplets per document. Then generate the Cypher scripts.
The agent writes everything into ./kg_out:
kg_out/
manifest.json # chunk plan + progress — the resume anchor
schema.json # your schema, normalized
triples.jsonl # {"doc": ..., "chunk": 1, "subject": ..., "relation": ..., "object": ...}
entities.jsonl # canonical names + aliases
rejected.jsonl # schema violations (quarantined by the validator)
cypher/ # 00_constraints_{neo4j,memgraph}, 01_entities, 02_relations — load the 00 for your DB, then 01, 02
If the run is interrupted, just ask again with the same output directory — extraction continues from the first unfinished chunk.
Repo layout
The repo root is the plugin, and the repo doubles as its own single-plugin marketplace —
the same layout as anthropics/skills. Future skills
land as sibling directories under skills/.
.claude-plugin/
marketplace.json # marketplace pointing at "./"
plugin.json # plugin manifest
skills/
knowledge-graph-extract/ # the skill (self-contained)
SKILL.md # agent workflow
references/ # schema + output format specs
scripts/ # kg_status.py, kg_mark.py, validate_triples.py, generate_cypher.py
Related: GraWiki
This skill is a deliberately minimal counterpart to GraWiki (docs) — a Python framework for graph-backed knowledge extraction, retrieval, and agent memory. The two take opposite approaches to the same problem:
- This skill shows that an agent harness alone can build a knowledge graph: the agent reads the documents and extracts triplets, while a few stdlib-only scripts handle validation and Cypher generation. No pip installs, no framework, resumable by design.
- GraWiki is a full code pipeline — structured-output LLM extraction, embeddings, full-text + vector search, graph-traversal context expansion, entity deduplication, and persistent agent memory over FalkorDB/Memgraph.
Use the skill for exploratory, dependency-free extraction inside an agent session; reach for GraWiki when you need a production-grade, queryable knowledge graph.
No comments yet
Be the first to share your take.