Set Up a Neon Schema-Only Branch With Synthetic Test Data

Create a Neon schema-only branch, seed one synthetic order, and use two independent Postgres connections to verify the write landed only on the test branch.

Two table cutaways show the Neon schema-only branch retaining the source columns, starting with zero rows and receiving synthetic order 42. Sentinel order 9001 stays on the source.Two table cutaways show the Neon schema-only branch retaining the source columns, starting with zero rows and receiving synthetic order 42. Sentinel order 9001 stays on the source.
Illustrative fixture for task:order-status-01. Both endpoints carry the same table definition. Order 9001 stays on the source, and the test starts empty before seeding order 42. Based on Neon’s schema-only branching guide.

Your coding agent reports that it shipped order 42. Before you accept the test, you need to know which database received the write, whether the order was present before the write, and whether the source fixture stayed intact. A Neon schema-only branch gives you the table definition and an empty starting point. You supply the rows and check both endpoints yourself.

This tutorial is for developers maintaining database-backed coding-agent tests. In task:order-status-01, the source contains only sentinel order 9001 with status pending. The test branch starts with an empty copy of the table, gets synthetic order 42, and exercises a transition from pending to shipped. The final evidence is two reads from fresh connections. The test branch should return only 42,shipped. The source should return only 9001,pending. The results below are illustrative expected observations.

Neon’s December 2, 2026 engineering post describes giving each coding-agent request a branch populated with real data. The branch-per-request pattern also fits this smaller test, where the behavior under review requires a single synthetic order with a predictable starting status. Neon’s engineering post

Title area of Neon’s Building a software factory on Neon engineering post
Neon’s engineering blog shows the title of its account of building a software factory on Neon. · Original source

Prepare the source branch and its sentinel

  1. Use a disposable Neon project with permission to create branches, room for another root branch, and a writable source database where your PostgreSQL role can create a table in public. Use an authenticated Neon CLI that supports --schema-only and --no-secrets, and have native psql with --csv support on your path. Neon documents --no-secrets for CLI version 4.9.0 and later. Neon CLI branch reference · PostgreSQL psql reference
  2. Save the four blocks below as baseline.sql, inspect-orders.sql, seed-order.sql and ship-order.sql. Run the terminal commands from the directory containing those files. Use neondb and neondb_owner if those are the database and role in your disposable project. Substitute the actual names if your project uses different ones.
  3. Set the project ID and list its branches. Record the source branch name and its ID. Confirm that the example test branch name is free. If it is already in use, choose an unused name and use that name consistently for this run.
PROJECT_ID='replace-with-your-disposable-project-id'
SOURCE_BRANCH='main'
TEST_BRANCH='orders-status-01'
DB_NAME='neondb'
DB_ROLE='neondb_owner'

# Expected: the disposable project's source branch is listed.
neon branches list --project-id "$PROJECT_ID"

The example uses main because Neon documents that projects created through its CLI or API start with that root branch name. A Console-created project starts with a root named production. If the source in your disposable project is named production, double-check the project ID before using that name. Branch names are unique within a project. The same friendly name can describe a completely different database in another project, so the commands carry the project ID even for read-only checks. Neon branch management

Use a shell session with command tracing disabled and keep database connection details out of shared logs. The commands resolve the connection by branch, database and role, then ask Neon to launch psql. Record the compute hostname and result rows together. A transcript with the expected CSV line and no endpoint identity is difficult to use when two terminals are open to the same database name. Neon connection-string reference

Save this as baseline.sql.

CREATE TABLE public.order_status_fixture (
    order_id integer PRIMARY KEY,
    status text NOT NULL,
    CONSTRAINT order_status_fixture_valid_status
        CHECK (status IN ('pending', 'shipped'))
);

INSERT INTO public.order_status_fixture (order_id, status)
VALUES (9001, 'pending');

The fixture name is qualified with public so all four files refer to the same relation. The integer primary key lets you pick IDs that distinguish the branches without looking up generated values. NOT NULL and the status constraint turn a missing status or a spelling error into a database error. The constraint permits either legal value. The update later specifies the transition the test is exercising. PostgreSQL CREATE TABLE reference

The plain CREATE TABLE also exposes a reused source. If the table already exists, inspect its definition with \d public.order_status_fixture in native psql. For a deliberate replay on the same disposable source, keep the baseline if the definition and sole sentinel row match. For an unfamiliar table, choose a fresh disposable source. CREATE TABLE IF NOT EXISTS would suppress the conflict even if the existing relation had a different definition. PostgreSQL CREATE TABLE reference · PostgreSQL psql reference

Run the source setup on its own connection.

neon connection-string "$SOURCE_BRANCH" --project-id "$PROJECT_ID" \
  --database-name "$DB_NAME" --role-name "$DB_ROLE" --psql -- \
  -X -v ON_ERROR_STOP=1 -1 -f baseline.sql

Arguments after -- reach psql. -X skips client startup files, -v ON_ERROR_STOP=1 stops processing at a script error, and -1 wraps the file in a transaction. If the insert fails after table creation, psql rolls back the file’s changes with these options. A fresh setup should show CREATE TABLE and INSERT 0 1. The final 1 is the number of rows inserted. Check that the invocation finishes successfully before continuing. Neon connection-string reference · PostgreSQL psql reference · PostgreSQL INSERT reference

Save the read-only inspection file as inspect-orders.sql.

\conninfo
SELECT order_id, status
FROM public.order_status_fixture
ORDER BY order_id;
neon connection-string "$SOURCE_BRANCH" --project-id "$PROJECT_ID" \
  --database-name "$DB_NAME" --role-name "$DB_ROLE" --psql -- \
  -X -v ON_ERROR_STOP=1 --csv -f inspect-orders.sql

Record the hostname reported by \conninfo as the source endpoint after matching it to the source branch’s compute in the Neon Console. In the SQL query output after the connection information, expect the CSV header order_id,status and exactly one data line, 9001,pending. Keep the query unfiltered. A query limited to order 9001 would return the same line if someone had already seeded order 42 on the source. If any extra row is present, resolve the baseline before creating the test branch. The insert command tag counts what that one statement inserted. This read gives you the contents of the fixture table. Neon branch management · PostgreSQL psql reference

Create the schema-only branch and prove it starts empty

  1. Create orders-status-01 using main as the schema source in the explicit project. Record the test branch ID and compute ID from the creation response. Those details help you distinguish this run from a previous run with the same name.
  2. Open a fresh connection to the new branch. Compare the hostname with the source hostname you recorded, then read the entire fixture table before inserting anything.
  3. Continue when the test hostname belongs to the new branch’s compute and the query returns the CSV header with zero data lines. A successful empty read shows that the selected table and columns are available. A query error calls for investigating the connection or schema before seeding.
neon branches create --project-id "$PROJECT_ID" \
  --parent "$SOURCE_BRANCH" --name "$TEST_BRANCH" \
  --schema-only --no-secrets

--parent selects the source of the schema. Neon creates the result as an independent root branch with no parent relationship. A dash in the Console’s Parent column is therefore expected. The schema-only option requires exactly one read-write compute, which the default create command supplies. Neon documents the feature as beta and counts the result against the project’s root branch allowance. If creation fails for lack of room, check which roots already exist. Use another disposable project with capacity or clean up a confirmed earlier test branch. Neon schema-only branching guide · Neon CLI branch reference

A comparison matrix shows that current-data creation copies existing rows and retains a parent, while a Neon schema-only branch copies the definition and starts as an independent root.A comparison matrix shows that current-data creation copies existing rows and retains a parent, while a Neon schema-only branch copies the definition and starts as an independent root.
Choose schema-only creation when the fixture must start empty. The resulting root branch has no parent to reset from. Source: Neon’s Manage branches and Schema-only branches documentation.

neon connection-string "$TEST_BRANCH" --project-id "$PROJECT_ID" \
  --database-name "$DB_NAME" --role-name "$DB_ROLE" --psql -- \
  -X -v ON_ERROR_STOP=1 --csv -f inspect-orders.sql

The hostname should differ from the source hostname. Open the test branch in the Neon Console and compare the compute there with the endpoint you reached. The two branches in the exercise use the same database, role and relation names. The hostname identifies the compute, and the result set shows what the connection can read from the fixture. Keep the empty result beside the test hostname before going on to the insert. Neon branch management

If the endpoint is still coming up, retry the inspection once the branch and its compute are available. If the connection never opens, examine the project, branch, database and role selections. If the hostname matches the source, check the shell variable and command arguments. If the hostname belongs to the new compute and you see 9001,pending there, inspect the branch creation command. An ordinary current-data clone copies the sentinel along with the schema. Preserve that observation and rebuild the confirmed disposable branch using the recovery procedure below. Neon branch management · Neon’s engineering post

If psql reports that the relation is missing, check that both commands selected the same database name and that the baseline read succeeded before branch creation. Run the source inspection again if the setup output is ambiguous. A source with the expected row and a test branch with a missing table calls for investigating the schema copy and the selected database. Creating the table manually on the test branch would bypass the operation you are trying to verify. If you use a Git worktree for the surrounding application, there is a separate guide to pinning and checking the database branch for that checkout. Verify each Git worktree’s database branch

Seed order 42 and exercise the status change

  1. Run seed-order.sql once against the verified empty test branch. Check that the insert returns 42,pending and that the invocation completes successfully.
  2. Run the inspection file against the same test branch in a separate invocation. Expect one data line, 42,pending, with no 9001. Keep this observation as the before state for the write.
  3. Run ship-order.sql on the test branch. For the first pass, this file stands in for the database write your agent or application would perform. Check that the returned record has ID 42 and status shipped before moving on to the independent reads.

Save this as seed-order.sql.

INSERT INTO public.order_status_fixture (order_id, status)
VALUES (42, 'pending')
RETURNING order_id, status;
# Expected: the insert returns 42,pending.
neon connection-string "$TEST_BRANCH" --project-id "$PROJECT_ID" \
  --database-name "$DB_NAME" --role-name "$DB_ROLE" --psql -- \
  -X -v ON_ERROR_STOP=1 -1 --csv -f seed-order.sql

# Expected: the test compute returns only 42,pending.
neon connection-string "$TEST_BRANCH" --project-id "$PROJECT_ID" \
  --database-name "$DB_NAME" --role-name "$DB_ROLE" --psql -- \
  -X -v ON_ERROR_STOP=1 --csv -f inspect-orders.sql

The seed sets both fields explicitly. Every newly created empty test branch gets the same starting row from the same file. A duplicate key error on a second invocation signals that order 42 already exists. An upsert that sets pending could change an already shipped order back to the starting state and obscure what happened during an earlier attempt. The plain insert exposes a reused fixture. RETURNING reports what the statement inserted, while the new connection confirms the row is visible after the seed transaction. PostgreSQL INSERT reference

Save this as ship-order.sql.

UPDATE public.order_status_fixture
SET status = 'shipped'
WHERE order_id = 42
  AND status = 'pending'
RETURNING order_id, status;
neon connection-string "$TEST_BRANCH" --project-id "$PROJECT_ID" \
  --database-name "$DB_NAME" --role-name "$DB_ROLE" --psql -- \
  -X -v ON_ERROR_STOP=1 -1 --csv -f ship-order.sql

The primary key makes the ID predicate match at most one row in this fixture. The status predicate also requires the expected starting state. A second call on an already shipped order returns zero rows. PostgreSQL treats a zero-row update as a successful SQL command, so an exit status alone can miss a failed test expectation. Expect one returned row with 42,shipped. An empty result calls for inspecting the endpoint and current row before trying again. The role needs UPDATE permission for status and SELECT permission for the columns it reads in the predicate and returns. PostgreSQL UPDATE reference

For an agent-backed run, rebuild and reseed first if you already ran the reference write. Replace the shipment invocation with one call through the agent’s normal database-backed feature or test harness. Point that process at the verified test endpoint using its existing secret configuration. Keep the source connection with the operator. The example uses the owner role to create a disposable fixture. If the harness has a dedicated test role, check that its existing grants allow it to read the fixture and perform the status update. Keep the same independent SQL reads for grading so the agent’s report and the persisted result can be evaluated separately. AgentOps · Test harnesses for agentic software

Preserve the order of operations when switching from the reference write to the application. For example, if your application starts by loading its own seed, run a fresh inspection after startup and before calling the shipment feature. If the startup seed inserted a second order or changed order 42, the application is starting with a different fixture. Disable that additional seed through the test harness’s existing configuration or use the SQL reference case by itself. Keeping the same before state lets you use the same expected results to judge both paths.

Read both endpoints after the write

Separate psql reads of the Neon schema-only branch and the source branch lead to distinct expected results, 42 shipped and 9001 pending.Separate psql reads of the Neon schema-only branch and the source branch lead to distinct expected results, 42 shipped and 9001 pending.
Illustrative final check. Run the same inspection file through two fresh connections and match each complete result to its hostname. Based on Neon branch connection documentation and the PostgreSQL psql reference.

  1. Open a fresh psql connection to orders-status-01 and run inspect-orders.sql. Confirm the test compute hostname and one data row, 42,shipped.
  2. Open a separate psql connection to the source using $SOURCE_BRANCH and run exactly the same file. Confirm the original hostname and one data row, 9001,pending.
  3. Compare the complete results with the pre-write observations. Both final counts are one. Accept the result only when the IDs and statuses match their respective hostnames.
# Expected: test hostname and only 42,shipped.
neon connection-string "$TEST_BRANCH" --project-id "$PROJECT_ID" \
  --database-name "$DB_NAME" --role-name "$DB_ROLE" --psql -- \
  -X -v ON_ERROR_STOP=1 --csv -f inspect-orders.sql

# Expected: original source hostname and only 9001,pending.
neon connection-string "$SOURCE_BRANCH" --project-id "$PROJECT_ID" \
  --database-name "$DB_NAME" --role-name "$DB_ROLE" --psql -- \
  -X -v ON_ERROR_STOP=1 --csv -f inspect-orders.sql

The read file uses the same columns and ordering for each endpoint, so you can compare the CSV query results directly. Each invocation has its own connection and identifies that connection before the query. This makes the final check independent of a write session that may have seen its own changes before commit. If the write returned 42,shipped and a fresh read still says 42,pending, look at transaction completion and routing. Check the write’s terminal output for any error after the returned row, then confirm the endpoint configured by the caller. PostgreSQL psql reference

Input Action Expected result
task:order-status-01, source main, sentinel 9001,pending Run baseline.sql on $SOURCE_BRANCH, then run inspect-orders.sql in a fresh source connection. The source query returns exactly 9001,pending and the connection information identifies the source compute.
task:order-status-01, fresh orders-status-01 in the same project Run neon branches create --project-id "$PROJECT_ID" --parent "$SOURCE_BRANCH" --name "$TEST_BRANCH" --schema-only --no-secrets, then inspect $TEST_BRANCH. A different compute answers the query and returns the order_id,status header with zero data lines.
task:order-status-01, verified empty public.order_status_fixture on orders-status-01 Run seed-order.sql against $TEST_BRANCH, then run inspect-orders.sql against the same branch in a new connection. Order 42,pending is the sole row before the write.
task:order-status-01, test order 42,pending and source sentinel 9001,pending Run ship-order.sql on $TEST_BRANCH, then run inspect-orders.sql separately on $TEST_BRANCH and $SOURCE_BRANCH. The test returns only 42,shipped and the source returns only 9001,pending, with distinct compute hostnames.

The unfiltered read also catches extra rows. For example, a final test result containing 42,shipped plus another order fails the fixture even if the update returned the expected record. A query filtered to order 42 would miss the extra data. The source read serves as the control. When the before and after source results match, you have verified the final state of the source fixture for this operation. A wider application test would need checks for the other tables and external effects it can touch. LangSmith backtesting for a wrong order lookup

Read the results in order if the final state looks right but the history is unclear. For example, a test branch already containing 42,shipped can return the expected final data even when the current invocation affects zero rows. The empty read shows that the fixture table started unpopulated in this run. The pending read establishes a valid starting row. The write result and final reads together establish the transition and its expected persisted outcome for the fixture. Run the example with exclusive use of the test fixture so an unrelated writer cannot supply the transition between your reads. PostgreSQL UPDATE reference

Diagnose mismatches and rebuild the test branch

Observation Interpretation Next check
The test read before seeding reports the source hostname and 9001,pending. The read reached the source endpoint. Correct the branch or connection selection and rerun the read before any further write.
The confirmed new test endpoint returns 9001,pending before seeding. The starting state contains source data, consistent with a full clone. Check the recorded create command and branch details. Recreate only the confirmed disposable target.
The confirmed test endpoint still returns zero rows after the seed. Order 42 is absent from the committed fixture. Read the insert error or transaction output and confirm where the seed ran before invoking the update.
The write returns zero rows and the test read shows 42,shipped. The predicate might be seeing a previously completed write. Check the before state and whether there was a prior run. Use a fresh branch for a clean replay.
The test read still shows 42,pending after the write. The intended transition is absent on the test endpoint. Check the write result, transaction completion and the configured hostname before retrying.
The source now contains 42 or its sentinel status has changed. The control failed. Stop writes, preserve both results, and check which process and endpoint performed each operation before resetting anything.

A duplicate seed error followed by 42,pending on the correct endpoint means the row already existed when the latest insert ran. A failed seed followed by an empty result leaves the shipment step with no matching row. Save the error alongside the inspection result because those cases need different diagnoses. To compare two attempts, rebuild from the same confirmed source and repeat the empty and pending reads before the second write. Coding agent retry evaluation

Deletion is permanent and removes the target branch’s databases, roles and compute. Paste the ID recorded during creation and inspect it first. Confirm its project and name, compare it with the recorded source ID, and verify that the branch is dedicated to this test and has no dependent work. If Neon refuses deletion because of the branch’s status or dependents, resolve its ownership before taking further action. Neon branch management

TEST_BRANCH_ID='replace-with-the-confirmed-test-branch-id'
neon branches get "$TEST_BRANCH_ID" --project-id "$PROJECT_ID" --output json

After confirming that ID, delete the disposable test branch. The list should still show the source, and the deleted ID should be absent.

neon branches delete "$TEST_BRANCH_ID" --project-id "$PROJECT_ID"
neon branches list --project-id "$PROJECT_ID"

For a replay, rerun the source inspection first. If it shows a different hostname or any result other than the single sentinel row, investigate the source before basing another run on it. Once the source matches, create the replacement with the same command.

neon branches create --project-id "$PROJECT_ID" \
  --parent "$SOURCE_BRANCH" --name "$TEST_BRANCH" \
  --schema-only --no-secrets

Record the replacement ID and resolve its connection again even though the friendly name is the same. Verify the empty table on the replacement compute and reuse seed-order.sql. Reset from parent requires a parent relationship. Restoring from the source copies schema and data and establishes a parent, which would change this test’s starting state. Recreating with --schema-only preserves the empty-table checkpoint. For final cleanup, stop after deleting the confirmed test branch and verifying its absence from the project list. Neon schema-only branching guide · Neon CLI branch reference

Sources

Many assistants.
One place to remember.

Bring your AI sessions, context, and usage together with Automater.

Meet Automater