sql_schema

A reference for the stable version-one SQL views exposed by ctx, including symbols, files, relationships, and metadata. These views describe the indexed codebase in tables that SQL queries can read.

In plain words
What is it for?
Use it to learn the available SQL fields and relationships before querying the code-intelligence index.
Why use it?
It explains which tables and columns are safe to use when writing queries, while distinguishing them from internal data that may change.

Command

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/agentis-tools/ctx/sql_schema
Clone the repo
git clone --depth 1 https://github.com/agentis-tools/ctx
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,934 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.01934
Opus 5 $0.00000 $0.00967
Sonnet 5 $0.00000 $0.00387
Haiku 4.5 $0.00000 $0.00193

Measured yesterday against content hash a4581d8cf2ea, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

sql_schema scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

src/commands/sql_schema.md · 180 lines

How it starts

The opening of the file, as written. The whole thing — 180 lines — stays where its author put it; the contents beside it link to each section on GitHub.

ctx sql — Public Schema (v1)

ctx sql runs read-only SQL against the code-intelligence index through DuckDB. The query surface is the versioned v1 schema: a set of stable views over the physical index. Query v1.* — not the underlying tables.

Stability contract

  • v1.* is the contract. Columns and views may be added within schema_version 1. Renaming or removing anything increments v1.meta.schema_version and is noted in the changelog.
  • Everything outside v1.* is internal and unstable. The raw index is reachable as code.*, but its shape can change at any time and it is excluded from all compatibility guarantees. Do not depend on it.
  • Access is read-only and engine-hardened. Filesystem access, extension loading, and attaching other databases are disabled; the index cannot be modified.

Views

v1.symbols — one row per symbol

Column Type Description
id VARCHAR Stable symbol identifier
name VARCHAR Symbol name
qualified_name VARCHAR Fully-qualified name, when known
kind VARCHAR function, method, struct, enum, trait, …
file VARCHAR Path of the file that defines the symbol
line_start BIGINT First line of the symbol
line_end BIGINT Last line of the symbol
is_public BOOLEAN Whether the symbol is publicly visible
complexity BIGINT fan_out * 2 + fan_in heuristic complexity score
fan_in BIGINT Number of resolved incoming calls edges
fan_out BIGINT Number of outgoing calls edges
doc VARCHAR Docstring or brief, when present

Read the full file on GitHub · 180 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 180 lines · 0 tokens per session scan A a4581d8cf2ea

Subscribe to this mod's changes

sql_schema is a command published in the GitHub repository agentis-tools/ctx (11 stars, last pushed 15d ago), licensed Apache-2.0. It costs nothing until one of its globs matches a file; then it loads 1,934 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.