Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Neon 7 min read How-to mediumAdept

Looking at How Replit Agent Handles Databases

Replit Agent can keep a Flask app's code and its Neon-hosted Postgres schema in sync by generating Alembic migrations from SQLAlchemy model changes, with a little prompting to use Alembic. A TODO app is built and extended through natural-language prompts. Adding a due date and then a priority field each produces a separate migration file with upgrade and downgrade functions. Rolling back a feature runs the downgrade script, which removes both the UI change and the database column.

Assumes: SQLAlchemy ORM basicsdatabase migrations

Related posts

  • An API to Track Database Schema Changes

    Neon mediumAdept

    Neon's Schema Diff feature now has a `compare_schema` API endpoint, available on all plans, that takes two Neon branch IDs and returns a unified diff of their Postgres schemas. The goal is to let AI agents such as Replit Agent and CI/CD pipelines check schema differences programmatically. Optional LSN or timestamp parameters pin a branch to a point in time, but the two are mutually exclusive. The suggested workflow is to apply schema changes on a branch holding a copy of production data, use the API to track discrepancies, then run the migration in production once it has been tested.

  • Writing Test Evals For Our MCP Server

    Neon mediumAdept

    Neon tests its 20+ tool MCP server with Braintrust evals that check whether an LLM correctly uses the stateful prepare_database_migration / complete_database_migration workflow instead of applying schema changes directly via run_sql. Each eval pairs a natural-language migration request with an expected response and scores it two ways: a Claude-based LLM-as-a-judge factuality classifier with weighted choice scores, and a main-branch integrity check that diffs pg_dump schemas before and after the run. Pass rate rose from about 60% to 100% purely by rewriting the tool descriptions, with no code changes.

  • Track Schema Changes Automatically in Your Pull Requests

    Neon mediumAdept

    Neon's Schema Diff GitHub Action compares the schema of a pull request's Neon child branch against its parent (or a specified base_branch) and posts the result as an SQL patch in a single PR comment. The comment is edited in place on new commits, and nothing is posted when the schemas match. A sample workflow creates a per-PR Neon branch with create-branch-action, runs migrations against it, posts the diff, and deletes the branch when the PR closes. The action also outputs a comment_url for further automation, such as Slack notifications.

  • Build Checkpoints For Your Agent Using Neon Snapshots

    Neon mediumAdept

    Neon's new snapshots API, built on copy-on-write branching, can implement checkpoints for agentic app builders so that rolling back an app version restores the matching Postgres schema and data along with the code. The demo pairs an app database with a meta database that maps each checkpoint to a snapshot ID. A snapshot is taken after every prompt, and rollback calls the restore API with finalize_restore and the current production branch ID, then polls operations until they reach a terminal state. Resolve the production branch ID by name before each restore rather than caching it, because it can change across restores.

  • The Hidden Ops Layer of Agent Platforms

    Neon mediumAdept

    Anything's Max coding agent gets a dedicated Neon database branch for every session, created in about 200 ms. The agent runs its migrations there and merges back into development atomically through Neon's restore API. Failed migrations go to a separate LLM "Migration Fixer" for up to three retries before rollback, and merges fail if the development schema changed in the meantime. After crashed sessions left 2,847 orphaned branches, the team added a 6-hourly cleanup job plus 24-hour expires_at timestamps on branches. Connection pooling and 0.25–1 CU autoscaling handle bursty workloads of about 30 peak connections.

The quest for software engineering knowledge.

Look:
Layout: