Agent skill

Knowledge Graph

by gnomeria in gnomeria/usbtree

Set up and maintain a lightweight, file-based knowledge graph of the repo — entities, typed relations, decisions, gotchas — so agents load context fast instead of re-exploring the codebase every…

MITAuto-check passedKnowledge Management

Install Knowledge Graph

skills CLI
$ npx skills add gnomeria/usbtree --skill knowledge-graph -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install gnomeria/usbtree knowledge-graph --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/gnomeria/usbtree.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/knowledge-graph .claude/skills/knowledge-graph && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
knowledge-graph
GitHub stars
688
Token cost
~1.5k tokens
SKILL.md length
786 words
Files
4 (incl. scripts, references)
Skills in repo
5
Repo updated
First seen
Licence
MIT

At a glance

Set up and maintain a lightweight, file-based knowledge graph of the repo — entities, typed relations, decisions, gotchas — so agents load context fast instead of re-exploring the codebase every…

  • Works in 4 steps: Create .knowledge/README.md (query +… → Seed 5–15 entities from the current… → Copy kg.sh into the repo (scripts/ or… → …
  • The user says knowledge graph
  • SKILL.md covers Pick the right tier — most…, Tier 1 layout, Querying — it's just grep and The two protocols that keep it…, plus 3 more sections
  • Runs Shell scripts from its folder

What it does

Knowledge Graph is an agent skill from gnomeria/usbtree. Set up and maintain a lightweight, file-based knowledge graph of the repo — entities, typed relations, decisions, gotchas — so agents load context fast instead of re-exploring the codebase every session. Use when the user says "knowledge graph", "remember this", "codebase memory", "the agent keeps re-discovering things", or a .knowledge/ directory exists in the repo.

Its SKILL.md is about 1.5k tokens, which your agent loads only when the skill is triggered. The skill folder holds 5 other files, including scripts and reference files (for example `references/formats.md`, `references/session-memory.md` and `scripts/kg.sh`).

It sits in Knowledge Management, covering Knowledge graphs. It works with SQLite. The repository describes itself as: Live USB device tree in your terminal. Rust TUI, no root, no libusb. Full activity metrics on Linux; device tree on macOS/Windows. The licence is MIT.

When your agent uses it

  • The user says knowledge graph
  • Codebase memory
  • The agent keeps re-discovering things
  • A .knowledge/ directory exists in the repo

Example prompts

  • “knowledge graph”
  • “remember this”
  • “codebase memory”
  • “/knowledge-graph”

Requirements

  • A Bash shell

Workflow steps

4 steps, taken from the first numbered list in SKILL.md.

  1. Create .knowledge/README.md (query + update rules, 5 lines) and entities/.
  2. Seed 5–15 entities from the current architecture: the modules, the stores, standing decisions, known gotchas. Don't inventory everything…
  3. Copy kg.sh into the repo (scripts/ or keep calling it from the installed skill) and wire kg.sh stale into CI.
  4. Add one line to CLAUDE.md/AGENTS.md: "Read .knowledge/README.md before exploring; follow its update rule."

What it can do on your machine

Read from SKILL.md and the folder at commit 8ba6a5e. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships 1 file in scripts/ (Shell), which the agent can run.

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Knowledge Graph loads about 1.5k tokens when it runs, and up to ~4.4k if it reads all its reference files. Until then it costs about 97 tokens; SKILL.md has 786 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~97
When it runs · the whole SKILL.md, loaded when a task matches
~1.5k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~4.4k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); the scripts in this folder are not scanned.

SKILL.md

The full file from gnomeria/usbtree at commit 8ba6a5e, republished under its MIT licence (© gnomeria). 786 words, ~1,534 tokens.

Download SKILL.mdSave it as .claude/skills/knowledge-graph/SKILL.md (or your agent's skills folder). This skill also uses 3 other files; get the full folder from GitHub.
name
knowledge-graph
description
Set up and maintain a lightweight, file-based knowledge graph of the repo — entities, typed relations, decisions, gotchas — so agents load context fast instead of re-exploring the codebase every session. Use when the user says "knowledge graph", "remember this", "codebase memory", "the agent keeps re-discovering things", or a `.knowledge/` directory exists in the repo.

Knowledge Graph

Agents forget everything between sessions and re-derive the architecture by reading code — slow, token-hungry, and lossy for things code can't say (why a decision was made, which subsystem bites). The fix is a small, committed knowledge graph the agent reads first and updates as it works. Plain files by default: greppable by any agent, reviewable in PRs, no dependencies. A database only when scale genuinely demands it.

Pick the right tier — most repos stop at 0 or 1

  • Tier 0 — one agents file. CLAUDE.md / AGENTS.md with architecture notes. If the repo's durable knowledge fits in ~100 lines, stop here; a graph would be ceremony.
  • Tier 1 — file graph (the default). .knowledge/ with one markdown file per entity and typed relation lines. Right for most real projects. Everything below describes this tier; exact format in references/formats.md.
  • Tier 2 — SQLite. Same node/edge model in one sqlite3 file. Escalate only past ~200 entities or when you need real traversal (transitive impact, shortest path). Schema + recursive-CTE queries and a file→SQLite migration in references/formats.md.
  • Tier 3 — real graph DB (Kuzu, Neo4j). Only when the application needs graph queries. For agent memory it's overkill: a server or bindings other agents won't have, invisible to grep, unreviewable in diffs. Recommend against unless asked.

Tier 1 layout

.knowledge/
  README.md            # 5 lines: what this is, how to query, the update rule
  entities/<id>.md     # id = <type>-<name>: service-orders, decision-auth-jwt, gotcha-sqlite-wal

Entity types that earn their keep: service/module (code units), store (DBs, queues), decision (what + why + alternatives rejected), gotcha (traps that cost someone an hour), flow (cross-module paths: "checkout touches these five things"). Skip entities for things one ls reveals.

Each entity: frontmatter (id, type, anchors: — real file paths it describes), 3–8 lines of prose an agent can't get faster from the code, and typed relation lines (- depends_on: service-users). Relations are the payoff — backlinks service-users answers "what breaks if I change users?" without reading a line of code.

Querying — it's just grep

scripts/kg.sh bundles the common queries: list, show <id>, links <id> (outgoing), backlinks <id> (who points here — reverse edges are the high-value query), stale (anchors pointing at deleted files), orphans (unlinked entities), anchored <path> (entities whose anchors cover a file — the read-protocol query), new <type> <name>. No script available? Plain grep does everything: grep -l 'depends_on: service-users' .knowledge/entities/*.md.

The two protocols that keep it alive

A stale graph is worse than none — the agent trusts it and acts on lies. Two rules, stated in .knowledge/README.md so every agent sees them:

Read protocol (session start / task start). Before exploring code for a task, run kg.sh anchored <path> for the files in scope; read the hits and their 1-hop neighbors first. Then explore only what the graph doesn't cover.

Write protocol (same commit as the code).

  • Touched code that an entity anchors? Update the entity in the same commit if the description or relations changed.
  • Made a non-obvious choice? Add a decision-* entity — what, why, what was rejected.
  • Lost >30 min to something surprising? Add a gotcha-*. That's the highest-ROI entity type.
  • Run kg.sh stale in CI or pre-commit so renames/deletions can't silently rot anchors.

Keep it small: prune entities whose knowledge became obvious from the code; a 40-entity graph that's true beats a 400-entity graph nobody trusts.

Show full SKILL.md (269 more words)Show less

Beyond the curated graph: session memory

The .knowledge/ graph is semantic memory — deliberate, reviewed, committed. Its complement is episodic memory: observations captured automatically from sessions (what was tried, decided, discovered), stored locally and gitignored, with the good parts promoted into the graph instead of rotting in a log. When a repo needs that layer — "the agent keeps re-learning what it did last week" — see references/session-memory.md: the capture/consolidate/retrieve pipeline distilled from mem0, claude-mem, and Letta, plus a single-binary Go blueprint (SQLite + FTS5, lifecycle hooks, progressive-disclosure retrieval, promote bridging into .knowledge/). No Python, no servers, works with any agent.

With other skills

  • orchestrate skill: the planner reads the graph during analysis and points each task brief at the relevant entity files; worker Discovered notes in results reports get merged into the graph during integration — parallel work becomes a knowledge harvest.
  • debug skill: a confirmed root cause that was expensive to find is a gotcha-* entity.
  • Works for any agent: it's markdown in the repo. Non-Claude agents get "read .knowledge/README.md first" in their brief or agents file.

Setup checklist (new repo)

  1. Create .knowledge/README.md (query + update rules, 5 lines) and entities/.
  2. Seed 5–15 entities from the current architecture: the modules, the stores, standing decisions, known gotchas. Don't inventory everything — seed what you had to learn, not what you can see.
  3. Copy kg.sh into the repo (scripts/ or keep calling it from the installed skill) and wire kg.sh stale into CI.
  4. Add one line to CLAUDE.md/AGENTS.md: "Read .knowledge/README.md before exploring; follow its update rule."

Formats, relation vocabulary, SQLite schema and migration: references/formats.md. Episodic session memory (auto-capture, hooks, Go blueprint): references/session-memory.md.

© gnomeria, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 3 other files (scripts, references) in .agents/skills/knowledge-graph of gnomeria/usbtree.

  • SKILL.md
  • references/formats.md
  • references/session-memory.md
  • scripts/kg.sh

Open the folder on GitHubat commit 8ba6a5e

Compare with similar skills

Knowledge Graph next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Knowledge Graph compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Knowledge Graph this skillgnomeria/usbtree688—~1.5kAutomated safety check: PassMIT
Cortexdbliliang-cn/cortexdb273—~5.7kAutomated safety check: WarnMIT
Graph Buildathola/claude-night-market342—~609Automated safety check: PassMIT
Cortexdb Memory Hermesliliang-cn/cortexdb273—~1.7kAutomated safety check: PassMIT
Cortexdb Memory Openclawliliang-cn/cortexdb273—~1.6kAutomated safety check: PassMIT
Cortexdbliliang-cn/cortexdb273—~18kAutomated safety check: WarnMIT

Similar skills

  • Cortexdb

    liliang-cn/cortexdb

    Use CortexDB for local-first AI memory, vector search, RAG, knowledge graphs, SPARQL/RDFS/SHACL, corpus-to-graph workflows, and MCP/tool calling.

    273 GitHub stars~5.7k tokensUpdated today
    Knowledge ManagementAuto-check: warnings
  • Graph Build

    athola/claude-night-market

    Builds or updates the code knowledge graph via tree-sitter AST and SQLite.

    342 GitHub stars~609 tokensUpdated yesterday
    Knowledge ManagementAuto-check passed
  • Cortexdb Memory Hermes

    liliang-cn/cortexdb

    Give a Python agent (such as Hermes Agent by Nous Research) durable, local-first memory plus a queryable SPARQL knowledge graph, backed by CortexDB through its gRPC sidecar and the cortexdb-client…

    273 GitHub stars~1.7k tokensUpdated today
    Knowledge ManagementAuto-check passed
  • Cortexdb Memory Openclaw

    liliang-cn/cortexdb

    Give a Node.js agent (such as OpenClaw) durable, local-first memory plus a queryable SPARQL knowledge graph, backed by CortexDB through its gRPC sidecar and the cortexdb-client npm package.

    273 GitHub stars~1.6k tokensUpdated today
    Knowledge ManagementAuto-check passed
  • Cortexdb

    liliang-cn/cortexdb

    Use CortexDB for local-first AI memory, vector search, RAG, knowledge graphs, SPARQL/RDFS/SHACL, corpus-to-graph workflows, external structured-data import (CSV / SQL dumps), and MCP/tool calling.

    273 GitHub stars~18k tokensUpdated today
    Knowledge ManagementAuto-check: warnings
  • LLM Wiki Knowledge Graph

    Egonex-AI/Understand-Anything

    Detects a Karpathy-pattern LLM wiki and builds an interactive knowledge graph with entities, implicit relationships and topic clusters.

    85k GitHub starsUsed in 1 repo~1.5k tokens
    Knowledge ManagementAuto-check passed

More from gnomeria/usbtree

  • CI GitHub Actions

    gnomeria/usbtree

    GitHub Actions CI pipeline conventions — job shape, caching, permissions, and action pinning.

    688 GitHub stars~1.4k tokensUpdated 1 mo ago
    Auto-check passed
  • Debug

    gnomeria/usbtree

    Systematic root-cause debugging — reproduce, isolate, fix at the source, prove the fix.

    688 GitHub stars~715 tokensUpdated 1 mo ago
    Auto-check passed
  • Refactor

    gnomeria/usbtree

    Behavior-preserving restructuring done safely — test net first, small verified steps, no mixed-in feature changes.

    688 GitHub stars~669 tokensUpdated 1 mo ago
    Auto-check passed
  • Write Tests

    gnomeria/usbtree

    Author tests that match the repo's stack and existing test style, at the cheapest level that catches the regression.

    688 GitHub stars~622 tokensUpdated 1 mo ago
    Auto-check passed

Works with

Questions about Knowledge Graph

What does Knowledge Graph do?

Set up and maintain a lightweight, file-based knowledge graph of the repo — entities, typed relations, decisions, gotchas — so agents load context fast instead of re-exploring the codebase every…. Knowledge Graph is an agent skill from gnomeria/usbtree. Set up and maintain a lightweight, file-based knowledge graph of the repo — entities, typed relations, decisions, gotchas — so agents load context fast instead of re-exploring the codebase every session.

When should I use Knowledge Graph?

Knowledge Graph fits situations like: the user says knowledge graph; codebase memory; the agent keeps re-discovering things; A .knowledge/ directory exists in the repo.

How do I install Knowledge Graph in Claude Code?

Run `npx skills add gnomeria/usbtree --skill knowledge-graph -a claude-code`. Or copy the skill folder (.agents/skills/knowledge-graph in gnomeria/usbtree) into .claude/skills/knowledge-graph in your project. Claude Code loads it when a task matches its description.

How do I install Knowledge Graph in Codex?

Run `npx skills add gnomeria/usbtree --skill knowledge-graph -a codex`. Or copy the skill folder (.agents/skills/knowledge-graph in gnomeria/usbtree) into .agents/skills/knowledge-graph in your project. Codex loads it when a task matches its description.

Can I use Knowledge Graph in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add gnomeria/usbtree --skill knowledge-graph -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/knowledge-graph, .gemini/skills/knowledge-graph, .github/skills/knowledge-graph and .opencode/skills/knowledge-graph in your project.

What does Knowledge Graph need to run?

Going by SKILL.md and its folder, Knowledge Graph needs a shell for the scripts in its folder. Our summary lists: A Bash shell.

Does Knowledge Graph access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Knowledge Graph safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. The check reads SKILL.md only: the scripts in the folder are not scanned, so read them before running anything.

What licence does Knowledge Graph use?

Knowledge Graph is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Knowledge Graph use?

About 1.5k tokens (SKILL.md is roughly 6.1k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 2.9k tokens, read only when the agent opens those files.

What are the alternatives to Knowledge Graph?

Skills that share tags, products or a category with Knowledge Graph: Cortexdb (liliang-cn/cortexdb, 273 stars), Graph Build (athola/claude-night-market, 342 stars), Cortexdb Memory Hermes (liliang-cn/cortexdb, 273 stars) and Cortexdb Memory Openclaw (liliang-cn/cortexdb, 273 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Knowledge Graph?

gnomeria (a GitHub user) maintains it in gnomeria/usbtree, which has 688 GitHub stars. The repository holds 5 skills in this directory. The repository was last updated on August 20, 2026.

Source: gnomeria/usbtree on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.