{
  "video_id": "vJBAzdOACD8",
  "channel_slug": "techwithtim",
  "channel_handle": "Tech With Tim",
  "title": "I gave Claude its own database, here's what happened",
  "duration_seconds": 813,
  "url": "https://www.youtube.com/watch?v=vJBAzdOACD8",
  "upload_date": "20260428",
  "transcript": "If you're building an app in 2026, then\nyou need a database. The issue is that\nmost databases are expensive, annoying\nto configure, and can't be handled\nnatively by AI agents. And even if they\ncan, the AI agent can make one mistake\nand nuke your entire database. So, in\nthis video, I'm going to show you a\nsolution to that, and I'm going to give\nClaude its own database that's\nspecifically designed for working with\nAI agents that will allow me to run\nhundreds of databases in parallel at the\nexact same time, fork existing\ndatabases, delete them, create them,\nread them, list them, everything\nnatively inside of this AI tool, so that\nI don't need to do anything manually.\nAnd the best part is this is completely\nfree. So, what is the database that I'm\ntalking about? Well, it is ghost.build.\nIt is free to use, and you can install\nit with literally just one command, and\nthen add as an MCP server to things like\nClaude, Codex, any of the main tools\nthat you're using specifically for\ndevelopment. Now, the idea here is that\nwe can really easily spin up databases.\nWe can then fork those databases to\ncreate multiple versions. So, if we want\nto test something, or we want the AI\nagent to build something, we can do it\non a clone of our existing database\nrather than on the base one. So, if\nsomething goes wrong, nothing will be\nharmed, and then we can test all\ndifferent types of database strategies,\nand then apply the one that actually\nworks back to the main DB. Now, I want\nto show you exactly how to set it up,\nbut I'm just going to quickly pop into\nthe docs here so you can understand when\nyou would actually use this. And first\nof all, there's a free tier here. You\nget 100 compute hours per month, 1 TB of\nstorage, and unlimited databases and\nforks. So, you could use this for just\npersistent memory on your own if you\nwant to have notes or blogs or something\ninside of Claude cuz it doesn't have\nmemory by itself, or you can use it for\nvarious projects like I'm going to. And\nin the case of using it, it's good for\npersistent Postgres storage, the freedom\nto create and discard databases really\neasily without the anxiety of the cost,\nand then forking like I was talking\nabout as well as those hard spending\ncaps. Now, it's probably not the best\nfor something like a web dashboard or\nsomething like usage-based pricing for\nprecise cost control. You get the idea.\nOkay, so let me show you how to set it\nup. It's very basic. I'm going to leave\nthe commands in the description or the\nlink to the documentation. Whether\nyou're on Mac or Linux, you can copy one\nof these commands. In my case, I am on\nMac. We can just go to the terminal. We\ncan paste it in, hit enter, and then\nstart running. Okay, so I've already got\nit installed, but it will just take a\nsecond. And then once you've done that,\nyou're just going to run the command\nghost login. When you do that, it's just\ngoing to prompt you to log in with\nGitHub here. I've already authenticated,\nhence why I'm just signed in. Again, you\ndon't even need to like sign up. You\njust literally connect with your GitHub\naccount. And then we can go back, and\nwhat we're going to run next is the\nghost MCP install. When we run that\ncommand, we can pick Claude, Codex,\nCursor, whatever. In my case, I'm going\nto go with Claude Code, because that's\nwhat I want to use, and then it will\ninstall. Anyways, I've already got this\ninstalled, so it said, \"Hey, you know,\nfailed to run cuz it's installed\nalready.\" But in your case, it should\ninstall it. Pick whatever tool you want.\nAnd then what I'm going to do is just\nrun Claude Code here. And just to verify\nthe install, we can just run the slash\nMCP command. If we go here, we should\nsee the ghost MCP server. If we click\ninto it, we can view some of the tools.\nWe can see, you know, login, execute\nSQL, create database, etc. So, let's get\nout of that. And now what I want to do\nis start running a few demos, so I can\nshow you why this is actually useful and\nhow you can get a benefit from it inside\nof Claude Code. So, for the first demo,\nlet's keep it really simple. I'm going\nto go with something like spin up a new\nghost database called reading log and\ngive me a simple schema for tracking\nbooks. I want title, author, the date\nfinished, and then a rating out of five.\nThrow in maybe 10 different books about\nAI and machine learning. Let's start\nwith that. Okay. Cool. We'll go ahead\nand press enter, and you can see that we\nactually get this really nicely\nformatted text. You guys always ask me\nwhat I'm using for the voice dictation\nhere. I'm using a tool called Whisper\nFlow. I'll just quickly pop into it here\nwhile this is actually running the\nthing. You can see that I'm literally a\npower user. I have 103,000 words in a\n214 words per minute. It's obviously a\nlot faster than you having to type\nmanually. And I like the fact that it\nsaves the transcripts and gives you all\nof the automatic formatted text. It is\nfree to try out and use. I'll leave a\nlink to the description. Unfortunately,\nI have a long-term partnership with them\nbecause I literally use it all the time\nanyways, no matter what, so I figured\nI'd let you guys know. Regardless, let's\nwait for this to finish. We can see it's\nin the process of calling ghost. You can\nsee it's creating a new database called\nreading log. We're going to wait for\nthat to finish, and then once it's done,\nwe'll pop in here, see the database, and\nstart experimenting with it. Okay, cool.\nSo, it looks like it just finished. If I\nwant to see the commands that it called,\nI'm just going to press control O, and\nyou can see that it just kind of seated\nthe database with a bunch of different\nvalues here. It executed some SQL to\ncreate the different tables, and this is\nhappening natively inside of Claude code\njust using the MCP server without me\nreally having to know anything about the\ndatabase config. Now, from here, what we\ncan do is we can ask it something like,\n\"What's the average rating of the books\nin the database?\" Right? And then I can\ngo and hopefully execute that query.\nOkay, and we can see that we get a 4.4\nout of 5 as that average rating. And\nthen, of course, we can ask it pretty\nmuch anything else. What I'm going to\nsay \"Give me the books organized by\nrating.\"\nOkay, and let's see if it could just\npull those out and sort them by the\naverage rating. Okay, cool. And then we\nget our five-star, four-star, and\nthree-star books showing up in the\nconsole. That's the first demo just\nshowing you very easy. Connects to the\nMCP and uses it automatically. If for\nsome reason it's not using the MCP, just\nmake sure you include ghost. If you\ninclude ghost, it will know to go for\nthat for the database in case you have\nmaybe some other tools installed. Now,\nlet's do something a little bit more\ncomplex. Okay, so for this demo, I'm\ngoing to say, \"Make a new database\ncalled movie night with a schema for\ntracking movies. I want the title,\ndirector, year, genre, runtime, the\nrating out of 10, and then I want you to\nseed it with 100 different movies across\na mix of genres and decades.\"\nOkay, so let's run that and get it to\ncreate something a little bit larger.\nOkay, so it looks like it's finished.\nWe've got a bunch of movies here. Now,\nwhat I'm going to do is have it build a\ndashboard around this. I'm going to say,\n\"Now build me a simple dashboard for\nthis. I want one page, Next.js,\nShadcn/ui components, connect directly\nto the movie night database. I want a\ntable view of all of the movies, a\nfilter by genre, and three statistic\ncards at the top showing the total\nmovies, average rating, and most common\ndirector. Keep it minimal, just make it\nwork. Okay, so let's pop this prompt\ninside of here, and now I'm just going\nto have it create a kind of simple\ndashboard. It's not the best for making\ndashboards just because everything\nnatively is happening through the MCP.\nHowever, you can grab the connection\nstring of the underlying database and\nuse it kind of however you want, but\ntypically it's meant to be used directly\nby the AI agent and managed through the\nMCP server. So, I'm just going to go yes\nand kind of just accept all of these\ncommands. Let's wait for it to finish.\nI'll be right back and let's see what it\nlooks like. All right, so it took a\nminute there, but this is the dashboard\nthat it created, and you can see that we\ncan view all of the different movies. We\ncan see the rating. We can sort by, you\nknow, category, whatever, right? And\nkind of go through this. Obviously not\nperfect, but I just asked it to keep it\nsimple, which it obviously did. And now,\nlet's continue and move to the next\ndemo. And actually, before we do that, I\nwant to show you that if I exit out of\nthis, right? Because Claude doesn't have\nmemory persistently by default, and then\nI go back into it and I say, \"What\ndatabases do you have access to with\nGhost, for example?\" You'll see these\ndatabases will still exist. And then\nwhat we can do is we can nuke them, we\ncan clear them, we can fork them, which\nI'm going to show you in the next demos\nright here. But you can see it's listing\nit. We have the two DBs, and I can say,\n\"Okay, delete them both.\"\nRight? It's probably going to ask to\nverify that, but let's see, and then\nlet's get rid of them. Okay, and we can\nsee that both of these databases are\ndeleted. Now let's move to the next\ndemo. All right, so for this one, I want\nto do something that really shows the\nbenefit of having this kind of tool,\nwhich is running multiple databases at\nthe same time to test various\nstrategies. In this case, we'll start\nwith like optimizing a query. So, first\nlet's create a database that we can use\nto optimize. So, I'm going to say, \"Make\na a called shop analytics with a small\ne-commerce schema. I want customers,\norders, order items, products,\ncategories seeded with 100,000\ncustomers,\n500,000 orders, and 1 million order\nitems. Don't add any indexes beyond the\nprimary keys. I want this to be slow on\npurpose. Okay. So, this is going to be\ncrazy. I don't know how long it's going\nto take to actually create all of these\nentries here. The thing is I want a\nreally large database with a bunch of\ndifferent values so that we can see how\nslow it is when I try to query for\nsomething with out any indexes or\nmaterialized views or different\nstrategies. And then what we'll do is\nwe'll fork three databases at the same\ntime. We'll try different strategies.\nWe'll run different queries on them. And\nthen whatever one gives us the best\nresult, we'll go back and apply that to\nthe base DB. Okay, so it looks like it's\ndone. It's created all of these values.\nNow, what I want to do is run a query on\nthis and just see how slow it is and\nthen we'll do the optimization. Here's\nthe query that I want you to run. I want\nyou to show the top 10 customers by\ntotal spend in the last 90 days plus\ntheir order count and average order\nvalue. Write it, run it, and then show\nme the timing and the query plan. I want\nto see how long it takes. Okay, so it\ngave me the result here. We're looking\nat like 1 second, 800 milliseconds. Not\nextremely slow, but obviously we can\nmake this faster. So, now let's see how\nwe can optimize this. So, I'm going to\nsay, \"Okay, it's not too slow, but I\nthink we can make this better. What I\nwant you to do is fork three databases.\nDo this in parallel. Don't wait for the\ndatabases to finish forking before you\nfork the next one. Just fork all three\nof them at the same time. And then what\nI want you to do is apply three\ndifferent strategies on these databases\nwithout touching the base database that\nwould make this query faster. What I\nwant you to do is something like\ntargeted indexes, materialized view, and\nthen maybe a denormalized summary table.\nI want you to benchmark the query on all\nthree of these databases and then give\nme the results and rank them.\"\nOkay. So, let's run this now and see\nwhat we get. Okay, so it just finished\nhere and you can see that we have the\nmaterialized view, summary table, and\ntargeted indexes and we get the speed\nincrease versus the base query. So now\nwhat we can do because we see how much\nfaster it actually is right across these\ndifferent strategies is we can just tell\nit to apply this to the base DB. So we\nsay, \"Okay, this is great. Now let's\napply this strategy to the base DB.\nLet's use a materialized view so that we\nhave an improved query speed.\" Now the\nbenefit is that I was testing this on a\nseparate database instance. I can then\njust discard that database instance\nafter doesn't cost me any money, it's\nfree, and that means that I didn't mess\nsomething up in my main DB before I\nverified that it was actually going to\nwork where especially with AI agents is\nextremely important. You can see boom,\nit just went ahead and did this and now\nwe're good to go. So I'm going to say,\n\"Cool. Okay, remove the other three\ndatabase forks. We don't need them\nanymore.\" Right? And then we can just\nremove them and there we are. Like this\nis crazy and that's why I like this tool\na lot specifically for these types of\nexperiments. And now I want to do\nsomething even crazier. Okay, so now I\nwant to do something that is pretty\ncommon where you have some like\nmalformed data, you want to clean\nsomething up, but I want to do this with\n10 databases running in parallel. So\nwhat I'm going to do for now is I'm\ngoing to say the following. I'm going to\nsay, \"Make a database called user space\nwith let's go 500 fake users. I want\nname, email, phone number, a created at\ndate, and I want to make the phone\nnumber column messy on purpose. So I\nwant 3% null, 2% straight up malformed,\nand the rest valid but a bunch of\ndifferent formats. Mix the bad rows\nthroughout. I want to do this for a\ndemo.\" So I want to create this kind of\nmalformed database which is very common\nto deal with especially at large\ncompanies where you have data coming\nfrom different sources. And then I want\nto spin up 10 databases in parallel to\nrun some different strategies on\ncleaning up the database and see how\nmany rows we delete, how many we keep,\nand what those strategies end up\nactually resulting in again before I\napply them and potentially have\nsomething dangerous or destructive on\nthe main DB. Okay, so the base DB is\ncreated. Now what I want to do is the\nfollowing. I'm going to say, \"I want to\nadd a not null and a strict format check\nto the phone number column. But I need\nto clean the data first and I don't know\nwhich approach is best. So, I want you\nto fork the users base 10 times. Don't\nuse the wait when you're forking it.\nJust make sure that we fork them all at\nthe same time without waiting. And I\nwant you to have it to be like migration\ntest one, migration test two, migration\ntest three, and try a different cleanup\nstrategy for each. So, dropping bad\nrows, backfilling, regex, normalization,\nquarantine tables, whatever you can\nthink of. Let's just do 10 different\nstrategies, and then tell me what each\none does after. Okay? So, let's run\nthis, and notice that I'm telling it not\nto use the wait command because by\ndefault it will wait for the database to\nfinish forking before it forks the other\none. That's going to take a really long\ntime. So, if we just tell it to fork\nthem all at the same time in parallel,\nit can do that, but we just need to\nmanually instruct that. So, that's what\nI'm saying. Let's wait. Let's see what\nwe get. Okay, so you can see that it's\nforking them. I did it in parallel. All\n10 of them happened pretty much\ninstantly. And now it's going to go\nthrough and do that cleanup strategy.\nAll right, so it's just giving me the\nresult right now. It looks like it was\nable to apply all 10 of the forks and\nthen do all of the different strategies\nhere. Now, it says for a real migration\nwe should combine five with three. So,\nI'm going to say, \"Okay, let's run the\nreal migration on each of them. See how\nit performs, then take the best one and\napply it to the base DB.\" Okay, and it\nlooks like it's applied, and we are good\nto go here. Okay, nice. And then yeah,\nwe can say, \"Nuke the other 10 DBs.\" And\nI think this is the thing that is a big\nunlock for me when using this is that\nwhen databases aren't annoying, they\ndon't take a long time to spin up, you\ndon't have to spend money on them, you\nstop treating them as precious, and you\njust allow yourself to experiment with\nthem like I'm doing right now. And\nespecially with this AI agentic\ndevelopment, you know, I could build\nfour versions of the same app with four\ndifferent DBs, and then as soon as I'm\ndone with one I just scrap that version\nof the app, scrap the DB, and I move on,\nand there's no cost associated with\nthat. So, look guys, that's pretty much\nall I had to show you here. This is a\nsuper cool tool. Again, it's free to\nuse. I think it's just a great MCP to\nhave and have the ability to use inside\nof something like Cloud Code or really\nany other developer tool. I'd love to\nhear what you guys think of it, so let\nme know in the comments down below, and\nI look forward to seeing you in another\nvideo.",
  "transcript_chars": 16955,
  "ingested_at": "2026-05-21T19:03:15.795302+00:00",
  "source": "retry-no-transcript",
  "yt_meta": {
    "view_count": 21451,
    "like_count": 504,
    "channel_id": "UC4JX40jDee_tINbkjycV4Sg"
  }
}