{"id":"ce977b7c-29b2-4ea6-8ed9-7eba0b81cd02","shortId":"8jn4wB","kind":"skill","title":"mini-context-graph","tagline":"A persistent, compounding knowledge base combining Karpathy's LLM Wiki pattern\nwith a structured knowledge graph. Ingest documents once — the LLM writes wiki\npages, extracts entities/relations into the graph, and stores raw content for\nevidence retrieval. Knowledge accumulates an","description":"# Mini Context Graph Skill\n\n## The Core Idea\n\nStandard RAG re-discovers knowledge from scratch on every query. This skill is different:\n\n1. **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.\n2. **Graph layer** — Entities and relations are extracted once and stored as a navigable knowledge graph. BFS traversal answers structural queries without re-reading sources.\n3. **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.\n\n> The LLM writes; the Python tools handle all bookkeeping.\n\n---\n\n## Three Layers\n\n| Layer | Where | What the LLM does | What Python does |\n|-------|-------|-------------------|-----------------|\n| **Raw Sources** | `data/documents.json` | Reads (never modifies) | Stores chunks + metadata |\n| **Wiki** | `wiki/` (markdown) | Writes/updates pages | Manages index.md + log.md |\n| **Graph** | `data/graph.json` | Extracts entities + relations | Persists, deduplicates, traverses |\n\n---\n\n## ⚡ Quick Start for Agents\n\n```python\nfrom scripts.contextgraph import ContextGraphSkill\nfrom scripts.tools import wiki_store\n\nskill = ContextGraphSkill()\n\n# ===== INGEST WITH FULL RAG + WIKI =====\n# 1. Read references/ingestion.md and references/ontology.md first\n# 2. Extract entities and relations (LLM reasoning step)\nentities = [\n    {\"name\": \"memory leak\",   \"type\": \"issue\",  \"supporting_text\": \"memory leaks cause crashes\"},\n    {\"name\": \"system crash\",  \"type\": \"issue\",  \"supporting_text\": \"system crashes due to memory leaks\"},\n]\nrelations = [\n    {\"source\": \"memory leak\", \"target\": \"system crash\", \"type\": \"causes\",\n     \"confidence\": 1.0, \"supporting_text\": \"System crashes due to memory leaks.\"},\n]\n\nresult = skill.ingest_with_content(\n    doc_id=\"doc_001\",\n    title=\"System Crash Analysis\",\n    source=\"/docs/incident_report.pdf\",\n    raw_content=\"System crashes due to memory leaks. Memory leaks occur when objects are not released.\",\n    entities=entities,\n    relations=relations,\n)\n# result = {\"doc_id\": \"doc_001\", \"chunk_count\": 1, \"nodes_added\": 2, \"edges_added\": 1}\n\n# 3. Write a wiki summary page for this document\nwiki_store.write_page(\n    category=\"summary\",\n    title=\"System Crash Analysis Summary\",\n    content=\"\"\"---\ntitle: System Crash Analysis\nsource_document: doc_001\ntags: [summary, incident]\n---\n\n# System Crash Analysis\n\n**Source:** incident_report.pdf\n\n## Key Claims\n\n- [[memory-leak]] causes [[system-crash]] (confidence: 1.0)\n\n## Entities\n\n- [[memory-leak]] (issue)\n- [[system-crash]] (issue)\n\"\"\",\n    summary=\"Incident report: memory leaks cause system crashes.\",\n)\n\n# ===== QUERY WITH EVIDENCE =====\nresult = skill.query_with_evidence(\"Why does the system crash?\")\n# Returns: {\"query\": ..., \"subgraph\": ..., \"supporting_documents\": [...], \"evidence_chain\": ...}\n\n# ===== WIKI SEARCH (read wiki before answering) =====\npages = wiki_store.search_wiki(\"memory leak\")\n# Returns: [{slug, category, path, snippet}, ...]\n```\n\n---\n\n## Operations\n\n### Ingest\n\nWhen a user provides a new document:\n\n1. Read `references/ingestion.md` — entity/relation extraction rules.\n2. Read `references/ontology.md` — type normalization rules.\n3. Extract entities and relations using your LLM reasoning.\n4. Call `skill.ingest_with_content(...)` — stores raw content + chunks + graph nodes + provenance.\n5. **Write a wiki summary page** using `wiki_store.write_page(category=\"summary\", ...)`.\n6. **Update entity pages** — for each new/updated entity, write or update `wiki_store.write_page(category=\"entity\", ...)`.\n7. **Update topic pages** if the document touches an existing synthesis topic.\n8. A single document ingest will typically touch 3–10 wiki pages.\n\n### Query\n\nWhen a user asks a question:\n\n1. **Check the wiki first** — `wiki_store.search_wiki(query)` to find relevant pages. Read them.\n2. If the wiki has a good answer, synthesize from wiki pages (fast path).\n3. If deeper graph traversal is needed, call `skill.query_with_evidence(query)`.\n4. Return the answer with evidence citations from `supporting_documents`.\n5. If the answer is valuable, file it back as a new wiki topic page.\n\n### Lint\n\nPeriodically health-check the wiki:\n\n```python\nfrom scripts.tools import wiki_store\nissues = wiki_store.lint_wiki()\n# Returns: {orphan_pages, missing_pages, broken_wikilinks, isolated_pages}\n```\n\nAsk the LLM to review and fix: broken links, orphan pages, stale claims, missing cross-references. See `references/lint.md` for full lint workflow.\n\n---\n\n## Ingestion Constraints\n\n- ❌ Do NOT hallucinate entities not present in the text\n- ❌ Do NOT add relations without explicit textual evidence\n- ❌ Do NOT add edges with confidence < 0.6\n- ✅ Provide `supporting_text` for every entity and relation — this enables provenance\n- ✅ Write a wiki summary page for every ingested document\n- ✅ Update existing entity pages when new information arrives\n- ✅ Flag contradictions in wiki pages when new data conflicts with old claims\n\n---\n\n## Retrieval Constraints\n\n- 🔒 Traversal depth MUST NOT exceed 2 (config: MAX_GRAPH_DEPTH)\n- 🔒 Only edges with confidence ≥ 0.6 (config: MIN_CONFIDENCE)\n- 🔒 Maximum 50 nodes returned (config: MAX_NODES)\n- ❌ Do NOT fabricate nodes or edges not in the graph\n\n---\n\n## Full Python API Reference\n\n| Method | Purpose | When to Use |\n|--------|---------|-------------|\n| `skill.ingest_with_content(doc_id, title, source, raw_content, entities, relations)` | Full RAG ingest: raw docs + graph + provenance | Every new document |\n| `skill.add_node(name, node_type)` | Add single entity (no provenance) | Quick additions without a source doc |\n| `skill.add_edge(source_name, target_name, relation, confidence)` | Add single relation | Quick additions without a source doc |\n| `skill.query(query)` | Graph-only retrieval → subgraph | Structural queries |\n| `skill.query_with_evidence(query)` | Graph + provenance → subgraph + source chunks | Queries requiring citations |\n| `wiki_store.write_page(category, title, content, summary)` | Write/update a wiki page | After every ingest; after answering queries |\n| `wiki_store.read_page(category, title)` | Read a wiki page | Before answering; for cross-referencing |\n| `wiki_store.search_wiki(query)` | Keyword search across wiki | Fast path before graph traversal |\n| `wiki_store.list_pages(category)` | List all wiki pages | Getting an overview |\n| `wiki_store.get_log(last_n)` | Read recent operations | Understanding wiki history |\n| `wiki_store.lint_wiki()` | Health check | Periodic maintenance |\n| `documents_store.list_documents()` | List all ingested raw sources | Audit / provenance checking |\n| `documents_store.search_chunks(query)` | Chunk-level search | Finding specific evidence |\n\n---\n\n## Design Philosophy\n\n> \"The wiki is a persistent, compounding artifact. The cross-references are already there. The synthesis already reflects everything you've read.\" — Karpathy\n\n| Layer | What Happens | Who Owns It |\n|-------|-----------|-------------|\n| **LLM Reasoning** | Extraction, synthesis, writing wiki pages | Agent (.md guidance files) |\n| **Wiki Persistence** | Index, log, file I/O | `wiki_store.py` |\n| **Graph Persistence** | Dedup, index, BFS traverse | `graph_store.py`, `retrieval_engine.py` |\n| **Raw Source Storage** | Immutable docs + chunks + provenance | `documents_store.py` |\n\nThe human curates sources and asks questions. The LLM writes the wiki, extracts the graph, and answers with citations. Python handles all bookkeeping.","tags":["mini","context","graph","awesome","copilot","github","agent-skills","agents","custom-agents","github-copilot","hacktoberfest","prompt-engineering"],"capabilities":["skill","source-github","skill-mini-context-graph","topic-agent-skills","topic-agents","topic-awesome","topic-custom-agents","topic-github-copilot","topic-hacktoberfest","topic-prompt-engineering"],"categories":["awesome-copilot"],"synonyms":[],"warnings":[],"endpointUrl":"https://skills.sh/github/awesome-copilot/mini-context-graph","protocol":"skill","transport":"skills-sh","auth":{"type":"none","details":{"cli":"npx skills add github/awesome-copilot","source_repo":"https://github.com/github/awesome-copilot","install_from":"skills.sh"}},"qualityScore":"0.700","qualityRationale":"deterministic score 0.70 from registry signals: · indexed on github topic:agent-skills · 33270 github stars · SKILL.md body (7,604 chars)","verified":false,"liveness":"unknown","lastLivenessCheck":null,"agentReviews":{"count":0,"score_avg":null,"cost_usd_avg":null,"success_rate":null,"latency_p50_ms":null,"narrative_summary":null,"summary_updated_at":null},"enrichmentModel":"deterministic:skill-github:v1","enrichmentVersion":1,"enrichedAt":"2026-05-18T18:52:17.486Z","embedding":null,"createdAt":"2026-05-05T06:52:16.345Z","updatedAt":"2026-05-18T18:52:17.486Z","lastSeenAt":"2026-05-18T18:52:17.486Z","tsv":"'/docs/incident_report.pdf':285 '0.6':655,712 '001':279,310,346 '1':66,214,313,319,427,517 '1.0':263,365 '10':507 '2':95,220,316,433,531,703 '3':121,320,439,506,545 '4':448,557 '5':460,567 '50':717 '6':471 '7':486 '8':498 'accumul':42 'across':852 'ad':315,318 'add':643,651,768,787 'addit':774,791 'agent':196,943 'alreadi':86,919,923 'analysi':283,336,342,352 'answer':113,407,538,560,570,831,842,986 'api':735 'arriv':683 'artifact':913 'ask':514,607,975 'audit':892 'back':140,575 'base':9 'bfs':111,958 'bookkeep':156,992 'broken':603,614 'call':449,552 'categori':331,415,469,484,819,835,861 'caus':238,261,360,380 'chain':401 'check':518,586,882,894 'chunk':131,175,311,456,813,896,899,967 'chunk-level':898 'citat':563,816,988 'claim':356,619,695 'combin':10 'compound':7,912 'confid':262,364,654,711,715,786 'config':704,713,720 'conflict':692 'constraint':631,697 'content':37,275,287,338,452,455,744,750,821 'context':3,45 'contextgraphskil':201,208 'contradict':685 'core':49 'count':312 'crash':239,242,248,259,267,282,289,335,341,351,363,373,382,394 'cross':83,622,845,916 'cross-refer':82,621,915 'cross-referenc':844 'curat':972 'data':691 'data/documents.json':170 'data/graph.json':186 'dedup':956 'dedupl':191 'deeper':547 'depth':699,707 'design':905 'differ':65 'discov':55 'doc':276,278,307,309,345,745,757,778,795,966 'document':22,126,328,344,399,426,492,501,566,675,762,886 'documents_store.list':885 'documents_store.py':969 'documents_store.search':895 'due':249,268,290 'edg':139,317,652,709,728,780 'enabl':665 'entiti':78,98,188,222,228,302,303,366,441,473,478,485,635,661,678,751,770 'entities/relations':30 'entity/relation':430 'everi':60,93,135,660,673,760,828 'everyth':925 'evid':39,385,389,400,555,562,648,807,904 'exact':143 'exceed':702 'exist':495,677 'explicit':646 'extract':29,102,187,221,431,440,938,982 'fabric':725 'fast':543,854 'file':573,946,951 'find':526,902 'first':219,521 'fix':613 'flag':684 'full':211,627,733,753 'get':90,866 'good':537 'graph':4,20,33,46,96,110,136,185,457,548,706,732,758,799,809,857,954,984 'graph-on':798 'graph_store.py':960 'guidanc':945 'hallucin':634 'handl':154,990 'happen':932 'health':585,881 'health-check':584 'histori':878 'human':971 'i/o':952 'id':277,308,746 'idea':50 'immut':129,965 'import':200,204,592 'incid':349,376 'incident_report.pdf':354 'index':949,957 'index.md':183 'inform':682 'ingest':21,94,209,419,502,630,674,755,829,889 'isol':605 'issu':233,244,370,374,595 'karpathi':11,929 'key':355 'keyword':850 'knowledg':8,19,41,56,109 'last':871 'layer':68,97,124,158,159,930 'leak':231,237,252,256,271,293,295,359,369,379,412 'level':900 'link':133,615 'lint':582,628 'list':862,887 'llm':13,25,70,149,163,225,446,609,936,978 'log':870,950 'log.md':184 'maintain':73 'mainten':884 'manag':182 'markdown':75,179 'max':705,721 'maximum':716 'md':944 'memori':230,236,251,255,270,292,294,358,368,378,411 'memory-leak':357,367 'metadata':176 'method':737 'min':714 'mini':2,44 'mini-context-graph':1 'miss':601,620 'modifi':173 'must':700 'n':872 'name':229,240,765,782,784 'navig':108 'need':551 'never':172 'new':425,578,681,690,761 'new/updated':477 'node':137,314,458,718,722,726,764,766 'normal':437 'object':298 'occur':296 'old':694 'oper':418,875 'origin':125 'orphan':599,616 'overview':868 'own':934 'page':28,76,79,181,325,330,408,465,468,474,483,489,509,528,542,581,600,602,606,617,671,679,688,818,826,834,840,860,865,942 'path':416,544,855 'pattern':15 'period':583,883 'persist':6,74,190,911,948,955 'philosophi':906 'present':637 'proven':132,459,666,759,772,810,893,968 'provid':423,656 'purpos':738 'python':152,166,197,589,734,989 'queri':61,115,383,396,510,524,556,797,804,808,814,832,849,897 'question':516,976 'quick':193,773,790 'rag':52,212,754 'raw':36,122,168,286,454,749,756,890,962 're':54,118 're-discov':53 're-read':117 'read':119,171,215,404,428,434,529,837,873,928 'reason':226,447,937 'recent':874 'refer':84,623,736,917 'referenc':846 'references/ingestion.md':216,429 'references/lint.md':625 'references/ontology.md':218,435 'reflect':924 'relat':100,189,224,253,304,305,443,644,663,752,785,789 'releas':301 'relev':527 'report':377 'requir':815 'result':272,306,386 'retriev':40,696,801 'retrieval_engine.py':961 'return':395,413,558,598,719 'review':611 'richer':91 'rule':432,438 'scratch':58 'scripts.contextgraph':199 'scripts.tools':203,591 'search':403,851,901 'see':624 'singl':500,769,788 'skill':47,63,207 'skill-mini-context-graph' 'skill.add':763,779 'skill.ingest':273,450,742 'skill.query':387,553,796,805 'slug':414 'snippet':417 'sourc':120,123,169,254,284,343,353,748,777,781,794,812,891,963,973 'source-github' 'specif':903 'stale':618 'standard':51 'start':194 'step':227 'storag':964 'store':35,105,128,174,206,453,594 'structur':18,114,803 'subgraph':397,802,811 'summari':77,324,332,337,348,375,464,470,670,822 'support':146,234,245,264,398,565,657 'synthes':81,539 'synthesi':496,922,939 'system':241,247,258,266,281,288,334,340,350,362,372,381,393 'system-crash':361,371 'tag':347 'target':257,783 'text':144,235,246,265,640,658 'textual':647 'three':157 'tie':134 'titl':280,333,339,747,820,836 'tool':153 'topic':80,488,497,580 'topic-agent-skills' 'topic-agents' 'topic-awesome' 'topic-custom-agents' 'topic-github-copilot' 'topic-hacktoberfest' 'topic-prompt-engineering' 'touch':493,505 'travers':112,192,549,698,858,959 'type':232,243,260,436,767 'typic':504 'understand':876 'updat':472,481,487,676 'use':444,466,741 'user':422,513 'valuabl':572 've':927 'wiki':14,27,67,89,177,178,205,213,323,402,405,410,463,508,520,523,534,541,579,588,593,597,669,687,825,839,848,853,864,877,880,908,941,947,981 'wiki_store.get':869 'wiki_store.lint':596,879 'wiki_store.list':859 'wiki_store.py':953 'wiki_store.read':833 'wiki_store.search':409,522,847 'wiki_store.write':329,467,482,817 'wikilink':604 'without':116,645,775,792 'workflow':629 'write':26,71,150,321,461,479,667,940,979 'write/update':823 'writes/updates':180","prices":[{"id":"24311438-d38c-4991-9d38-993439ac1acb","listingId":"ce977b7c-29b2-4ea6-8ed9-7eba0b81cd02","amountUsd":"0","unit":"free","nativeCurrency":null,"nativeAmount":null,"chain":null,"payTo":null,"paymentMethod":"skill-free","isPrimary":true,"details":{"org":"github","category":"awesome-copilot","install_from":"skills.sh"},"createdAt":"2026-05-05T06:52:16.345Z"}],"sources":[{"listingId":"ce977b7c-29b2-4ea6-8ed9-7eba0b81cd02","source":"github","sourceId":"github/awesome-copilot/mini-context-graph","sourceUrl":"https://github.com/github/awesome-copilot/tree/main/skills/mini-context-graph","isPrimary":false,"firstSeenAt":"2026-05-05T06:52:16.345Z","lastSeenAt":"2026-05-18T18:52:17.486Z"}],"details":{"listingId":"ce977b7c-29b2-4ea6-8ed9-7eba0b81cd02","quickStartSnippet":null,"exampleRequest":null,"exampleResponse":null,"schema":null,"openapiUrl":null,"agentsTxtUrl":null,"citations":[],"useCases":[],"bestFor":[],"notFor":[],"kindDetails":{"org":"github","slug":"mini-context-graph","github":{"repo":"github/awesome-copilot","stars":33270,"topics":["agent-skills","agents","ai","awesome","custom-agents","github-copilot","hacktoberfest","prompt-engineering"],"license":"mit","html_url":"https://github.com/github/awesome-copilot","pushed_at":"2026-05-18T01:26:59Z","description":"Community-contributed instructions, agents, skills, and configurations to help you make the most of GitHub Copilot.","skill_md_sha":"76c383f81f301d6527654b73b40007b030e58f5f","skill_md_path":"skills/mini-context-graph/SKILL.md","default_branch":"main","skill_tree_url":"https://github.com/github/awesome-copilot/tree/main/skills/mini-context-graph"},"layout":"multi","source":"github","category":"awesome-copilot","frontmatter":{"name":"mini-context-graph","description":"A persistent, compounding knowledge base combining Karpathy's LLM Wiki pattern\nwith a structured knowledge graph. Ingest documents once — the LLM writes wiki\npages, extracts entities/relations into the graph, and stores raw content for\nevidence retrieval. Knowledge accumulates and cross-references; it is never\nre-derived from scratch."},"skills_sh_url":"https://skills.sh/github/awesome-copilot/mini-context-graph"},"updatedAt":"2026-05-18T18:52:17.486Z"}}