agentleFS
dimasyankauskasdimasyankauskas/llm-knowledge-base/AGENTS.md

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.

  • In this repository2 other files it gives its agents.

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
  1. Distinctive:

    Use the active CLI agent (Codex, Claude Code, Gemini CLI, etc.) as the reasoning/writing engine.

    line 24
  2. Very specific:

    SCHEMA.yaml is the constitution: Read it before any wiki operation.

    line 50
  3. Distinctive:

    Every factual claim must cite its confidence level in frontmatter.

    line 84
  4. Distinctive:

    Use typed wikilinks to express relationships between concepts:

    line 88
  5. Distinctive:

    Merge over Create: When a concept already exists, merge new information into it.

    line 102
  6. Distinctive:

    Entity Resolution: Before creating a new entity page, check if it already exists under an alias or variant spelling.

    line 104
  7. Distinctive:

    Never silently overwrite conflicting information.

    line 130
  8. Distinctive:

    Use the wiki CLI to delegate knowledge operations:

    line 184
  9. Distinctive:

    No external model is required (or supported) — use the active agent.

    line 214
  10. Very specific:

    Wikilinks only: Use [[Page Name]] for internal references.

    line 218
  11. Very specific:

    Source citations: Every factual claim needs [source: filename, §section] or source_refs in frontmatter

    line 220

≈ “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.

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

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 suite

Requires 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:

LayerLocationMutability
Raw Sourcessources/Read-only: never modify
The Wikiwiki/AI-managed: create, update, link, lint
The SchemaSCHEMA.yamlHuman-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_only
  • Key Properties: facts_only
  • How It Works: mixed
  • Relationships: facts_only
  • Open Questions: inference_only
  • Sources: 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] CONTRADICTION callouts
  • Resolution uses > [!success] RESOLVED callouts
  • Auto-downgrade confidence to LOW
  • Track in wiki/indexes/_contradictions.md
  • HIGH/MEDIUM pages must include a ## Counter-Arguments & Data Gaps section

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 timer

For 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 concept

When to use each:

  • wiki agent-ingest: default for new sources when the current CLI agent can read, reason, and write pages
  • wiki pack --json: default for retrieving existing wiki context without provider credentials
  • wiki query: when the user asks what the wiki knows about X, or to gather context before writing
  • wiki save-answer: after a query that produces useful context, to persist it

Agent-first behavior:

  1. wiki agent-ingest registers/profiles a source, finds merge candidates, and prints schema/citation rules.
  2. The active CLI agent reads the source and writes atomic drafts into wiki/drafts/.
  3. wiki validate promotes zero-error drafts.
  4. wiki rebuild, wiki quality --json, and wiki coverage <source> --json verify the result.
  5. 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] or source_refs in 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.py fails with ModuleNotFoundError. Use wiki CLI (after pip install -e .) or set PYTHONPATH=.
  • wiki command not found: You forgot pip 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.

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.