Syntax Video
stop getting hacked: use devvm
- 0:00 intro
- 3:45 devvm initial setup
- 5:12 building the base image once
- 5:43 managing devvm images
- 6:05 running commands inside the vm
- 6:26 automatic port forwarding
- 6:58 devvm ssh vs code
- 7:32 devvm blocks network requests
- 7:52 devvm network log
- 8:04 devvm with claude
- 9:22 a second vm with cached layers and tools
- 10:44 removing the first vm after claude finishes
- 11:23 devvm works on a synced folder by default
- 11:45 devvm --clone for a local git remote
- 12:47 docker inside devvm
- 13:28 custom layers
- 14:43 devcontainer.json support
- 15:04 boot vms from docker images
- 15:33 built on top of Lima
- 15:52 pulling from devvm clone git remote
- 16:51 using devvm with herdr and t3 code
- 18:55 managing and deleting vms
- 19:25 devvm prevents losing unsaved work inside a vm
- 20:12 devvm feedback
intro
Please stop getting hacked. As a developer, you are a target for hackers these days. They want to get your API keys. They want to get your credentials. And pretty often developer machines are privileged. They have access to a lot of stuff. Um, and so you probably know that you should be coding inside of some kind of container or sandbox, but a lot of the tools are pretty clunky to do all of that. And so I thought I wanted to build my own that is super easy and just works and it's called devm. So with devm you can cd into any project folder on your machine. Type devm and this will spin up a virtual machine for that folder and it automatically syncs all file changes by default and detects your tool chain. So this is a hono project. So it detected that I needed node. In my default setup I basically said that I want access to all coding agents. And then in your default setup, you can also specify how many CPUs, memory, and and disk size that the VM gets as well as the network
allow list. So by default, this is set to allow list, which means everything is blocked except for what's needed. So this VM would need access to like npm and anthropic and uh OpenAI, but everything else is blocked by default. And when things are blocked, you'll get a notification and you can add it if you want to, but it essentially keeps things locked down and also keeps all of your API keys and everything else outside of the VM. So, I'm just going to choose the default options here. And this will create a brand new virtual machine for this specific project folder. Now, because I've run devm before, everything that this VM needs is already cached on my machine. So, it has a base layer that's based on Ubuntu. It has all of the tool chains like node and claude, everything downloaded and cached in a readonly spot as well as things like oh my bash which gives me a nice terminal theme. Um there's also zoxside tlddr tree. All of the common DLI tools that you typically need when you're developing you get all of those by default and they're built into the base image. So you you just get them. So I can run things like tree and and see all
of my stuff. The other thing is I can run my agents inside of the virtual machine. So I don't even have to install claude on my main machine. I install it inside of the VM. And so later in the video, I'll show you how all of this gets set up, but Claude is ready to go and automatically logged in inside of the VM. So DevM actually has a proxy that sits outside of the VM and that intercepts all requests to any specific agent or or LLM that you're using and injects the API keys on the outside. So your API keys, your OOTH keys, none of that ever makes it into the VM. It always lives outside of the VM. So I'm here inside of Cloud. I can say hello and just ask him some questions. So, I just asked it, "What machine is this?
What do you have access to? Can you make a request to w3cj.com?" And as you'll see, that's going to be blocked by default. And there's actually built-in helpful commands inside of the VM. So, if an agent is ever blocked or things are going wrong, it can run that help command to help you figure out how to how to fix things. And so, uh, this is a dev, Linux VM called Hono Example.
It knows all of the specs. It tells me where we're at and it tells it what we have access to as well as the fact that it can't access this domain. And if we wanted to access this, we need to run this command from the host machine because that sets the proxy settings. So devm is a tool that I built because I needed it. I wanted a really easy way to spin up virtual machines that have all the stuff inside of them that I need. I wanted network blocking. I didn't want to have my API keys and secrets inside of the machine. And DevVM gives you all of that and a whole lot more. So, in this video, I'm going to show you how to set it up, how to use it, and all of the things that you can do with it to start writing code inside of a sandbox. If that sounds good, let's dive in. My name is CJ. Welcome to Syntax. [music]
devvm initial setup
Now, the first time you run Dev VM, it's going to ask you some questions to set up the base image. So, we can specify how many CPUs. I'm going to choose two. How much memory? I'll choose 4 gigs. And then we can choose which coding agents should be in every VM that we open up. Uh I'm going to choose all of them because I switch between them a lot. You can also choose the features in the base image. So these are things like CLI tools like bat, zoxside, tree, fuzzy search, and then also Oh my bash, which gives you a themed prompt and completions and various other aliases built in. So this is really useful to just have by default to not have to install every time you need them. Now, from there, because I just ran devm inside of this project folder, now I'm going to create a VM for this specific project. And you can see it detected the tool chain. So, it saw that this project has a package.json. So, it's going to use node. It's going to use all of those agents that I specified during the initial setup. And the other key piece to look at is the network tier. So, this starts as allow list, which means by default, the only network resources this VM will be able to access are what it
needs. All the things that would be needed for these things to actually run, that's the only thing that's going to be allowed by default. Any other network requests that are made will be blocked. And I'll show you how to unblock those if they do get blocked. Now, if you choose to customize, you have options for all of the things in terms of tool chains and agents and layers and also specifying the network and CPUs and memory. So, you can customize that for each individual VM or you can just use the defaults that you specified in base.
But, I'll go with all those defaults. And now, it'll set things up. So the first run will actually take up to 10 minutes because this has to build the base image. So it has to download all of the Ubuntu packages. It has to download all of the tools that we specified. It has to download all the layers we specified. So this will take a bit, but it caches it on your machine. So once that base image is built, every other VM you spin up after that will spin up in about 5 seconds because it can layer on top of that base image. So that took about 5 minutes, but now I'm inside of a virtual machine. So if I do an ls here, I am in the VM. I'm not on my host machine. And if you run devm images, that'll actually show you all of the stuff that's on your machine. So we have our base Ubuntu image. We have our Docker image which has all of its tools and everything else. And then all of the shared tools that have been built. And so like I mentioned, I'll show you in a second how quick it is once all of that's there. But DevVM does show you all of the things that are on your machine and how much space it's taking up and the fact that that stuff will be reused. Okay, so I'm inside the VM. I'm actually going to run a pmppm install.
building the base image once
managing devvm images
running commands inside the vm
And again, this is running inside the VM. So nothing is touching my machine. If if there were any approved builds or like postinstall or pre-install that any of those npm scripts would have run, it would have happened inside of the VM. Uh now I can do a pnpm dev that's going to start up this Hono server and now I can visit it. And this is the other beautiful thing about devm is it automatically forwards ports for you. So there's no special config. Essentially any port that starts listening inside of the VM you can instantly access on your machine. Now, you can of course lock this down in the settings. You can basically make it so that it only allows ports that you add, but it's nice to enable it by default, especially if you start things on various ports pretty often. So, from here, I can start coding. And the thing about virtual machines is they are just running in the background. So, if I exit, that virtual machine is still running. And if I do devm, I can see the fact that I have a virtual machine and it's running in the background. Now, one way you might edit the code here is to use something like VS Code. So if I type devm code, this actually sets up an SSH entry in my SSH
automatic port forwarding
devvm ssh vs code
config. So I'm going to allow this. And that allows VS Code to then connect to the VM over SSH. And so I can get my same VS Code experience. Uh, of course, I can go in here. Maybe I change this to hello from devm. And now if I go back into the virtual machine. So now if I type devm, it knows that there's a virtual machine for this folder. I'm instantly back in a shell. And then I can run pnpmdev again. And now if I refresh the page, we see the latest changes there. Now if I kill the server, you can actually see some of the requests that this machine tried to make uh while VS Code was open. Uh it was trying to make various requests to like Microsoft and then some other IP addresses and all of those were blocked.
devvm blocks network requests
Um and so that's the other beautiful thing about running this inside of a VM. I don't have to enable those unless I want to. Uh but there are some built-in commands for managing your network. If you do devm network log, that will show you everything that has been allowed or blocked. And so this gives you an idea of what requests are being made when your code is running. Now, of course, maybe you just want to use cloud to code with this thing. And devm actually makes it so that you don't need to install claude on your host machine. So if you say devm agent login claude, this is going to trigger the login flow, but inside of the VM. So if I visit this URL and then go through the oath flow, which I'll do, I'll paste in the code. And now that login is saved, but it's saved on the host. So the API key for Claude, it never actually makes it into the VM. And that API key can actually be shared between all of my Dev VM instances. So I won't have to log in again. So if I head back into the VM and I launch Claude, I'll of course have to go through my initial settings, but as you can see, I'm logged in and I'm actually logged in
devvm network log
devvm with claude
with the OOTH flow, but DevVM sends all of its traffic through a proxy that's running on your host machine. So Claude sees this as an API key, but it's technically using your OOTH. It's just running through the proxy that's on your machine. Uh, but now I can start coding. So I said, let's add five new endpoints to the Hono app. Use sub agents and work trees. Each agent should be creative with what they add. So it's going to go off and start working. But the beautiful thing about this is it's inside of a VM.
So I could background this and then exit. And that's still running inside of the VM. I can go off and do other things. But if I do a devm ls, the machine's still running. and uh I can come back to it later. All right, while those agents are working, I'm going to spin up another virtual machine inside of the syntax website. So, if I just type devm in this folder, you'll see it has all of my defaults. I'm just going to allow it and it's going to create it.
a second vm with cached layers and tools
And you'll see how fast it starts now that it has everything cached. So, that took about 5 seconds. Um, and so that's the beautiful thing about caching the tools and the layers. Every VM I start from here on out just uses all of that. So, I don't have to wait so long uh when starting a new VM. So, I'm going to go through my my whole workflow for working inside of here. Essentially, I'll install my npm dependencies and then also this repo uses Docker. And so, because I have Docker inside of the VM, I'll go ahead and start up all of the uh Docker containers in the background. And then we'll start working on this website. Now, when installing dependencies, we actually ran into a network block. You can see that Prisma was trying to download some things and and also hit some URLs. Um, so it actually tells me what I need to do. I need to run this command from the host.
So, back on the host, not inside the VM. If I run that command, it's going to add those two domains to the allow list. So, it should be able to ping Prisma. Now, when I install the dependencies, and if you start your VMs with the allow list by default, you might run into this and you'll gradually build up that allow list of things that essentially your dependencies depend on. Uh cuz look at that. We just found another one for Playright. So, I'll run that and install it. And while that's running, let's actually go check in on our agents over here. So, I'm going to head back into my Hono example. I can bling up bring up Claude with resume. And would you look at that? It's added five endpoints. So, all five endpoints are merged to master.
removing the first vm after claude finishes
We've got a readability endpoint. Plan a meeting across time zones. Um, get ingredients for a potion brewing machine. Fine. I told it to to be random with it, but all my work is done here in this VM. So, now I can actually just remove it. So, I've exited the VM. If I do devm rm, that's going to delete that running virtual machine and it actually exports your agent history to a folder that can be imported later. So if I ever run devm in this folder again, I can get all of my agent history. But by default, devm is actually synced to this current folder. Um, and so if I do a get log, all of my changes are here because the agents were actually directly editing the files on my local machine. And that's the default behavior. And for most use cases, that's totally fine. But there are some scenarios where maybe you don't want the agents editing code on your computer at all. If that's the case, you can actually use clone mode.
devvm works on a synced folder by default
devvm --clone for a local git remote
And so if you run devm clone, again, we'll use the defaults. This will make it so the virtual machine is not syncing the files between your host. It has its own clone of the git repo inside of the VM and actually creates a remote that we can push and pull from in our local folder. So, as you can see, it lets us know how to work with this. But essentially, I'm going to just get back into claw. And now I'll tell it to add some more stuff. So say all of that, and then I'll say commit everything to a branch called new endpoints. So it's going to do its work.
It's working inside of a clone, which means the code on my computer isn't being touched at all. And when I'm ready, and when that work is done, I can actually pull it back down to my machine. So we will do that. But I'm going to background it for now and then get out of this VM and then head over back to my website which is having more network issues. Um, and so this is really the the growing pains of of using a network block. You actually see how many different URLs your codebase is is trying to hit when it does things. Okay, so that that at least did it. And so now that all the dependencies are installed, I'm going to spin up Docker because uh this repo has a Postgress database and Reddus and a few other things. Um, but I'm actually going to be running Docker inside of the virtual machine. So, we'll spin all of that up and then I can start my app. And again, ports get forwarded by default. So, if I head to 5173, that will load up the syntax website. There we go. And from here, of course, I could spin up Cloud, I can prompt it, etc., etc. Uh, but at this point, you kind of get the gist of DevM. You've got virtual
docker inside devvm
machines running on your computer. You can run your agents inside of them. They automatically forward ports. It's a block network by default and they have layers including things like the the Docker layer which we're using here. Now Devm comes built in with several different common tool chains like Node, Python, Rust and Go and then uh common layers like the desktop layer and Docker. But there might be layers that you want to add yourself and you don't have to wait for me to add them. So DevVM supports custom layers. If you do devm layer new and then give it a name, a layer is essentially just a shell script. And so inside of that shell script, you can add all of the sequences of commands that need to happen for that layer to get set up. And so this is an example of creating a custom layer for mail pit, uh, which is a common tool used when you're when you want to route emails to local host for for testing.
custom layers
But uh, like I said, the layers are just shell scripts. So ask your agent to build a layer for you. uh that gets thrown in the do.config/devvm/ layers folder and then that layer becomes available to you when you're creating new VMs. Um so if there's something you do very often in every single VM, add it as a new layer. That makes it super easy. Um you could also set one up for like your dot files and so every new dev gets all of your dot files ready to go. You could change your default shell to something like zish.
You could add other tool chains that aren't supported yet like maybe uh net or java. Anything can be done inside of the custom layers as well. Now, a few other things to mention. DevVM supports the devontainer spec by default. So, if you have a devontainer.json in your directory, it will actually spin up a VM that uses all of the features specified in that dev container. So, dev containers are technically running in containers by default, but if you use devm, you you can use dev containers inside of VMs. And on top of that, DevVM supports docker images. And so if you head to the doc under starting from a container image, we actually support any Docker containers that are based on DBN, Ubuntu or Alpine. We'll add support for more in the future. These are just the ones I've tested so far. But essentially, if you already have a Docker image out there that has everything you need, you can start a VM from that image. Essentially downloads the Docker image, converts it into a disc that can be used and layered on top of the virtual machine, and then you get that same Docker container experience, but inside of a VM instead. Now, in terms of how all of this works, it's
devcontainer.json support
boot vms from docker images
built on top of Lima
built on top of Lima. So Lima is Linux virtual machines and it's a command line tool that lets you spin up virtual machines. So behind the scenes, DevVM is spinning up those virtual machines for you, but with all of these developer features added on top like layers and tools and all the things that you typically need when you're running things inside of a VM. Okay, but speaking of docs, in the docs, we talk about how to work with clones. It's got all the commands and everything you need. But let's go back to our Hono example and see how it's doing. Okay, so it's done. It added five new endpoints and it actually did this on a branch called new endpoints. So if I get out of the virtual machine, I'm now back on the host. And if I do get fetch devm, that's going to pull down all of the branches that were inside of the virtual machine.
pulling from devvm clone git remote
You can see it has all of these work trees. We we could have deleted those. Um, but the one that we care about is devm new endpoints. And so right now, uh, I'm just on the master branch here. But if I do get merge devm new endpoints, that's going to take all of the changes that happened inside of the VM and then add them to my local repo.
So this is a great workflow, especially if you maybe don't trust the code inside of that repo, do everything inside of the VM, and then any changes you actually care about, pull them back to your host with Dev VM fetch. Now, the last thing I'll show you is since every single one of these VMs is just an SSH endpoint, you can use some of the existing orchestration tools that you're already used to. So, inside of a folder that's running a VM, if you do devm host, this will tell you the name of the SSH host. And earlier, we actually set it up so that these hosts exist inside of our SSH config. And I can use this name to connect to tools like Herder or T3 codes. So inside of her, if I go to add machine, it'll actually automatically detect my virtual machines by name because those were added to my SSH config. And for instance, I can add this uh hono app and it will install the uh herder server on that and then we can start prompting it from inside of her.
using devvm with herdr and t3 code
So once it shows up, I can create a new space. You can see by default it puts me in my home directory, but the way that we set up VMs is the path inside the VM will be the same path that it was on your host. So I actually have to go to slash users cjdev slashdevm example hono example. So essentially wherever that folder was on your host machine that's where you have to cd into inside of the VM if you're using a tool like herder that doesn't put you in that folder by default. But from here again I can launch claude. I can keep this running in the background.
Do do all the stuff that I'm normally used to but it's running inside of the VM. And of course I can add my other machine. So I can add my uh syntax machine. Get back into that folder and then launch Claude and start prompting to my heart's content. And you can do the exact same thing inside of T3 Code because of course they're all just SSH endpoints. So inside of T3 Code, if I go into settings and then environments, I can add an environment. I'll choose SSH and the same entries are here. So I'm going to choose DevM website and then I'll add also the Hono example. And when you add a project, you can choose which VM that code is on. So if we go to the Hono example, I'm going to choose a local folder. And we'll just have to navigate to again to users and the specific path that that project is in.
But now I can start prompting it. Now, like I mentioned earlier, at any time you can do devm. That'll tell you all of the VMs that are running, anything that's enabled inside of them. Uh, but now we can clean up because I'm not using those VMs anymore and they're always running in the background. So they're essentially taking system resources. So, uh, I chose mine to use two CPUs and 4 gigs of RAM. Um, I have a pretty beefy machine. It's got like 32 gigs of RAM, so I could leave these running in the background all the time, but what I like to do is just if I'm if I'm done, I'm not using them anymore, I'm just going to remove them. And then later on, if I need them again, I'll spin that VM back up. Now, one other thing that Dev VM tries to be helpful with is if there are uncommitted changes inside of a VM that was created from a clone, it's going to warn you. So when we were using cloud inside of this hono instance, it actually created work trees inside of the cloud folder. And so if I remove this VM and don't save any of those changes, I'm going to lose all of those work trees. Um, and so Dev VM is smart enough to warn you when you're removing your VMs to make sure that nothing's important gets deleted. But in this case, I don't really care about those work trees, so I'm just going to
managing and deleting vms
devvm prevents losing unsaved work inside a vm
delete them. And uh, we're good to go. And so now, if I do a devm, I don't have any VMs running anymore. But I do have all of the other things like the base image, the Docker image, and all of the tools. So if I do need to spin up DevVM again, it's going to be pretty instant and can import my previous settings and basically just get me up and running exactly where I was last time. So that's DevM. This is the tool that I wish existed for the longest time and I finally made it and it's been very useful for me. So hopefully you can get some use out of it as well. Let me know in the comments if you give it a try.
devvm feedback
Let me know if you have any questions and then also if you have any ideas for layers that you think should be built into DevVM or tool chains that should be built into DevM open up an issue. So if you go to new issue we have a template here for tool chain request. So you could request something like net java whatever else and then we can make that available by default inside of devm.
Similar if you have an idea for a built-in layer um I've been thinking of adding like databases like Postgress or MySQL or maybe we add layers for thing common things like playright and then that has everything ready to go and and cached uh but you let me know open an issue and also if you just have general questions about DevM do that inside of discussions as well okay that's all I got for you give it a try let me know if you like it and I'll catch you in the next
Quote it with credit and a link. Quoting Syntax