etl
AGENTS.md2.3k starsChanged 2 months agoApache-2.0View on GitHub
Postgres logical-replication engine. etl is the library, etl-replicator is the standalone binary, and etl-destinations holds built-in destinations. Product docs: https://supabase.github.io/etl/. Human walkthrough: DEVELOPMENT.md. This file is for agents. Read it before changing code. Use it to set up the repo, not only to implement in it. Do this on a fresh clone before tests, examples, or local services. 1. Toolchain: Rust 1.95.0 from rust-toolchain.toml (rustup uses it automatically), psql, Docker Compose, and cargo-nextest. 2. SQLx CLI (migrations; cargo x init…
- Installs packages
Trending
Quiet since September.thin dataabout the whole repository
Who's talking about supabase/etl
- feldera/feldera“[adapters] Add Postgres CDC input connector with crash-safe replication”GitHub · Apr 3, 2026 · 3 reactions
- @rusttrending.bsky.social“supabase / etl: Stream your Postgres data anywhere in real-time. Simple Rust building blocks for change …”Bluesky · Nov 28, 2025 · 2 likes
- @sap1ens.com“It looks like github.com/supabase/etl is the answer!”Bluesky · Sep 9, 2025 · 2 likes
- @tom-doerr.bsky.social“https://github.com/supabase/etl”Bluesky · Jan 8, 2026 · 1 likes
- @tom-doerr.bsky.social“https://github.com/supabase/etl/”Bluesky · Nov 5, 2025 · 1 likes
The biggest 5 of 12 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 12
Talked about on GitHub and Bluesky (12 times).
On GitHub · 8
- Apr 3, 2026[adapters] Add Postgres CDC input connector with crash-safe replication — feldera/feldera3 reactions · 23 comments
- Sep 10, 2026Postgres CDC: land upstream etl PR 881 and drop the shutdown-error workaround — feldera/feldera0 reactions
- Jul 23, 2026ref(pipelines): Update pricing descriptions given new egress calculation — supabase/supabase0 reactions · 5 comments
- Jul 17, 2026Add header — iambriccardo/gcp-bigquery-client0 reactions
- Jan 19, 2026pg: fetch using logical replication — nisshi-io/nisshi0 reactions
3 more on GitHub
- Dec 2, 2025Connector for postgres snapshot-and-follow — feldera/feldera0 reactions · 15 comments
- Nov 24, 2025Support High Availability (HA) for CDC deployment — ponix-dev/ponix-rs0 reactions · 1 comment
- Nov 10, 2025feat: add stopping pipeline status in ui — supabase/supabase0 reactions · 4 comments
On Bluesky · 4
- Nov 28, 2025supabase / etl: Stream your Postgres data anywhere in real-time. Simple Rust building blocks for change data capture (CDC) pipelines. ★2009… — @rusttrending.bsky.social2 likes and reposts
- Sep 9, 2025It looks like github.com/supabase/etl is the answer! — @sap1ens.com2 likes and reposts · 1 reply
- Jan 8, 2026https://github.com/supabase/etl — @tom-doerr.bsky.social1 likes and repost
- Nov 5, 2025https://github.com/supabase/etl/ — @tom-doerr.bsky.social1 likes and repost
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository3 other files it gives its agents.
- site/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- site/CLAUDE.mdCLAUDE.md
The file
Show its rules and text
We split this AGENTS.md into the rules it gives an agent
30 rules. About 5 are common, 8 are distinctive, and 17 are very specific to this project.
≈5
Common · estimate
Many files like this have a rule of this kind.
≈8
Distinctive · estimate
This author's own choices. Worth a look.
17
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Distinctive: line 13
Do this on a fresh clone before tests, examples, or local services.
- Distinctive: line 23
Start the local data plane (Postgres, ClickHouse, Iceberg catalog, migrations).
- Very specific: line 45
Default stack: Postgres localhost:5430 (postgres/postgres), replica 6430, ClickHouse http://localhost:8123 (etl/etl).
- Very specific: line 65
After Rust changes, when diagnostics fail, when workflow assumptions change, or when the user asks: run the smallest relevant …
- Very specific: line 86
Keep code in its owning crate unless another crate has a real dependency.
- Distinctive: line 98
Keep diffs focused. Prefer small changes unless a broader refactor is justified.
- Distinctive: line 101
Never commit, push, open PRs, or perform other git writes unless the user explicitly asks.
- Very specific: line 118
Keep shared dependencies in [workspace.dependencies] and inherit them with workspace = true.
- Very specific: line 120
Keep the workspace Cargo.lock tracked and include relevant lockfile changes with intentional dependency updates.
- Distinctive: line 135
Do not add destination runtime value-domain checks merely to predict reject, coerce, round, truncate, clamp, or reinterpret.
- Distinctive: line 140
Treat each committed migration as a durable deployment boundary.
- Distinctive: line 147
Every intermediate state must be valid, restart-safe, and retryable.
- Common: line 157
Treat the repo, every branch, commit, PR, and review comment as public.
- Common: line 158
Never put real secrets, credentials, tokens, private URLs/hostnames, customer data, or production payloads in code, tests, docs, comments, …
- Very specific: line 162
Do use fake placeholders (example.com, 127.0.0.1, placeholder-token) or <redacted>.
- Common: line 164
Do not: add secret-like values to rustdoc, snapshots, fixtures, panics, errors, or assertions, even in tests.
- Common: line 166
If a value looks real (env, local config, command output, non-public source): do not commit or quote it.
- Common: line 168
Before a requested git write, scan the staged diff, message, branch, and PR text.
- Very specific: line 185
No compatibility facades or wildcard re-exports during refactors unless the facade is an intentional public API.
- Very specific: line 194
Never place constants above imports.
- Very specific: line 197
Do not add #[must_use] unless the user asks.
- Very specific: line 210
Prefer From/TryFrom over as when the conversion exists or was range-checked.
- Very specific: line 247
Avoid unsafe unless necessary.
- Very specific: line 259
Use AbortOnDropHandle, TaskGroup for fallible children, and TaskRegistry for shared destination tasks.
- Distinctive: line 267
Apply: stop intake and drain buffered batches and pending write results under existing deadlines, durability, and error policies.
- Very specific: line 279
Background work: use abort_and_join for disposable tasks and abort_and_join_result for tasks returning EtlResult<()>.
- Very specific: line 289
Tests: use channels or state barriers to test lifecycle boundaries and error propagation, rather than repeating Tokio's handle behavior.
- Very specific: line 295
Document every item (public and private), stdlib-style, punctuated.
- Very specific: line 307
Do not log passwords, secrets, tokens, sensitive request/response bodies, or source cell/row values.
- Very specific: line 311
Prefer Display (%) over Debug (?) unless the type is known not to contain sensitive values.
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Repository Guidelines
Postgres logical-replication engine. etl is the library, etl-replicator is
the standalone binary, and etl-destinations holds built-in destinations.
Product docs: https://supabase.github.io/etl/. Human walkthrough:
DEVELOPMENT.md.
This file is for agents. Read it before changing code. Use it to set up the repo, not only to implement in it.
First-time setup
Do this on a fresh clone before tests, examples, or local services.
- Toolchain: Rust 1.95.0 from
rust-toolchain.toml(rustup uses it automatically),psql, Docker Compose, and cargo-nextest. SQLx CLI (migrations;
cargo x initneeds it):cargo install --version 0.9.0 sqlx-cli --no-default-features --features rustls,postgres --lockedStart the local data plane (Postgres, ClickHouse, Iceberg catalog, migrations). This does not write app config or apply Kubernetes:
cargo x initThen configure only the service you need:
cargo x setup replicator && cargo x seed && cargo x run replicator- Generated files in
crates/etl-replicator/configuration/are gitignored. Re-run with--forceto replace them. Do not commit them or put real secrets in tracked files.
| Need | Do |
| Existing Postgres, no Docker | SKIP_DOCKER=1 and POSTGRES_HOST, POSTGRES_PORT, POSTGRES_USER, POSTGRES_PASSWORD, POSTGRES_DB |
| Test clusters only | cargo xtask postgres start |
| Ports and destination env | DEVELOPMENT.md |
Default stack: Postgres localhost:5430 (postgres/postgres), replica
6430, ClickHouse http://localhost:8123 (etl/etl).
Commands
cargo x is the workspace task runner (cargo x --help). Stable toolchain for
build/lint/test; nightly formatter only via cargo x fmt.
cargo build --workspace --all-targets --all-features
cargo x fmt
cargo x fmt --check
cargo clippy --workspace --all-targets --all-features -- -D warnings
cargo nextest run --workspace --all-features --lib # unit tests, no Postgres
cargo nextest run -p etl-config --all-features # one crate
cargo nextest list --workspace --all-features
cargo test --doc --workspace --all-features # nextest has no doctests
cargo xtask nextest run # full sharded suite (needs Postgres)After Rust changes, when diagnostics fail, when workflow assumptions change, or when the user asks: run the smallest relevant build/clippy/test and report what ran. Skip expensive workspace checks for docs-only or YAML-only edits.
Layout
| Path | Owns |
crates/etl/ | Replication behavior and replication-specific types |
crates/etl-postgres/ | Reusable Postgres primitives, source helpers, slots, ETL metadata SQL |
crates/etl-destinations/ | Destination implementations |
crates/etl-config/ | Config types and loading |
crates/etl-replicator/ | Standalone replicator binary |
crates/etl-telemetry/ | Tracing and Prometheus |
crates/etl-examples/, crates/etl-benchmarks/ | Examples and benches |
crates/xtask/ | cargo x automation |
site/ | Next.js/Fumadocs site; docs in site/content/docs/ |
scripts/docker/ | Local Compose stack |
src/ / tests/ | Tests next to code; crate integration tests in tests/main.rs |
Crate boundaries are for reuse across crates, not for organizing one domain.
Keep code in its owning crate unless another crate has a real dependency.
Module names should be domain concepts (schema, data, event, store,
source, slots), not types/utils/common.
From etl, expose the smallest useful setup surface: pipeline
config/building, destination and store traits, ETL schema/data/event types, and
dependency types callers must use to implement those traits. Keep worker
orchestration, Postgres codec internals, runtime plumbing, and store
implementation details private.
Working here
- Keep diffs focused. Prefer small changes unless a broader refactor is justified. Match nearby code before adding a new pattern. Do not add dependencies unless the task needs them.
- Never commit, push, open PRs, or perform other git writes unless the user explicitly asks.
Cargo.tomlworkspace lints,rustfmt.toml, and compiler diagnostics are the enforceable style source of truth. Prefer tightening static checks over adding prose rules here.- Migrations already on
mainare immutable (SQL, comments, whitespace, filenames). Add a new file. Do not edit a migration that is not yet onmainunless the user asks, including comments.
Dependency versions
- Specify registry dependencies as full
x.y.zversions without an operator (Cargo's default caret requirement). Use a minimum that provides the APIs and fixes we need; adding.0to an abbreviated version does not tighten its range. - Allow SemVer-compatible updates. Use exact pins (
=x.y.z), tilde requirements, or tighter upper bounds only for a concrete compatibility need, and document the reason next to the dependency. - Keep shared dependencies in
[workspace.dependencies]and inherit them withworkspace = true. Pin Git dependencies to a commit withrev. - Keep the workspace
Cargo.locktracked and include relevant lockfile changes with intentional dependency updates. Use--lockedin CI build, lint, and test commands for workspaces with a committed lockfile; do not rely on exact manifest pins for reproducible builds. For task aliases, usecargo --locked xorcargo --locked xtask; Cargo commands spawned by the task runner need their own--lockedflag.
Destination compatibility
| Situation | Do |
| Schema permits a value/event the destination might not preserve | Expose stable destination capabilities so callers can warn; do not reject the schema |
| ETL can faithfully build the destination request/wire form | Send it; rely on the destination’s native behavior and errors |
| ETL cannot build that form, or a structural/state invariant is broken | Typed local error at the encoding point; same path for copy, insert, and update |
Do not add destination runtime value-domain checks merely to predict reject, coerce, round, truncate, clamp, or reinterpret.
Migrations
Treat each committed migration as a durable deployment boundary. Prefer one transactional migration for one semantic transition (schema, backfill, and cleanup together). Split only when PostgreSQL or a real deployment constraint requires a commit boundary (operation must commit before its result can be used, expand/backfill/contract, multi-version compatibility, or a backfill whose locking/runtime must be separate). Document that limitation.
Every intermediate state must be valid, restart-safe, and retryable. Make
ordering explicit. Comments should explain what changes, why, how existing rows
are handled, and non-obvious locking, performance, compatibility, recovery, or
rollback impact — not restate the SQL. For reversible migrations, make
dependent data compatible in down before dropping the schema it needs. Add
focused tests when classification, backfill, retry, or rollback is not obvious
from the SQL.
Secrets
Treat the repo, every branch, commit, PR, and review comment as public. Never put real secrets, credentials, tokens, private URLs/hostnames, customer data, or production payloads in code, tests, docs, comments, examples, commits, PR text, logs, or generated files.
- Do use fake placeholders (
example.com,127.0.0.1,placeholder-token) or<redacted>. Keep secrets in env vars, ignored files, or secret managers. - Do not add secret-like values to rustdoc, snapshots, fixtures, panics, errors, or assertions, even in tests.
- If a value looks real (env, local config, command output, non-public source): do not commit or quote it; stop and ask, without repeating the secret.
- Before a requested git write, scan the staged diff, message, branch, and PR text. On review, flag suspected secrets with file:line and do not reproduce the full value. If something is already exposed: stop, recommend rotation, and do not push or paste the diff. Say what you checked for leaks.
Rust
Project-specific judgment only; rustfmt/clippy already own formatting and most lints.
- Absolute crate imports for shared items (
use crate::metrics::{...}), notuse super::{...}. - SQL keywords and identifiers lowercase unless quoting or an API requires casing.
- Flat
schema.rswhen the module has no children;mod.rsonly when it owns children or a grouped entrypoint. Prefer a module directory when several files share constants, helpers, or one entrypoint. - No compatibility facades or wildcard re-exports during refactors unless the
facade is an intentional public API. Re-export from domain modules;
pub useis the public contract (nopub use child::*). - Binaries orchestrate; implementation lives in helpers/modules. Prefer clear, boring code. Prefer existing workspace patterns.
- Compound names: singular attributive modifiers (
event_batch,EventBatchMetadata), notevents_batch. Keep plurals when the noun is the head (table_rows,write_events). Preserve established external names. - Item order: imports first, then module-level constants, then other items.
Never place constants above imports. Define helpers before the items that use
them; order related items as
struct, inherentimpl, then trait impls. In inherent impls: constructors, public methods, private helpers. - Do not add
#[must_use]unless the user asks. Rustdoc goes above all attributes on the item (#[derive],#[serde],#[cfg_attr], macros). - Visibility: private by default, then
pub(super),pub(crate),pub.pubonly for crate APIs, integration tests, examples, or user-facing entrypoints. Fields private; constructors/accessors over mutable public fields. Tighten an internal module before leaving deep itemspub. Prefer private children plus selectivepub useinmod.rs. Inside a crate, refer to re-exported dependency types via the domain module (crate::schema::SchemaError) unless you are at an integration boundary. After visibility changes:cargo rustc -p <crate> --all-features -- -W unreachable_pub, then the smallest relevant checks. - Log message prose lowercase; SQL, identifiers, and product names may keep required casing.
- Prefer
From/TryFromoveraswhen the conversion exists or was range-checked. Useasfor intentionally lossy conversions or ones Rust does not expose (u64→f64metrics).Fromonly when the mapping is infallible, semantically lossless, value-preserving, and obvious. - Patch-style API updates: omitted fields preserve stored values, explicit
nullclears or resets defaults, non-null replaces. Converting a non-patch API config into an update config needs an explicit helper such asfrom_api_config, notFrom(absent optionals would becomeClear).
Errors, panics, parsers
Typed Result for recoverable failures. Wrap with source: error or
.with_source(error); do not embed {error} or error.to_string() in the
message. Detail fields are owned context (operations, tables, IDs, SQL).
Preserve the source chain. Error text is sentence case and starts with an
uppercase letter (thiserror included).
- ETL Postgres and DuckDB: keep the chain for debugging, still avoid highly critical data.
- Panics only for programmer errors or broken invariants.
debug_assert!/unreachable!for internal invariants; typed errors for external input or system state. Document# Panicsonly when the function can panic.
Parser entrypoints must not panic on malformed input: typed parse error,
EtlError, None, or an explicit failure. Unexpected EOF, bad tokens, invalid
bytes/ranges, and unsupported syntax are recoverable. Prefer slice.get,
str::get, iterators, or byte-slice parsing; convert None to the parser
error. [] only when the invariant is local (bytes[index] while
index < bytes.len(), or chunks_exact). Parse ASCII protocols as bytes so
non-ASCII cannot panic on a UTF-8 boundary. expect/panic!/unreachable! in
parsers only for programmer invariants already guaranteed; the message must
state that invariant. Add malformed-input tests: empty, unterminated
quotes/escapes, invalid UTF-8-adjacent text, non-ASCII in ASCII formats,
overflow/underflow, unsupported syntax.
Unsafe and concurrency
Avoid unsafe unless necessary. Every unsafe block needs a preceding
// SAFETY: comment. Prefer ownership/borrowing over extra clones or interior
mutability. Name long-running async work.
Task ownership and shutdown
Controlled teardown stops work and joins tasks. Silently accept requested cancellations; propagate panics, task errors, and unexpected cancellations immediately. On failure, drop remaining owned handles without awaiting secondary cleanup. Recovery correctness still applies: never checkpoint unfinished work.
- Ownership: the spawner owns teardown unless ownership is transferred.
Use
AbortOnDropHandle,TaskGroupfor fallible children, andTaskRegistryfor shared destination tasks. Transfer handles into completion futures so early returns drop them even if the outer owner survives. UseJoinSet::shutdown()only when task results may be discarded. - Signals and waits: the pipeline owns the shared cancellation token;
destinations do not handle process signals. Use
with_shutdown!only for cancellation-safe waits. Keep a running pipeline's pinned completion future alive when requesting shutdown, then await it to finish cleanup. - Apply: stop intake and drain buffered batches and pending write results under existing deadlines, durability, and error policies. Do not force early flushes or cancel in-flight apply writes. Coordination waits must observe shutdown when a stopping worker may never publish the awaited state.
- Copy and startup: initial sync is replayable. Keep copy waits, including the final empty write and its result, cancellable. On controlled shutdown, abort and join copy children before releasing the snapshot. Cancel startup separately from apply draining; clean up constructed destinations when a signal cancels startup. Startup errors return immediately.
- Destination calls:
write_eventsshould dispatch long-running writes and return promptly.write_table_rowsmay write inline: each copy partition has its own task and waits for the result before reading another batch. - Background work: use
abort_and_joinfor disposable tasks andabort_and_join_resultfor tasks returningEtlResult<()>. Keep memory sampling alive until workers and destination cleanup finish. Reap destination tasks during operation; retain table-sync results for the final wait. - Drop and native work: dropping handles requests abort; it does not undo
remote writes or stop started
spawn_blockingwork. Keep native guards and interruption/deadlines alive until that work exits. Avoid ownership cycles; existing destination/registry cycles still require explicit cleanup. Never block or spawn cleanup fromDrop. Detached tasks need a documented lifetime and termination mechanism, such as client/observer channel closure. - Tests: use channels or state barriers to test lifecycle boundaries and
error propagation, rather than repeating Tokio's handle behavior. Leave a
blank line after
biased;and betweenselect!branches.
Docs, metrics, logs
Document every item (public and private), stdlib-style, punctuated. Link
[Type] and [Type::method]. Public/module docs: fully qualified links
outside the module ([crate::store::PipelineStore]). Item docs may use short
links when the type is imported and central. Do not add imports only to shorten
links. No rustdoc examples in this repo. Comments explain why, live on the line
above, and end with ..
Metric names and label keys are constants. Share labels in the parent metrics
module. Register descriptions once (Once or equivalent). One
spawn_*_metrics_task per source plus one orchestration helper. Low-cardinality
labels unless high cardinality is operationally required.
Do not log passwords, secrets, tokens, sensitive request/response bodies, or
source cell/row values. Structural metadata is fine (table/column/type names,
counts, lengths, LSNs, IDs, operations). Production errors: error = %err or
error = %error (not err =, source =, or debug for the primary error).
Prefer Display (%) over Debug (?) unless the type is known not to
contain sensitive values. Table state: table_state_type (one) and
table_state_types (list).
Tests
Process-per-test via cargo-nextest. Full sharded suite: cargo xtask nextest
run. Single crate: cargo nextest run. Integration tests live in
tests/main.rs; filter with -- module_name::. Doctests: cargo test --doc.
0 passed; 0 failed; 0 ignored; n filtered out is a failure (nothing ran).
Confirm expected tests actually ran. Prefer cargo nextest list before filters
if unsure. Fix one crate with the narrowest tests first, then broaden.
In tests, prefer unwrap()/unwrap_err() over expect(). Use expect only
when it adds diagnostics the expression does not already give; put non-obvious
intent in a preceding comment. Prefer assertions without custom messages. A
message is justified only for non-sensitive runtime context the default output
lacks (table-driven case ids). Add or update tests when behavior changes.
Reuse crates/etl/src/test_utils/ and nearby helpers before inventing setup.
Register NotifyingStore::notify_on_* and TestDestinationWrapper::wait_for_*
before the producer can fire (they only arm on later updates):
let ready = store.notify_on_table_state_type(id, Ready).await;
pipeline.start().await.unwrap();
ready.notified().await;Need Postgres? cargo xtask postgres start (or cargo x init) and
TESTS_DATABASE_HOST. Debug with ENABLE_TRACING=1 and a focused RUST_LOG,
for example
RUST_LOG=etl::replication::apply=debug,etl_destinations::bigquery=debug.
Integration tests: source writes first, wait for notifications, then
shutdown_and_wait() before assertions. Do not assert destination state while
the pipeline is running unless the test is about in-flight or recovery
behavior. For TestDestinationWrapper, assert cumulative get_events();
clear_events() only on restart or a new isolated phase. CDC shapes must be
ones PostgreSQL can emit for that replica identity (FULL, PK, USING INDEX);
partial update rows only occur for update new-tuples.
Before you finish
Changed target or workspace, as appropriate: compiles, cargo x fmt, Clippy
with workspace lints, tests, doctests. Docs and comments match behavior. New
metrics, logs, and labels follow existing naming.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

