2026-05-11 00:45:43 -07:00
---
title: Quickstart
2026-05-20 17:33:38 +02:00
description: Install ktx, run setup, and connect your coding agent.
2026-05-11 00:45:43 -07:00
---
2026-05-19 15:22:17 +02:00
import { CopyButton } from "@/components/copy-button";
2026-05-18 19:22:19 +02:00
This guide takes a local analytics project from empty to agent-ready. You'll
install the CLI, run one guided setup command, and hand the context to a
coding assistant.
docs: consolidate AI Resources into a single page (#274)
* docs: consolidate AI Resources into a single page
The AI Resources section was four pages (agent-quickstart, markdown-access,
agent-instructions, prompt-recipes) that repeated the same docs-consumption
guidance. Collapse them into one page at /docs/ai-resources covering markdown
endpoints, retrieval order, the task router, agent instructions, prompts, and
guardrails.
Also fix a stale claim: the page actions are a single "Copy as Markdown"
button, not the documented "Copy MD / View MD / Copy MDX" trio.
Update the cross-references in README, the introduction cards, the quickstart,
and the llms.txt entry points to the consolidated page.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(docs-site): redirect retired AI Resources slugs, preserving .md route
Redirect the retired per-page slugs (/docs/ai-resources/*) to the consolidated
page. Because Next evaluates redirects before the .md rewrite, a single
catch-all would 308 a cached per-page Markdown URL to the HTML page and break
the agent Markdown contract. Match the .md variant first and keep its suffix so
it lands on /docs/ai-resources.md.
Extend the routing test to assert both the HTML and .md redirects, and that
following the .md URL end to end serves text/markdown.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* docs: move AI Resources under the Community & Resources section
As a single page, AI Resources rendered as an orphaned, unbolded link wedged
between the top-level multi-page sections instead of as a section of its own.
Move it under Community (renamed "Community & Resources") so it renders as a
normal child link, consistent with how the single-page Configuration section
already works.
Redirect the former top-level URL and the retired per-page slugs (HTML and .md,
the .md variants first so cached Markdown URLs keep their suffix) to the new
home, relabel the llms.txt group to match, and repoint the README, introduction,
quickstart, and llms.txt cross-links.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-08 21:28:56 -07:00
If you're a coding assistant choosing a docs route, start with
[AI Resources](/docs/community/ai-resources) instead.
2026-05-18 19:22:19 +02:00
<div
2026-05-21 16:04:58 +02:00
className="not-prose my-8 overflow-hidden rounded-2xl border"
2026-05-18 19:22:19 +02:00
style={{
2026-05-21 16:04:58 +02:00
borderColor: 'color-mix(in oklch, #ff8a4d 32%, transparent)',
background:
'linear-gradient(135deg, color-mix(in oklch, #ff8a4d 10%, transparent) 0%, color-mix(in oklch, #ff8a4d 3%, transparent) 100%)',
2026-05-18 19:22:19 +02:00
}}
>
2026-05-21 16:04:58 +02:00
<div className="flex flex-col gap-6 p-5 sm:p-7 md:flex-row md:items-center md:gap-10">
<div className="min-w-0 flex-1">
<div
className="text-[11px] font-black uppercase tracking-[0.16em]"
style={{ color: '#ff8a4d' }}
>
Need a warehouse to play with?
</div>
<div className="mt-2.5 text-base leading-relaxed text-fd-foreground">
Try **ktx** against a real data stack - Postgres, dbt, Metabase, and Notion
2026-05-29 15:02:57 +02:00
pre-loaded with the Orbit demo corpus. Hit **copy agent setup** on the page
for a one-shot prompt that has an agent install the full four-source demo,
or grab the raw credentials to paste into `ktx setup` yourself.
2026-05-21 16:04:58 +02:00
</div>
<a
2026-06-01 16:44:41 +02:00
href="https://www.kaelio.com/start"
2026-05-21 16:04:58 +02:00
className="group mt-5 inline-flex items-center gap-2 rounded-full px-4 py-2.5 text-sm font-semibold text-white no-underline shadow-[inset_0_1px_0_rgba(255,255,255,0.35),0_2px_4px_rgba(255,138,77,0.2),0_10px_24px_-8px_rgba(255,138,77,0.55)] transition-all duration-200 hover:-translate-y-0.5 hover:shadow-[inset_0_1px_0_rgba(255,255,255,0.4),0_3px_6px_rgba(255,138,77,0.28),0_16px_30px_-8px_rgba(255,138,77,0.65)]"
style={{
background: 'linear-gradient(180deg, #ff9d63 0%, #f97316 100%)',
}}
>
2026-06-01 16:44:41 +02:00
Get demo credentials at www.kaelio.com/start
2026-05-21 16:04:58 +02:00
<svg
width="14"
height="14"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="2.4"
strokeLinecap="round"
strokeLinejoin="round"
className="transition-transform duration-200 group-hover:translate-x-0.5"
aria-hidden="true"
>
<line x1="5" y1="12" x2="19" y2="12" />
<polyline points="12 5 19 12 12 19" />
</svg>
</a>
</div>
<div
className="relative grid h-[152px] w-[152px] shrink-0 grid-cols-2 grid-rows-2 gap-2.5 self-center md:h-[168px] md:w-[168px]"
aria-hidden="true"
>
{[
{ src: '/ktx/icons/postgresql.svg', tint: '#e9eef5', rotate: -7, name: 'Postgres' },
{ src: '/ktx/icons/metabase.svg', tint: '#e8f1fc', rotate: 6, name: 'Metabase' },
{ src: '/ktx/icons/dbt.svg', tint: '#fde6dc', rotate: -4, name: 'dbt' },
{ src: '/ktx/icons/notion.svg', tint: '#f0eee8', rotate: 8, name: 'Notion' },
].map((sticker) => (
<div
key={sticker.name}
className="flex items-center justify-center rounded-2xl border border-fd-border bg-fd-card shadow-[0_2px_4px_rgba(20,18,12,0.04),0_14px_28px_-12px_rgba(20,18,12,0.22)]"
style={{ transform: `rotate(${sticker.rotate}deg)` }}
>
<span
className="flex h-full w-full items-center justify-center rounded-2xl"
style={{ background: sticker.tint }}
>
<img
src={sticker.src}
alt=""
width="38"
height="38"
style={{ objectFit: 'contain' }}
/>
</span>
</div>
))}
</div>
2026-05-18 19:22:19 +02:00
</div>
</div>
2026-05-19 15:22:17 +02:00
<div
className="not-prose my-6 rounded-lg border p-4"
style={{
borderColor: 'color-mix(in oklch, var(--color-fd-primary) 35%, transparent)',
background: 'color-mix(in oklch, var(--color-fd-primary) 8%, transparent)',
}}
>
2026-05-28 16:05:19 +02:00
<div className="flex flex-wrap items-center gap-x-3 gap-y-2">
<div className="text-sm font-semibold text-fd-foreground">
Or, ask an AI agent to install and configure **ktx** for you.
</div>
<div className="group relative ml-auto inline-flex">
<button
type="button"
aria-describedby="agent-setup-overlay"
className="inline-flex cursor-help items-center gap-1.5 rounded-full border border-fd-border bg-fd-background/70 px-2.5 py-1 text-xs font-medium text-fd-muted-foreground transition-colors hover:border-fd-primary/40 hover:text-fd-foreground focus:outline-none focus-visible:border-fd-primary/40 focus-visible:text-fd-foreground"
>
<svg
width="12"
height="12"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="2.4"
strokeLinecap="round"
strokeLinejoin="round"
aria-hidden="true"
>
<circle cx="12" cy="12" r="10" />
<path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3" />
<line x1="12" y1="17" x2="12.01" y2="17" />
</svg>
What does it do?
</button>
<div
id="agent-setup-overlay"
role="tooltip"
className="invisible absolute right-0 top-full z-20 translate-y-0.5 pt-2 opacity-0 transition-all duration-150 group-hover:visible group-hover:translate-y-0 group-hover:opacity-100 group-focus-within:visible group-focus-within:translate-y-0 group-focus-within:opacity-100"
>
<div className="w-[min(24rem,calc(100vw-2rem))] rounded-lg border border-fd-border bg-fd-popover p-3 text-sm leading-6 text-fd-popover-foreground shadow-xl">
<div className="text-xs font-semibold uppercase tracking-wide text-fd-muted-foreground">
The agent will
</div>
<ol className="mt-2 space-y-1.5 pl-0">
{[
<>Check prerequisites on your machine</>,
<>Ask only for credentials and connection choices</>,
<>Run <code className="whitespace-nowrap">ktx setup</code> in your project</>,
<>Verify each connection it configured</>,
<>Report what was installed and what is ready</>,
].map((item, index) => (
<li key={index} className="flex gap-2.5">
<span
className="mt-0.5 inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full text-[11px] font-bold tabular-nums"
style={{
background: 'color-mix(in oklch, var(--color-fd-primary) 18%, transparent)',
color: 'var(--color-fd-primary)',
}}
>
{index + 1}
</span>
<span className="leading-6">{item}</span>
</li>
))}
</ol>
<div className="mt-3 border-t border-fd-border pt-2 text-xs text-fd-muted-foreground">
Works with any AI coding agent.
</div>
</div>
</div>
</div>
2026-05-19 15:22:17 +02:00
</div>
<div className="mt-3 max-w-full overflow-hidden rounded-md border bg-fd-background">
<div className="flex items-center justify-between gap-2 border-b px-3 py-2">
<span className="text-xs font-semibold uppercase tracking-wide text-fd-muted-foreground">
Prompt
</span>
<CopyButton
2026-05-28 12:28:10 +02:00
text={[
2026-06-02 00:14:43 +02:00
'Run npx skills add Kaelio/ktx --skill ktx and use the ktx skill',
2026-05-28 15:30:51 +02:00
'to install and configure ktx',
2026-05-28 12:28:10 +02:00
].join(' ')}
2026-05-19 15:22:17 +02:00
className="-my-1"
/>
</div>
2026-05-28 15:30:51 +02:00
<div className="p-3 font-mono text-[13.5px] leading-6 text-fd-foreground">
2026-06-02 00:14:43 +02:00
Run {'`npx skills add Kaelio/ktx --skill ktx`'} and use the ktx skill to install and configure ktx
2026-05-19 15:22:17 +02:00
</div>
</div>
</div>
2026-05-11 16:42:08 -07:00
2026-05-14 18:09:26 -04:00
## Install the CLI
2026-05-11 16:42:08 -07:00
2026-05-18 19:22:19 +02:00
Install the published package globally:
2026-05-11 00:45:43 -07:00
```bash
2026-05-11 23:32:10 -07:00
npm install -g @kaelio/ktx
2026-05-11 00:45:43 -07:00
```
2026-06-08 17:10:36 -07:00
To upgrade an existing install later, re-run with the `@latest` tag:
```bash
npm install -g @kaelio/ktx@latest
```
2026-05-20 17:33:38 +02:00
**ktx** is open source. If you'd like to hack on it or run from a local checkout,
2026-05-18 19:22:19 +02:00
the source lives at [github.com/kaelio/ktx](https://github.com/kaelio/ktx) -
see [Contributing](/docs/community/contributing) to get set up.
2026-05-11 00:45:43 -07:00
2026-05-18 19:22:19 +02:00
## Run setup
2026-05-11 00:45:43 -07:00
2026-05-18 19:22:19 +02:00
From your project directory, run:
2026-05-11 00:45:43 -07:00
2026-05-14 18:09:26 -04:00
```bash
2026-05-18 19:22:19 +02:00
ktx setup
2026-05-16 12:06:34 +02:00
```
2026-05-20 17:33:38 +02:00
The wizard walks you through everything **ktx** needs in one pass:
2026-05-18 19:22:19 +02:00
1. **Project** - creates or resumes `ktx.yaml` in the current directory.
2. **LLM** - picks a Claude backend. The default uses your local Claude Code
session, so no API key is required. You can also use an Anthropic API key
or Vertex AI.
3. **Embeddings** - picks an embeddings backend. Choose OpenAI for hosted
embeddings or `sentence-transformers` to run locally without an API key.
4. **Database** - adds at least one primary connection. Supported drivers:
docs: rewrite Semantic Querying concept with imperative-vs-declarative diagram (#156)
* docs: rewrite Semantic Querying concept with imperative-vs-declarative diagram
Reframe semantic-layer-internals.mdx around the contract the semantic
layer offers an agent: declare what you want (a Semantic Query), KTX
figures out how to compute it. Replaces the old "Context-Aware SQL"
framing with a clear imperative-vs-declarative narrative.
Adds a React Flow component (semantic-layer-flow.tsx) that contrasts a
buggy 4-table agent-authored SQL (chasm trap, LEFT-JOIN-in-WHERE,
hardcoded DATE_TRUNC) against the chasm-safe per-fact CTE SQL the
planner actually emits, including the outer GROUP BY over the requested
dimensions. Both lanes converge into a shared warehouse node and each
SQL card now has parallel bullet notes (failures on the left, KTX
behavior on the right).
Side fixes bundled in:
- include the /ktx basePath in the favicon metadata so the icon resolves
under the production prefix
- migrate docs-site/middleware.ts to docs-site/proxy.ts (Next 16 rename)
- redirect / to /ktx/docs/getting-started/introduction so the apex docs
URL works
- add tests covering the apex redirect, the favicon basePath, and the
middleware-to-proxy rename
- propagate the Semantic Query terminology across the ktx-sl CLI
reference, the context-layer concept page, and the agent-clients /
primary-sources integration pages
* Fix CI dead-code failures
* docs-site: polish semantic-layer-internals code blocks and flow diagram
- Make CodeBlock a server component so children traverse synchronously
under React 19 RSC streaming; previously extractText returned "" in
dev SSR, leaving code blocks empty.
- Add custom JSON/YAML/SQL/code-like tokenizers with theme-aware token
classes; drop the colored file-glyph dot and gradient tab-head.
- Tighten tab-head: subtle grey background, smaller monospace filename
in muted grey, smaller rectangular language pill placed to the left
of the filename.
- Polish the React Flow semantic-layer diagram (controls, fit-view
padding, edge types).
* docs-site: annotate imperative SQL, add section anchor, drop ClickHouse
- Wire numbered red badges to each problematic span in the "Without KTX"
SQL with hover sync between SQL gutter, lines, and the notes list.
- Add #imperative-vs-declarative anchor on the flow section header so
the eyebrow link is shareable; reveals a # glyph on hover/focus.
- Align the compiled-SQL note dots to the first-line midpoint
(mt-[6px] instead of mt-1) so 4px dots sit at y=8 in a 16px line.
- Remove all ClickHouse references from docs-site (primary-sources,
quickstart, ktx-setup, contributing, agents-setup, mechanics test,
warehouse drivers in the flow diagram).
* test: drop ClickHouse contributing-docs assertion
Align the workspace-package mirror test with the ClickHouse removal
from docs-site (75907eb). The connector-clickhouse package still
exists in packages/, but contributing.mdx no longer lists it, so the
test that mirrored docs against the workspace was failing.
2026-05-19 23:41:29 +02:00
SQLite, PostgreSQL, MySQL, SQL Server, BigQuery, and Snowflake.
2026-05-18 19:22:19 +02:00
5. **Context sources** - optionally adds dbt, MetricFlow, LookML, Looker,
Metabase, or Notion. You can skip and add them later.
2026-06-03 01:00:21 +02:00
6. **Build** - offers to run the first ingest so semantic sources and wiki
pages are ready for agents. If you skip it, build later with `ktx ingest`.
2026-05-18 19:22:19 +02:00
7. **Agent integration** - installs project-local rules for Claude Code,
Codex, Cursor, OpenCode, or universal `.agents`.
2026-05-20 17:33:38 +02:00
If you choose local `sentence-transformers` embeddings, **ktx** uses the managed
2026-05-18 19:22:19 +02:00
Python runtime. To prepare it before setup, run:
2026-05-11 00:45:43 -07:00
```bash
2026-05-20 01:36:54 +02:00
ktx admin runtime install --feature local-embeddings --yes
ktx admin runtime start --feature local-embeddings
2026-05-11 00:45:43 -07:00
```
2026-05-18 19:22:19 +02:00
During the database step, setup tests the saved connection and builds initial
schema context:
2026-05-11 00:45:43 -07:00
2026-05-14 18:09:26 -04:00
```text
Testing warehouse
2026-05-14 01:43:06 +02:00
Connection test passed
2026-05-14 18:09:26 -04:00
Building schema context for warehouse
2026-05-29 17:41:04 +02:00
Running database scan
2026-05-11 00:45:43 -07:00
```
2026-05-20 17:33:38 +02:00
If setup exits early, rerun `ktx setup` in the same directory. **ktx** keeps
2026-05-18 19:22:19 +02:00
progress under `.ktx/setup/` and resumes from the remaining work.
2026-05-11 00:45:43 -07:00
2026-05-20 17:33:38 +02:00
> **Note:** Running bare `ktx` in an interactive terminal outside a **ktx**
2026-05-18 19:22:19 +02:00
> project opens the same wizard. Inside a project, it opens a menu for
> resuming setup, connecting an agent, checking status, or exploring a
> pre-built demo project.
2026-05-11 00:45:43 -07:00
2026-06-03 01:00:21 +02:00
When the wizard finishes, it states where you stand and the single next action:
- **Context built** - **ktx** confirms it is ready for agents and points you to
open your coding agent and ask a data question.
- **Build skipped** - **ktx** tells you setup is complete and that the only step
left is to build context with `ktx ingest`.
Re-running `ktx setup` on an already-configured project goes straight to the
remaining step - building context or connecting an agent - instead of
re-asking every question. Once everything is ready, it confirms you are set
rather than reopening the configuration menu.
2026-05-18 19:22:19 +02:00
## Verify
2026-05-11 00:45:43 -07:00
2026-05-18 19:22:19 +02:00
When setup finishes, check readiness:
2026-05-11 00:45:43 -07:00
2026-05-18 19:22:19 +02:00
```bash
ktx status
```
2026-05-11 00:45:43 -07:00
2026-05-18 19:22:19 +02:00
```text
2026-05-20 17:33:38 +02:00
ktx project: /home/user/analytics
2026-05-18 19:22:19 +02:00
Project ready: yes
LLM ready: yes (claude-sonnet-4-6)
Embeddings ready: yes (text-embedding-3-small)
Databases configured: yes (warehouse)
Context sources configured: yes (dbt_main)
2026-05-20 17:33:38 +02:00
ktx context built: yes
2026-05-18 19:22:19 +02:00
Agent integration ready: yes (codex:project)
```
2026-05-11 00:45:43 -07:00
2026-05-18 19:22:19 +02:00
For a structured check inside scripts, use `ktx status --json`.
2026-05-11 00:45:43 -07:00
2026-06-03 01:00:21 +02:00
If you skipped the build, `ktx context built` shows `no`. Build it with
`ktx ingest` - there is no need to re-run `ktx setup`.
2026-05-29 17:41:04 +02:00
When setup finishes building context, its final context check looks like:
2026-05-11 00:45:43 -07:00
2026-05-14 18:09:26 -04:00
```text
2026-05-20 17:33:38 +02:00
ktx context is ready for agents.
2026-05-11 00:45:43 -07:00
2026-05-14 01:43:06 +02:00
Databases:
2026-05-29 17:41:04 +02:00
warehouse: database context complete
2026-05-11 00:45:43 -07:00
Context sources:
2026-05-14 18:09:26 -04:00
dbt_main: memory update complete
2026-05-11 00:45:43 -07:00
```
2026-06-03 13:08:46 +02:00
Before the build starts, **ktx** runs a live test for every connection the
build depends on. A context build can take several minutes, so if any required
connection is unreachable or misconfigured the build is blocked up front and
**ktx** names the failing connection by id and connector type:
```text
KTX cannot build context: a required connection failed its live test.
Failed connections:
warehouse (postgres)
Each connection must be reachable before KTX builds context.
Run `ktx connection test <id>` to see the error, fix the connection, then retry.
```
Run `ktx connection test <connection-id>` to see the underlying error, fix the
connection, then continue. In interactive setup you can retry without
restarting; with `--no-input` the build exits non-zero and names the failing
connection so scripts can stop early.
2026-05-18 19:22:19 +02:00
## Connect a coding agent
2026-05-11 00:45:43 -07:00
2026-05-18 19:22:19 +02:00
The setup wizard installs project-local agent rules in the last step. To
install or change targets later:
2026-05-11 00:45:43 -07:00
2026-05-14 18:09:26 -04:00
```bash
2026-05-18 19:22:19 +02:00
ktx setup --agents
2026-05-14 18:09:26 -04:00
```
2026-05-18 19:22:19 +02:00
Claude Code and Codex also support global installs with `--global`. Agent
2026-05-20 17:33:38 +02:00
rules point at the **ktx** CLI path that created them, so agents don't need a
2026-05-18 19:22:19 +02:00
separate `ktx` binary on `PATH`. If the CLI path changes, rerun
`ktx setup --agents`.
2026-05-11 23:32:10 -07:00
2026-05-18 19:22:19 +02:00
## What setup writes
2026-05-11 16:42:08 -07:00
2026-05-20 17:33:38 +02:00
**ktx** writes plain files so people and agents can review changes in git.
2026-05-11 16:42:08 -07:00
2026-05-14 18:09:26 -04:00
| Path | Purpose |
|------|---------|
2026-05-18 19:22:19 +02:00
| `ktx.yaml` | Project configuration |
| `.ktx/secrets/*` | Local secret files referenced from `ktx.yaml` - do not commit |
2026-05-20 17:33:38 +02:00
| `semantic-layer/<connection-id>/*.yaml` | Semantic sources for SQL compilation |
2026-05-14 18:09:26 -04:00
| `wiki/global/*.md` | Shared business context and metric definitions |
2026-05-18 19:22:19 +02:00
| `.claude/skills/ktx/`, `.agents/skills/ktx/`, `.cursor/rules/ktx.mdc`, `.opencode/commands/ktx.md` | Installed agent rules |
2026-05-14 18:09:26 -04:00
2026-05-18 19:22:19 +02:00
## Scripted setup
2026-05-14 18:09:26 -04:00
2026-05-18 19:22:19 +02:00
For repeatable fixtures and automation, skip prompts with flags:
2026-05-14 18:09:26 -04:00
```bash
ktx setup \
--project-dir ./analytics \
--no-input \
2026-05-19 19:23:35 +02:00
--yes \
2026-05-14 18:09:26 -04:00
--skip-llm \
--skip-embeddings \
--database postgres \
2026-05-19 19:23:35 +02:00
--database-connection-id warehouse \
2026-05-14 18:09:26 -04:00
--database-url env:DATABASE_URL \
--database-schema public
```
Then build context:
```bash
2026-05-29 17:41:04 +02:00
ktx ingest warehouse
2026-05-14 18:09:26 -04:00
```
See [ktx setup](/docs/cli-reference/ktx-setup) for the full automation flag
surface.
2026-05-18 19:22:19 +02:00
## Common issues
2026-05-11 16:42:08 -07:00
2026-05-18 19:22:19 +02:00
| Symptom | Fix |
|---------|-----|
| `ktx: command not found` | Reinstall `@kaelio/ktx` and open a new shell |
| Setup resumes the wrong project | Pass `--project-dir <path>` |
| LLM or embeddings health check fails | Rerun setup and pick a different credential, model, or backend |
2026-06-03 13:08:46 +02:00
| Database test fails | Use the setup recovery menu to retry or re-enter details; if it still fails, verify the same connection with the database's native client |
| Context build blocked: a connection failed its live test | Run `ktx connection test <connection-id>` to see the error, fix the connection, then retry the build |
2026-05-18 19:22:19 +02:00
| Agent integration is incomplete | Run `ktx setup --agents --target <target>` |
2026-05-11 16:42:08 -07:00
2026-05-11 00:45:43 -07:00
## Next steps
2026-05-18 19:22:19 +02:00
- Refresh context with [Building Context](/docs/guides/building-context).
- Edit semantic sources and wiki pages with
[Writing Context](/docs/guides/writing-context).
2026-05-14 18:09:26 -04:00
- Connect more tools with [Agent Clients](/docs/integrations/agent-clients).
2026-05-18 19:22:19 +02:00
- Read [The Context Layer](/docs/concepts/the-context-layer) to understand
the architecture.