Ktx: An Executable Context Layer to Fix Data Agent Accuracy

Ktx is an open-source executable context layer designed to make AI agents like Claude Code, Codex, Cursor, and OpenCode query your data warehouse accurately. After building production-grade data agents for dozens of companies, the team at Kaelio found that accuracy is the #1 issue: agents generate valid SQL but it's often incorrect due to stale columns, hidden business rules, join fanout, and missing attribution logic.
Ktx splits the problem into two parts:
- Business context goes into Markdown wiki pages that are auto-ingested, organized, deduplicated, and flagged for contradictions.
- Queryable definitions go into YAML files defining tables, row grain, joins, measures, dimensions, filters, and filter groups.
When an agent needs a metric, it asks ktx for a measure, dimensions, and filters instead of writing the whole query. Ktx's planner chooses the join path, uses grain and relationship metadata, catches issues like join fanout and chasm joins, and compiles the warehouse SQL while also leveraging unstructured knowledge from ingested docs.
Ktx integrates with most warehouses (BigQuery, Snowflake, Postgres, ClickHouse, MySQL, SQL Server, SQLite), modeling tools (dbt, MetricFlow, LookML), BI tools (Looker, Metabase), and doc tools like Notion.
Quick Start
npm install -g @kaelio/ktx
ktx setup
ktx status
After setup, ktx status shows readiness checks for LLM, embeddings, databases, context sources, and agent integration.
First Commands
ktx setup # Create, resume, or update a ktx project
ktx status # Check project readiness
ktx ingest # Build context for every configured connection
ktx sl "revenue" # Search semantic sources
ktx wiki "refund policy" # Search local wiki pages
ktx mcp start # Start the MCP server for agent clients
For agent users: run npx skills add Kaelio/ktx --skill ktx in your project directory to install and configure ktx via the skill.
Who It's For
Use ktx if you want agents like Claude Code or Codex to query your warehouse with approved metric definitions, have business knowledge scattered across dbt, Looker, Metabase, and Notion, or need agents to reuse canonical SQL instead of inventing it on every prompt. Skip it if you don't have a SQL warehouse or only need one-off ad-hoc queries.
📖 Read the full source: HN AI Agents
👀 See Also

Self-Hosted GitHub Bot Runs Claude Code with 40+ Webhook Triggers and MCP Tools
A self-hosted GitHub bot leverages Claude Agent SDK with full Claude Code features, supporting 40+ webhook triggers, 4 built-in MCP servers, and custom YAML-based workflows for PR review, CI auto-fix, and issue triage.

MCP Server Indexes Codebases into Knowledge Graph for 10x Token Reduction
A new MCP server called codebase-memory-mcp parses codebases into a persistent knowledge graph using tree-sitter, reducing token usage by at least 10x for structural queries. Benchmarked across 35 real-world repositories, it replaces file-by-file exploration with graph queries.

sourcecode: Open-Source CLI to Compress Large Java/Spring Monorepos for Claude
sourcecode CLI reduces a ~4k-file Java/Spring monorepo from ~3M tokens to 1.7k tokens (compact mode). Currently focuses on context compression, git hotspot detection, and symbol lookup.

Godogen: Claude Code Skills for Complete Godot Game Generation
Godogen is an open-source pipeline that uses Claude Code skills to generate complete, playable Godot 4 projects from text prompts. It handles architecture design, 2D/3D asset generation, GDScript writing, and visual QA testing, addressing specific engineering bottlenecks like GDScript training data scarcity and build-time vs runtime state issues.