Opinions & Insights

How we built Netlify Database for AI-native development

It’s difficult to overstate how much AI has changed software development. Building software is no longer limited to people who learned how to write code — if you have an idea and you decide to build it, you are now a developer.

As hard as it is to imagine a world without them, AI-powered coding tools are still new, and many of the companies building them are just getting started. They entered the market alongside the new type of builder they serve, starting with a clean slate.

That’s not the case with Netlify. For more than a decade, we’ve served millions of developers, from hobbyists to some of the largest corporations in the world. We’ve lived through multiple industry shifts, some of which we have introduced or helped shape. We have baggage.

You might think that history would weigh us down. Serving different audiences is hard, and pivots can go wrong in a very specific way: you lose what made you great for your original users, without becoming truly great for the new ones. But we didn’t have to pivot.

Our many years of experience give us a unique perspective on the right workflows when building for the web, regardless of technical background. Rather than choosing whether to cater to seasoned developers or newcomers, we focus on exposing best-in-class tooling and practices in a way that is accessible to everyone.

Builders are builders. Our job as a platform is to set them up for success with the best tools for the job on day one, letting them decide how deeply they want to engage with the technical details over time.

This is exactly what we’ve done with Netlify Database, which we announced recently. In this article, we’ll explore the thinking behind designing and building it as an AI-native primitive: a database that can be provisioned, branched, migrated, and operated safely in workflows shared by humans and agents.

It all starts with a prompt

When you build with an AI agent on Netlify, we’re judged by how well we can translate your prompt into a working, production-ready application. Inferring the intent behind the prompt and provisioning the right primitives is what makes this process truly inclusive.

If we only provision a database when the prompt explicitly states “add a database”, we exclude a whole category of builders who may not know what a database is or whether they need one.

On the flip side, we’re not interested in selling you a database unless you actually need one. That’s why we’ve invested heavily in fine-tuning Agent Runners and our skills and context files to automatically provision a database only when it adds real value to your project.

Getting this balance right is an ongoing effort, and I’d love to hear from you if you encounter cases where we miss the mark.

Deploy previews for your database

Historically, teams relied on a small number of fixed environments for development and testing. When working on a feature, developers shared staging environments, hoping their changes wouldn’t clash and that the environment hadn’t drifted from production.

In 2016, Netlify pioneered deploy previews, breaking away from that model and introducing isolated environments for each individual work stream. When you start working on a feature, we create a fork of your application state, layer your changes on top, and give you a unique URL for you to test your work.

If there are 20 features in progress, you get 20 isolated environments, instead of an impossible race over who gets access to staging.

These environments include instances of almost every part of your application: static files, functions, edge functions, Blobs, environment variables, headers and redirects. The missing piece was the database, which was still a single shared instance.

Netlify Database changes that by extending the exact same ergonomics to the data layer. Every deploy preview gets its own database branch, allowing developers — and their AI agents — to experiment in complete isolation, without risking production data or performance.

Zero config, zero humans in the loop

In traditional setups, using a database means clicking through a dashboard, copying a connection string, setting environment variables, and wiring everything up in code.

Those manual steps are a poor fit for AI-driven workflows, where agents get blocked waiting for human input at every step.

With Netlify Database, you can go from nothing to a fully working database without human intervention. AI agents can create databases programmatically, and Netlify automatically configures access for the correct branch. Connection strings are never something you have to think about.

Database connectivity also comes with subtle pitfalls that can introduce bugs or performance issues. Different drivers rely on different connection methods, from traditional TCP to serverless options over HTTP or WebSockets.

Instead of asking developers to navigate these tradeoffs, Netlify Database includes its own database driver, which automatically selects the optimal connection method based on the context and the runtime.

Best-in-class tooling for everyone

In relational databases, there is a strict schema that defines the shape of your data and how it relates to other data. This comes in the form of tables, columns, data types, keys and relationships, and evolving this schema over time is arguably the hardest part of operating a database in production.

For years, the standard approach has been database migrations: ordered files that describe every schema change from the beginning of your project to today. This allows you to take any past state (even an empty one) and bring it up to date by applying the relevant migrations.

Think of it like a recipe for baking a cake, where each migration describes a series of steps with ingredients and quantities. If you’re starting from scratch, you’ll begin with the very first migration, which gets you started on the batter; if you went as far as adding the frosting, you can apply only the last migration that adds the cherry on top.

Migrations are proven and widely used, but writing and managing them can feel daunting — even for experienced developers. So should we look for a different solution for less technical builders?

We don’t think so. If migrations are what production systems rely on, that’s what we should expose. It’s our job as a platform to make them simple and seamless. We do this on two levels.

First, when using Agent Runners or your AI coding agent of choice, you can describe the changes and the agent generates the necessary migrations — unless you want to write them yourself.

Second, Netlify automatically applies the migrations at the right points in the development cycle:

  • In deploy previews, migrations are applied automatically on every new deploy, so that you can test schema changes instantly in your preview environment.
  • In production deploys, migrations are applied whenever the deploy becomes published, ensuring your application code and your database schema are always in lockstep.

More broadly, we don’t believe in inventing new abstractions when great ones already exist. Instead, we look at the best tooling in the ecosystem and focus on making it accessible to everyone.

Drizzle is a good example. It’s a widely adopted TypeScript ORM that keeps your schema in code, which we believe leads to more maintainable applications. Because of that, we guide AI agents to prefer Drizzle when generating projects.

We then made sure the integration feels native. Netlify Database includes a dedicated Drizzle adapter, and the migrations generated by Drizzle Kit work out of the box. You get the benefits of a mature ecosystem without having to stitch things together yourself.

Operational safety

In recent months, we’ve seen multiple cases of AI agents deleting production databases, causing companies substantial financial and reputational loss.

These incidents should make us rethink how we use AI in our development processes, but the answer shouldn’t be to ban agents from database-adjacent workloads, as I heard from some teams. You shouldn’t have to choose between productivity and operational safety.

We believe that the answer lies in guardrails at the platform level that stop agents from taking harmful actions, with multiple layers of protection in place — including a human in the loop when needed.

Netlify Database was designed with these guardrails from day one:

  1. When you use Agent Runners, the agent never has access to your production database. It has full access to its own database branch, so it can autonomously iterate on your application and reason about the shape of your database, but it cannot access production data.
  2. The API endpoint that returns the connection string for your production database always returns credentials for a read-only user. This means that when you build with AI agents locally, such as Claude Code or Cursor, the agents can never mutate your production data. Read-write credentials for the production database are only available in the Netlify dashboard.
  3. It is not possible to delete a database via the API. That operation is only available in the Netlify dashboard.

On top of this, we back up your entire database before every production deploy, as well as daily at midnight. If anything goes wrong, there’s always a path to recovery.

A CLI-first primitive

Command-line interfaces have been a cornerstone of the developer experience for decades. They’re fast, composable, and easy to integrate into existing workflows. But they’re also proving to be a great interface for a new kind of builder: AI agents.

Agents don’t do well in clicking through dashboards or navigating complex UIs. They operate best in environments that are structured, predictable, and scriptable — all qualities that CLIs excel at. This makes the command line a uniquely powerful interface that works equally well for humans and machines.

With Netlify Database, we’ve embraced this by making the Netlify CLI a primary entry point into the feature.

When you run your application locally, we spin up a fully functional Postgres database directly on your machine. It’s powered by a Wasm build of Postgres, which means it runs the same database engine locally that you use in production. It works out of the box with the Netlify CLI and integrates seamlessly with Vite-based frameworks, giving you a consistent experience from local development to production.

The CLI is also how you interact with your database on a day-to-day basis. Commands like netlify database status give you a clear overview of your setup, from whether the feature is enabled to which migrations have been applied and which ones are still pending. Just as importantly, they guide you on what to do next, suggesting the exact commands needed to move forward.

All commands are designed to work seamlessly for both humans and agents. They support structured output formats that agents can reliably parse, and they automatically adapt their behaviour depending on who is using them — avoiding interactive prompts for agents while preserving them for humans.

The result is an interface that plays to the strengths of both audiences, making the CLI not just a developer tool, but a foundational piece of how Netlify Database works as an AI-native primitive.

What’s next?

We’ve been excited to see the incredible ideas that people are bringing to life with Netlify Database and we’ll be featuring some of these projects soon — if you’re building something, we’d love to hear from you.

And we’re just getting started. We’ll continue to reimagine what a database should look like in the AI era and how we can empower a new generation of builders to take their ideas from prompt to production quickly and safely.

Watch this space.


Keep reading

Recent posts

How do the best dev and marketing teams work together?