Mini Context Graph
GitHubOfficialFirst committed by fizznixDistributed by GitHub
- Skill
- Tool integration
- Data and AI
- MIT
- Low risk
- Has scripts
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
Mini Context Graph implements a persistent knowledge management system designed to overcome the limitations of standard RAG. Instead of re-deriving knowledge from scratch, it maintains three synchronized layers: a wiki for human-readable synthesis, a knowledge graph for structural traversal, and an immutable raw source store for provenance. The agent acts as the curator, ingesting documents, extracting entities and relations, and continuously updating the wiki and graph to ensure knowledge accumulates and cross-references over time.
What it does
- Ingests documents to extract entities and relations into a structured knowledge graph.
- Maintains a persistent markdown wiki that synthesizes information and cross-references entities.
- Stores raw source content immutably to provide verifiable evidence for every graph node and edge.
- Supports structural graph traversal to answer complex queries without re-reading source documents.
- Provides a linting workflow to identify contradictions, orphans, and stale claims within the knowledge base.
- Enables fast-path retrieval by searching the wiki before performing deeper graph analysis.
When to use it
- When you need a long-term, evolving knowledge base that grows more accurate with every document ingested.
- When you require strict provenance and citations for every claim made by the agent.
- When you need to perform structural analysis or relationship mapping across a large set of documents.
- When you want to avoid the computational overhead of re-processing raw data for every query.
- When you need to maintain a clean, human-readable wiki alongside a machine-navigable graph.
Advantages
- Compounding knowledge: The system gets smarter and more interconnected as more data is added.
- Verifiable: Every graph connection is linked to specific source text for auditability.
- Hybrid retrieval: Combines the speed of wiki search with the depth of graph traversal.
- Self-maintaining: Includes built-in linting to detect and resolve data inconsistencies.
- Persistent: Knowledge is stored and refined, not generated from scratch on every request.
Usage examples
- “Ingest the provided incident report and update the knowledge base.”
- The agent extracts entities and relations, updates the graph, writes a summary wiki page, and links the new information to existing entity pages.
- “Why does the system crash? Provide evidence.”
- The agent searches the wiki for relevant context and performs a graph traversal to identify the cause, returning the answer with direct citations from the source documents.
- “Run a health check on the wiki.”
- The agent executes the linting workflow to identify and report on orphan pages, broken links, or potential contradictions in the knowledge base.
Install
Download the skill as a ZIP:
https://autogineer.com/agent-skills/github/mini-context-graph/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip mini-context-graph.zip -d .agents/skills
Documentation by fizznix
Mini Context Graph Skill
The Core Idea
Standard RAG re-discovers knowledge from scratch on every query. This skill is different:
Wiki layer — The LLM writes and maintains persistent markdown pages (summaries, entity pages, topic syntheses). Cross-references are already there. The wiki gets richer with every ingest.
Graph layer — Entities and relations are extracted once and stored as a navigable knowledge graph. BFS traversal answers structural queries without re-reading sources.
Raw source layer — Original documents are stored immutably with chunks. Provenance links tie every graph node and edge back to the exact text that supports it.
The LLM writes; the Python tools handle all bookkeeping.
Three Layers
| Layer | Where | What the LLM does | What Python does |
|---|---|---|---|
| Raw Sources | data/documents.json | Reads (never modifies) | Stores chunks + metadata |
| Wiki | wiki/ (markdown) | Writes/updates pages | Manages index.md + log.md |
| Graph | data/graph.json | Extracts entities + relations | Persists, deduplicates, traverses |
⚡ Quick Start for Agents
A complete runnable version of this workflow is in scripts/template_agent_workflow.py — copy and adapt it.
from scripts.contextgraph import ContextGraphSkill
from scripts.tools import wiki_store
skill = ContextGraphSkill()
# ===== INGEST WITH FULL RAG + WIKI =====
# 1. Read references/ingestion.md and references/ontology.md first
# 2. Extract entities and relations (LLM reasoning step)
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."},
]
result = skill.ingest_with_content(
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=entities,
relations=relations,
)
# result = {"doc_id": "doc_001", "chunk_count": 1, "nodes_added": 2, "edges_added": 1}
# 3. Write a wiki summary page for this document
wiki_store.write_page(
category="summary",
title="System Crash Analysis Summary",
content="""---
title: System Crash Analysis
source_document: doc_001
tags: [summary, incident]
---
# System Crash Analysis
**Source:** incident_report.pdf
## Key Claims
- [[memory-leak]] causes [[system-crash]] (confidence: 1.0)
## Entities
- [[memory-leak]] (issue)
- [[system-crash]] (issue)
""",
summary="Incident report: memory leaks cause system crashes.",
)
# ===== QUERY WITH EVIDENCE =====
result = skill.query_with_evidence("Why does the system crash?")
# Returns: {"query": ..., "subgraph": ..., "supporting_documents": [...], "evidence_chain": ...}
# ===== WIKI SEARCH (read wiki before answering) =====
pages = wiki_store.search_wiki("memory leak")
# Returns: [{slug, category, path, snippet}, ...]Operations
Ingest
When a user provides a new document:
Read
references/ingestion.md— entity/relation extraction rules.Read
references/ontology.md— type normalization rules.Extract entities and relations using your LLM reasoning.
Call
skill.ingest_with_content(...)— stores raw content + chunks + graph nodes + provenance.Write a wiki summary page using
wiki_store.write_page(category="summary", ...).Update entity pages — for each new/updated entity, write or update
wiki_store.write_page(category="entity", ...).Update topic pages if the document touches an existing synthesis topic.
A single document ingest will typically touch 3–10 wiki pages.
Query
When a user asks a question:
Check the wiki first —
wiki_store.search_wiki(query)to find relevant pages. Read them.If the wiki has a good answer, synthesize from wiki pages (fast path).
If deeper graph traversal is needed, call
skill.query_with_evidence(query).Return the answer with evidence citations from
supporting_documents.If the answer is valuable, file it back as a new wiki topic page.
Lint
Periodically health-check the wiki:
from scripts.tools import wiki_store
issues = wiki_store.lint_wiki()
# Returns: {orphan_pages, missing_pages, broken_wikilinks, isolated_pages}Ask the LLM to review and fix: broken links, orphan pages, stale claims, missing cross-references. See references/lint.md for full lint workflow.
Ingestion Constraints
❌ Do NOT hallucinate entities not present in the text
❌ Do NOT add relations without explicit textual evidence
❌ Do NOT add edges with confidence < 0.6
✅ Provide
supporting_textfor 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 (config: MAX_GRAPH_DEPTH)
🔒 Only edges with confidence ≥ 0.6 (config: MIN_CONFIDENCE)
🔒 Maximum 50 nodes returned (config: MAX_NODES)
❌ Do NOT fabricate nodes or edges not in the graph
Full Python API Reference
| Method | Purpose | When to Use |
|---|---|---|
skill.ingest_with_content(doc_id, title, source, raw_content, entities, relations) | Full RAG ingest: raw docs + graph + provenance | Every new document |
skill.add_node(name, node_type) | Add single entity (no provenance) | Quick additions without a source doc |
skill.add_edge(source_name, target_name, relation, confidence) | Add single relation | Quick additions without a source doc |
skill.query(query) | Graph-only retrieval → subgraph | Structural queries |
skill.query_with_evidence(query) | Graph + provenance → subgraph + source chunks | Queries requiring citations |
wiki_store.write_page(category, title, content, summary) | Write/update a wiki page | After every ingest; after answering queries |
wiki_store.read_page(category, title) | Read a wiki page | Before answering; for cross-referencing |
wiki_store.search_wiki(query) | Keyword search across wiki | Fast path before graph traversal |
wiki_store.list_pages(category) | List all wiki pages | Getting an overview |
wiki_store.get_log(last_n) | Read recent operations | Understanding wiki history |
wiki_store.lint_wiki() | Health check | Periodic maintenance |
documents_store.list_documents() | List all ingested raw sources | Audit / provenance checking |
documents_store.search_chunks(query) | Chunk-level search | Finding specific evidence |
Design Philosophy
"The wiki is a persistent, compounding artifact. The cross-references are already there. The synthesis already reflects everything you've read." — Karpathy
| Layer | What Happens | Who Owns It |
|---|---|---|
| LLM Reasoning | Extraction, synthesis, writing wiki pages | Agent (.md guidance files) |
| Wiki Persistence | Index, log, file I/O | wiki_store.py |
| Graph Persistence | Dedup, index, BFS traverse | graph_store.py, retrieval_engine.py |
| Raw Source Storage | Immutable docs + chunks + provenance | documents_store.py |
The human curates sources and asks questions. The LLM writes the wiki, extracts the graph, and answers with citations. Python handles all bookkeeping.
Files
- ATTRIBUTION.mdAdded by AutoGineer867 B
- LICENSELicence file added by AutoGineer1.0 KiB
- SKILL.md8.0 KiB
- references/ingestion.md5.0 KiB
- references/lint.md4.1 KiB
- references/ontology.md3.2 KiB
- references/retrieval.md4.3 KiB
- scripts/config.pyScript893 B
- scripts/contextgraph.pyScript11.5 KiB
- scripts/template_agent_workflow.pyScript6.6 KiB
- scripts/tools/__init__.pyScript0 B
- scripts/tools/documents_store.pyScript5.7 KiB
- scripts/tools/graph_store.pyScript6.0 KiB
- scripts/tools/index_store.pyScript2.8 KiB
- scripts/tools/ontology_store.pyScript4.8 KiB
- scripts/tools/retrieval_engine.pyScript1.6 KiB
- scripts/tools/wiki_store.pyScript9.4 KiB
references/retrieval.md
Retrieval Instructions
This file defines how the agent answers queries using the two-layer retrieval strategy: wiki-first (fast path), then graph traversal with evidence (deep path).
Overview
Retrieval is a 7-step process:
Parse the query
Check the wiki first (fast path)
Find seed nodes in the graph
Expand the graph via BFS
Prune noisy nodes
Build the subgraph with provenance
Return structured context
Step 1: Parse the Query
Read the query string and identify:
Key noun phrases: potential entity names (e.g., "system crash", "memory leak")
Keywords: individual meaningful words (e.g., "crash", "leak", "memory")
Normalize all terms to lowercase
Ignore stopwords (e.g., "the", "a", "is", "why", "does", "how", "what").
Step 2: Check the Wiki First (Fast Path)
Before touching the graph, search the wiki. The wiki contains compiled knowledge — cross-references already resolved, contradictions flagged, syntheses written.
from scripts.tools import wiki_store
results = wiki_store.search_wiki(query)For each relevant result, read the page:
content = wiki_store.read_page_by_slug(result["slug"])If the wiki has a sufficient answer:
Synthesize from wiki pages.
Cite the source pages (e.g., "According to [[memory-leak]] and [[system-crash]]...").
File the answer as a new wiki topic page if it's valuable and not already captured:
wiki_store.write_page(category="topic", title="Why System Crashes", content=..., summary=...)Return early — no graph traversal needed.
If the wiki answer is incomplete or missing: proceed to Step 3.
Step 3: Find Seed Nodes
Call index_store.search(query) with the original query string.
This returns node IDs matching entity names or keywords.
If no seed nodes are found:
Try searching with individual keywords from Step 1.
If still no results, return an empty subgraph: "No relevant entities found."
Step 4: Expand the Graph (BFS)
Call retrieval_engine.retrieve(seed_node_ids, depth=2).
BFS from seed nodes:
Depth 1: direct neighbors
Depth 2: neighbors of neighbors
Rules:
Only traverse edges with confidence ≥ MIN_CONFIDENCE (from config.py)
Do NOT traverse beyond depth 2
Collect all visited node IDs
Step 5: Prune Nodes
Limit total nodes to MAX_NODES (from config.py)
Prioritize:
Seed nodes (always include)
Nodes at depth 1
Nodes at depth 2 (as space allows)
Remove nodes only weakly connected (edge confidence < MIN_CONFIDENCE)
Step 6: Build the Subgraph with Provenance
For a standard query, call:
subgraph = skill.query(query)
# Returns: {"nodes": {node_id: {name, type, source_document, source_chunks}},
# "edges": [{source, target, type, confidence, source_document, supporting_text, chunk_id}]}For queries requiring evidence (citations, fact-checking), call:
result = skill.query_with_evidence(query)
# Returns:
# {
# "query": str,
# "subgraph": {"nodes": {...}, "edges": [...]},
# "supporting_documents": [
# {
# "doc_id": str,
# "doc_title": str,
# "supporting_chunks": [{"chunk_id": str, "text": str}, ...]
# }
# ],
# "evidence_chain": "memory leak --[causes]--> system crash"
# }Step 7: Return Structured Context
Return the result with:
Subgraph: nodes + edges (the graph answer)
Supporting documents: source chunks that prove each relation
Evidence chain: human-readable path summary
Wiki references: links to relevant wiki pages found in Step 2
If valuable, file the answer back into the wiki:
wiki_store.write_page(
category="topic",
title=query,
content=f"# {query}\n\n**Evidence chain:** {result['evidence_chain']}\n\n...",
summary="...",
)This way, future queries on the same topic find the answer instantly in the wiki.
Rules
NEVER fabricate nodes or edges not present in the graph
NEVER traverse deeper than depth 2
ALWAYS check the wiki before the graph (wiki-first)
Always include seed nodes in the result, even if they have no edges
Prefer edges with higher confidence when pruning
File valuable answers back into the wiki as topic pages
Return an empty subgraph (not an error) if no relevant nodes are found
Requirements and compatibility
Written for: GitHub Copilot
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Needs Python, Needs Node.js
Security
What our scanner noticed· Low risk
- Scripts that your agent may run
This skill includes scripts that your agent may run. Read them before you use it.
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- First committed by
fizznix
- Publisher
- GitHub (Official)
- Distributed by
- GitHub
- Source
- github/awesome-copilot · skills/mini-context-graph · commit 797337f
- Licence
- MIT License (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
- Contributors
- fizznix, stbenjam
AutoGineer is not affiliated with or endorsed by fizznix or GitHub.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download mini-context-graph.zip