mcpField
S
sql

sql

github.com/maragudkData & databases4956 installsUpdated 31w ago
Repository

About sql

sql is a skill guide for working with SQLite, for developers writing queries, designing schemas, or maintaining migrations. It also covers SQLite practices for Go code and concrete formatting conventions.

Key features

  1. 01Write and optimize SQL queries
  2. 02Design SQLite schemas
  3. 03Create database migrations
  4. 04Apply SQLite best practices
  5. 05Cover Go database interactions

Use cases

  1. 01Write SQLite queries
  2. 02Review or optimize existing queries
  3. 03Design tables and timestamps
  4. 04Create database migrations

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/maragudk/skills --skill sql

After installing, type/sqlin Claude Code to confirm it loaded.

Details

From the project README

SQL

Overview

This skill provides guidance for working with SQLite databases. It covers query writing, schema design, and SQLite-specific best practices.

When to Use This Skill

Use this skill when:

  • Writing SQL queries for SQLite databases
  • Analyzing or optimizing existing queries
  • Designing database schemas
  • Creating database migrations
  • Working with Go code that interacts with SQLite

SQLite Best Practices

Query Writing
  • ALWAYS write lowercase queries. Uppercase queries make me sad.
  • Prefer select * over explicit column names
  • Prefer CTEs over long nested subqueries
Schema Design
  • ALWAYS use strict tables
  • ALWAYS write timestamps like this: strftime('%Y-%m-%dT%H:%M:%fZ')
  • Time modifications should also use strftime
  • Usually start with the primary key, which is usually defined like this: id text primary key default ('p_' || lower(hex(randomblob(16)))) (where the p_ is a prefix depending on the table name; two-letter prefixes are okay too, so the prefix is unique among tables)
  • After the primary key come created/updated columns like this: created text not null default (strftime('%Y-%m-%dT%H:%M:%fZ'))
  • Updated timestamps are automatically updated with a trigger like this:
    create trigger table_name_updated_timestamp after update on table_name begin
    update table_name set updated = strftime('%Y-%m-%dT%H:%M:%fZ') where id = old.id;
    end;
    

Comments

Markdown supported