sl_capture

Captures reusable metrics, segments, and joins into ktx semantic layer YAML sources.

1.6k|101|Updated May 10, 2026
One-click install
npx skills add https://github.com/Kaelio/ktx --skill sl-capture
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sl_capture
Source: https://github.com/Kaelio/ktx/tree/main/packages/cli/src/skills/sl_capture
Command: npx skills add https://github.com/Kaelio/ktx --skill sl-capture

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Analytical agents repeatedly rediscover the same business metrics, join patterns, and derived dimensions in raw SQL. This Skill defines when and how to persist those reusable patterns into ktx's semantic layer so future queries reuse governed definitions instead of ad-hoc SQL.

Core Features & Use Cases

  • Capture decision rules: Distinguishes patterns worth capturing (business metrics, derived views, join patterns, computed dimensions) from one-off explorations that should be skipped.
  • Generalization guidance: Enforces generic measures with query-time filters over hardcoded variants, named segments for repeated predicates, and computed dimensions for derived categories.
  • Overlay-first editing: Requires overlays on manifest-backed tables via sl_discover, sl_edit_source, and sl_write_source, with inherits_columns_from for slim standalone SQL sources.
  • Use Case: After answering "average order value last quarter" with raw SQL, the memory agent writes an avg_order_value measure overlay on the orders source and validates it with sl_validate.

Quick Start

Ask the agent to capture the reusable metric or join pattern from the current conversation into the semantic layer and validate the resulting source.

Frequently Asked Questions about sl_capture

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a new measure to the ktx semantic layer?

Run sl_discover on the target name first; if a manifest schema exists, write an overlay with sl_write_source containing only name and measures. For edits to existing sources, use sl_edit_source with exact-string yaml_edits, then run sl_validate.

When should a pattern be captured in the semantic layer?

Capture business metric aggregations, derived multi-signal calculations, reusable join patterns, and computed dimensions. Skip simple previews, trivial counts, one-off explorations, and measures that duplicate existing ones.

Should I hardcode date filters in semantic layer measures?

No. Time anchors and value lists belong in callers' query-time filters or in named segments, not inlined in measure expressions. Bake in a date only for regulatory cutovers, contractual boundaries, or one-time events.

What is the difference between an overlay and a standalone SQL source?

Overlays patch manifest-backed tables with measures, segments, joins, and column_overrides while inheriting columns and grain. Standalone sql sources are only for metrics needing per-entity derivation or multi-step CTEs, and must target names not in the manifest.

Why does my semantic layer write fail validation on BigQuery?

Expression SQL must match the warehouse dialect and the column's manifest type; comparing TIMESTAMP columns to DATE-arithmetic results fails on BigQuery. The inline validator runs a LIMIT 1 probe per measure, so fix the expression and retry.

When should I update the wiki instead of editing the semantic layer?

Use wiki-only edits when documenting a measure's business definition, owner, or policy without changing its SQL. Any request to change a measure's expression or filter requires an sl_edit_source or sl_write_source call.