Skip to content

Search and query the knowledge base

The CLI has three ways to find things: sklad search ranks sections by text, sklad query lists documents that match a filter, and sklad links and sklad related walk the link graph. All of them read the index sklad builds from the files on disk, so they see edits immediately.

  • A knowledge base with a .kb/framework.toml; see Getting started.
  • Run the commands inside the knowledge base, or point at it: the CLI uses --root <dir>, else $KB_ROOT, else the nearest parent directory that holds .kb/ or .git.

Pass one or more words. Every word is optional; sections that match more of them rank higher. Each hit is a section, printed with its line range and heading:

Terminal window
sklad search timers cron
reference/linux/systemd-timers.md:5-8 Systemd timers Timers replace cron jobs. Back to alpha
reference/linux/systemd-timers.md:9-11 Calendar events OnCalendar takes a calendar expression such as weekly
projects/alpha.md:7-10 Alpha See the timer note

--limit caps the hits (default 10) and --per-doc caps hits from one document (default 3, 0 for no cap). Search takes the same filters as query, described next, so sklad search timer --path 'projects/**' searches only projects.

sklad query lists every document that matches, unranked, sorted by path. --where takes a predicate KEY OP VALUE:

Terminal window
sklad query --where 'tags = home'
sklad query --where 'started >= 2026-02-01'
sklad query --where 'status missing' --not-path 'journal/**'
Operator Matches when the field
eq, = equals the value; for a list field such as tags, contains it
!= does not equal the value; for a list field, does not contain it
in, nin is (is not) one of a comma-separated list: tags in home,garden
lt <, lte <=, gt >, gte >= compares below or above the value
exists, missing is present or absent; takes no value

Values are read as YAML scalars: 3 is a number and true a boolean. Quote a value to compare it as a string. Repeat --where to require several predicates.

Other filters combine with --where:

Flag Effect
--path <glob> Only paths matching the glob; repeat for any of several
--not-path <glob> Skip paths matching the glob
--kind <kind> Only units of that kind outside the archive
--state <group> With --kind: only units whose state is in active, inactive, or done

Kinds and state groups come from the framework definition:

Terminal window
sklad query --kind project --state active

Shape the output with --fields (frontmatter keys to print), --sort (KEY or KEY:desc; default path), and --limit (default 100):

Terminal window
sklad query --kind project --sort started:desc --fields started
projects/beta/index.md Beta started=2026-02-01
projects/alpha.md Alpha started=2026-01-05

For an OR across conditions, pass a whole filter as JSON with --filter. A filter has path, not_path, where (a list of {"key", "op", "value"}), and any (a list of sub-filters, of which at least one must match):

Terminal window
sklad query --filter '{"any": [
{"where": [{"key": "status", "op": "eq", "value": "paused"}]},
{"path": ["reference/**"]}
]}'

The flags still apply and are ANDed with the JSON filter.

sklad links shows a note’s outlinks and backlinks. Pass its vault path, including .md:

Terminal window
sklad links projects/alpha.md
out
projects/alpha.md:9 -> reference/linux/systemd-timers.md#calendar-events
in
README.md:3 Example KB
projects/beta/index.md:9 Beta
reference/linux/systemd-timers.md:7 Systemd timers

--in and --out limit the output to one direction, --depth N adds the documents up to N hops away, --external includes links that leave the knowledge base, and --unresolved lists only outlinks that point at nothing.

sklad related ranks notes near one note by links and shared frontmatter values:

Terminal window
sklad related projects/alpha.md
reference/linux/systemd-timers.md Systemd timers (link:1, shared:tags=home)
README.md Example KB (link:1)
projects/beta/index.md Beta (link:1)

sklad stats prints the size of the index: documents, sections, terms, links, unresolved links, and build time.

Every command takes --json and prints one JSON object instead of text:

Terminal window
sklad query --where 'tags = home' --json
{"docs":[{"fields":{},"path":"projects/alpha.md","title":"Alpha"},{"fields":{},"path":"reference/linux/systemd-timers.md","title":"Systemd timers"}]}

A malformed argument exits with status 2, such as --where: unknown operator.

See the search, query, links, and related references for every flag.