agentleFS
89jobrien89jobrien/godmode/skills/mini-context-graph/SKILL.md

godmode:mini-context-graph

Skill1 starsChanged 57 days agoMITView on GitHub

A persistent, compounding knowledge base combining Karpathy's LLM Wiki pattern with a structured knowledge graph. Ingest documents once — the LLM writes wiki pages, extracts entities and relations into the graph, and stores raw content for evidence retrieval. Knowledge accumulates and cross-references across sessions; it is never re-derived from scratch. Use when building or querying a knowledge base where provenance, structural traversal, and cumulative synthesis matter.

  • Installs packages

The file

Show its rules and text

We split this skill into the rules it gives an agent

20 rules. About 0 are common, 11 are distinctive, and 9 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈11

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 9

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    All commands use --root <dir> to set the data directory (default: .kgx in cwd).

    line 47
  2. Distinctive:

    When a new document arrives:

    line 53
  3. Very specific:

    Read references/ingestion.md — entity/relation extraction rules.

    line 55
  4. Very specific:

    Read references/ontology.md — type normalization rules.

    line 56
  5. Very specific:

    Write a wiki summary page via kgx wiki write.

    line 60
  6. Very specific:

    Update entity pages — for each new or updated entity, write or update via kgx wiki write --category entity.

    line 61
  7. Distinctive:

    Update topic pages if the document touches an existing synthesis topic.

    line 63
  8. Distinctive:

    When answering a question:

    line 82
  9. Very specific:

    Check the wiki first — kgx wiki search <query> to find relevant pages.

    line 84
  10. Distinctive:

    If the wiki has a good answer, synthesize from wiki pages (fast path).

    line 85
  11. Very specific:

    If deeper graph traversal is needed, call kgx query <entity-name>.

    line 86
  12. Distinctive:

    If the answer produces new synthesis, file it back as a wiki topic page.

    line 88
  13. Distinctive:

    Do NOT add entities not explicitly present in the source text

    line 118
  14. Distinctive:

    Do NOT add relations without direct textual evidence

    line 119
  15. Distinctive:

    Do NOT add edges with confidence below 0.6

    line 120
  16. Distinctive:

    Write a wiki summary page for every ingested document

    line 122
  17. Distinctive:

    Update existing entity pages when new information arrives

    line 123
  18. Very specific:

    Only edges with confidence >= 0.6 (MIN_CONFIDENCE)

    line 131
  19. Distinctive:

    Do NOT fabricate nodes or edges not present in the graph

    line 133
  20. Very specific:

    All commands output JSON to stdout.

    line 139

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Mini Context Graph

Standard RAG re-discovers knowledge from scratch on every query. This skill is different:

  1. Wiki layer — Persistent markdown pages (summaries, entity pages, topic syntheses). Cross-references are already there. The wiki gets richer with every ingest.
  2. Graph layer — Entities and relations are extracted once and stored as a navigable knowledge graph. BFS traversal answers structural queries without re-reading sources.
  3. Raw source layer — Original documents stored immutably with chunks. Provenance links tie every graph node and edge back to the exact text that supports it.

The LLM writes; kgx handles all bookkeeping.


Three Layers

LayerWhereWhat the LLM doesWhat kgx does
Raw Sources.kgx/data/documents.jsonReads (never modifies)Stores chunks + metadata
Wiki.kgx/wiki/ (markdown)Writes/updates pagesManages index.md + log.md
Graph.kgx/data/graph.jsonExtracts entities + relationsPersists, deduplicates, traverses

Setup

Install the kgx CLI from the kgx workspace:

cargo install --path ~/dev/kgx/crates/kgx-cli

All commands use --root <dir> to set the data directory (default: .kgx in cwd).


Ingest

When a new document arrives:

  1. Read references/ingestion.md — entity/relation extraction rules.
  2. Read references/ontology.md — type normalization rules.
  3. Extract entities and relations via LLM reasoning.
  4. Pipe a JSON payload to kgx ingest — stores raw content, chunks, graph nodes, provenance.
  5. Write a wiki summary page via kgx wiki write.
  6. Update entity pages — for each new or updated entity, write or update via kgx wiki write --category entity.
  7. Update topic pages if the document touches an existing synthesis topic.

A single document ingest typically touches 3-10 wiki pages.

# Ingest a document with entities and relations
'{"doc_id":"doc_001","title":"System Crash Analysis","source":"/docs/incident_report.pdf","raw_content":"System crashes due to memory leaks. Memory leaks occur when objects are not released.","entities":[{"name":"memory leak","type":"issue","supporting_text":"memory leaks cause crashes"},{"name":"system crash","type":"issue","supporting_text":"system crashes due to memory leaks"}],"relations":[{"source":"memory leak","target":"system crash","type":"causes","confidence":1.0,"supporting_text":"System crashes due to memory leaks."}]}' | kgx ingest
# => {"doc_id": "doc_001", "chunk_count": 1, "nodes_added": 2, "edges_added": 1}

# Write a wiki summary page (content from a file)
# Write the markdown to a temp file, then pipe it:
open /tmp/wiki-page.md | kgx wiki write --category summary --title "System Crash Analysis Summary" \
  --summary "Incident report: memory leaks cause system crashes."

Query

When answering a question:

  1. Check the wiki first — kgx wiki search <query> to find relevant pages. Read them.
  2. If the wiki has a good answer, synthesize from wiki pages (fast path).
  3. If deeper graph traversal is needed, call kgx query <entity-name>.
  4. Return the answer with evidence citations from supporting_chunks.
  5. If the answer produces new synthesis, file it back as a wiki topic page.
# Fast path — search wiki
kgx wiki search "memory leak"
# => [{"slug": "...", "category": "summary", "path": "...", "snippet": "..."}]

# Full path with provenance — BFS from a seed entity
kgx query "memory leak"
# => {"query": "...", "nodes": [...], "edges": [...], "supporting_chunks": [...]}

Lint

Periodically health-check the wiki:

kgx wiki lint
# => {"orphan_pages": [...], "missing_pages": [...], "broken_wikilinks": [...], "isolated_pages": [...]}

Review and fix: broken links, orphan pages, stale claims, missing cross-references. See references/lint.md for the full lint workflow.


Ingestion Rules

  • Do NOT add entities not explicitly present in the source text
  • Do NOT add relations without direct textual evidence
  • Do NOT add edges with confidence below 0.6
  • Provide supporting_text for every entity and relation — this enables provenance
  • Write a wiki summary page for every ingested document
  • Update existing entity pages when new information arrives
  • Flag contradictions in wiki pages when new data conflicts with old claims

Retrieval Constraints

  • Traversal depth must not exceed 2 (MAX_GRAPH_DEPTH)
  • Only edges with confidence >= 0.6 (MIN_CONFIDENCE)
  • Maximum 50 nodes returned (MAX_NODES)
  • Do NOT fabricate nodes or edges not present in the graph

CLI Reference

All commands output JSON to stdout. Use --root <dir> to override the data directory.

CommandPurposeWhen to use
kgx ingest (stdin JSON)Full ingest: raw docs + graph + provenanceEvery new document
kgx query <name>BFS subgraph + provenance chunksQueries requiring citations
kgx graph add-node <name> --entity-type <t>Add single entityQuick additions without a source doc
kgx graph add-edge <src> <tgt> --relation-type <t>Add single relationQuick additions without a source doc
kgx graph search <query>Search nodes by keywordFinding entities
kgx wiki write --category <c> --title <t> --summary <s> (stdin)Write/update a wiki pageAfter every ingest; after queries
kgx wiki read --category <c> --title <t>Read a wiki pageBefore answering; cross-referencing
kgx wiki search <query>Keyword search across wikiFast path before graph traversal
kgx wiki list --category <c>List all wiki pagesGetting an overview
kgx wiki lintHealth checkPeriodic maintenance
kgx docs listList all ingested raw sourcesAudit / provenance checking
kgx docs search <query>Chunk-level searchFinding specific evidence
kgx export --format json --output <dir>Export full context as JSONSnapshots, backups, data exchange
kgx export --format markdown --output <dir>Export as Obsidian-compatible vaultHuman review, Obsidian integration
kgx statsNode/edge/document countsQuick overview

Responsibility Split

LayerWhat happensOwned by
LLM ReasoningExtraction, synthesis, wiki writingAgent (this skill + reference docs)
All PersistenceGraph, wiki, documents, dedup, traversalkgx CLI (Rust)

The human curates sources and asks questions. The LLM writes the wiki, extracts the graph, and answers with citations. kgx handles all bookkeeping.


Related

  • skills/context-map/SKILL.md — pre-implementation codebase mapping (same evidence-first pattern)
  • skills/doublecheck/SKILL.md — verify claims extracted during ingest before committing them
  • references/ingestion.md — entity/relation extraction rules (read before every ingest)
  • references/ontology.md — type normalization rules
  • references/lint.md — wiki health-check workflow
  • Source: https://github.com/89jobrien/kgx

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.