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/lint.md
Lint Instructions
This file defines the wiki health-check workflow.
Run this periodically (or after a large batch of ingests) to keep the wiki clean and accurate. The pattern is from Karpathy's LLM Wiki: detect contradictions, orphans, broken links, stale claims, and data gaps.
When to Run
After ingesting 5+ documents
When the user asks "check the wiki" or "health check"
When answers seem inconsistent or contradictory
Before a major synthesis or presentation
Step 1: Run the Automated Health Check
from scripts.tools import wiki_store
issues = wiki_store.lint_wiki()
# Returns:
# {
# "orphan_pages": [list of slugs in files but not in index],
# "missing_pages": [list of slugs in index but file deleted],
# "broken_wikilinks": {slug: [broken link targets]},
# "isolated_pages": [slugs with no wikilinks at all],
# }Step 2: Triage Each Issue Type
Orphan Pages
Pages exist on disk but are not in the index. They are invisible to search. Fix: Add them to the index or delete if stale.
# To add to index, re-write the page (this auto-updates the index):
wiki_store.write_page(category="...", title="...", content=existing_content)
# To delete (manual step — confirm with user first):
# rm wiki/{category}/{slug}.mdMissing Pages
In the index but the file was deleted. Dangling references. Fix: Either recreate the page from knowledge or remove from index.
Broken Wikilinks
[[slug]] references that point to pages that don't exist.
Fix: Create the missing page, or correct the link.
Isolated Pages
Pages with no [[wikilinks]] — they are unreachable via link traversal.
Fix: Add links from/to related pages.
Step 3: Check for Contradictions
Read the wiki index and scan for pages that might contradict each other:
pages = wiki_store.list_pages()
# Returns [{slug, category, summary, date}, ...]Look for:
Same entity with conflicting
typein different pagesSame relation with different direction in different pages
Newer ingests that update/supersede older claims
When you find a contradiction:
Add a
## Contradictionssection to the relevant entity/topic pages:## Contradictions - doc_001 says X; doc_003 says not-X — unresolvedFlag it in the log:
# Handled by wiki_store.write_page which auto-appends to log.md
Step 4: Check for Stale Claims
Review pages ingested more than N days ago (use the date field from the index).
Ask: "Has any newer document superseded this claim?"
When a claim is stale:
Update the page: add a
## Supersededsection or update the body.Mark the old claim with (superseded by [[newer-doc-summary]]).
Step 5: Check for Missing Cross-References
For each entity page, check: does it link back to all summary pages that mention it? For each summary page, check: does it link to all entity pages it extracted?
Fix: Read the page and add missing [[slug]] links.
Step 6: Identify Data Gaps
Review entity pages that lack:
A proper description (just a stub)
Any
## RelationssectionAny
## Mentioned inlinks
These are candidates for deeper research or new ingests.
Step 7: Log the Lint Pass
# wiki_store.write_page automatically logs the activity.
# For a manual lint summary, append to log.md via write_page on a topic:
wiki_store.write_page(
category="topic",
title="Lint Pass YYYY-MM-DD",
content="# Lint Pass\n\n## Issues Found\n\n...\n\n## Fixed\n\n...",
summary="Lint pass results",
)Quick Lint Commands
from scripts.tools import wiki_store
# Full health check
issues = wiki_store.lint_wiki()
# Get recent history
log = wiki_store.get_log(last_n=10)
# List all pages
all_pages = wiki_store.list_pages()
# Search for a concept across wiki
results = wiki_store.search_wiki("memory leak")Rules
NEVER delete pages without user confirmation
NEVER auto-resolve a contradiction — flag it for human review
File all lint results as a topic page in the wiki (so the history is visible)
Prefer adding cross-references over rewriting existing content
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