2026-05-11 00:45:43 -07:00
---
title: Quickstart
2026-05-14 18:09:26 -04:00
description: Set up KTX, build local context, and connect your coding agent.
2026-05-11 00:45:43 -07:00
---
2026-05-14 18:09:26 -04:00
This guide gets a local analytics project ready for KTX. You will install the
CLI, run the setup wizard, connect a database, build context, and install agent
rules that teach your coding assistant which KTX commands to run.
2026-05-11 00:45:43 -07:00
2026-05-14 18:09:26 -04:00
If you are a coding assistant choosing a docs route, start with the
[Agent Quickstart](/docs/ai-resources/agent-quickstart). This page is the
human setup walkthrough.
2026-05-11 17:20:11 -07:00
2026-05-14 18:09:26 -04:00
## What setup does
2026-05-11 16:42:08 -07:00
2026-05-14 18:09:26 -04:00
`ktx setup` is the main project workflow. It can create or resume `ktx.yaml`,
configure model and embedding providers, add database connections, add optional
context sources, build the first context artifacts, and install agent
integration.
2026-05-11 16:42:08 -07:00
2026-05-14 18:09:26 -04:00
When you run bare `ktx` in an interactive terminal outside a KTX project, the
CLI opens the same setup experience. Inside an existing project, `ktx setup`
resumes incomplete work or opens a menu for changing setup, connecting an
agent, checking status, or exploring a demo project.
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-14 18:09:26 -04:00
Install the published `@kaelio/ktx` package:
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-05-14 18:09:26 -04:00
Then run setup from the analytics project directory:
2026-05-11 00:45:43 -07:00
```bash
ktx setup
```
2026-05-14 18:09:26 -04:00
The local checkout workflow is only for KTX contributors. See
[Contributing](/docs/community/contributing) for that path.
2026-05-11 00:45:43 -07:00
2026-05-14 18:09:26 -04:00
## Step 1: Choose the project
2026-05-11 00:45:43 -07:00
2026-05-14 18:09:26 -04:00
In an interactive terminal, setup can create a new KTX project or resume the
nearest existing project. The main project file is `ktx.yaml`.
2026-05-11 00:45:43 -07:00
2026-05-14 18:09:26 -04:00
For scripted setup, pass the project directory explicitly:
2026-05-11 00:45:43 -07:00
2026-05-14 18:09:26 -04:00
```bash
ktx setup --project-dir ./analytics
2026-05-11 00:45:43 -07:00
```
2026-05-15 15:31:51 -04:00
If setup exits early, rerun `ktx setup` in the same directory. KTX keeps local
setup progress under `.ktx/setup/` and resumes from the remaining work.
2026-05-11 00:45:43 -07:00
2026-05-14 18:09:26 -04:00
## Step 2: Configure the LLM
2026-05-11 00:45:43 -07:00
2026-05-14 18:09:26 -04:00
KTX uses a Claude model for ingest agents that turn schemas, SQL, BI metadata,
and documents into semantic-layer sources and wiki context.
2026-05-11 00:45:43 -07:00
2026-05-16 12:06:34 +02:00
Setup supports three LLM provider paths:
2026-05-11 00:45:43 -07:00
2026-05-14 18:09:26 -04:00
| Provider | Use when | Credential model |
|----------|----------|------------------|
2026-05-17 19:15:09 +02:00
| Claude subscription (Pro/Max) | You want KTX to use your local Claude Code session | Claude Code local authentication |
| Anthropic API key | You have an Anthropic API key | `ANTHROPIC_API_KEY` or a local `file:` secret |
2026-05-14 18:09:26 -04:00
| Google Vertex AI for Anthropic Claude | Your organization runs Claude through Google Cloud | Application Default Credentials plus Vertex project and location |
2026-05-11 00:45:43 -07:00
2026-05-14 18:09:26 -04:00
For Anthropic API, setup can read the key from the environment or save a pasted
key to `.ktx/secrets/anthropic-api-key`. `ktx.yaml` stores an `env:` or `file:`
reference, not the raw key.
2026-05-11 00:45:43 -07:00
2026-05-14 18:09:26 -04:00
For Vertex AI, setup uses Google Application Default Credentials. It can read
your active `gcloud` project, list visible projects, or accept explicit
`--vertex-project` and `--vertex-location` values.
2026-05-16 12:06:34 +02:00
To use your local Claude Code session instead of an API key, set:
```yaml
llm:
provider:
backend: claude-code
models:
default: sonnet
triage: haiku
candidateExtraction: sonnet
curator: sonnet
reconcile: sonnet
repair: sonnet
```
`claude-code` uses the Claude Code authentication already configured on your
machine. It doesn't use `ANTHROPIC_API_KEY`, Vertex credentials, AI Gateway
tokens, or Bedrock credentials. In non-interactive setup, pass
`--llm-model opus`, `--llm-model sonnet`, `--llm-model haiku`, or a full Claude
model ID to select the Claude Code model.
2026-05-14 18:09:26 -04:00
Setup checks the selected model before saving. Anthropic API setup fetches live
Claude model choices when possible and falls back to bundled defaults if model
discovery is unavailable.
## Step 3: Configure embeddings
2026-05-11 00:45:43 -07:00
2026-05-14 18:09:26 -04:00
KTX uses embeddings for semantic search over semantic-layer sources, wiki
context, schema metadata, and relationship evidence.
2026-05-11 00:45:43 -07:00
2026-05-14 18:09:26 -04:00
| Backend | Default model | Notes |
|---------|---------------|-------|
| OpenAI | `text-embedding-3-small` | Recommended for hosted embeddings. Requires an OpenAI API key. |
| Local sentence-transformers | `all-MiniLM-L6-v2` | Runs through the KTX-managed Python runtime. No hosted embedding key is required. |
OpenAI setup reads `OPENAI_API_KEY` or saves a local secret file. Local
sentence-transformers setup can install and start the managed runtime during
setup. To prepare that runtime before setup, run:
2026-05-11 00:45:43 -07:00
```bash
2026-05-12 23:51:46 +02:00
ktx dev runtime install --feature local-embeddings --yes
ktx dev runtime start --feature local-embeddings
2026-05-11 00:45:43 -07:00
```
2026-05-14 18:09:26 -04:00
## Step 4: Add a database
2026-05-11 00:45:43 -07:00
2026-05-14 18:09:26 -04:00
KTX needs at least one primary database connection before it can build database
context. The wizard supports SQLite, PostgreSQL, MySQL, ClickHouse, SQL Server,
BigQuery, and Snowflake.
2026-05-11 00:45:43 -07:00
2026-05-14 18:09:26 -04:00
You can usually enter connection fields interactively or provide a URL. Secret
URLs can be stored as local files under `.ktx/secrets/` or referenced with
`env:NAME` in `ktx.yaml`.
2026-05-11 00:45:43 -07:00
2026-05-14 18:09:26 -04:00
After saving a connection, setup tests it and builds fast 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-14 01:43:06 +02:00
Running fast database ingest
Database ready
2026-05-14 18:09:26 -04:00
warehouse - PostgreSQL - schema context complete
2026-05-11 00:45:43 -07:00
```
2026-05-14 18:09:26 -04:00
PostgreSQL, BigQuery, and Snowflake can also enable query-history ingest. Query
history helps KTX learn common query patterns, joins, service-account filters,
2026-05-15 15:31:51 -04:00
and warehouse-specific usage. BigQuery and Snowflake support a lookback window;
Postgres reads the current `pg_stat_statements` aggregate data instead.
2026-05-11 00:45:43 -07:00
2026-05-14 18:09:26 -04:00
## Step 5: Add context sources
2026-05-11 00:45:43 -07:00
2026-05-14 18:09:26 -04:00
Context sources are optional, but they make the first context layer much richer.
Setup can add:
2026-05-11 00:45:43 -07:00
2026-05-14 18:09:26 -04:00
| Source | Typical input | What KTX learns |
|--------|---------------|-----------------|
| dbt | Local project or Git repo | Models, columns, tests, descriptions, tags |
| MetricFlow | Local project or Git repo | Semantic models, metrics, dimensions, entities |
| LookML | Local files or Git repo | Views, explores, dimensions, measures, joins |
| Looker | API URL and credentials | Explores, looks, dashboards, model metadata |
| Metabase | API URL and key | Questions, dashboards, BI database mappings |
| Notion | Integration token and crawl settings | Business docs and knowledge pages |
2026-05-11 00:45:43 -07:00
2026-05-14 18:09:26 -04:00
Setup maps BI and source metadata back to your primary warehouse connection so
generated context points at the right tables.
2026-05-11 00:45:43 -07:00
2026-05-14 18:09:26 -04:00
You can skip this step and add sources later by rerunning `ktx setup`.
2026-05-11 00:45:43 -07:00
2026-05-14 18:09:26 -04:00
## Step 6: Build context
2026-05-11 00:45:43 -07:00
2026-05-14 18:09:26 -04:00
The context build turns configured databases and sources into local artifacts
agents can read. It runs database ingest first, then source ingest and memory
updates.
2026-05-11 00:45:43 -07:00
2026-05-14 18:09:26 -04:00
Fast database ingest records deterministic schema grounding. Deep ingest adds
AI-enriched descriptions, embeddings, relationship evidence, and query-history
context when configured.
2026-05-11 00:45:43 -07:00
2026-05-14 18:09:26 -04:00
When the build finishes, setup verifies that agent-ready context exists:
2026-05-11 00:45:43 -07:00
2026-05-14 18:09:26 -04:00
```text
2026-05-11 00:45:43 -07:00
KTX context is ready for agents.
2026-05-14 01:43:06 +02:00
Databases:
2026-05-14 18:09:26 -04:00
warehouse: deep 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
Verification:
Agent context: ready
Semantic search: ready
```
2026-05-14 18:09:26 -04:00
If a foreground build is interrupted, rerun `ktx setup` or build the same target
with `ktx ingest <connectionId>`.
2026-05-11 00:45:43 -07:00
2026-05-14 18:09:26 -04:00
## Step 7: Install agent integration
2026-05-11 00:45:43 -07:00
2026-05-14 18:09:26 -04:00
The final setup step installs project-local rules for your coding assistant.
Supported targets are Claude Code, Codex, Cursor, OpenCode, and universal
`.agents`.
2026-05-11 00:45:43 -07:00
2026-05-14 18:09:26 -04:00
You can also run this step later:
2026-05-11 00:45:43 -07:00
2026-05-14 18:09:26 -04:00
```bash
ktx setup --agents --target codex
2026-05-11 00:45:43 -07:00
```
2026-05-14 18:09:26 -04:00
Claude Code and Codex also support global installs:
2026-05-11 00:45:43 -07:00
2026-05-14 18:09:26 -04:00
```bash
ktx setup --agents --target codex --global
```
Agent rules are CLI-based. They point agents at the KTX CLI path that created
the file, so agents do not need a separate `ktx` binary in `PATH`. If the CLI
path changes after reinstalling or moving a checkout, rerun `ktx setup --agents`.
2026-05-11 23:32:10 -07:00
2026-05-11 16:42:08 -07:00
## Generated files
2026-05-14 18:09:26 -04:00
KTX writes plain files so people and agents can inspect changes in git.
2026-05-11 16:42:08 -07:00
2026-05-14 18:09:26 -04:00
| Path | Purpose |
|------|---------|
2026-05-15 15:31:51 -04:00
| `ktx.yaml` | Project configuration for LLMs, embeddings, connections, context sources, and query-history settings |
2026-05-14 18:09:26 -04:00
| `.ktx/secrets/*` | Local secret files referenced from `ktx.yaml`; do not commit these |
| `.ktx/setup/*` | Local setup and context-build state |
| `.ktx/agents/install-manifest.json` | Manifest used to manage installed agent files |
| `semantic-layer/<connection-id>/*.yaml` | Semantic source definitions used for SQL generation |
| `wiki/global/*.md` | Shared business context and metric definitions |
| `wiki/user/<user-id>/*.md` | User-scoped notes and local context |
| `.claude/skills/ktx/SKILL.md` | Claude Code project skill |
| `.agents/skills/ktx/SKILL.md` | Codex or universal project skill |
| `.cursor/rules/ktx.mdc` | Cursor project rule |
| `.opencode/commands/ktx.md` | OpenCode project command |
2026-05-11 16:42:08 -07:00
2026-05-14 18:09:26 -04:00
## Verify setup
2026-05-11 00:45:43 -07:00
2026-05-14 18:09:26 -04:00
Run:
2026-05-11 00:45:43 -07:00
```bash
ktx status
```
2026-05-14 18:09:26 -04:00
Example output:
```text
2026-05-11 00:45:43 -07:00
KTX project: /home/user/analytics
Project ready: yes
LLM ready: yes (claude-sonnet-4-6)
Embeddings ready: yes (text-embedding-3-small)
2026-05-14 18:09:26 -04:00
Databases configured: yes (warehouse)
Context sources configured: yes (dbt_main)
2026-05-11 00:45:43 -07:00
KTX context built: yes
2026-05-14 18:09:26 -04:00
Agent integration ready: yes (codex:project)
2026-05-11 00:45:43 -07:00
```
2026-05-14 18:09:26 -04:00
Use JSON when an agent or script needs a structured readiness check:
```bash
ktx status --json
```
## Scripted setup example
Use non-interactive setup when creating repeatable fixtures or automation:
```bash
ktx setup \
--project-dir ./analytics \
--no-input \
--skip-llm \
--skip-embeddings \
--database postgres \
--new-database-connection-id warehouse \
--database-url env:DATABASE_URL \
--database-schema public
```
Then build context:
```bash
ktx ingest warehouse --fast
```
See [ktx setup](/docs/cli-reference/ktx-setup) for the full automation flag
surface.
2026-05-11 16:42:08 -07:00
## Common errors
2026-05-14 18:09:26 -04:00
| Symptom | Likely cause | Recovery |
|---------|--------------|----------|
| `ktx: command not found` | The global package is not installed or your shell cannot find it | Reinstall `@kaelio/ktx` and open a new shell |
| Setup resumes the wrong project | `KTX_PROJECT_DIR` or the nearest `ktx.yaml` points somewhere else | Pass `--project-dir <path>` |
| Anthropic health check fails | API key, model id, or access is invalid | Fix `ANTHROPIC_API_KEY` or rerun setup with a different key or model |
| Vertex AI health check fails | Vertex API, Claude access, project, location, or IAM permissions are missing | Check the project, location, Application Default Credentials, and Vertex AI permissions |
| OpenAI embeddings fail | `OPENAI_API_KEY` is missing or invalid | Export the key or choose local sentence-transformers embeddings |
| Local embeddings fail | Managed Python runtime cannot install or start | Run `ktx dev runtime status`, then install the local embeddings runtime |
| Database test fails | Credentials, network access, database, warehouse, or schema is wrong | Test the same values with the database's native client, then rerun setup |
| Context is not built | Setup saved configuration but skipped or interrupted the build | Run `ktx setup` or `ktx ingest --all` |
| Agent integration is incomplete | Setup skipped the agents step or installed a different target | 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-14 18:09:26 -04:00
- Build and refresh context with [Building Context](/docs/guides/building-context).
- Edit semantic sources and wiki pages with [Writing Context](/docs/guides/writing-context).
- Connect more tools with [Agent Clients](/docs/integrations/agent-clients).
- Read [The Context Layer](/docs/concepts/the-context-layer) to understand the architecture.