sql-embedder
Original:🇺🇸 English
Translated
Instructions for working with sql-embedder generated files. Use when editing or working with .sql.ts files that contain the comment "This file was generated by sql-embedder". NEVER edit these generated files directly—edit the source .sql file and regenerate instead.
4installs
Sourcefartlabs/sql-embedder
Added on
NPX Install
npx skill4agent add fartlabs/sql-embedder sql-embedderTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →sql-embedder
This skill provides guidance for working with sql-embedder generated files.
About sql-embedder
sql-embedder embeds SQL into TypeScript source code. It makes developing and
distributing TypeScript applications easier when you need access to SQL
databases at runtime—no special permissions required. It generates statically
analyzable modules.
How It Works
The tool converts files into TypeScript modules (). Each SQL
statement with a preceding comment becomes an exported constant:
.sql.sql.tsbooks.sql → books.sql.ts
queries.sql → queries.sql.tsIdentifying Generated Files
Generated files always start with this exact comment:
typescript
// This file was generated by sql-embedder. Do not edit manually.Critical Rule
NEVER edit files directly. These files are auto-generated and any
manual changes will be overwritten.
.sql.tsIf you see the generated file comment, find the corresponding file (same
name, without the extension) and edit that instead.
.sql.tsCorrect Workflow
- Edit the source file (e.g.,
.sql)books.sql - Identify the generation command by checking the project's task runner config:
- → look for a
deno.jsontaskgenerate - → look for a
package.jsonscript ingeneratescripts - → look for a
Makefiletargetgenerate - → look for a
justfilerecipegenerate
- Run the identified command to regenerate the TypeScript files
Example
To add a new query called :
findBooksByAuthor-
Edit:
books.sqlsql-- findBooksByAuthor finds all books by a given author. SELECT * FROM books WHERE author_id = ?; -
Check the project config (e.g.,,
deno.json) for the generate commandpackage.json -
Run the generation command
The new query will appear in as an exported constant.
books.sql.ts