Last reviewed May 31, 20263 min read

Introducing ktx: the Open-Source Context Layer That Makes Data Agents Reliable

At a glance

ktx is the open-source, executable context layer for data agents. It ingests your data stack and internal docs and turns them into an executable semantic layer plus a wiki, so agents query ktx for correct SQL instead of guessing from raw schema.

Reading time

3 minutes

Last reviewed

May 31, 2026

Topics

Today we're open-sourcing ktx, an executable context layer that makes agents reliable on your data stack.

If you've tried pointing Claude Code, Codex or your custom-built agent at your data warehouse, you already know the problem: accuracy is the #1 issue. Agents are great at generating valid SQL, but valid SQL is not always correct SQL. It might quietly be using the wrong joins, filters, or metric logic. In the data world, a number that's slightly wrong is still wrong.

The current state

Most attempts to solve this fall into two buckets:

The first is to give the agent more context through skills or wiki-style Markdown docs. That gives it some guidance through a single recipe, but still makes it guess as soon as the question needs a variation or a combination.

The second is to create and maintain a semantic layer with high coverage. That solves the executable part, but it's a real pain to build and maintain, since those tools were designed for legacy BI, not for agents. And as a standalone tool, a semantic layer lacks all the useful context that lives in unstructured sources like internal docs, dashboards, query history, and Slack threads.

ktx combines the best of both worlds: the breadth of a knowledge base and the SQL safety of a semantic layer, optimized for agents to use and for teams to maintain.

How ktx works

ktx has 2 parts:

  1. Business context goes in Markdown wiki pages that are auto-ingested and auto-populated.
  2. Queryable definitions go into YAML files that define tables, row grain, joins, measures, dimensions, filters, and filter groups.

Both are plain files in git, so you review them in pull requests like any other code. ktx ingests them from sources such as BigQuery, Snowflake, Postgres, dbt, MetricFlow, LookML, Looker, Metabase, and Notion, plus corrections from your analysts during agent sessions.

That way, when an agent needs a metric, it asks ktx for a measure, dimensions, and filters instead of writing the whole query itself. ktx's planner chooses the join path, uses grain and relationship metadata, catches issues like join fan-out and chasm joins, and compiles the warehouse SQL, all while using the extra unstructured knowledge it has access to.

So instead of querying raw schema, agents query ktx, which translates their requests into accurate SQL against your warehouse. The model never got smarter. It just stopped writing the SQL.

Try it out

ktx is open source under Apache 2.0. It works with Claude Code, Codex, or whatever agent you're using, and you don't need any API keys if you're on a Claude Code Pro or Max plan.

Install it manually:

npm install -g @kaelio/ktx
ktx setup

Or give this prompt to your agent:

Run npx skills add Kaelio/ktx --skill ktx and use ktx skill to install and configure ktx

The quickstart walks through connecting your warehouse and context sources. If you'd like help managing context for your data agents, we run a hosted version too: ktx Cloud.

Go to the GitHub repo to find out more.

FAQ

What is ktx?

ktx is an open-source, executable context layer for data agents. It ingests your data stack and internal docs, then produces an executable semantic layer interlinked with a wiki-style knowledge base. Instead of querying raw schema, agents query ktx, which translates their requests into accurate SQL against your warehouse.

How is ktx different from a semantic layer like dbt MetricFlow or Cube?

ktx includes its own semantic layer, but it's built for agents. Definitions live in plain YAML and Markdown that agents can search, read, and validate through files, the CLI, and MCP. Around that semantic model, ktx adds a wiki of business context, source evidence, warehouse metadata, and query history that a standalone semantic layer doesn't capture.

Does ktx replace dbt, Looker, or Metabase?

No. ktx complements the tools you already use. It ingests from dbt, MetricFlow, LookML, Looker, Metabase, Notion, warehouse metadata, and query history, then exposes that context to agents. Your transformations, dashboards, and BI workflows stay in place.

Which agents and warehouses does ktx work with?

ktx works with Claude Code, Codex, Cursor, or whatever agent you're using, through the CLI and MCP. It connects to sources such as BigQuery, Snowflake, Postgres, dbt, MetricFlow, LookML, Looker, Metabase, and Notion.

How do I install ktx?

Run npm install -g @kaelio/ktx, then ktx setup from your project directory. You can also give your agent the prompt: run npx skills add Kaelio/ktx --skill ktx and use the ktx skill to install and configure ktx. ktx is Apache 2.0 and needs Node.js 22 or newer.

Sources

Get Started

Give your data and analytics agents the context layer they deserve.

Auto-built. Governed by your team. Ready for any agent.

SOC 2 Compliant
256-bit Encryption
HIPAA