- Follow system and developer messages first.
- Then follow workspace or repo guides such as this file.
- More specific AGENTS.md files override broader ones.
- If instructions conflict, ask the user.
- Avoid destructive commands unless the user asks.
- Keep changes focused on the task.
- Do not print secrets or private data.
- Read
README.md,CONTRIBUTING.md, andgit statusbefore edits. - Prefer
rgfor search andapply_patchfor edits. - Use Bun for installs and scripts.
- For multi step tasks, write a short plan and update it.
- Run relevant tests or linters when practical and report results.
- Summarize what changed, where, and why.
- Reference file paths with line numbers.
- Source lives in
src/(driver.ts,session.ts,dialect.ts,columns.ts,migrator.ts,utils.ts) with public reexports fromsrc/index.ts. - Build artifacts in
dist/*.mjsanddist/*.d.tsare generated. Do not edit them by hand.bun.lockbandnode_modules/are managed by Bun. - Tests live in
test/.test/duckdb.test.tsmirrors upstream Drizzle Postgres coverage and is long. Add new specs intest/<feature>.test.tsunless you need to touch the big suite. Migration snapshots for integration runs sit intest/drizzle2/pgand DuckDB specific migrations intest/duckdb/pg.meta/holds the journals.
- Use Bun. Main commands are
bun install,bun run build,bun run build:declarations,bun test, andbun run t. - ESM only.
moduleResolutionisbundlerand imports include.tsextensions. Keep relative paths explicit and preferimport typewhen you only need types. - Do not add Postgres JSON or JSONB columns. The dialect rejects them. Use
duckDbJsonif you need DuckDB JSON.
- Use 2 space indentation and trailing commas on multi line literals. Prefer named exports over defaults. Helpers use camelCase and classes use PascalCase.
- Collapse reexports in
src/index.tsand stick to modern syntax such as??and optional chaining. Avoidanyunless DuckDB bindings lack types. - Document DuckDB compared with Postgres behavior inline, such as aliasing or result mapping quirks in
utils.tsandDuckDBSelectBuilder.
- Preferred client is
@duckdb/node-api@1.4.4-r.1. Tests use it. For hermetic runs, useDuckDBInstance.create(':memory:')orDuckDBConnection.create. - Clean up connections with
closeSync,close, ordisconnectSync. Avoid leaving.duckdbfiles in the repo. - Custom column helpers live in
src/columns.ts(duckDbStruct,duckDbMap,duckDbBlob). For JSON like structures, use these helpers or Drizzle custom types, not Postgres JSON columns.
- Use Vitest only. Share utilities via
test/utils.ts. When exercising migrations, mirror layouts undertest/drizzle2/pg/metaortest/duckdb/pg/metaand keep snapshots in sync. - The large
test/duckdb.test.tssets up sequences and schemas inbeforeAllandbeforeEach. Follow that pattern or create fresh tables in new files to avoid cross test bleed. - Regression tests should cover DuckDB specific branches such as aliasing, selection mapping, transaction handling, and migrator behavior.
- Perf benchmarks use
bun x vitest bench --run test/perf --pool=threads --poolOptions.threads.singleThread=true --no-file-parallelism. Add--outputJson perf-results/latest.jsonif you need an artifact. Vitest 1.6 rejects the--runInBandflag.
- Use short, imperative subjects under 72 chars, for example
Add migrator to exports. - Include a body when documenting workarounds or DuckDB quirks. Reference DuckDB tickets inline.
- PRs should link issues, summarize behavior changes, call out schema and migration updates, and attach
bun testandbun run buildoutput. Screenshots help when showing SQL traces or planner output.
- Bump the
package.jsonversion. - Run
bun run buildandbun testwhen practical. - Commit with a message like
Release v1.3.2. - Tag the commit as
v1.3.2. - Create a GitHub release from the tag to trigger the publish pipeline.
- Avoid em dashes and sentence dashes.
- Avoid semicolons.
- Avoid heavy adjectives and adverbs.
- Avoid using an ampersand in sentences.