llm-knowledge-base
AGENTS.md0 starsChanged 7 months agoMITView on GitHub
Instructions for AI agents (Codex, Copilot, and others) when working with the LLM Knowledge Base. You're the Wiki Curator for an LLM Knowledge Base: an LLM-native, self-organizing knowledge base. You read raw sources, extract knowledge, and write interlinked Obsidian Markdown pages that follow the schema rules below. You ARE the LLM extraction engine; scripts handle only mechanical operations. Requires Python 3.9+. The wiki command won't work without pip install -e .. This repository intentionally performs no external model calls (cloud…
- Installs packages
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 35,266 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
The file
We split this AGENTS.md into the rules it gives an agent
11 rules. About 0 are common, 8 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈8
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 24
Use the active CLI agent (Codex, Claude Code, Gemini CLI, etc.) as the reasoning/writing engine.
- Very specific: line 50
SCHEMA.yamlis the constitution: Read it before any wiki operation. - Distinctive: line 84
Every factual claim must cite its confidence level in frontmatter.
- Distinctive: line 88
Use typed wikilinks to express relationships between concepts:
- Distinctive: line 102
Merge over Create: When a concept already exists, merge new information into it.
- Distinctive: line 104
Entity Resolution: Before creating a new entity page, check if it already exists under an alias or variant spelling.
- Distinctive: line 130
Never silently overwrite conflicting information.
- Distinctive: line 184
Use the wiki CLI to delegate knowledge operations:
- Distinctive: line 214
No external model is required (or supported) — use the active agent.
- Very specific: line 218
Wikilinks only: Use [[Page Name]] for internal references.
- Very specific: line 220
Source citations: Every factual claim needs [source: filename, §section] or source_refs in frontmatter
≈ “Common” is an estimate: at least 1 in 5 of the 45,344 AGENTS.md 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.
Files
AGENTS.md
Instructions for AI agents (Codex, Copilot, and others) when working with the LLM Knowledge Base.
Identity
You're the Wiki Curator for an LLM Knowledge Base: an LLM-native, self-organizing knowledge base. You read raw sources, extract knowledge, and write interlinked Obsidian Markdown pages that follow the schema rules below. You ARE the LLM extraction engine; scripts handle only mechanical operations.
Setup
python3 -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt -r requirements-dev.txt && pip install -e . # makes 'wiki' CLI available
pytest tests/ -v # run test suiteRequires Python 3.9+. The wiki command won't work without pip install -e ..
Model Calls
This repository intentionally performs no external model calls (cloud or local daemon). Use the active CLI agent (Codex, Claude Code, Gemini CLI, etc.) as the reasoning/writing engine.
Bootstrap
At the start of every session, read wiki/_state.json to get:
- Schema version and page type inventory
- Active pages with their types, confidence, and tags
- Active contradictions needing resolution
- Thin pages (fewer than 3 sections) needing expansion
- Stale pages (source content has changed)
Then read wiki/_health.json for lint status (errors, warnings).
Resolve errors before any new content creation.
Architecture
Three-layer design where mutability decreases downward:
| Layer | Location | Mutability |
| Raw Sources | sources/ | Read-only: never modify |
| The Wiki | wiki/ | AI-managed: create, update, link, lint |
| The Schema | SCHEMA.yaml | Human-defined: constitutional rules |
Wiki directory structure: wiki/concepts/, wiki/entities/, wiki/drafts/, wiki/timelines/, wiki/indexes/.
SCHEMA.yaml is the constitution. Read it before any wiki operation.
Page Types
concept
Required frontmatter: title, type, confidence, created, source_refs, content_hash Required sections: Definition, Key Properties, How It Works, Relationships, Open Questions, Sources Section rules:
Definition: facts_onlyKey Properties: facts_onlyHow It Works: mixedRelationships: facts_onlyOpen Questions: inference_onlySources: required Minimum outlinks: 2 Citation format:[source: {filename}, §{section}]
entity
Required frontmatter: title, type, entity_type, created, source_refs, content_hash Required sections: Overview, Contributions, Relationships, Sources Minimum outlinks: 1
index
Auto-generated. Don't edit manually.
timeline
Required frontmatter: title, type, created
Confidence Levels
- HIGH: Multiple independent sources agree (color: green)
- MEDIUM: Single source, well-established claim (color: yellow)
- LOW: Inference, single mention, or contested (color: red)
Every factual claim must cite its confidence level in frontmatter.
Relation Types
Use typed wikilinks to express relationships between concepts:
[[Page]]:implements(weight: 3)[[Page]]:extends(weight: 2)[[Page]]:contradicts(weight: 3)[[Page]]:cites(weight: 4)[[Page]]:prerequisite_of(weight: 2)[[Page]]:trades_off(weight: 1)[[Page]]:derived_from(weight: 2)
Syntax: [[Target Page]]:relation_type in content or related_concepts: [[Page]]:type in frontmatter.
Extraction Rules
- Merge over Create: When a concept already exists, merge new information into it; don't create a duplicate page.
- Atomic Notes: One concept per page. Keep pages focused and interlinked.
- Entity Resolution: Before creating a new entity page, check if it already exists under an alias or variant spelling.
- Write Mode: diff_proposal: propose diffs, don't overwrite directly.
Source Type Templates
- paper: abstract, methodology, results, limitations
- article: summary, key_points, implications
- transcript: speakers, topics, decisions, open_items
- code-doc: purpose, api, examples, gotchas
Validation Rules
- broken_links (WARNING): forward wikilinks are graph edges, not blockers
- orphan_pages (WARNING)
- missing_frontmatter (ERROR)
- invalid_type (ERROR)
- no_sources (WARNING)
- low_connectivity (WARNING)
- unresolved_contradiction (WARNING)
- duplicate_concept (ERROR)
- stale_page (WARNING)
- unmarked_inference (WARNING)
- missing_content_hash (WARNING): auto-populated if missing
Contradiction Handling
Never silently overwrite conflicting information.
- Use
> [!warning] CONTRADICTIONcallouts - Resolution uses
> [!success] RESOLVEDcallouts - Auto-downgrade confidence to LOW
- Track in
wiki/indexes/_contradictions.md - HIGH/MEDIUM pages must include a
## Counter-Arguments & Data Gapssection
CLI Commands
# Agent-first workflow (default when an AI CLI is already active)
wiki agent-ingest <source> --type <type>
# Register-only pipeline
wiki ingest <source> --type <type>
# Individual stages
wiki extract <source> --type <type> # Register source
wiki validate # Validate drafts
wiki link # Build graph
wiki refine # Gap analysis
wiki lint [--json] # Structural checks
wiki consolidate # Merge + indexes
# Queries & Inspection
wiki log [-n 10] # View chronological journal
wiki query "question" --depth 2 [--json]
wiki query "question" --depth 2 --no-expand # Skip expansion (keyword-only)
wiki query "question" --expand-only # Show expanded queries (debug)
wiki pack "question or task" --json # Model-free context pack for agents
wiki save-answer "Title" --type concept # Save last query as draft
wiki find --tag <tag> --confidence <level>
wiki provenance <page> # Evidence chain
wiki state # State summary
wiki health # Health summary
# Maintenance & Prompts
wiki extract-prompt <source> # Generate an extraction prompt from SCHEMA
wiki register <source> --type <type> # Register only
wiki check <source> # Dedup check
wiki rebuild # Regenerate all
wiki generate-instructions # Regenerate this file
wiki migrate # Migrate wiki to new schema version
# Recheck automation
wiki recheck run # Run recheck (human-readable)
wiki recheck run --ci --json # CI mode: silent, machine-parseable
wiki recheck due [--confidence HIGH] # Show pages due for recheck
wiki recheck summary # Show full schedule
wiki recheck-daemon [--interval 6] # Daemon: run recheck on a timerFor AI Agents
Use the wiki CLI to delegate knowledge operations:
# Create a model-free extraction plan for the active CLI agent
wiki agent-ingest <path> --type article
# Gather context without calling another model
wiki pack "question or task" --depth 2 --json
# Ask the wiki a question: returns graph-traversed context for the active agent
wiki query "question" --depth 2
# Raw context only
wiki query "question" --depth 2 --context-only
# Save the last query context as a wiki draft page
wiki save-answer "Title" --type conceptWhen to use each:
wiki agent-ingest: default for new sources when the current CLI agent can read, reason, and write pageswiki pack --json: default for retrieving existing wiki context without provider credentialswiki query: when the user asks what the wiki knows about X, or to gather context before writingwiki save-answer: after aquerythat produces useful context, to persist it
Agent-first behavior:
wiki agent-ingestregisters/profiles a source, finds merge candidates, and prints schema/citation rules.- The active CLI agent reads the source and writes atomic drafts into
wiki/drafts/. wiki validatepromotes zero-error drafts.wiki rebuild,wiki quality --json, andwiki coverage <source> --jsonverify the result.- No external model is required (or supported) — use the active agent.
Key Conventions
- Wikilinks only: Use
[[Page Name]]for internal references; never[text](path.md)markdown links - Atomic notes: One concept per page. Merge into existing pages before creating new ones
- Source citations: Every factual claim needs
[source: filename, §section]orsource_refsin frontmatter - Confidence scoring:
HIGH(multiple independent sources),MEDIUM(single source, well-established),LOW(inference or contested) - File naming: Concept pages use Title Case (
Retrieval-Augmented Generation.md), entity pages use canonical names, index pages prefixed with_ - Tags: lowercase kebab-case with domain prefix (
domain/ai,topic/retrieval,entity/person)
Gotchas
- Don't run scripts directly:
python scripts/cli.pyfails withModuleNotFoundError. UsewikiCLI (afterpip install -e .) or setPYTHONPATH=. wikicommand not found: You forgotpip install -e .; it registers the entry point- Forward wikilinks aren't errors: A
[[Page]]link to a nonexistent page is a WARNING (graph edge), not an ERROR. Don't delete them. - SCHEMA.yaml is the source of truth: Page types, validation rules, and relation weights are defined there. This file summarizes them; if they conflict, trust the schema.
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
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.

