Skip to content

Custom graph models

Define your own node and edge types so cognee builds a structured knowledge graph

Stars
33,002
Licence
Apache-2.0
Files
1 file

What it does

This skill teaches an agent how to shape the knowledge graph that the cognee library builds from documents. By default cognee extracts a generic graph of entities and relationships; with this skill the agent writes Python classes (node types, typed edges, identity and search fields) and passes them as graph_model= so the language model fills your own structure. It also covers building such models from a JSON schema and debugging issues like duplicated nodes or missing edges.

Great for

  • Developers building a cognee-based pipeline who need a fixed schema for people, organizations, or other domain entities
  • Engineers debugging duplicated nodes, missing relationships, or InvalidReferenceTypeError in cognee extraction

Skip it if

  • Users who just want to store and query documents with default extraction; this is only needed when customizing the graph schema
  • Non-developers without Python experience, since the guidance is code-level and assumes cognee is already set up

Try asking

  • “Define a Person and Role graph model with identity fields so the same person is not duplicated across documents”
  • “Create typed edges like married_to or sibling_of between people using Literal relationship names”
  • “Convert a JSON Schema describing my domain into a cognee graph model”
  • “Why are my nodes not showing up in recall? Check index_fields and model imports”
Step-by-step guide: how to use Custom graph modelsInstall, first run, examples, tips and FAQs

Install in 3 steps

  1. 1

    Download the skill

    The ZIP contains the 1 original files, the Apache-2.0 licence and an attribution note.

    cognee-custom-graph-models.zip
  2. 2

    Add it to your agent

    Claude Code (all projects)

    mkdir -p ~/.claude/skills && unzip cognee-custom-graph-models.zip -d ~/.claude/skills/

    Claude Code / Agent SDK (this project only)

    mkdir -p .claude/skills && unzip cognee-custom-graph-models.zip -d .claude/skills/

    Claude apps (web/desktop): Settings → Capabilities → Skills → Upload skill, and choose the ZIP.

  3. 3

    Ask for the task

    No special command needed — the agent reads the skill's description and loads it when your request matches. Try one of the prompts above.

Get better results

  • Always set identity_fields on every node type representing a real-world entity, or the same entity will be duplicated in every chunk and run.
  • Write metadata explicitly rather than relying on the Embeddable/Dedup annotation shortcut, since Embeddable does not currently create an index.
  • Import your model classes in any process that performs recall, because graph completion only searches collections of DataPoint classes loaded in that process.

What's inside

  • SKILL.md

Redistributed unmodified from topoteretes/cognee under the Apache-2.0 licence. The assessment was drafted with AI from the skill's files on 2026-10-29. Skills can instruct your agent to run code — read SKILL.md and any scripts before installing.