Skip to main content

knott

A local, file-first knowledge layer for AI agents.

Markdown files are the source of truth. Knott adds structure (typed entities), semantics (relations between them), and validation, without turning your notes into an opaque database. A Knott vault stays useful without Knott: browse it in a file manager, read it in any editor, open it in Obsidian, diff it in Git.

Install

uvx knott --help        # run without installing
uv add knott            # or add it to a project

Requires Python 3.12+.

Quick start

mkdir my-vault && knott init my-vault

Each type is a Markdown concept file in .knott/concepts/. Its frontmatter is the schema. my-vault/.knott/concepts/script.md:

---
name: script
description: A script for a recorded episode.
properties:
  title:
    type: string
    required: true
---

and one that refers to it, .knott/concepts/transcript.md. Its body is a template that agents copy when they write a transcript:

---
name: transcript
properties:
  title:
    type: string
  derived_from:
    type: reference
    target: script
---
# Transcript

<!-- Who speaks, and what the recording covers. -->

Write entities as ordinary Markdown with frontmatter, anywhere in the vault:

---
type: transcript
title: Episode 42 transcript
derived_from: "[Episode 42](../scripts/foo.md)"
---
# Transcript

Then validate:

$ knott validate
✓ 2 schemas
✓ 2 entities
✓ 1 relation
✓ vault is valid

Commands

Command Purpose
knott init [PATH] Create .knott/concepts/ and .knott/config.yaml
knott validate [PATH...] Check all schemas, plus all entities or those under PATH (--format json for agents, --fix to add missing kids)
knott types [--verbose] List discovered types (--verbose: properties, nested shapes, references and whether a template exists)
knott migrate [PATH] Convert a pre-0.5 .knott/schemas/ folder into concept files, then validate
knott view [PATH] Draw the ontology as an HTML page and open it (-o FILE, --no-open)
knott version Print the installed version
knott skill install [PATH] Install the bundled Agent Skill to .claude/skills and/or .agents/skills (--claude, --agents; asks interactively without flags)

Exit codes: 0 valid, 1 validation issues, 2 usage or configuration error.

Concept files

Concept files live in .knott/concepts/**/*.md, one type per file, identified by name:. All fields go in one properties map. Value types: string, integer, number, boolean, date, datetime, plus list, object and map built from them and nested to any depth. Typing is strict: an unquoted no is a boolean, not a string.

A property with type: reference points at another entity. It can sit anywhere a shape can, and target may name several types. Problems name their exact location, e.g. speakers[1].person:

properties:
  recording_of: { type: reference, target: [episode, meeting] }
  speakers:
    type: list
    items:
      type: object
      fields:
        person: { type: reference, target: person, required: true }
        role:   { type: string }

The body of a concept file is an optional template for entity bodies: real headings, with a <!-- --> comment under each saying what goes there. Knott stores it and never checks entities against it.

References

A reference is a relative path or a quoted Markdown link, resolved relative to the containing file. References are stored only on the source entity. type: reference holds exactly one; for several, declare a list of references:

derived_from: "[Episode 42 script](../scripts/episode-42.md)"
sources:
  - ../scripts/episode-42.md
  - "[Notes](../notes/episode-42.md)"

Wikilinks, URLs, #fragments, and absolute paths are rejected. Matching is case-sensitive on every OS.

Stable identity

knott validate --fix gives every entity a kid, a knott-managed UUID that survives moves and renames. A reference can then name it as kid:<uuid>. A concept file can require one with kid: required. Markdown links stay the recommended form; use kid: where a reference must survive renames.

kid: 3f2b8c1e-9d4a-4c2e-b7f1-0a6d5e9c8b21
includes:
  - kid:0192f4a1-7c3e-4b2a-9f10-3d5e8c2b4a61

Obsidian

Markdown links in properties are clickable in Obsidian 1.11+ and are updated on rename. Use these settings:

  • Files & links → New link format: Relative path to file
  • Use [[Wikilinks]]: off

Upgrading from 0.4

Knott 0.5 reads types from .knott/concepts/ only. A vault that still has .knott/schemas/ reports one issue, schema-legacy-layout, and nothing else is checked until you convert it:

$ knott migrate
+ .knott/concepts/compilation.md
+ .knott/concepts/media/episode.md
+ .knott/concepts/script.md
  list of reference: compilation.sources
- .knott/schemas/

✓ 3 schemas
✓ 4 entities
✓ 4 relations
✓ vault is valid
  • Each YAML schema becomes a concept file at the same relative path. type becomes name, and attributes and relations merge into properties.
  • A relation becomes a reference, or a list of references when any entity already stores a list there (the list of reference: lines).
  • Entities are not changed. From now on, a single reference accepts exactly one value and a list reference needs a list.
  • It writes nothing if any schema can't be converted or a concept file already exists (exit 2). Review the diff in Git afterwards.

The Python API changed too: OntologyType.attributes and .relations are now one properties list, and OntologyRelation is gone. See decision 0010 and knott migrate.

Python API

from knott import Knott

vault = Knott.open(".")              # walks up to the vault root
result = vault.validate()            # or vault.validate(["transcripts/foo.md"])
result.ok, result.issues, result.stats
vault.types()                        # ["script", "transcript"]
vault.ontology()                     # Ontology(vault, types, schema_issues)
for t in vault.ontology().types:
    t.properties, t.template, t.references()   # references(): [("speakers[].person", …), …]

Validation problems come back as data; only usage errors raise (KnottError subclasses).

For agents

Knott ships an Agent Skill describing how to read concept files, write entities and references, and validate (SKILL.md). Install it into a project:

knott skill install            # pick targets interactively
knott skill install --claude   # .claude/skills/knott/ (Claude Code)
knott skill install --agents   # .agents/skills/knott/ (Codex and other agents)

Development

uv sync
uv run pytest
uv run ruff check src tests
uv run mypy

Metadata

Release files for knott 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for knott 0.5.0
File Size Uploaded Provenance Actions
knott-0.5.0.tar.gz 192.4 kB Without provenance Details for knott-0.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for knott 0.5.0
File Interpreter ABI Platform Actions
knott-0.5.0-py3-none-any.whl Python 3 none any Details for knott-0.5.0-py3-none-any.whl

Total release size: 251.6 kB

Release files / knott-0.5.0.tar.gz

Download URL knott-0.5.0.tar.gz
Size 192.4 kB
Tags Source
SHA-256 checksum
How to use checksums
9d6320dd588ad159daec9386bc12469dcd554e72d22a35be3575fe175b64e392
BLAKE2b-256 checksum
How to use checksums
94870ab393504fd3571914e1ed56859024a8a160be92c56f84448b35232765a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / knott-0.5.0-py3-none-any.whl

Download URL knott-0.5.0-py3-none-any.whl
Size 59.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
07cf74ae41ff1c58685fcf6fffd84476b5d3da3ba4b46d9f971a975ccb2114e9
BLAKE2b-256 checksum
How to use checksums
1df6a7984810019e08a23266ac01acb14f905bd1b087cb487c61f8a795b89d31
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for knott 0.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page