Knowledge as Code
A small reference generator for serving evidence-backed, typed knowledge to people and agents from plain-text source files.
Canonical project home: https://knowledge-as-code.com/
The Implementation
Knowledge-as-Code keeps typed reference data in version-controlled plain text, validates its relationships and review dates, and generates consistent human- and machine-readable outputs from one source.
Six Properties
| Property | What It Means | In This Project |
|---|---|---|
| Plain text canonical | Knowledge in human-readable, version-controlled files. No database, no CMS, no vendor lock-in. | Markdown and YAML files in data/ |
| Drift-aware | Deterministic checks flag old review dates and incomplete relationships for human review. | Staleness, mapping, and completeness checks |
| Multi-output | One source produces consistent human- and machine-readable formats. | HTML site, JSON API, SEO pages, sitemap, llms.txt, and a separate local MCP runtime |
| Zero-dependency | Core tooling uses platform built-ins rather than a package dependency tree. | Node.js built-ins only |
| Git-native | Git is the collaboration layer, audit trail, and deployment trigger. | Issues, PRs, CI/CD, version history — all through Git |
| Ontology-driven | A vendor-neutral taxonomy maps to domain-specific implementations. | 3 Requirements across 2 Frameworks |
The Ontology
Every Knowledge-as-Code project has four entity roles:
| Role | This Project | What It Is |
|---|---|---|
| Primary | Requirement | Stable anchors that persist when sources change |
| Container | Framework | Grouping entities that contain provisions |
| Authority | Organization | Source entities that produce containers |
| Secondary | Provision | Mapping entities connecting containers to primaries |
Primaries are stable; containers are unstable. When a framework is amended, its provisions change, but the underlying requirements persist.
Standing on Shoulders
This repository is one practical implementation of established ideas, not a claim to have originated the broader category.
- File over App — Steph Ango on durable digital artifacts as files you control
- Docs as Code — Managing documentation with version control, pull requests, CI, plain text formats. Write the Docs community
- Living Documentation — Cyrille Martraire on documentation that evolves with the system it describes
- GitOps — Git as single source of truth with automated drift detection. Coined by Weaveworks (2017)
- Anti-entropy — Distributed systems pattern for detecting and repairing state divergence (Dynamo, Cassandra)
Live Examples
Ecosystem
- Knowledge as Code — The maintained reference generator and canonical project home
- Graceful Boundaries — How services communicate operational limits to humans and agents
- Siteline — AI agent readiness scanner for websites
Get Started
git clone https://github.com/snapsynapse/knowledge-as-code-template.git
cd knowledge-as-code-template
node scripts/init.js ../my-knowledge-base
cd ../my-knowledge-base
node scripts/build.js
open docs/index.html
Template: github.com/snapsynapse/knowledge-as-code-template
Knowledge as Code is a PAICE.work project.