Guides SQLite schema design and query writing with best practices. Covers table templates, naming conventions, migrations, and common pitfalls.
Ships in claude-skills-collection. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
sqlite3 --version), volumes de données attendus.create table users (
id text not null primary key default ('u_' || lower(hex(randomblob(16)))),
created text not null default (strftime('%Y-%m-%dT%H:%M:%fZ')),
updated text not null default (strftime('%Y-%m-%dT%H:%M:%fZ')),
email text not null unique,
name text not null,
active integer not null default 1 -- bool : 0/1
) strict;
create trigger users_updated
after update on users
begin
update users set updated = strftime('%Y-%m-%dT%H:%M:%fZ')
where id = old.id;
end;
| Élément | Convention |
|---|---|
| Clé primaire | id text + préfixe table (u_, p_, o_) + randomblob(16) |
| Timestamps | strftime('%Y-%m-%dT%H:%M:%fZ') — ISO 8601 avec ms, toujours UTC |
| Booléens | integer not null default 0 (0/1) — pas de type bool natif |
| JSON | text + contrainte check(json_valid(meta)) si nécessaire |
| Clés étrangères | user_id text not null references users(id) |
pragma foreign_keys = on;
SQLite n'active pas les FK par défaut. À mettre dans l'initialisation de chaque connexion.
Toujours versionner avec une table dédiée :
create table if not exists migrations (
version integer primary key,
name text not null,
applied text not null default (strftime('%Y-%m-%dT%H:%M:%fZ'))
);
Pattern de migration safe :
begin;
-- modification du schéma
alter table posts add column slug text;
insert into migrations(version, name) values (3, 'add_posts_slug');
commit;
select de production — jamais select *.with) aux sous-requêtes imbriquées profondes.with active_users as (
select id, name, email
from users
where active = 1
),
recent_posts as (
select author_id, count(*) as cnt
from posts
where created > date('now', '-30 days')
group by author_id
)
select u.name, u.email, coalesce(rp.cnt, 0) as posts_last_30d
from active_users u
left join recent_posts rp on rp.author_id = u.id
order by posts_last_30d desc;
insert into settings (key, value)
values ('theme', 'dark')
on conflict(key) do update set
value = excluded.value,
updated = strftime('%Y-%m-%dT%H:%M:%fZ');
-- Offset (simple, mais lent sur grands volumes)
select id, title, created from posts
order by created desc
limit 20 offset 40;
-- Keyset (performant, reprend après le dernier élément vu)
select id, title, created from posts
where created < '2026-06-01T12:00:00.000Z'
order by created desc
limit 20;
-- Création de l'index virtuel
create virtual table posts_fts using fts5(
title, body, content=posts, content_rowid=id
);
-- Indexation initiale
insert into posts_fts(posts_fts) values('rebuild');
-- Requête
select p.id, p.title, rank
from posts_fts
join posts p on p.id = posts_fts.rowid
where posts_fts match 'sqlite AND performance'
order by rank;
-- Extraction de champ
select json_extract(meta, '$.country') as country from users;
-- Filtre sur champ JSON
select * from orders
where json_extract(payload, '$.status') = 'paid';
-- Construction
select json_object('id', id, 'name', name) from users;
explain query plan
select * from posts where author_id = 'u_abc' order by created desc;
-- Index simple
create index idx_posts_author on posts(author_id);
-- Index composite (ordre = sélectivité décroissante)
create index idx_posts_author_created on posts(author_id, created desc);
-- Index partiel (réduit la taille de l'index)
create index idx_active_users on users(email) where active = 1;
pragma journal_mode = wal;
pragma synchronous = normal; -- sécurité acceptable, perf ++
pragma table_info(posts); -- colonnes et types
pragma index_list(posts); -- index existants
analyze; -- mise à jour des stats pour l'optimiseur
# Ouvrir / créer
sqlite3 mydb.db
# Import CSV
sqlite3 mydb.db -cmd ".mode csv" ".import data.csv my_table"
# Export CSV
sqlite3 -header -csv mydb.db "select * from users;" > users.csv
# Dump SQL complet
sqlite3 mydb.db .dump > backup.sql
# Exécuter un fichier SQL
sqlite3 mydb.db < schema.sql
| Anti-pattern | Problème | Solution |
|---|---|---|
select * en production | Casse si colonnes ajoutées, lisibilité zéro | Nommer explicitement les colonnes |
Table sans strict | SQLite accepte n'importe quel type — bugs silencieux | Toujours strict |
offset sur grande table | O(n) — ralentit proportionnellement | Keyset pagination |
like '%terme%' sur gros volumes | Full scan | FTS5 |
FK sans pragma foreign_keys = on | Contraintes ignorées silencieusement | Activer à chaque connexion |
Timestamps avec datetime() | Moins précis que strftime (pas de ms) | strftime('%Y-%m-%dT%H:%M:%fZ') |
| Connexions multiples en écriture sans WAL | Contention — SQLITE_BUSY fréquents | pragma journal_mode = wal |
| Migrations manuelles non versionnées | Impossible de rejouer ou auditer | Table migrations + transactions |
Booléens en text ('true'/'false') | Comparaisons cassées | integer 0/1 |
like ? — Dès que la table dépasse ~10k lignes ou que la recherche est fonctionnelle, FTS5.where).What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
sqlite-guide, database-schema, sql-best-practices, migrations
/claude-skills-collection:dev-sqlite-guidefrom claude-skills-collection
npx claudepluginhub vantaflow/claude-skills-collection --plugin claude-skills-collection348 skills in this plugin
/agent-a2a-protocol-guideGuide du protocole Agent-to-Agent (A2A) de Google pour l'interopérabilité entre agents IA — découverte, communication et collaboration inter-agents, avec exemples de code, critères de décision et pièges à éviter. Se déclenche avec "A2A", "agent-to-agent", "protocole A2A", "Google A2A", "interopérabilité agents". Also triggers on "agent-to-agent protocol", "agent interoperability", "connect two agents"./agent-agent-observabilityInstrumentation technique d'un agent IA — tracing distribué des appels LLM et outils, spans, métriques custom, corrélation de logs et dashboards de supervision. Pour les alertes et garde-fous de production, voir agent-monitoring-setup. Se déclenche avec "observabilité agent", "tracing agent", "LangSmith", "Langfuse", "OpenTelemetry agent", "spans LLM", "corréler les logs agent". Also triggers on "trace my agent", "LLM tracing", "agent spans"./agent-api-caller-subagentSous-agent spécialisé dans les appels API REST/GraphQL avec retry, auth et transformation de données. Se déclenche avec "sous-agent API", "API caller agent", "agent qui appelle une API", "REST agent", "HTTP agent", "API integration subagent", "external API agent". Also triggers on "subagent that calls an API", "API calling agent", "agent HTTP requests"./agent-autogen-guideDéveloppement d'agents conversationnels avec Microsoft AutoGen. Création de group chats, agents spécialisés et workflows multi-agents avec exécution de code. Se déclenche avec "AutoGen", "Microsoft AutoGen", "autogen agent", "group chat agent", "ConversableAgent", "AssistantAgent", "UserProxyAgent", "coding agent", "agents qui conversent". Also triggers on "AutoGen agents", "group chat agents", "conversable agent"./agent-browser-agent-builderConstruction d'agents de navigation web autonomes incluant scraping intelligent, interaction DOM et gestion de sessions. Se déclenche avec "browser agent", "agent navigateur", "agent web autonome", "Puppeteer agent", "Playwright agent. Also triggers on "web browsing agent", "autonomous scraping agent"./agent-claude-code-extension-builderConstruction d'extensions et skills pour Claude Code — slash commands, hooks, intégration MCP et commandes personnalisées. Se déclenche avec "extension Claude Code", "skill Claude", "slash command", "Claude Code plugin", "custom command Claude". Also triggers on "build a Claude Code plugin", "custom slash command", "Claude Code hooks".Other plugins' skills for the same job