# Export to OKF

`tkt export --okf <dir>` writes the store as an [Open Knowledge Format](https://okf.md/spec/) bundle with links that any OKF consumer reads without `tkt`; the store is not changed.

The target must be outside the store and new, empty or an earlier export (whose files are replaced), else `ERR_EXPORT_TARGET`, nothing written. No REST counterpart.

- Every item gets one index line: its id, title and one-line description. The bundle is a snapshot: run the export again after changes.
- Every `##` / `###` section of a doc is an index line of its own, under its doc (`<doc id>#<heading>`, as `tkt doc get <id> --anchor` and `tkt search` name it); the doc stays one page.
- `--describe` lets the configured LLM write the descriptions; it is off by default.
- The output prints the line to add to `AGENTS.md` / `llms.txt`; nothing is written outside the target.

## Details

- Contents: `index.md`, `log.md` (by date, newest first), `okf-base.yaml` (the okflint manifest), per section an `index.md` and one file per item: `tickets/`, `groups/`, `docs/`, `gotchas/`, `milestones/<id>.md`, `decisions/<id>.md`.
- Every file has `type`, `title`, `description`, `tags`, `timestamp`, then its own keys; bodies are kept. Links are bundle-absolute; a missing target is `X (missing)`. `doc://`, `gotcha://` and ticket id mentions become links (code and existing links do not); a link pointing nowhere (e.g. `@[Name](urn…)`) is written `[text]\(target)`, so okflint passes.
- No export time: byte-identical, git-diffable. Check with `okflint validate --manifest <dir>/okf-base.yaml`.
- The description is the item's own `description` field; without one: a ticket's Description section, a decision's first paragraph that does not repeat its title (in practice the Rationale), a doc's intro, a section's first paragraph, else the title.
- `--describe`: one call per item, with only that item's own text, marked as data; the answer is one line of plain text (no image, link, HTML or URL), a bad answer is dropped and counted. The description gets `generated: {by, at}` and `sources`. Cached by content (`.aitodo/cache/llm/`, `AITODO_LLM_CACHE=0` turns it off, `--refresh` asks again), so only new or changed items cost. The run reports how many it wrote and took from the cache, the cost, and how many items' text went where; it warns about items that look like they hold a secret (a key, a password). Without a provider it exports the deterministic descriptions. Doc section lines are never generated.
- `tkt export` is always local: a server-hosted store's `/cli` does not run it.

- `tkt export --okf ../kb --json`: `{dir, counts, files, sections, discovery, describe}`; `describe` is `null` without `--describe`.
- The provider of `--describe`: `--llm-cmd "<command>"`, `--llm-provider local|server`, else `AITODO_LLM_CMD`, else the project's server LLM; `--refresh` asks again.
- `describe`: `{provider, place, described, cached, dropped, calls, sentItems, sentChars, inputTokens, outputTokens, costUsd, error, setupHint, secretItems}`; `place` is `this machine` or `tkt server`, a `null` number: the provider did not report it.

## Commands on this page

- [`tkt export`](/en/docs/reference/commands/maintenance.md#tkt-export): Export the store for other tools; the store itself is not changed

## Related

- Error code · 422: [`ERR_EXPORT_TARGET`](/en/docs/reference/errors.md#ERR_EXPORT_TARGET): tkt export: the target is inside the store, or a non-empty dir that is no earlier export
