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.
Prerequisites
Section titled “Prerequisites”- 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.
Search by text
Section titled “Search by text”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:
sklad search timers cronreference/linux/systemd-timers.md:5-8 Systemd timers Timers replace cron jobs. Back to alphareference/linux/systemd-timers.md:9-11 Calendar events OnCalendar takes a calendar expression such as weeklyprojects/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.
Filter by frontmatter
Section titled “Filter by frontmatter”sklad query lists every document that matches, unranked, sorted by path. --where takes a predicate KEY OP VALUE:
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:
sklad query --kind project --state activeShape the output with --fields (frontmatter keys to print), --sort (KEY or KEY:desc; default path), and --limit (default 100):
sklad query --kind project --sort started:desc --fields startedprojects/beta/index.md Beta started=2026-02-01projects/alpha.md Alpha started=2026-01-05Filters as JSON
Section titled “Filters as JSON”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):
sklad query --filter '{"any": [ {"where": [{"key": "status", "op": "eq", "value": "paused"}]}, {"path": ["reference/**"]}]}'The flags still apply and are ANDed with the JSON filter.
Follow links
Section titled “Follow links”sklad links shows a note’s outlinks and backlinks. Pass its vault path, including .md:
sklad links projects/alpha.mdout projects/alpha.md:9 -> reference/linux/systemd-timers.md#calendar-eventsin 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:
sklad related projects/alpha.mdreference/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.
Script it
Section titled “Script it”Every command takes --json and prints one JSON object instead of text:
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.