knowledge_graph_skill

A skill for searching and updating a SQLite-backed knowledge graph: a database of facts, concepts, and links organized by team, agent, and directory.

In plain words
What is it for?
Use it to search stored project knowledge, follow links between facts, and add or evolve structured knowledge within the correct scope.
Why use it?
It helps find related information through exact words, meaning-based matches, or connections instead of relying only on file browsing.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/npc-worldwide/npcpy/knowledge_graph_skill
Any agent
npx skills add NPC-Worldwide/npcpy --skill knowledge_graph_skill
Clone the repo
git clone --depth 1 https://github.com/NPC-Worldwide/npcpy

Made for: Claude Code, Codex.

Per session 474 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,301 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00474 $0.01301
Opus 5 $0.00237 $0.00651
Sonnet 5 $0.00095 $0.00260
Haiku 4.5 $0.00047 $0.00130

Measured 3d ago against content hash c7e4d0a292f7, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

knowledge_graph_skill scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

The scan reads SKILL.md. This mod also ships 1 executable file (instruct.py), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/knowledge_graph_skill/SKILL.md · 80 lines

How it starts

The opening of the file, as written. The whole thing — 80 lines — stays where its author put it; the contents beside it link to each section on GitHub.

knowledge_graph_skill

Skill for searching and evolving the SQLite-backed Knowledge Graph. Use this when you need structured fact/concept/link search across one or more teams, NPCs, or directory scopes. The Knowledge Graph (KG) is stored in the application's database (not YAML). It is scoped by (team_name, npc_name, directory_path). Facts and concepts carry generation numbers and origin tags. Search methods (choose the right one):

  1. Keyword search — fast substring match over fact statements. kg_search_facts(engine_or_kg, "keyword") → List[str]

  2. Embedding search — semantic cosine similarity via vector embeddings. kg_embedding_search(engine_or_kg, query="...", embedding_model="nomic-embed-text", embedding_provider="ollama", similarity_threshold=0.6, max_results=20) → List[dict] with 'content', 'type', 'score'

  3. Link search — graph traversal (BFS/DFS) starting from keyword-matched seeds. kg_link_search(engine_or_kg, query="...", max_depth=2, breadth_per_step=5, strategy="bfs", max_results=20) → List[dict] with 'content', 'type', 'depth', 'path', 'score'

  4. Hybrid search — combines keyword + embedding + link, boosting results found by multiple methods. kg_hybrid_search(engine_or_kg, query="...", mode="all", max_depth=2, similarity_threshold=0.6, max_results=20) → List[dict] with 'content', 'type', 'score', 'source'

Graph evolution (use sparingly, usually in background): - kg_initial(content, model, provider) — build a new KG from text - kg_evolve_incremental(existing_kg, new_content_text, ...) — add content - kg_sleep_process(existing_kg, model, provider) — prune/deepen/consolidate - kg_dream_process(existing_kg, model, provider, num_seeds) — speculative synthesis When a user asks a question that spans facts, concepts, and their relationships, prefer hybrid search. For pure semantic similarity without graph structure, use embedding search. For exploring connected neighborhoods, use link search with BFS.

Inputs

Read the full file on GitHub · 80 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 80 lines · 474 tokens per session scan A c7e4d0a292f7

Subscribe to this mod's changes

knowledge_graph_skill is a skill published in the GitHub repository NPC-Worldwide/npcpy (1,494 stars, last pushed 7d ago), licensed MIT. It adds 474 tokens to every session and 1,301 once invoked, about $0.0024 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.