Skip to content

Commit a1aef7a

Browse files
snapsynapseclaude
andcommitted
Complete template for public sharing
Documentation: - New data/_schema.md: full file format reference for all entity types, covering frontmatter fields, body structure, provision parsing format, and mapping file syntax - README: added data replacement guide, expanded MCP server docs, updated Quick Start to reference schema and npm scripts - CLAUDE.md: updated commands to use npm scripts, added schema reference Fixes: - project.yml: mapping.file path corrected from "provisions/index.yml" to "mapping/index.yml" (was relying on undocumented fallback) - Added last_verified dates to all example entities (eliminates "NEVER VERIFIED" warnings on fresh clone) New: - package.json with build/validate/verify scripts and Node >=16 engine Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent ee05583 commit a1aef7a

10 files changed

Lines changed: 273 additions & 19 deletions

File tree

CLAUDE.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ docs/ # Generated output (HTML + JSON API)
2222
## Key Commands
2323

2424
```bash
25-
node scripts/build.js # Build site + JSON API
26-
node scripts/validate.js # Validate cross-references
25+
npm run build # Build site + JSON API (or: node scripts/build.js)
26+
npm run validate # Validate cross-references
27+
npm run verify # Check entity freshness / staleness
2728
```
2829

2930
## Entity Model
@@ -41,12 +42,14 @@ Relationship: Authority → Container → Secondary → Primary
4142

4243
## Adding Data
4344

44-
1. Create a `.md` file in the appropriate `data/` directory
45-
2. Add YAML frontmatter with required fields (see existing files for format)
45+
See `data/_schema.md` for the full file format reference.
46+
47+
1. Create a `.md` file in the appropriate `data/examples/` directory
48+
2. Add YAML frontmatter with required fields per the schema
4649
3. For containers: add timeline table and provision sections separated by `---`
4750
4. Add mapping entries to `data/examples/mapping/index.yml`
48-
5. Run `node scripts/validate.js` to check cross-references
49-
6. Run `node scripts/build.js` to generate the site
51+
5. Run `npm run validate` to check cross-references
52+
6. Run `npm run build` to generate the site
5053

5154
## Customization
5255

README.md

Lines changed: 59 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ A template for building structured, version-controlled knowledge bases with an o
1212

1313
## Quick Start
1414

15-
1. **Use this template** click "Use this template" on GitHub, or clone locally
16-
2. **Edit `project.yml`** define your domain entities, groups, colors, and site identity
17-
3. **Add data** — create markdown files in `data/` following the schema in `data/_schema.md`
18-
4. **Build** `node scripts/build.js`
19-
5. **Deploy** push to GitHub, Pages deploys automatically
15+
1. **Use this template** -- click "Use this template" on GitHub, or clone locally
16+
2. **Edit `project.yml`** -- define your domain entities, groups, colors, and site identity
17+
3. **Replace example data** -- see [Replacing example data](#replacing-example-data) below
18+
4. **Build** -- `node scripts/build.js` (or `npm run build`)
19+
5. **Deploy** -- push to GitHub, Pages deploys automatically
2020

2121
## What You Get
2222

@@ -74,11 +74,32 @@ All domain-specific settings live in `project.yml`:
7474
- **Bridge pages** — which SEO pages to generate
7575
- **Theme** — accent colors
7676

77+
## Replacing example data
78+
79+
The template ships with example data in `data/examples/` (ISO 27001, NIST CSF). To replace it with your own domain:
80+
81+
1. **Update `project.yml`** -- rename entity types, groups, statuses, and colors to match your domain. The directory names under `entities.*.directory` control where the build script looks for files.
82+
83+
2. **Delete example files** -- remove the contents of `data/examples/requirements/`, `data/examples/frameworks/`, `data/examples/organizations/`, and `data/examples/mapping/index.yml`.
84+
85+
3. **Create your data files** -- add markdown files following the format documented in [`data/_schema.md`](data/_schema.md). Each entity type has specific frontmatter requirements and body structure.
86+
87+
4. **Update the mapping file** -- create entries in `data/examples/mapping/index.yml` that connect your containers to your primaries.
88+
89+
5. **Validate and build:**
90+
```bash
91+
node scripts/validate.js # Check cross-references
92+
node scripts/build.js # Generate the site
93+
```
94+
95+
The build script looks for data in `data/examples/` first, then `data/`. You can rename `data/examples/` to `data/` if you prefer a flatter structure.
96+
7797
## Commands
7898

7999
```bash
80-
node scripts/build.js # Build the site
81-
node scripts/validate.js # Validate cross-references
100+
node scripts/build.js # Build the site (or: npm run build)
101+
node scripts/validate.js # Validate cross-references (or: npm run validate)
102+
node scripts/verify.js # Check entity freshness (or: npm run verify)
82103
```
83104

84105
## Architecture
@@ -92,11 +113,37 @@ node scripts/validate.js # Validate cross-references
92113

93114
Every Knowledge-as-Code site includes machine-readable discovery files:
94115

95-
- **MCP Server**`mcp-server.js` provides read-only access to all entities via Model Context Protocol. Tools are dynamically named from your `project.yml` config. Run with `node mcp-server.js` or add to your MCP client config via `mcp.json`.
96-
- **llms.txt** — Generated at `docs/llms.txt` with entity model, API endpoints, and entity listings for LLM context
97-
- **agents.json** — Machine-readable metadata at `docs/agents.json` for agent discovery
98-
- **RSS feed** — Recent updates at `docs/index.xml`
99-
- **JSON API** — Programmatic access at `docs/api/v1/`
116+
- **MCP Server** -- `mcp-server.js` provides read-only access to all entities via Model Context Protocol
117+
- **llms.txt** -- Generated at `docs/llms.txt` with entity model, API endpoints, and entity listings
118+
- **agents.json** -- Machine-readable metadata at `docs/agents.json` for agent discovery
119+
- **RSS feed** -- Recent updates at `docs/index.xml`
120+
- **JSON API** -- Programmatic access at `docs/api/v1/`
121+
122+
### Using the MCP server
123+
124+
The MCP server exposes your knowledge base as tools that AI agents can call. Tool names are dynamically generated from your `project.yml` entity configuration.
125+
126+
**Add to Claude Code** (or any MCP-compatible client) via `mcp.json`:
127+
128+
```json
129+
{
130+
"mcpServers": {
131+
"knowledge-base": {
132+
"command": "node",
133+
"args": ["mcp-server.js"],
134+
"description": "Read-only access to the knowledge base"
135+
}
136+
}
137+
}
138+
```
139+
140+
**Test it directly:**
141+
142+
```bash
143+
node mcp-server.js
144+
```
145+
146+
The server reads `project.yml` at startup and exposes tools for listing and retrieving each entity type. For example, with the default config you get tools like `list_requirements`, `get_requirement`, `list_frameworks`, `get_framework`, etc. The exact tool names depend on your entity configuration.
100147

101148
## Verification
102149

data/_schema.md

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
# Data Schema
2+
3+
This file documents the file format for each entity type. All data files use YAML frontmatter followed by a markdown body.
4+
5+
## Primary entities
6+
7+
**Directory:** `data/examples/{primary.directory}/` (configured in `project.yml` as `entities.primary.directory`)
8+
9+
**Example:** `requirements/access-control.md`
10+
11+
```yaml
12+
---
13+
id: access-control # Required. Kebab-case identifier, must match filename
14+
name: Access Control # Required. Human-readable name
15+
group: governance # Required. Must match a group name in project.yml
16+
status: active # Optional. Lifecycle state
17+
last_verified: 2026-03-25 # Optional. Date of last verification check
18+
search_terms: # Optional. Additional search keywords
19+
- authorization
20+
- permissions
21+
---
22+
```
23+
24+
**Body sections:** Defined in `project.yml` under `entities.primary.body_sections`. Each section is an `## H2` heading followed by markdown content. For the example config:
25+
26+
```markdown
27+
## Summary
28+
29+
One paragraph describing the requirement.
30+
31+
## What Counts
32+
33+
- Concrete examples that satisfy this requirement
34+
35+
## What Does Not Count
36+
37+
- Anti-patterns or things that look similar but don't qualify
38+
```
39+
40+
## Container entities
41+
42+
**Directory:** `data/examples/{container.directory}/`
43+
44+
**Example:** `frameworks/iso-27001.md`
45+
46+
```yaml
47+
---
48+
name: ISO 27001 # Required. Human-readable name
49+
authority: iso # Required. ID of the authority entity
50+
jurisdiction: International # Required if scope_field is set in project.yml
51+
type: standard # Optional. Category label
52+
status: active # Required. Must match a status in project.yml
53+
enacted: 2022-10-25 # Optional. Date of enactment
54+
effective: 2022-10-25 # Optional. Date it took effect
55+
official_url: https://... # Optional. Link to official source
56+
last_verified: 2026-03-25 # Optional. Date of last verification check
57+
---
58+
```
59+
60+
**Body structure:** Container files have a specific structure that the build script parses. The body has two parts separated by `---`:
61+
62+
1. **Timeline table** (optional, when `has_timeline: true` in config)
63+
2. **Provision sections** (one or more, separated by `---`)
64+
65+
```markdown
66+
## Timeline
67+
68+
| Milestone | Date | Notes |
69+
|-----------|------|-------|
70+
| Published | 2022-10-25 | Initial release |
71+
| Amendment | 2024-01-15 | Updated controls |
72+
73+
---
74+
75+
## Provision Title
76+
77+
| Property | Value |
78+
|----------|-------|
79+
| Obligation | access-control |
80+
| Sections | Annex A.5-A.8 |
81+
| Status | active |
82+
| Effective | 2022-10-25 |
83+
| Verified | 2026-03-25 |
84+
| Checked | 2026-03-25 |
85+
86+
### Requirements
87+
88+
| Requirement | Details |
89+
|-------------|---------|
90+
| Access control policy | Define and enforce access control rules |
91+
92+
### Talking Point
93+
94+
> "A single quoted sentence for use in summaries or presentations."
95+
96+
### Sources
97+
98+
- [Source Name](https://source-url.com)
99+
100+
---
101+
102+
## Another Provision Title
103+
104+
(same structure as above)
105+
```
106+
107+
**Important format requirements:**
108+
109+
- The `| Property | Value |` table is required for each provision. The `Obligation` row links this provision to a primary entity by ID.
110+
- Provision sections are separated by `---` (horizontal rule).
111+
- The `### Requirements` table is optional but recommended.
112+
- The `### Talking Point` must be a blockquote with the text in double quotes.
113+
- The `### Sources` section uses markdown link syntax.
114+
115+
## Authority entities
116+
117+
**Directory:** `data/examples/{authority.directory}/`
118+
119+
**Example:** `organizations/iso.md`
120+
121+
```yaml
122+
---
123+
id: iso # Required. Kebab-case identifier
124+
name: International Organization for Standardization # Required. Full name
125+
jurisdiction: International # Optional. Geographic scope
126+
website: https://www.iso.org # Optional. Official website
127+
last_verified: 2026-03-25 # Optional. Verification date
128+
---
129+
```
130+
131+
**Body:** A list of container IDs that this authority produces:
132+
133+
```markdown
134+
## Regulations
135+
136+
- iso-27001
137+
- iso-42001
138+
```
139+
140+
The heading name should match your container entity's plural name (e.g., "Regulations", "Products", "Frameworks").
141+
142+
## Mapping file
143+
144+
**Path:** `data/examples/mapping/index.yml` (configured in `project.yml` as `mapping.file`)
145+
146+
The mapping file connects containers to primaries through secondary (provision) entities:
147+
148+
```yaml
149+
- id: iso-27001-access-control # Unique provision ID
150+
regulation: iso-27001 # Container file name (without .md)
151+
authority: iso # Authority ID
152+
source_heading: Information Security Controls (Annex A) # Must match an ## H2 in the container file
153+
obligations: # List of primary entity IDs this provision maps to
154+
- access-control
155+
```
156+
157+
The `regulation` field should use your container entity name from config (the field name comes from `project.yml`). The `obligations` field should use your primary entity name from config.
158+
159+
## File naming
160+
161+
- All files use kebab-case: `access-control.md`, `iso-27001.md`
162+
- The filename (without `.md`) is used as the entity ID for primaries and authorities
163+
- Container files use the `name` frontmatter field (lowercased, spaces replaced with hyphens) as their ID
164+
165+
## Adding new entities
166+
167+
1. Create the `.md` file in the appropriate directory
168+
2. Add YAML frontmatter with required fields
169+
3. If adding a container, create corresponding mapping entries in `mapping/index.yml`
170+
4. Run `node scripts/validate.js` to check cross-references
171+
5. Run `node scripts/build.js` to generate the site

data/examples/organizations/iso.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ id: iso
33
name: International Organization for Standardization
44
jurisdiction: International
55
website: https://www.iso.org
6+
last_verified: 2026-03-25
67
---
78

89
## Regulations

data/examples/organizations/nist.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ id: nist
33
name: National Institute of Standards and Technology
44
jurisdiction: Federal
55
website: https://www.nist.gov
6+
last_verified: 2026-03-25
67
---
78

89
## Regulations

data/examples/requirements/access-control.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ id: access-control
33
name: Access Control
44
group: governance
55
status: active
6+
last_verified: 2026-03-25
67
search_terms:
78
- authorization
89
- permissions

data/examples/requirements/data-quality.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ id: data-quality
33
name: Data Quality
44
group: technical
55
status: active
6+
last_verified: 2026-03-25
67
search_terms:
78
- data validation
89
- data integrity

data/examples/requirements/incident-response.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ id: incident-response
33
name: Incident Response
44
group: operational
55
status: active
6+
last_verified: 2026-03-25
67
search_terms:
78
- incident management
89
- breach response

package.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "knowledge-as-code-template",
3+
"version": "1.0.0",
4+
"description": "Template for building structured, version-controlled knowledge bases with an ontology-first approach.",
5+
"license": "MIT",
6+
"scripts": {
7+
"build": "node scripts/build.js",
8+
"validate": "node scripts/validate.js",
9+
"verify": "node scripts/verify.js"
10+
},
11+
"author": "PAICE.work PBC <https://paice.work/>",
12+
"homepage": "https://github.com/snapsynapse/knowledge-as-code-template",
13+
"repository": {
14+
"type": "git",
15+
"url": "https://github.com/snapsynapse/knowledge-as-code-template"
16+
},
17+
"keywords": [
18+
"knowledge-base",
19+
"ontology",
20+
"static-site",
21+
"zero-dependency",
22+
"knowledge-as-code",
23+
"mcp"
24+
],
25+
"engines": {
26+
"node": ">=16"
27+
}
28+
}

project.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ entities:
7171

7272
# Mapping file — connects containers to primaries via secondaries
7373
mapping:
74-
file: "provisions/index.yml"
74+
file: "mapping/index.yml"
7575

7676
# ---------------------------------------------------------------------------
7777
# Site navigation

0 commit comments

Comments
 (0)