kemalcr/kemal/kemal-database
Claude Code and agent skill by kemalcr/kemal
- community
Checking that the SKILL.md file is still in the repository.
Database initialization and interaction with SQLite and raw SQL in Kemal, following established project patterns.
Install
npx vskill@latest install kemalcr/kemal/kemal-databaseSKILL.md
The same SKILL.md was published earlier as kemalcr/kemal/kemal-database.
Kemal Database Integration
This skill provides expert guidance on integrating SQLite databases with Kemal using the db and sqlite3 shards, strictly following patterns from `kemal-by-example`.
Core Mandates
- Dependencies: Always
require "db"andrequire "sqlite3"in the main application file. Add them toshard.yml. - Connection: Centralize the database connection in a
config/database.crfile. Use environment variables for the URL:
```crystal module MyProject module Database extend self DATABASE_URL = ENV["DATABASE_URL"]? || "sqlite3:./db/database.db"
@@mutex = Mutex.new @@connection : DB::Database? = nil
def connection : DB::Database @@connection || @@mutex.synchronize { @@connection ||= DB.open(DATABASE_URL) } end end end ```
- Schema Setup: Use a
Schema.setupmethod to runCREATE TABLE IF NOT EXISTSstatements:
```crystal module MyProject module Schema extend self
def setup Database.connection.exec <<-SQL CREATE TABLE IF NOT EXISTS items ( id INTEGER PRIMARY KEY, name TEXT NOT NULL, created_at TEXT NOT NULL ) SQL end end end ```
- Model Mapping: Use
include DB::Serializablein models for automatic mapping from SQL results:
``crystal class Item include DB::Serializable property id : Int64? property name : String property created_at : String end ``
- Data Retrieval: Use
query_allandquery_one?with explicit column lists and theas: Classargument: Database.connection.query_all("SELECT id, name, created_at FROM items", as: Item)Database.connection.query_one?("SELECT id, name, created_at FROM items WHERE id = ?", id, as: Item)
Patterns from Source Code
Database Module Pattern (All Projects)
Schema Setup with Multiple Tables
Model with DB::Serializable
Initialization in Main File
Best Practices
- Initialization: Call
Schema.setupbeforeKemal.runin the main application file. - Timestamps: Always use
Time.utc.to_sfor storingcreated_atandupdated_atasTEXTin SQLite. - ID Handling: Use
Int64?for IDs to accommodate auto-incrementing fields during creation. - Transactions: Use
Database.connection.transaction do |tx| ... endfor atomic operations. - SQL Execution: Use
Database.connection.exec("SQL", args)for insert, update, and delete operations. - Explicit Column Lists: List all columns explicitly in SELECT statements rather than using
SELECT *.
When to Use
- When setting up a new database or modifying an existing schema.
- When implementing model methods that interact with the database.
- When configuring database connections and initialization logic.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryChecking.github/skills/kemal-database/SKILL.md
Popularity
- Repository stars
- 3,918
- Repository forks
- 205
- 7-day trend score
- 41
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/kemalcr/kemal/kemal-database)