In today's video, we're gonna build out our own coding agent like Claude Code. Most vibe coding tutorials show you how to max out Claude Code with skills or settings. They don't explain the core fundamentals. I've been coding more than thirty years and the fundamentals have always been my advantage. You need the fundamentals if you wanna build something great and if you wanna build agentic agents into your projects. Just like the second brain I'm building out inside my community, it's an Obsidian clone except that it has an agentic agent built directly inside of it. So if you want the advantage in your coding projects, stick around to the end of the video. Let's get into it. Alright. So let's jump in. I'm gonna jump over to Cloud Code. I'm gonna make a new directory
coding agent
and load up Cloud Code and then I'm just gonna grab this prompt here that will build out
our agent. It looks long but it's not really and we're just gonna paste this in here and we're gonna let it run and while it's building I'll have a chance to explain more about coding agents and what they are and really demystify how they work. So at the heart of it when you're using something like Cloud Code, you've got this terminal here and you're able to send it messages. You send that message. The magic is really it's just an LLM running in a loop. So if you're used to something like n eight n, you've probably used something like this where you send a provider like OpenAI or Anthropic a prompt and then you get a response. Now that's the same thing that's happening with a coding agent like Cloud Code. You give it a message, the model decides what to do. Coding agents typically run some sort of tool, right, because they're running on your computer. So they have access to, you know, look at your files and write files and read files. So the agent is deciding what to do. It runs that tool and then at the end the agent looks at what it did and then the agent reads the result of that tool and then at the end it decides, hey, did we get the job done? And if not, it just continues that process in a loop until it feels like it completed the task you gave it in this original request
and then it replies back to you. And in n eight n, they solve that same problem with the AI agent here. It does the same thing. It's really doing the same thing as this except there is a loop here where something decides whether it's done or not and if not, it just sends it back into the message again until it's done and then it comes out the other end. And you can see here even this message model here has a place to add tools, right? So this is like a built in feature that OpenAI and Anthropic have had for a long time. This is nothing new. The agent is nothing more than the loop itself
and the ability to run these tools on your computer. So if I come back here to Cloud Code, it looks like it's actually already done. It's a very small program. So we sent it the prompt. It decided to figure out what version of node I was running. Decided it wasn't done, so it decided to run another tool just like you would have sent a message in n eight n. It wrote the file, it decided it wasn't done yet. It wrote another file, decided it wasn't done yet. It wrote another file, decided it wasn't done yet until it had done all of the work, decided it was done and replies back to us with the task complete.
And what really gives these coding agents a lot of power, the LLM
has access to these tools where they can read and write
and run commands
on our computer which you couldn't really do on something like n eight m because these tools running inside of the cloud do not have access to whatever is running
on your local computer. Now one other thing to touch on as well which is pretty interesting when you start to think about these different agents here. While it's running inside of this loop, every single call
to the LLM agent is starting from scratch. It's simply remembering
all of the things that you asked it and then all of the things that the agent came back with and each time this is obviously getting longer and longer and longer and it just keeps feeding this back into the agent over and over and over again. Every time you send this a message and that's why we have this memory here on these AI agents, we just continue to send that same conversation
back into the LLM over and over and over and it gets longer and longer and it looks at that conversation to understand what it should do next. Now one thing I do wanna mention in this particular video is I'm using this SDK called the Vercel
AI SDK, but it's a free library that helps you build these types of things. And specifically, when I build this coding agent, I didn't want it to be tied to a specific provider or a specific model. I wanted it to be able to work with
OpenAI
or Anthropic
or really any of the other LLMs out there. And what it provides is basically an abstraction. So it gives you this ability to message a model. And I guess it's a lot like this as well where you come in here and you select which model you want in your n eight n automation. So instead of building your coding agent to work with a specific provider, you use this SDK and it allows you to configure it. You send the message to the SDK,
you configured it to work with a specific model and then it will call that model and it will abstract all of the differences so that you can use one single call and at any time you can switch from model one to model two and you're never locked into a single provider. Now this SDK does a whole bunch of other things as well. It actually has its own coding agent built into it as well but again in this example we are building out our own
coding agent just to really understand the fundamentals. If you're enjoying this video make sure to like and subscribe it tells me what type of content you want more of. Alright. So let's get back to Cloud Code. I'm gonna open up this project in Visual Studio
Code. We can see the different files that it created and here's the main one, our agent. So we'll open that up. Notice at the top here, we are including a couple of different libraries, one for Anthropic so that our coding agent works with Anthropic and we also added another one for DeepSeek and we could add libraries for all the others. Here we gave our agent a system prompt that it's a CLI coding agent and describing what it has access to. It can read files, write files, and run shell commands. Shell commands are the things that we type here like l s to list all the files in our terminal. Here are all the different tools that we define, so obviously we can write other tools as well. It wrote a function to actually execute each of these different tools. It created a object here with a list of all of the different providers. So if we added other providers, would just add those in there. Few other functions here to help set everything up. A function here to call the model. You can see it's passing in a system message,
the actual messages.
We talked about that earlier. That's the memory. The messages that we have that we build up over time between you and the agent. We pass in the tools and then here's where we send in the actual user input and here's that loop, that while loop. This is a loop in your code and then it just loops forever. This is basically saying loop while this is true and we're passing true. So it's just gonna keep looping. So let's go into our shell here. Actually first, I'm gonna need to set up the environment variables. It's defaulting to use anthropic with this model and now we got to put in an API key.
Let me grab that.
Just drop that here.
Save it. Come back to the terminal, CD into the coding agent. We can look back to the instructions on how to run the
agent. I believe we can just do NPM
start. We're actually running our own agent. We can type in
anything we want. Let's just go type test.
So you can see it's streaming back to us. That's one of the things that the AI SDK gave us the ability to. If you remember when you're using AI agents or if you're using cloud or OpenAI,
whenever you ask it a question it streams it to you. It gives it to you live in bits. You don't just ask it a question
and it goes and thinks for ten seconds and there's just dead space and then it responds back. So when you are developing your own AI agents or coding agents, you want to make sure you're always streaming the response back so it feels more responsive. So we can go ahead and say, show me
all the all
the files in this directory.
So now you can see it's running a tool. Right?
And now it's just listing the files. So here it ran the command
l s dash l a. The dash l a just means that it listed them down this way and the a means that it responds hidden files like the dot ENV file. So now we should be able to say
create me a Node
JS
hello
world
program. And for anybody that's not familiar with the hello world program, if you're a computer science major, when you take your first programming lesson, the first thing that they do is they tell you to create an application that just says hello world. Nowadays, this seems so basic, it's kind of anticlimactic
but it's just a good exercise to go through. So let's go ahead and run that.
So we built our own coding agent here. We have a new file called hello j s
and it's right here and it tells us how to run it. So we can just grab this,
we can open up another terminal and we'll run it and we've got hello world. Now let's use it to actually solve a problem. I'm not sure if you're familiar with that question. Would you rather have a million dollars today or would you rather have a penny that is doubled every day for thirty days? So let's write a program that'll solve that for us. Write a program that will solve the question,
would it be smarter
to
have a million
dollars
today
or a
penny that is doubled every day for thirty days?
Create a program that loops
through
and
doubles the value
showing each day
and the final output.
So we'll run that.
Cool. So there we go. Let's jump back over here.
Now we've got the penny app. Okay? So now let's do node
penny
and we've got our answer here. Pennies
$1.02
so
thirty days.
Wow. So that's obviously much better. I'll take the 5,000,000 over the million. And then if we look inside the penny app, again, we're gonna see a loop. This loop is a little bit different. So this is a for loop. There's two different types of loops. There's while loops and for loops. What this is saying is let day equal one. So it's taking this variable here and it's setting it to one. So it's day one and it's saying loop
until this day
is greater than days. And what is days? Days is 30. Okay? So day equals one, keep looping until this is less than 30 and then at the end of the loop right here, it doesn't say it. We we write it here.
Just showing you some basics. Where that actually happens is right here and the plus plus means
add one today.
So then it outputs to the console and when people say console, when you see console log,
what that just means is right here. It's saying output that right here. This is the console and then you can see here
that it's outputting the day and then you can see the little pipe here. So you don't need to understand all of this here. I'm just trying to show you little elements of it. Here's the pipe. Here's the day, here's the value of the doubling penny. It's basically doubling the value of pennies every day. This here is essentially the equivalent of doing something like this, pennies
equals
pennies
times two.
These two are functionally the same, it's just written this is like shorthand for computers. And then it loops, we see it all the way to 30 and then increments it one more time. Now days equals 31.
So now this statement here is no longer true because now day is 31 and it's greater than this. So it breaks out of the loop and then it displays
those final results. Now again, there's lots of different types of coding agents. You don't really have to build your own. Like I said in this library here, there's a coding agent you can use Cloud,
agent SDK, there's the py coding agent that was made famous by OpenCloud. You can just import those directly into your project without having to build your own. But knowing how to build it is important and there might be times where you might want to, but even more importantly, the point is here is that where we're going with software, most software is gonna be agentic software. It's gonna have an AI agent at the center of it. What I noticed is most people that are getting into vibe coding, because this is what they know most,
is they go to build just traditional SaaS apps or they go and they want to build a bunch of dashboards. These things can be built in seconds. So you want to learn how to build software where it is agentic
first.
It everything revolves around the agent. Because if you think about traditional software, and this is a really important insight for you to understand,
is that it's all built around a user interface
that is supposed to make it easier for people
to use. And then not only that, but you have to build out all of these UI elements
one by one, feature by feature, and that's very difficult. It's very difficult to build software that people actually like to use. A gentic first software revolves around a chat. You don't have to build all the features. I can just ask my app to do something. I can say, hey, delete this file, delete that file. I can say delete
all the
untitled
MD files. Right? I don't have to go delete them. I don't have to create an interface. I do have it. Notice how I just delete it here. So you can just talk to your app. This is the future. Right? And like what if I want to do some research and then put it into my note taking app? Well, could go over to Claude and I could say,
what are all the
schools
in
Riverside,
California.
Right? I could wait for it to run, could cut and paste it or in my note taking app I could add a feature where I can just ask it directly in the app
and it can just give me the response directly inside of the app and this is the Obsidian clone that I'm building. Right? So you get that all here and then what if you want to rewrite something?
Give me the top five schools
only.
And I can just have it rewrite it. So I'm building this software called Shockwave with an AI agent mindset at the center of it versus just trying to replicate traditional apps that have been built and nobody's looking for. Because just remember, vibe coders come in, they wanna build traditional things, but what are the consumers looking for? What does everyone want? They want AI
agents.
They don't want software that makes it easy for them, they want software that does all of the work for them. Now if you wanna join a community where you can learn how to do all this stuff and you wanna see me literally build out this entire
second brain app that I just showed you here, make sure to jump into the AI architects. I'm totally revamping the classroom from start. I've got these live builds and I'm building out a full course that takes you from an absolute beginner to an expert AI product engineer. It's an amazing group. I'd love to see you there. But either way, hope you enjoyed this video and I'll see you on the