Language · Reference
Syntax Reference.
Complete reference for all KGL syntax primitives. A .kgl file is plain text — no required tooling to read or write it.
Node declaration
@Type Name
Declares a node. Everything below it — fields, tags, links, body — belongs to this node until the next @Type declaration or end of file.
Type is capitalised and semantic: @Person, @Project, @Service, @Decision, @Place.
Name is the node's identifier within the file. Use it in fragment links from other files: → people/alice.kgl#Alice Nguyen.
Multi-type nodes
@Type|Type Name
Both types apply simultaneously. Order matters: the first type is primary. A query for either type will match the node.
@Person|Contractor Ravi Mehta
@Place|Landmark Uluru
Fields
key: value
key: "value with spaces or punctuation"
Any key, freeform value. No required fields unless a schema defines them. Field names are lowercase, hyphen-separated by convention.
Field types (for schema use)
Types are hints for tooling and schema validation — not enforced at parse time.
| Type | Description |
|---|---|
text | Any string |
date | ISO 8601 date: 2024-11-01 |
url | A URL |
bool | true or false |
number | Integer or decimal |
Tags
#tag #another-tag
Tags are for clustering and discovery. Multiple tags per node, space-separated. A linter or query tool can filter nodes by tag.
#backend #python #team-platform
Links
Links connect nodes across files. They are the core feature of KGL.
Hard link
→ path/to/file.kgl
→ path/to/file.kgl#Node Name
A strong relationship. Signals to a reader (human or AI): follow this link to fully understand the current node.
The #Node Name fragment pins the link to a specific node inside a multi-node file.
Soft link
~> path/to/file.kgl
A weak relationship. Background context — relevant, but not required reading to understand the current node.
Named relationship
[relationship-name] → path/to/file.kgl
A hard link with a typed edge. The label describes how the two nodes relate.
[reports-to] → people/bob.kgl#Bob Chen
[depends-on] → services/legacy-api.kgl
[mentors] → people/diana.kgl#Diana Park
Multi-type relationship
[rel|rel] → path/to/file.kgl
Both labels apply simultaneously — not "either/or". Use when a relationship genuinely carries two meanings.
[depends-on|replaces] → services/legacy-search.kgl
Relationship properties
[employs] → people/alice.kgl#Alice Nguyen
role: lead engineer
since: 2024-11-01
note: "day-to-day lead, not line manager"
Indented lines immediately following any link are properties of that relationship. They are scoped to the relationship, not the node. The scope ends at the next non-indented line.
This applies to all link types — hard, soft, and named.
Free text body
---
Prose goes here.
The --- separator marks the start of a free text body. Everything after it is plain prose — not parsed as fields or links. Use it for context, nuance, and notes that structured fields can't capture.
The body applies to the most recent @Type node.
Comments
# This is a comment
Lines starting with # that are not tags are comments. By convention, place a comment at the top of every file identifying its path and purpose.
# people/alice.kgl
# AI note: follow → links for full context on each relationship.
Multiple nodes in one file
A single .kgl file can contain multiple nodes. Each @Type declaration starts a new node.
# people/alice.kgl
@Person Alice Nguyen
role: Senior Engineer
→ projects/search-revamp.kgl
@Person|Contractor Ravi Mehta
role: Backend Engineer
contract-end: 2025-03-31
→ projects/search-revamp.kgl
Group tightly related nodes in one file (a person and their skills, a team and its members). Keep loosely related nodes in separate files.
Conventions
| Convention | Recommendation |
|---|---|
| File names | lowercase-hyphenated.kgl |
| Folder names | lowercase/ — used as namespaces |
| Node names | Title Case |
| Field keys | lowercase-hyphenated |
| Relationship labels | lowercase-hyphenated |
| Tags | #lowercase |
| Comment at top | Always include file path and a brief note |
Complete example
# projects/search-revamp.kgl
# AI note: follow → links for full context. ~> links are background reading.
@Project Search Revamp
status: in-progress
deadline: 2025-08-01
#search #q3 #vector
[owned-by] → people/bob.kgl#Bob Chen
since: 2024-09-01
[depends-on|replaces] → services/legacy-search.kgl
sunset-date: 2025-08-01
note: "vector index must be live before deprecation"
[staffed-by] → people/alice.kgl#Alice Nguyen
role: lead engineer
since: 2024-11-01
~> decisions/search-engine-choice.kgl
~> planning/q3-roadmap.kgl#Search
---
Replacing legacy full-text search with a vector-based approach.
Phase 1: indexing pipeline. Phase 2: query rewrite. Phase 3: UI rollout.
Quick reference
@Type.