sqlspec

sqlspec is a skill for Claude Code from litestar-org/litestar-skills. It costs 51 tokens per session (4,245 once invoked), scanned A, original, MIT.

A guide for SQLSpec, a Python library that maps SQL queries to application code without being an object-relational mapper, or ORM.

In plain words
What is it for?
Use it for named SQL, filters, pagination, query drivers, data dictionaries, observers, and integrations with Litestar, FastAPI, Flask, Starlette, or Sanic.
Why use it?
It helps applications use raw SQL, query builders, or SQL files through consistent database connections, validation, parameters, and database-dialect conversion.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin. Also seen: positional $N argument.

Needs its repository: it reads a path above its own folder, which exists only inside the repository. The line is **Choosing between `sqlspec` and `advanced-alchemy`:** `advanced-alchemy` gives you an opinionated ORM service layer with `UUIDAuditBase`, lifecycle hooks, repo.

Part of the litestar plugin — 20 skills, 1 agent, 1 hook shipped together

Good fit Use it for named SQL, filters, pagination, query drivers, data dictionaries, observers, and integrations with Litestar, FastAPI, Flask, Starlette, or Sanic.

Compare 6 skills from other repositories ↓
Install

Getting it into your agent

It runs from inside its repository, so the clone comes first — what it calls does not travel with the file alone.

Clone the repo
git clone --depth 1 https://github.com/litestar-org/litestar-skills
agentmods
npx agentmods add skills/litestar-org/litestar-skills/sqlspec

Made for: Claude Code.

Or install litestar, the plugin that ships this one along with the rest of its 20 skills, 1 agent, 1 hook.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for sqlspec

README.md
[![agentmods](https://agentmods.dev/badge/skills/litestar-org/litestar-skills/sqlspec/github.svg)](https://agentmods.dev/skills/litestar-org/litestar-skills/sqlspec)
Your own site
<a href="https://agentmods.dev/skills/litestar-org/litestar-skills/sqlspec"><img src="https://agentmods.dev/badge/skills/litestar-org/litestar-skills/sqlspec/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for sqlspec

Your own site · 80×15
<a href="https://agentmods.dev/skills/litestar-org/litestar-skills/sqlspec"><img src="https://agentmods.dev/badge/skills/litestar-org/litestar-skills/sqlspec.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 51 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 4,245 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
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.1 $0.00051 $0.04245
Opus 5.5 $0.00020 $0.01698
Sonnet 5.5 $0.00010 $0.00849
Haiku 4.5 $0.00005 $0.00424

Measured yesterday against content hash 0c0a3a4cec9b, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

sqlspec 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.

plugins/litestar/skills/sqlspec/SKILL.md · 330 lines

How it starts

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

SQLSpec Skill

SQLSpec is a type-safe SQL query mapper for Python -- NOT an ORM. It provides flexible connectivity with consistent interfaces across 20 database adapter packages. Write raw SQL, use the builder API, or load SQL from files. Statements pass through a sqlglot-powered AST pipeline for validation, parameter handling, and dialect conversion.

Match-Your-Framework — read first

sqlspec ships first-party extensions for five web frameworks. If your project uses one of these, jump directly to the matching integration guide and skip the others:

  • Litestar — register configs on SQLSpec, then pass that registry to SQLSpecPlugin. The plugin adds DI, the litestar db CLI, and request observability. See references/extensions.md.
  • FastAPI → references/fastapi-integration.md — Depends(plugin.provide_session()) DI, Annotated[...] handlers, filter providers.
  • Flask → references/flask-integration.md — plugin.init_app(app), pull-based plugin.get_session(), async-via-portal.
  • Starlette → references/starlette-integration.md — request.state-based session access, lifespan wrapping, middleware variants.
  • Sanic — first-party ASGI-style extension for Sanic applications; match Sanic's app/request lifecycle instead of copying Litestar DI examples.

Shared topics that apply to every framework live in references/commit-modes.md (autocommit / manual middleware) and references/multi-database.md (multi-config registry). Read the framework guide first, then those for depth.

The rest of this SKILL.md covers framework-agnostic topics: adapter setup, query builder, driver methods, filters, observability, migrations, the ADK extension, and data-dictionary introspection.

Code Style Rules

  • from __future__ import annotations rule — SQLSpec adapter config modules and driver definitions avoid from __future__ import annotations because configs are introspected at runtime. Consumer application modules (handlers, services, tests that use a configured driver) MAY and typically SHOULD use it — canonical Litestar apps use it in 100+ files.

Read the full file on GitHub · 330 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 Changed 0c0a3a4cec9b
  2. 17d ago Changed · +1 lines 0e3f48f11e94
  3. 25d ago Changed · +4 lines · -3 tokens per session 1b7e050855c2
  4. 1mo ago First seen · 325 lines · 54 tokens per session scan A 56ceb422001d

Subscribe to this mod's changes

sqlspec is a skill published in the GitHub repository litestar-org/litestar-skills (16 stars, last pushed 2d ago), licensed MIT. It adds 51 tokens to every session and 4,245 once invoked, about $0.0002 per session on Opus 5.5. 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.