Skip to content
Builder's Day
Will Madden, Engineering Manager, ORM at Prisma: Builder's Day speaker, October 26, 2026.

Will Madden, Engineering Manager, ORM at Prisma

The talk

How we built an ORM in 6 months

How the Prisma team rebuilt its ORM with AI, and kept the work moving in the right direction.

Will shares how the team rebuilt Prisma ORM from a blank slate in six months with no code written by hand. He walks through designing before coding, recording architectural decisions, giving agents documentation they can load as needed, and enforcing architectural boundaries with automated checks.

The talk covers testing, independent review agents, pressure-testing risky ideas, and the move from line-by-line code review to design review. Will also shows how Prisma 8's data contracts and migrations give application-building agents a more dependable foundation.

TranscriptEnglish · 30:18Read transcript
Download transcript

Auto-generated by YouTube; may contain transcription errors. Select a timestamp to play that part of the video.

Rebuilding Prisma ORM in six months

0:05

Hi everyone. Today I'm going to talk about how we rebuilt the Prisma ORM using AI. And how we rebuilt it in only 6 months. This was only possible because AI made us 10 times, 100 times faster. And that means our job is no longer writing code quickly. It's making sure that at 100 times the speed, we're going in the right direction.

0:29

We built a product that keeps other people's agents on track, the Prisma ORM. This is an ORM designed to be used with agents, designed to remain correct as you iterate on your product. And we built it by keeping our own agents on track. We're going to look at how we achieve both.

Where Prisma ORM was two years ago

0:47

But let's start with some history. When I joined Prisma 2 years ago, it was one of the most popular ORMs in JavaScript with 9 million downloads a month. But it had 3 and 1/2 thousand open issues and a couple of [clears throat] hundred open pull requests. And four engineers maintaining it.

1:07

Bugs were coming in faster than they could be fixed. The community felt ignored because the team couldn't even get close to replying to everything. And features people were asking for were languishing in the backlog for years. Features like these. Polymorphic polymorphic relationships, for example, was first requested in 2016.

1:28

Other features like database views and post GIS only exist in certain databases and not others. But because of the state of the code base with support for different databases highly coupled to each other, it was next to impossible for the team to act on these feature requests. My name's Will Madden. I'm the lead developer at the ORM at Prisma.

1:54

And I've been building software for about 20 years. I've worked across a variety of startups in different industries, about 10 different companies, two of them I owned, both of which failed. So, what I've learned from working in startups for so long is how to spot a system that's no longer maintainable, that can't change fast enough to survive.

2:17

And that's how I felt when I joined Prisma. Years of pivots had left the code in a state that nobody could maintain. That's what going fast in the wrong direction looks like. It would have taken a monumental effort to rewrite that code base by hand. And while it took humans years to get there, with AI, a team can get there in months.

2:40

So, when we took this on, we wanted to make sure that the effort of the fruit of our efforts would be successful. And that's what I want to share with you today.

What is an ORM for when AI writes the code?

2:52

But first, I want to pose to you the question that was posed to me. What is an ORM for when AI writes the code? Most people think of an ORM as the thing that they use to be able to write database communication in language that makes sense to them in the context of their application logic.

3:12

For example, your application might say, "Fetch the posts this user wrote." Your ORM needs to speak to your database in SQL, and the result looks something like this. Select the posts belonging to the users matching these conditions, and return them. Soren, the CEO, asked me over coffee, "What will ORMs look like when everyone writes code with agents?"

3:37

And that was about a year ago, and my initial reaction was probably really similar to lots of other people's. Why not just let the agent write the SQL directly? That's a lot easier than going through all of the steps of transformation that an ORM performs to take you from English-like language to database communication.

4:01

And I realized, even if I did that, I wouldn't feel very confident about the result. Because what I need from an ORM isn't translating English to SQL, it's I need it to tell me if the SQL is correct. Let me explain what that means. Here's a pretty typical migration. I've been working in this industry for about 20 years and I can read it and I can take a pretty educated guess as to what it does.

4:31

But I can't really tell you whether it's right. I can't tell you if it's safe, if we should merge this pull request. And the reason I bring this up isn't to demonstrate that I'm not very good at SQL, it's to illustrate that even experts can't check everything by eye. I'm an application developer. My expertise is in application logic. SQL isn't my forte.

4:56

What we need are tools that will perform these kinds of checks for us. Because while I can read it, I can't tell you whether it's right. A similar question is why use TypeScript when your agent writes the code? You could just ask your agent to write the JavaScript directly. But you don't.

5:16

The type system catches mistakes before the code runs. It gives you the confidence that the code that you understand is correct. We asked the same question about both our product and our team. What is an ORM for if agents are writing all the code? And what is an engineer for if agents are writing all the code?

5:36

Why do we need either of them? And the answer to both was very similar. We need the ORM to make sure that the code the agent writes is correct, and we need the engineer to make sure that the code the agent writes is correct. And that's what I meant at the beginning. AI makes you 10 times or 100 times faster, so your job isn't writing code quickly. That's taken care of for you.

6:02

It's making sure that if you're going 100 times the speed, that you're going in the right direction. There were four things we needed to get right in order to be able to work this fast and this effectively. We needed to ensure that the design of the system we were creating was good.

6:22

We needed to make sure that the design for the system we were creating was effective. We needed guardrails that would keep our agents writing this system correctly over time as we iterated on it. We needed to pressure test the direction that we were creating and we needed to change how our team functioned.

6:42

As individuals and together. Let's walk through what those things mean. Design before you write your code.

Design before you write code

6:52

When we first started working on the Prisma ORM 8, the rewrite from the original Rust TypeScript code base, we spent three or four weeks just working in text. I spent a long time talking to my agent after my initial conversation with Søren, doing research, proposing potential solutions to the overall problem of what an ORM could be in 2026, and testing those ideas through text and conversation.

7:24

And this is precisely what you would normally do with a team of engineers in front of a whiteboard. But in 2026, more often than not, you'll be one person working with an agent or a team of agents, and you need to be sure that the design that you're committing to is one that will serve you.

7:42

To do that, we formulated the principles for our design before we committed to a specific design. In our case, that was things like that the ORM should be contract first, that you should be able to state what expectations you have of a database and then verify whether or not a database is satisfies those expectations.

8:00

You should be able to interrogate the structure of queries and migrations before you run them. And that the framework core should be thin and its database targets, the packages that provide support for specific databases, should contain the majority of the logic. If you open the Prisma ORM repo today, you will still find the same architectural principles stated first up in the documentation.

8:25

And when we evaluate new designs, we do it against these principles. One of those being that you can tell whether a database satisfies the contract by looking only at the database and the contract. You don't need to load the rest of the repository's code for an application to make this evaluation.

8:45

Having formulated our design principles, we prototyped our riskiest ideas first. Can you actually check a real database against the contract written in JSON? Can anyone add a database or extension without changing the core?

Documentation for agents that forget

9:00

If either of these concepts prove to be false, the rest of the design wouldn't have made sense. The first commit in the Prisma 8 code base was on 12th of October 2025. There were 111 more commits in that first week. It was pretty light by our standards today. And a lot of what we committed was actually documentation.

9:27

Agents forget everything between sessions. So, if you want to begin a conversation with an agent and have it effectively [clears throat] understand the project that you're working on and the design that you spent so much time refining, you need to be able to express it in a structured way that allows agents to progressively take on more context.

9:46

We didn't really know how to do that when we started. So, we started talking to one of our agents about what's an effective way of structuring this information that allows it to be progressively disclosed. And what we settled on was something like what you see on screen. And you can check this out in the Prisma ORM repo anytime.

10:03

There's an architecture overview that describes the system at a high level, what its purpose is, how we expect users to use it, and roughly the steps that the system will execute through as people go through their normal workflows. From there, there's an index and a glossary that allows the agents to identify 11 subsystem documents that describe each of the components of that high-level system in detail.

10:28

And we picked up a habit from Martin Fowler, I believe, the architecture decision record, which is a document for each of the significant salient decisions that you make in the design of your system. For each decision, you write one document. We have 229 of them now, that describes what are the consequences of this decision, what was the context at the time we made it, what are the alternatives that we rejected when we chose to make this decision this way.

10:56

And that means that any agent that's picking up a topic in a new conversation can now start from the architecture overview, learn about the system that it's going to be interacting with, and even trace back the history of the decisions that shaped that system to their original reasoning.

11:14

We put this effort into the design and the documentation of the design because it's easy to change a design. It's really hard to change code. This is one of the big takeaways from the state that the Prisma 7 code base got into. Legacy decisions, the complexity from legacy technical decisions compounds over time. And you don't want to get into a situation where what you need from your system is something it is unable to deliver.

11:40

So, iterate on your design and do it in text. You can test a lot of what you care about in a design without writing a line of code, which is precisely what we did.

Keeping agents on track

11:53

When you are writing your system, when you have moved on from the design work, and you've moved on to implementation, and you're writing your system, how do you make sure that your agents stay on track? Let me give you a concrete example. The Prisma ORM consists of a framework core, which is general-purpose abstractions, things like tables and columns and data types, and specific database support packages.

12:21

For example, there's a Postgres package, there is a SQLite package, there will be a MySQL package, and users will plug in whichever database support package they want, and utilize the common framework core. Now, at some point, I asked an agent to do something with the PG vector extension. Now, PG vector adds vector data type support to the to the framework.

12:49

And deep in the framework core, going through general-purpose logic, my agent took a shortcut because it was being lazy, and it added an if statement that just checked the type of the column by string identifier, and if it was a vector column, did some kind of special handling. It worked, but it was an completely wrong place.

13:12

The right fix would have been a some kind of general-purpose way for an extension to say, "My data type beha- behaves differently than other data types." And for that general-purpose logic to be invoked according to what data type was being utilized. Agents will take the shortest path that's available to them.

13:34

One of the techniques that we can use to keep agents on track is to make sure that the shortest path is the right one. Or to put it in other terms, give them a pit of success to fall into. The techniques that I'm going to present here, including this one, none of them are novel. We didn't invent any of this.

13:51

And a lot of what we've done next, we took from clean architecture and domain-driven design, which I highly recommend anybody who's interested to research independently. So, the next thing we did to keep our agents creating code the right way was we moved our code into layers.

Architectural layers as guardrails

14:10

Architectural layering is the concept that you want to have responsibilities split between different areas of your code base in a unidirectional way. So, the physical analogy is layers that are on the top can see down to layers on the bottom, but layers on the bottom can't see up to layers that are above them.

14:29

And to make that really obvious for ourselves, we numbered our directories, which you can see in the Prisma ORM repo. They're They look very similar to what's on screen. You'd have zero-shared, one-framework, two-SQL family, three-extensions, and so on. The extensions layer is allowed to be aware of what happens in the framework layer. It can import concepts or abstractions from the framework or from the shared code layer, but the reverse is not true. The framework is not allowed to import concepts from the extensions layer, which is where Postgres went. And this is how we solved the Postgres in the core problem.

15:07

At first, this was just folder names, which was really handy for us as humans to evaluate, but agents would ignore them completely. So, the next thing we did was we added a a tool called Dependency Cruiser, which allowed us to establish mechanically checked rules for what is allowed to import from what. So, now if you try and import something from Postgres inside the framework core, CI will fail. In fact, your pre-commit hook will fail.

15:37

The system won't allow you to do this.

Errors that teach agents

15:40

And this keeps our agents working within the framework's layered system consistently. The next thing you got to do, once you've started to establish some guardrails for your agents, is teach them what they should be doing when they make a mistake. For example, we've got some linter rules that forbid using any or or using the as keyword in TypeScript, and the errors that agents will typically experience from ordinary linters look a bit like what you see on the left.

16:11

Unexpected any specified by different type. This doesn't give an agent much instruction about why this is a problem or how to do it better. Whereas our errors look something like what you see on the right. One really useful tool you can use to customize these kinds of errors is biome. Biome allows you to specify what errors to output when certain conditions are triggered.

16:36

The next unsurprising technique that we utilize is testing.

Testing and review agents

16:42

Our agents are instructed to perform test-driven development, which they do with moderate success. But we've also established very clear patterns for how we expect testing to happen. Every layer has its own integration tests. Layers together have Every layer has its own unit tests.

16:58

Layers together have their own integration tests. And we have end-to-end tests that operate the whole system from user input all the way down to database communication. The end result is we have about almost 2 and 1/2 times the amount of test code that we have product code. Which is a lot of lines of code.

17:19

We also have an autonomous code review agent, one that we created in-house called Gizmo. But there are existing tools in the industry that will do this for you, like Code Rabbit, which we utilized until recently. Every time our reviewer agent runs, it has a list of typical problematic patterns that we want it to check for or questions we wanted to ask about the incoming pull requests.

17:48

Whenever we identify a new bad pattern, we put it in this document that the reviewer agent will check for next time. The takeaway from this is to establish guardrails means every incoming change that you or an agent makes in your codebase must be checkable by a machine. You need to be able to automatically detect whether the change that's incoming is going to leave your system in a valid state.

18:20

But what this won't tell you is whether you will be leaving your system in a better state or not.

Pressure-testing your direction

18:28

Are you improving your system? Is it more suited to the task of your users? That's much more difficult to tell, and tests won't tell you that. For example, we found ourselves in a situation where all of our tests were passing. There were no Postgres imports in the core. The reviewer approved.

18:49

But we still had Postgres assumptions built into the design of the framework core. The [snorts] reason for this is we started off only supporting Postgres. It was the first database we were interested in, and what even once once we had built the framework core in terms of general-purpose abstractions, we discovered that some of those abstractions actually don't exist in some databases, or the behavior of a database under certain conditions would be different in other databases than it was in Postgres. So even though there were no explicit imports of any Postgres data structures or abstractions in our core, we had still built with assumptions that didn't hold under different conditions.

19:34

The only way to find that out was to try building support for a second database. And naturally we wanted to do that before our product could reach general availability. So about 3 months ago we started building support for SQLite. We built a proof of concept, and this highlighted many assumptions we didn't know we had in the core of our framework.

19:57

Last week we started working on MySQL for the same reason. Each new database we added showed assumptions we didn't know about before. Checks, lint rules, tests, integration tests, they keep you going down the road that you chose. They ensure that your agents are continuing to be consistent with the constraints that you imposed on them at the beginning. But they don't tell you whether the road that you've chosen is the right one or the wrong one, whether you're moving in the direction you really want.

20:29

So, when you're choosing the direction for your project, pick two or three two or three real cases before you generalize. This was a mistake we made with database support. But it's This is a mistake we made regarding Postgres and database support, which we're correcting now. If we had done this sooner, we would have less to correct.

20:50

If you have the opportunity, always try two or three different concrete scenarios before you pick a generalization.

Changing how the team works

20:58

The last big area we need to change was how we worked as individuals and how we worked as a team. A year ago, when I was asked what the future of our product was, I spoke to an agent and it was able to answer that question in about a minute. I watched it write out in seconds what would have taken me days or weeks of research and thought, and I couldn't help but be pretty pleased, pretty excited about the the outcome, but also deeply insecure about what value I was providing.

21:30

My boss could have just talked to his agent instead of talking to me. So, what value am I providing here? I felt the same thing when I watched agents writing out code for me. Um this is what I spent 20 years in my career honing as my craft. So, what value am I providing? And the answer is that our value was never lines of code.

21:56

It was making good decisions and helping the people around us make good decisions. And agents don't change that. Agents have made it clear that writing many lines of code isn't what we are bringing to the table, and they've also made it clear how bad they are at making good decisions.

22:15

But that fear was real, and I saw it not just in myself, but in the people around me. And this was a really common pattern in Prisma at the time, a year ago. When we were trying to transition everyone in the company to working with agentic tools as their primary method of doing software engineering.

22:36

And you've all probably seen this. Somebody posts a screenshot of the agent doing something stupid with a mocking derogatory comment like look what the dumb agent did this time. And a lot of this mentality comes from fear. Sometimes it's genuinely amusing, but a lot of it comes from our fear that we want to prove that we are still better than the machine, that we can't be simply replaced.

23:02

So, the next slide might come as a shock to some people. Zero lines of Prisma 8 code were written by hand. We did the entire thing with agents.

Zero lines written by hand

23:15

And the way that we achieved that was we changed we drastically changed the way that we worked. It was pretty uncomfortable at times, but when I started working with the team 2 years ago, we were a pretty typical agile team. We had sprints, we had daily stand-ups, we reviewed every line of code before it went into the code base. We spent a lot of time and effort writing the best possible code and the best solutions to the problems that we were facing.

23:43

>> [snorts] >> Now, agents write all of our code. Humans review designs rather than implementations. We have a daily design call instead of stand-ups. And that's where we put our effort. Often the effort that we put in isn't isn't deciding what not to build. It took a long time for us to refine our guiding principles to the point where we identified the Prisma core is what we want to be responsible for and we want our community to be able to build on that to create the solutions that they wanted.

24:16

Recently a community member opened a big pull request for a bunch of sophisticated caching behavior. And that sounds awesome. So, like we want people using the Prisma ORM to have their requests intelligently cached for them so they don't have to reach the database every time. But caching's really hard to do with blanket rules. A caching rule that makes sense for your application might not make sense for somebody else's application.

24:40

And we would have ended up with a lot of if then else then behaviors to switch on or off different pieces of this caching logic. So, we said no to putting it in Prisma, to putting it in the core. And instead, we provided small general-purpose abstractions that anyone can combine into their own caching middleware that they can include as an extension that they can maintain outside the core.

25:07

Beyond changing our software development life cycle and learning to say no to things, the other thing we wanted to do was empower every developer. Every developer in Prisma as an organization, we want to give them the autonomy to act as their own product manager, their own software architect, their own principal engineer, and their own engineering manager.

25:32

Because none of us are individual developers anymore. We are all running our own teams of agents. And in order to be able to do that, we need to use all of the techniques that we've discussed so far.

Prisma 8: data contracts and migrations

25:49

So, what does all of this look like in Prisma 8? In Prisma 8, we introduced the concept of a data contract. Your contract is an explicit statement of what your app needs to be able to work with the database. Your application builds against that contract, which states what it expects from the database.

26:09

And you can check a database at any point to say, "Does this database satisfy the data contract of your application?" When you use Prisma the CLI, it checks your database once and signs it. That is, it writes the signature of the contract into the database. So, at any point after that, you can say, "Was this database signed with this contract?"

26:29

Yes? Okay, then this application will work with it. A migration in Prisma 8 is then a state transition from one contract to another. Your agent doesn't need to write its migrations by hand. It gets to ask Prisma, it gets to tell Prisma, I've made some changes to my contract and I want you to make sure that my database will match that. So, plan me a migration.

26:55

It calls the Prisma CLI as you see on screen, Prisma migrate plan, and then when it's ready, it migrates the database with Prisma DB migrate. Your agent gets to stay talking in the realm of intent. It never needs to write its own SQL. It doesn't even need to know how the migrations work.

27:13

It just uses the system to do it for it. Because we have a simple mental model and simple atomic primitive operations for your agents to use, complex scenarios become really simple to manage. For example, if you have two developers working on topic branches, which each made their own changes to your data contract, or perhaps you have two agents work working on your machine, who have each made their own changes to your data contract, you don't get into a situation where the system will refuse to run your migrations because they are out of order.

27:50

The system allows you to say, "Take the changes from both branches in your contract, merge them together, and then plan a migration to the combined contract." That simple. Remember PostGIS, the Postgres extension from the list of features people waited years for? I think it was from 2016.

28:13

It's now an extension you can install. You import it from an NPM package, you add it as an extension to your configuration, and then you can make queries with it. Your query will output the geospatial data types, and you can even perform, as you see on screen, specific geospatial functions, specific queries that are only available for these geospatial data types.

28:40

The extension itself is pretty thin because most of the work that's that needs to be done for it is done by the framework core. So we've come a long way in 12 months.

By the numbers

28:52

In 6 months we went from a blank slate to a release candidate and in the remaining 6 months we've refined that release candidate and we're almost ready to release it to general availability. We've made 8,521 commits, we've merged about 1,000 pull requests, we created 229 architectural decision records.

29:12

We created 119 packages and wrote 3,000 test files. And we wrote zero lines of code by hand.

Get your whole team moving in the same direction

29:23

If you take one thing away from this talk, it should be this. Get your whole team moving in the same direction. Establish your principles, write design documents, use checks and tests to keep everyone on the same road. And pressure test your design to make sure that you're moving along the right road, not just the one that you happen to be on.

29:47

These principles work for everyone, not just us. AI makes you 10 times or 100 times faster. So your job is no longer writing code quickly, it's making sure that a that at 100 times the speed you're going in the right direction. Thank you. >> [music]

About Will

About Will Madden

Will leads the engineering team behind Prisma's open source ORM and guides its technical direction, with more than 15 years in software and an open source trail stretching back to 2008. He has appeared on podcasts including PodRocket to discuss ORM architecture and direction, and writes about ORM design, engineering leadership, and shipping software other engineers depend on.

On demand

Keep watching

Every Builder's Day session is prerecorded and free to watch, on this site and on YouTube.

7 recordings available now. More sessions coming soon. Free to watch.

Also in the lineup

More speakers

See the full lineup