writing-sql

A guide to writing SQL for Celigo integrations that move data between relational databases. SQL is the language used to read and change database records, while Celigo is an integration platform for connecting business systems.

In plain words
What is it for?
Use it to write or troubleshoot SELECT, INSERT, UPDATE, UPSERT, MERGE, delta, one-time, and bulk queries for supported databases.
Why use it?
It helps avoid errors caused by using the wrong query form, database syntax, or runtime record values. It also explains how queries differ when handling one record, a batch, or changed records.

Skill for Claude CodeCodex

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 skills/celigo/ai/writing-sql
Any agent
npx skills add celigo/ai --skill writing-sql
Clone the repo
git clone --depth 1 https://github.com/celigo/ai

Made for: Claude Code, Codex.

Per session 70 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 5,605 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.00070 $0.05605
Opus 5 $0.00035 $0.02802
Sonnet 5 $0.00014 $0.01121
Haiku 4.5 $0.00007 $0.00560

Measured 2d ago against content hash 7522ce3376aa, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

writing-sql 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 2d ago.

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.

skills/writing-sql/SKILL.md · 537 lines

How it starts

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

Writing SQL for RDBMS Integrations

RDBMS exports and imports use SQL queries to read from and write to relational databases. Queries are Handlebars templates -- the platform evaluates expressions like {{{record.fieldName}}} at runtime, then executes the resulting SQL against the connected database.

This skill covers what SQL to write and how to write it. For which adaptor type to use, connection setup, and queryType selection, see the related skills below.

Quick Reference

Context decision matrix

Where Field Handlebars prefix Braces Example
Export query rdbms.query record. (parameterized) or none (standalone) {{{ }}} SELECT * FROM orders WHERE id = {{{record.id}}}
Export delta query rdbms.query platform-injected tokens {{ }} or {{{ }}} WHERE updated_at > '{{lastExportDateTime}}'
Export once mark-as-processed rdbms.once.query record. {{{ }}} UPDATE orders SET exported = true WHERE id = {{{record.id}}}
Import per_record query rdbms.query[] record. {{{ }}} INSERT INTO users (name) VALUES ('{{{record.name}}}')
Import per_page query rdbms.query[] batch_of_records + record. {{{ }}} {{#each batch_of_records}}...{{{record.field}}}...{{/each}}
Import bulk_load override rdbms.bulkLoad.overrideMergeQuery staging table ref {{ }} MERGE INTO target USING {{import.rdbms.bulkLoad.preMergeTemporaryTable}}

Key syntax rules

  1. Always use record. prefix (AFE 2.0). Never bare fieldName or data.fieldName.
  2. Prefer triple braces {{{ }}} for values in SQL. Double braces {{ }} auto-wrap values in single quotes in RDBMS context -- this silently corrupts numeric values and breaks SQL syntax.
  3. Add your own quotes for strings: '{{{record.name}}}'. Triple braces give you full control.
  4. No quotes for numbers: {{{record.quantity}}}.
  5. Import query is an array of strings, not a single string: ["INSERT INTO ..."].
  6. Nested fields use dot notation: {{{record.address.city}}}.

Read the full file on GitHub · 537 lines

Files

What ships with it

2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. 2d ago First seen · 537 lines · 70 tokens per session scan A 7522ce3376aa

Subscribe to this mod's changes

writing-sql is a skill published in the GitHub repository celigo/ai (3 stars, last pushed 4d ago), licensed MIT. It adds 70 tokens to every session and 5,605 once invoked, about $0.0003 per session on Opus 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-31.