Claude Code for Beginners Tutorial

💬 Chat with this Video
Ask anything about this video…
Master Cloud Code and learn to integrate Anthropic's powerful AI directly into your development environment. This course is designed to take you from initial setup to managing complex multifile projects with a structured professional methodology. You will learn how to scaffold applications, enforce testing standards, and leverage AI for deep architectural reviews and security audits. Jeremy Morgan from CodeCloud developed this course. >> Okay, now here's the prerequisites and how to get started with Cloud Code. Cloud Code is an npm application at its core. So if you're familiar with npm, then this part is super easy. If not, you'll need to have NodeJS 18 or newer. So what I do, I'm on a Mac here, so I'll just do brew install Node. And it looks like we are at Node 24.4.1 4.1 already installed and up to date. Great. So, it requires Node.js 18 or newer. So, we're good there. And the way to install Node is different on each operating system. Generally on Mac, you can download it the binary installer or you can do brew install node. Um, I use Homebrew, so it manages all those packages. If you're on Linux, you can do uh, you know, pseudo app get install node, something like that. Um, in Windows you can download the installer, but you just want to make sure that you have NodeJS 18 or newer. And that's really all the requirements for this. I mean, aside from a cloud account. Okay, so we know that Cloud Code is an npm app. And if you're not familiar with npm, that's fine. You don't need to know a lot about it to use Cloud Code. What you'll need to type in to install it is npm install-gthropic-icode. Now, what is the -ash g? Well, that means we're installing it globally. So, if you install a nodejs without that - g, it will install cloud code into your project. So, whatever folder you're in, whether it's a git repo or an npm app or whatever, it'll install cloud code within that application. We want to run this on any application anywhere on our hard drive basically. So we're going to install this globally and that's what the slashg is is for global. So let's type that in and it'll go through and it says added 12 packages. So now cloud code is installed on our machine. Okay. So what do we do now? How do we run cloud code? Well, it's pretty easy. Let's type in Claude. Now it says welcome to Claude Code. And here's the first startup screen that you will see the very first time you start up Claude Code on your machine. And it says let's choose the text style looks best with your terminal. Dark mode, light mode. You can do dark mode, colorblind friendly, etc. I tend to do just regular old dark mode. Anzy colors are kind of nice, too. Let's do that. Now check this out. It says, "Welcome to Cloud Code." Cloud Code can now be used with your cloud subscription or build based on API usage through your console account. So here there's two different ways. So if you have a pro account, which is $20 a month, or the $100 a month max account, this is basically a predictable pricing model. So you'll be able to use this without being build too much. or you can just do an anthropic console account with API usage billing if you're only going to use this to try it out or whatever. Uh this can be a little bit cheaper, but I'm already using a Claude account with a subscription. Um I'm doing a Cloud Pro account, so I'm just going to select that. And it says using your browser to sign in. Now, here's something cool. If it says browser didn't open, use this URL to sign in. Right? So you can just take this URL, drop it in. Now where this is handy, the reason I'm bringing this up is because if you were running WSL in Windows, sometimes it does not pop up that browser automatically. Um, that's one thing that I've noticed. Now on my Mac, it did just pop up a browser for me, but uh when you're in Windows with WSL, it won't pop up that browser. or if you are sshed into a server. So you can run cloud code anywhere, right? So if you have a server, you're sshing into a Linux server somewhere out on AWS or whatever, uh it's not going to have a browser installed on it. So you won't be able to do that. But if you take this URL here, you can go into your browser and give it access. So like I said, mine did open up a browser for me on this machine. And it says cloud code would like to connect to your cloud chat account, access your anthropic profile information, contribute to your cloud subscription usage, etc. So I'll go ahead and authorize that. Now it says authentication code. Paste this into cloud code. So I'll click copy code. Here we go. It's asking for this code. Boom. We'll put this in. And it says login successful. Press enter to continue. Next, you'll see some security notes. Now, here it says, "Claude can make mistakes. You should always review the responses, etc. These are just basic standard boilerplate warnings." All right, so let's do a real life example here. So, I'm going to use one of my favorite websites, mockaroo.com. And what this does is it generates mock data for testing, software development, stuff like that. It's a really cool site. It's amazing. So, we'll hit generate data. And I'm going to download this and we'll call it uh members.csv and just download it into my awesome project. And now back at the cloud code prompt, I'm going to say create a Python file that reads members.csv and displays first and last names. Now, it's going to go through and of course, it's going to look and see if it can find that file, and it's going to create a Python file to read that and display first and last names. Here we go. Here's our code. Now, when you're adjusting the theme or the colors, things like that, it's mostly for this for the code highlighting. So, I can see this and we can see we have read members py import CSV. We have a read members function here that opens up member CSV readonly. It takes first name and last name and it looks like it will print that out. And of course if it doesn't find the file it throws an error. If there's any other kind of exception it captures it there. This is some good code right? This is good code for reading a CSV file. Now a lot of times they'll use pandas or something like that when things are complex but for this simple task this is a very good code generation. So I'm going to say do you want to create read members? Yes. There we go. Now what can we do from here? Well we can leave this prompt open. Right. This thing goes we can go back to Visual Studio Code. And here's one of the good things. Here's my awesome project right here. I've got that open. Now I can exit this and in Visual Studio Code I can go to the terminal here, create a new terminal and type in cloud here. And here we go. We can see that we have Cloud Code running in the terminal. So in here we can do terminal setup. We can change some settings etc. I'll press enter. And there we go. That way you don't have to have that window open all the time. So you saw that I had a terminal window open and I was running Claude code and doing things like that. But now I'm sitting here in my awesome project and looking at this new code that was created here by Claude looking at my member CSV. So for me it's a little bit easier to just run claude code within this terminal. And then I can just go here and just create a new terminal, you know, bash terminal or or whatever else. And we can do that. So I can say create a virtual environment. We'll activate it. And I can say Python read members py. And there we go. Within seconds, cloud code created this file that reads off the first and last names from that CSV file. So, I just wanted to show how to set up the prerequisites, how to install cloud code the first time, and this is on a Mac for this demonstration. However, it can be on Windows or Linux, basically the same. So, let's start digging into this and doing a little bit more advanced stuff. But this is how easy and quick it is to get set up with Cloud Code and get rolling right off the bat. All right, let's take a little deeper look at this and setting up your first session. Now, here we have some tips for getting started. Run slash andnit to create a Claude MD file with instructions for Claude. And we're going to dive into that and see what that means. Use cloud to help with file analysis, editing, bash commands, and git. Be as specific as you would with another engineer for best results. Now, this is probably the most important tip right here. Be as specific as you would with another engineer. So pretend like Claude code is an assistant because that's exactly what it is, but it's it's just another developer sitting next to you who happens to know a lot that you can discuss things with. You can say run terminal setup to set up terminal integration. So the first thing I want to do is do a net. Now here this is going to create a new cloud MD file. And you can see here it's going to go through several steps here. It's going to analyze things. It's going to find out what kind of project it is here. It's looking for package JSON, which we don't have. PI project toml. See, all we've done is created a Python file in a CSV. So, it is going to have to kind of figure out how this works. Now, let's take a look and see what it created for the Claude MD. Cloud MD. This file provides guidance to claude code when working with code in this repository. So this is a simple Python project that processes member data from a CSV file. Project consists of that has everything that we have uses Python 312 with a virtual environment. Here's how to activate it. Here's how to run the main script. Here's how to deactivate it etc. Now it's shows the code architecture here. Single purpose script code contains one main Python file that handles CSV reading and processing. Talks a little bit about the error handling. Right? So the script includes basic error handling. Uh flexible CSV parsing provides both snake case and title case column headers for names. Works with a large CSV data set. Appears to contain thousands of member records and has some key implementation details. So it says do you want to make this edit? I'm going to say yes. So we're going to edit that. Now what if I want to turn this into a a real application? Right now, we can see we've gone back here and if we do the front slash, there's a whole bunch of different stuff here that and we're going to take a look at that in this course for sure. But you can see here we have a config panel. We have a doctor which diagnoses and verifies your cloud code installation, manage agent configurations, etc. Now, one thing I'm going to do, I'm going to talk to this like a real engineer, right? I'm going to say how do I make this a real application that I can publish to GitHub? Now, what's a real application? That's really fuzzy, really indeterminate definition, but I will I'll double down a little bit and explain it. other applications and I would like to provide as much information to the developer using it as possible. Now we've kicked that off. Let's see what it says. Basically, I'm just saying, you know, how do I make this a something that I'm not afraid to put on GitHub and be embarrassed about? Okay, now we'll open this up just a little bit more so we can take a look at it here. We'll scroll all the way up. We've created Claude. It says, "I'll help you transform this into a proper Python package that can be published and easily integrated into other applications. Let me create a comprehensive structure with all the necessary files." Here's what it wants to do. And what it does is cloud code will create a set of to-dos and it'll walk through these. So create proper Python package structure. We're going to add a setup py or project toml for packaging a comprehensive readme a requirements.ext example usage and documentation proper handling and logging create unit tests add GitHub workflows for CI/CD and create contributing guidelines and update cloud MD with the new structure. Do I want to proceed? Yeah. Now granted, this isn't a super useful program. It's not really worth putting on GitHub uh because it has just this ver very narrow use but it's a good idea just to kind of see how these things can um can kind of evolve and stuff like if you're building some kind of project you can have cloud code say hey I want to make this so that other folks can use it and you know how do I do that we have an init py and we're looking here this is going to be an init py that's going to have some classes to it showing the errors that it uses. And basically, we're doing a lot of like documentation and um other things that are kind of tightening up the we got exceptions py that's tightening up the script a little bit and it's making it a little bit more production ready than it is now. Okay. We'll notice here that it is creating a reader py and it's a data class with some member data here and then a member reader that reads that data and it's putting this into a set of classes and asking me do you want to do this? Yeah, let's do this. So now it's putting it into a set of classes. Why does that matter? Well, it's good for expandability, right? If we want to just have this be a simple Python script that you run to read the first and last name of members, it's great. But if you want to make this uh into a real application or make it into a module to put into a real application, you're going to want to do a lot more. Some of the things like classes, you want to do that for organization purposes, for ease of upgrading and testing. We can see here it's creating a pi project toml and this is basically saying here's what it requires here's the name the version you can put my name in there a python package for reading and processing member data and it just goes through all of this information to make this a real Python project and here's the command line interface for the CSV member reader let it go through and we can see that things are getting definitely more complex. However, it's also becoming more like a real production application. Okay, now we've got a readme file here. I could see robust Python package for editing, etc. And we've got a nice readme file. And we have edits to requirement.ext, text, which right now doesn't really contain anything, but we'll see how it goes later on. Here's our development dependencies, which I'm not sure where I found those dependencies cuz I don't think I need any of those. But next is going to be creating example usage and documentation. This is basic usage py or basic usage example. Here's CLI examples. So in here we'll have a CLI usage example where it's going to say here's how to use it with a CLI CSV member reader members.csv show total member count verbose output with logging using different encoding etc. And now it wants to chod this shell script so that we can run it. So I'm going to say yes. And now it's going to create a test package. It says, "Do you want to make this edit to test reader py?" And this is going to be testing our application. And here I'm going to say yes and don't ask again because we're just going to let it go through and build all the tests and do all the things for our awesome project. And here, do you want to make this directory? Yes. Okay. Now we can see here the next steps to publish. We can set up a development environment. which we've already done but gives us instructions to do that again. Test everything works with pi test CSV members count create GitHub repository configure for publishing GitHub urls etc. The package can now be easily installed by others with pip install CSV member reader and used as both a library and CLI tool. Well, let's see. Let's find out. So, we'll go here to back to our bash And I'm going to go to CSV member reader and take a look at this. We'll go to tests Python test CLI. And we don't have piest installed. So we'll do that. And we should actually have a requirements text in here somewhere. And that requirements text does not have piest. Just as a note, we also don't have CSV member reader. So we're going to go back here cloud MD. We have our accident. We're going to do Python readmeers py. We can see that that works. And for this we can do pi test member reader. We want that to be HTML. So we can see here that these commands may not be 100% accurate for the pi test. Try running it within here. And we're still getting unrecognized documents. So that's something to note that there could be some hallucinations in here. So we can do pi test and one of the things we can do is we'll deactivate it and we will say let's see here and we'll follow the instructions exactly to make sure that we are not doing something wrong. It does need to be pip 3 because I'm on a Mac. We're going to type in pre commit install. It failed. It is installed. We're going to get repository directory. So, some of this stuff here I think we could remove out of here because as I go through the instructions I can see some things that don't exactly work. One of them here we can say and I don't see any dev directory where this is created. See where it says pip install- e. This is unfamiliar to me. So, I'm not really sure why it suggested that and how that works, but I also don't see that environment and where it was created. So, it does look like a bit of a mystery. So, I would take this out, run tests, take this out until we can find out the stuff that works and the stuff that doesn't. All right, we have code quality tests and we type in black here and it goes through all of these and says all done. 10 files reformatted. So, that one's good. What about flake 8 for flaky tests? See here like Kate says a bunch of these the line is too long. And finally we're going to do my pie. There we go. And we do have an import issue. So in here if we do my pi or my pi dot and it is not seeing our net py. So my pi appears to not be working. So that part isn't working quite as well either. So basically the point I'm trying to make here is we want to go through these and really go through your your cloud MD, go through your readme and make sure that things are accurate and they are set up the way they're supposed to be set up. Um things like that just to kind of double check your cloud installation. But I wanted to show some of the first session type things that you'll do in the first time you work with a new product. So, previously we did the prerequisites and the install. This is how you get set up and start your first session and kind of build out like we've built out this huge project here from a single Python script with a CSV. So, this is one of those things where you can use Cloud as an agent to kind of get you started to get all that not so fun stuff out of the way. Things like building tests, building readme files, and things like that. So, thank you for watching and let's continue to dive in. Now, there's another cool thing you can do with COD Code, which is analyzing code bases. So, I wanted to find a big giant code base that I have in my personal collection. One of them is Retroacraer which is a combination of a JavaScript NodeJS 3JS video game with a Go backend when and I have a Go API with a SQLite database for the backend for this. And so I just want to ask a few questions about this repository. So I'll type in Claude my terminal. It says cloud code may read files in the folder, might execute files. Now, this is something that is valid to ask for this because there's a Go application in here. So, this thing might execute Go apps, but uh I'm cool with it because it's mine. You can see here we can run init. You can use cloud to help with file analysis, editing, bash commands, and git. You can run terminal setup. So, we never did do terminal setup in the last one. So, let's do that now. the terminal setup and you can see here we're going to use VS Code terminal shift enter keybinding and so now cloud code knows that it lives within visual studio code and I can change those key bindings by editing this file here now what can we do here now we have cloud in here we can say something like give me a high-level overview of this codebase like just tell me what the heck this is that we're looking at here. Okay. And now we've got a good highle overview. So let's take a look at it. Retroacraer highle overview. It's a multiplayer racing game with a retro aesthetic built with modern mech web technologies and a go backend. The front end JavaScript based web client using 3JS for 3D graphics. The back end is a Go server with websocket support for real-time multiplayer gameplay. The build system is Vite for development and bunding. Here it shows our key components. Here's our front end entry point or main logic etc. And then our backend the server entry point server and client management core game logic physics etc. And it shows here our technology stack. And this is all completely accurate. This codebase appears to be a complete racing game implementation with real-time multiplayer capabilities, physics simulation, and a 3D graphics rendering. That's awesome. So, one of the things I can do is say explain the main architecture of the Go backend app. And now this is going to go through and it's going to take a look at the Go backend and just kind of explain how it works. And here we go. Key architectural patterns. Event-driven hub model and hub.go. It uses Go channels for non-blocking communication. 60 Hz game tick for real-time updates. Separate channels for registration, input, and broadcasting. Concurrent player management. Mutex protected shared state go routines for each client's readr operations. Channel blaze player life cycle management. We have physics integration. We have message protocol. The architecture supports up to eight concurrent players per hub with real-time physics simulation running at 60 frames a second using websocket connections for low latency multiplayer gameplay. So this is a really good overall kind of look at this. Now one of the things we can do here is say find the files that handle database access. And now you can see it's searching through the code. And let's take a look at what it says. It says, "Based on my analysis of the Retroacer codebase, there are no database access files. It uses in-memory storage only." Which is correct because the latest iteration of this actually doesn't use a back-end database. So it says no database dependencies, no imports from any Go files, no SQL database related code, no persistence layer. Everything is stored in memory via ghost trucks, which is correct. When you start up a multiplayer server and shut it back down, everything is lost. However, there is retroacraer server log. So, here's another cool thing we can do. What are the most recent errors found in Retroacraer server log? And we can just ask, hey, what kind of errors have we had for this thing recently? And we can look here and it says key issues found. Player client map synchronization problem which that is a problem with this. Players are being removed from the players map immediately after joining indicates a race condition between client registration and player tracking. Client count discrepancy broadcasted update players to list to zero clients. Show zero clients but players are joining successfully. Phantom heartbeat messages. Websocket connection errors. It's showing us a whole bunch of this stuff. And sometimes you can be very direct with this and just say fix this. And sometimes it works, sometimes it doesn't. Or you can just copy this, go down here and say, suggest some ways to fix. And I could just say item number one, but we're just kind of reminding Claude code which one we're talking about and suggest some ways to fix this. And it comes back with a recommended approach. So it takes a look at all the code here and says, "Hey, why don't you do all of these things, right? So add a registration state flag, which is something I actually did before that didn't work out great, but I haven't tried this with cloud code. Move player map date updates inside the hub's main event loop, etc." So it says, I'd suggest implementing solution number four, single source of truth, combined with solution number one because it eliminates synchronization complexity, reduces race conditions, maintains clear ownership of player state, etc. So I can say implement solution number four and solution number one as you suggested. And now it's going to start asking me one by one as it modifies files, do you want me to make this edit to client go? Yeah. And you can see here these are the changes that it wants to make. And it'll go through quite a few of these I imagine with this particular fix. And I can say yeah and don't ask again this section. Now we'll work on the hubstruct. Okay. Now let's come back to ask me a question again. And now it wants to build the Go backend and check for compilation errors. So I'm going to say yes. And it looks like we did have some compilation errors which Cloud Code's going to catch and attempt to fix. Okay, now it's going to try to build it again. Great. The compilation is successful. Now let me update the client registration logic to use atomic registration and mark the client as complete. So, this is how easy it is to use Cloud Code with a giant, and I say giant because this is a pretty fairly large project. And it basically will go in and take a look at all of your code files and make suggestions and things like that. And we have build successful. Do I want to proceed? And now it's going to mark the final to-do is complete. So, I can check this out, see if we have any errors or anything, but I just kind of wanted to show how to work with existing code bases with Cloud Code and how easy it is. And um it's very smart. It does a great job of looking at your entire codebase and figuring out how it works, what it needs. And then, of course, in this case, I said, "Hey, look at my logs and tell me what's wrong." And it went through those logs, told me what was wrong, and then now it's starting to do fixes. So, this is an indispensable tool for things like this, and this is pretty cool. So, thank you for watching. Let's dig in a little deeper. Okay. Now, I'm including this demo because I had some problems setting up machines on EC2 machines to do demos. This is a problem that you may run into. So, if you have a typical Ubuntu machine, EC2 or other platforms, you may run into this problem. So we'll type in pseudoapp update, right? We'll update the machine. Okay. And it shows here that we have some packages that could probably be upgradeable, right? So we'll do pseudo apt upgrade and upgrade the system. And this is part of the install instructions for claude. Okay, awesome. So we've got this thing upgraded. Right now, if we try to do as the cloud instructions say and do pseudoapp install NodeJS npm, right? Because we need that to install cloud. It's going to go through and say, hey, do you want us to install all this stuff? And we say, yeah, sure, that'd be great. Okay, now we're upgraded. We have npm, all that. And we'll copy this directly from the cloud code instructions where it says npm install-g for global anthropic AI cloud code. Right? And it specifically says on the anthropic site, do not use pseudo npm installg because it can lead to permission issues. So we're going to trust them that we shouldn't do that and we're going to run it as they say. And this is what we get. We get a permission denied here. It doesn't allow us to make user local lib node modules. Right? This operation was rejected by your operating system. It's likely you don't have the permissions, which is fine. So, there's a couple different ways we can approach this. We can change the permissions for node modules to allow the iuntu user to own user local live node modules. Now, why is that a problem? because any other users on the system aren't going to be able to access it. So, we have a choice here. We can either run pseudo npm install-g, which by the way, anthropic, like I said, tells us specifically not to do this. So, we could run that. So, we can run it, or we can change it to be user local live node modules. Either way, it's probably not the best idea. So, how do we solve this? Well, the way that I solved it was by installing this manually. And I'll show you now. One of the things that I should point out here is when you're creating an instance, like here, I'm doing it on light sale, right? We want to make sure that we're selecting this one. This has 4 gig of memory, two CPUs, 80 gig of storage. Why is that important? because it says right here system requirements. We need operating systems of these. We need four gigs of RAM in order to run claude code effectively. So I just wanted to make sure and put that in here that we want to select an operating system that meets the requirements and four gigs of RAM or more. Okay, so we're back at our machine here and we've installed npm and NodeJS and stuff like that and we couldn't get it to work. And here's how we can install it manually using the native installer. So here we're going to do pseudoapp install-y curl and git. Now git should already be installed and it looks like curl already is too, but it's something you want to do just in case. And then we're going to install cloud code from the binary. And the way we do that is do curl-f SSL https/cloud.ai install.sh and pipe that into bash. Now you can look at install.sh and examine it to see if that's something you want to run or you can just trust them and pipe it into bash like this. And here we can see it is going to install it manually. And it says claude code successfully installed which is great. So we'll do claude help. And it's not found which is fine. We can exit out of it and log back in. Okay. We'll type in claude help. And now we can see that Claude is installed. So, by the time you watch this video, this might be fixed. But this is just something that I noticed when I was going on to EC2 servers is I could not do a standard npm install-g of claude like you would on other machines. And I went to another iuntu server on another service and kind of found the same thing. So, I just wanted to show this is what I had to do. I had to go look it up and see. And so this is how you install it manually with that curl command that I gave you and then it'll work just fine. And like I said, they might get this fixed by the time you take this course and I hope so. But this is always an option to do. Thank you for watching. In this video, we're going to start our new project with Cloud Code. Now, I want to start something from fresh that we can work with, we can build tests for documentation, etc. And it's actually really fast and easy. We really don't need to know a ton about code in order to create really cool applications. However, I am going to use my previous knowledge of software development because I know exactly what I want this project to look like. Now, we're going to build a MEAR reader. What's a MEAR? Well, it's a format for reporting weather information to pilots. So, each airport puts out this MEAR weather report, and it's mostly used by pilots, sometimes used by weather people, folks like that. but it just kind of assists with weather forecasting and raw mear is highly standardized as it says here through the international civil aviation organization. So that means I should be able to build a tool that goes to each individual airport whatever airport we select and brings up this information in a human readable format. Now why is that important? Because this is what a mear looks like. It's a little cryptic, right? We can look at the KJFK and figure out maybe that's K JFK as in JFK airport. Uh this might be a time maybe or a date. We have 16008 KT. Who knows what that might be 10 SM etc. So this stuff now pilots can look at this and tell you exactly what it is. They can say, you know, winds 15 mi to the south, 80% humidity, and it's a 70° day or whatever, but we as regular folks don't know how to interpret this. And that's exactly what our mear reader is going to do. We're going to make it so we can type in KJFK or in my case, here's the airport that's right down the road from me, KHIO, and we'll be able to see some weather information for that area. and it'll be in a nice readable clean format. Now, as I said before, I am going to use my previous software development knowledge to dictate what I want. So, if I just go in here and type in, you know, build me an app that does this, well, it could be an Electron app. It could be a QT++ app. It could be anything. A web app, who knows? And I do want this to be a web app. And I want this to be a Flask application because I really like Flask and I have some other Flask stuff. So what we're going to do is we're going to fire up Claude. Now I have this folder created here. It's already a Git repository. And we've seen this a couple of times now where Claude may read files in the folder, etc. Now here we have some tips for getting started, right? We already know we can set up terminal integration. and we can create a cloud MD. But let's just get started with this. So what are some of the things that we need to know? Well, we need to know what the app is, what it's going to do, what it will be built with, and what we expect to be a criteria of success. With just those things, Claude can build us an application. So I'm going to say create a flask web application. This application will be a mear reader. Now I'm making an assumption here and this is one of the things I've talked about in all of the courses that I do when I build these courses with LLM tools is you have to make assumptions of what the LLM knows or explain everything. I'm going to assume it knows what a mear is and I'm going to give it an example so it should be able to figure that out. But I'm going to say create a flask web application. This application will be a mear reader. The user can type in an airport code and then the application will fetch the mear reading from that airport and decode it. I'm going to say MEAR is a standardized weather report. So I am going to put in some context there and do a little explaining just in case. MEAR is a standardized weather report. It is somewhat cryptic. So I would like to convert it into plain English. that people can understand. For instance, clear day, 70° wind. See? So, I'm basically saying this is what it looks like for success. And I'll double down on that a little bit. type in an airport code and receive a friendly readable weather report from it. Here is the service I will use. When you change the airport code, it outputs the corresponding NEAR. And so I'm going to go back to up here and copy this. And now I should be ready to go. And it might have some questions for me, but I think it will create an application pretty close to this just based on our very specific prompt. And we can see it's setting up the to-dos, right? So, as we've talked about before, Cloud Code sets up a to-do list and it brings out all these to-dos. This is a good thing for you to look at and say, "Oh, wait. That's not right. That doesn't look good." And um at that point, you can interrupt cloud code and say, "No, I didn't ask for that or I didn't want that or whatever." But now it's going through the to-dos. Okay. And we can see here we have our first edit request and it's trying to create a flask import here. It says meet me decoder. And here's our wind directions, right? So north, north, northeast, etc. Get wind direction. We got decode visibility. So if the visibility is 10 sm that means visible for 10 square miles or it ends with square miles and that must mean there's some visibility otherwise visibility not reported. And if you can't tell I I can tell what some of these codes are. Um I'm a little bit familiar with them but here's another one. Decode cloud types clear skies CLR. A lot of what you see in the summertime. SKC is another one. Sky clear. Few clouds scattered clouds. broken clouds or overcast. And we can see here decode weather phenomena, rain, snow, drizzle, fog, mist, thunderstorm, showers. So all of these are assumptions that claude code is making based on its knowledge of what a mear is because these are all mear codes. Uh intensity, etc. All of these are valid mear codes. So I'm just going to say, okay, this looks good. It's calling what I want it to call. So I'll say yes. And now I've noticed it comes up with a bunch of different words down here. Cerebrraiding, cerebrraiding, I'm not really sure. Now it says I want to make a directory named templates. So yeah, let's create some templates directory here. And here, do you want to make this edit to index html? So here's mear weather reader. Enter an airport code to get a friendly weather report. Yeah, sure. I'll say yes. And you can tell the to-dos are starting to get checked off here. Now we have a create results display template. And this is going to be the display with the raw mear included. So I'm going to say, yeah, that sounds good. And it wants to create a static directory for CSS files. Sure. Elucidating, I think it's what it says there. Okay. And we have a stylesheet. I'm just going to say yes. It says test the application with various airport codes. And then finally requirements.ext. Yes. Now it's articulating again. And right here it's creating a Python virtual environment. Installing requirements.ext. I'll just select yes. And it says start flask application and background of test. Yes. And we can see command timed out. So it tried to start it up and it already got an error. So now it's going to be flipped to jibbiting development server. Okay. And it says this app will be available at localhost 5000. And let's try it out. Okay. And I've got my local host up here. And hey, that's a kind of a nice looking like purple almost a code cloud styled background there. And we can see here we have our mear weather reader. Enter an airport code to get a friendly weather report. So, it says here for examples, KHO, Portland Hills, which is where uh that's like I said, the airport that's down the road from me. Let's try that one first. We'll say Khio. And it even says, what is a MEAR? Well, it's a standardized weather report used in aviation. Now, we can check this here and it says clear skies, 81° F, 27° C, which is accurate. wind from the north at zero knots. So if there is any wind that's coming from the north, zero knots means pretty much nothing. And it's observed at this time, that was when the MEAR created wind from the north, 0 knots, 10 plus miles of visibility, which means it's clear sky conditions, clear skies. Temperature again, due point, 52° F or 11° C. and even our barometric pressure at 30.05 and HG with the raw mear. So, it took all of this beautiful human readable stuff from this mear right here. So, let's check another airport. Let's see how things are doing in Los Angeles right now. Well, down there we have a few clouds at 25,000 ft, 75° F. So, oddly enough, we are hotter than Los Angeles today. 24° wind from the west at 11 knots. And here we go. We can check another airport. We'll say KGFK. This is New York, which is also 75° F. Some broken clouds at 24,000, wind from southeast, etc. So, I just wanted to create this as our base project that we're going to work on as we test out some of Claude Code's features. and we build agents and things like that. We're going to do this all around this MAR weather reader. We're going to use this to create some documentation. We're going to create some tests and stuff like that. But this is how easy it is to get started. This is a vibe coding dream as far as cloud code. If you're doing anything in Python or JavaScript, it pretty much builds things for you very, very fast. All right. Well, I'll see you in the next video. We'll keep going. All right. Now that we know our Python application works, this is something that I want to release publicly. So in order to do that, there's a few things that we need to do. We need to probably freshen up our Git ignore file and we need to create some documentation around this, mainly a readme file and things like that to kind of prep it for being placed in the public. Now, we can look at some of these files and say, well, they could be probably uh cleaned up a little bit. Maybe app py could use a little more documentation. So, I'm going to include that in there. Now, one of the things I can do here is say I would like to commit the initial creation of this application. help me create a good commit message, right? So, you can just ask it simple things like that. Okay. And it'll even do it for you where here it says get add app. py requirements.ext static templates and all application files to staging. Yeah. Now, here we have get commit-m add flask mear reader web application. And it does all of this stuff. Generated with Claude code, co-authored by Claude. Do I want to proceed? Yeah. Now, if you really wanted to, you could probably remove that from the code message, the commit message that it was created by Cloud Code, but I don't really care. It says this is now committed and ready. You can run it with Python app. py and I'll be able to get friendly weather reports. So, one thing I'm going to say is I want to release this publicly, please. Now, again, this is putting in. So, if you're just vibe coding with no background in software development, you can build a lot of cool stuff, a ton of cool stuff, but sometimes you need to know what to ask for. So, previous development experience really helps you out here. So, since I have previous development experience, I know what to ask Claude to do. And some of this is add comments to app.py using Python best practices. Then create a readme for GitHub that explains the application and how to install it. And for now, this could probably work. We'll add a little bit more, but this should go for now. And it's going to go through and put things here a pi do syntax or some type of syntax that's easy to understand. And we can see here flask mar reader web application web application blah blah blah. So I'm going to say yeah, let's do that. And it's going to put this in. I'm going to say yes and don't ask again this session. So, I'm just going to let it go through and throw all of these documentation notes in here. Now, this is all stuff that's put in through comments. It's generated with claw code, but this stuff is basically pi dot type comments. Okay. And now it's done. Here it says test the application after adding comments. And here it says from app import test test mear result decoding test passed result summary. Yeah, we could add some testing in there too. And it says commit the documentation code improvements in here. Do you want to proceed? Get add app. And like I said, you could change the commit messages so it doesn't say co-authored by claude or whatever. But I'm being transparent here and just kind of letting everybody know that uh that I use cloud code for this stuff. It says now it's fully documented and ready for GitHub release. Users will be able to understand the purpose, install easily, use effectively contribute and deploy. Your Flask MAR reader is now professional grade and ready to help aviation enthusiasts and weather lovers convert cryptic aviation weather codes into crystal clear forecasts. That's great. So we can take a look here at get log and we can see it's added some comprehensive documentation and code commits. This is great get status. All right, let's do get push which now if I go to github.com I can see I have my mear reader says hey what is mar example mAR code features all the different features such as global airport support responsive design we don't have any screenshots yet but I'll put those in there by hand but we do have installation and I can see here it says your usern username. We need to put in this. So, by the way, I am going to leave this up if you want to check after the course is done. It's going to be github.com/jeremyorggan/codecloud-mear-re. And here's the usage. Here's some different airport codes. Now, because I used Hillsbor, Hillsboro airport has is nowhere near in the same league as LAX and JFK and O'Hare and etc. But since I used that as an example, I think Claude threw it in there. Um, it says how it works. We have a mear decoding process. Then here we have the project structure, development, etc. How to put it into a Docker container, everything you need. So if you want to fork the repository, you can check it out. Does this open an actual license file? No, it does not. So, there's a few things that I need to check on here, but I just wanted to create some initial documentation. Now, here's something that is sort of interesting, and again, it's something you can probably remove if you don't want people to know this. However, you can see right here, contributors, two, Jeremy Morgan and Claude. So, Claude is listed as a contributor here because I asked it to commit things for me. Now, like I said, you could probably remove that. you can remove it from the commit messages and you can commit this stuff all on your own without having Claude as a contributor. Um, but in my case, I don't care. I have video evidence that Claude built this, right? So, it's not a big deal to leave it transparent, but I just wanted you to know as a student that this does show up here where Claude is a contributor to the project. So, for this, this is how we can kind of get this ready and get it prepped for public consumption. And so we're going to dig even deeper into it next. And thank you for watching. Okay. In this video, we're going to create some Python unit tests for this application. And we're going to do it by using cloud code, of course. So one of the things you can do is do a front slash. And you can look here and we could say add a new working directory, manage agent configurations, submit bug, etc. So, this is one of the things that, you know, I kind of like to just show off once in a while as we go through and just remember that we can export the current conversation to a file or clipboard, which is super important if you're wanting to keep track of things. But I just wanted to make sure that you knew about this slash window. It works. Now, one of the things I want to do with this is say I would like to create a set of unit tests for app.py. Help me decide which type and help implement them. I want to use mock near readings and test that they are interpreted correctly. All right. So now it's going to create a set of tests and we're going to take a look at some of the to-dos and things like that and just see how it approaches it. First it's going to analyze the mear decoder. Then it's going to design test structure using piest and mockmear data. So I was wondering if it was going to use pi test or something else but it's using piest. We're going to have some integration tests, some flask route tests and edge case tests. All right, let's see what it came up with here. We can see here we have test mear decoder. It's going to set up method test wind direction, test visibility, test clouds, weather phenomena, Celsius to Fahrenheit, and looks like we've got a good set of tests here. So, I'm just going to select yes. Now, one of the things that you'll notice here is it will probably run it for us because it likes to run things. So, now we need to update requirements.ext text. And here we're adding in pi tests and it shows how to run the tests. So we'll do that. So we're going to open up a new terminal here. pip install-r requirements.ext. And I forgot pip 3. Awesome. And here of course we have piest test app py-v. And we can see that we have some failed tests here. We've got a 404. Got a few different things here. So one thing we could do here is just say run the tests and analyze the output. I'm actually glad these failed because we want to see if Cloud Code is capable of doing this. Okay, we do have Python 3. And now it's running it and it's getting the same error message that I got. So now it's got some to-dos here. It's going to create a plan. And this plan, it looks like the only thing we're really updating is some weather phenomena stuff. So, I'm going to say, yeah, let's verify our fixes. Perfect. All tests are now passing. And now it wants to run tests with coverage analysis to see how much of our application is being covered by tests. So coverage is just how much of the code is being tested with our unit tests. And this gives a great example of what it tests. Wind direction conversion, visibility parsing, cloud layer decoding, weather phenomena, temperature conversion, etc. Real strings. And then it goes through our web routes and some edge cases. And this looks good. Update the readme to include testing information. Okay. And now it says running tests. It includes a comprehensive test suite with 99% code coverage. There we go. And so I'll say yes. And then we are updating the uh diagram that's showing the file structure. All right. Now I can say create a commit message. Commit this and push it. Now this one might not work. I noticed the push did not work previously, but I think it can create a commit for us. And now we're going to get push. Awesome. Now let's take a look at our repository. And we can see the readme has been updated. We'll look for testing. And there we go. Here's all the test stuff, how to run tests, etc. And this is how easy it is to add testing to your project. Now, you want to go through, you know, I'm kind of rushing through this a little bit, it feels like, because we're in a course environment, but you just want to go through and and look at these changes that it's made. Really examine things and make sure that it's doing exactly what you want it to do, right? We want it to test all of these different things. Look at how it's testing it. Make sure that it's not creating tests that are designed to pass. and you should be good. So, this is basically a way to add testing to our project. Thank you for watching. In this demo, we're going to look at autonomous task completion. Now, what does that mean? Well, we're going to see how Quad Code is far more than just a code completion tool like a lot of these generative AI tools started out as, you know, where they worked in an IDE and they completed some code for you. Cloud code goes far beyond that and I'll show you how. What we're going to do here is uh what they call vibe coding a lot where they just kind of specify an end result that you want and you just kind of let the tool build out what you want to build. Now we're going to see how capable Claude Code is. So we're starting out here with simple React app. And this is just an empty folder. has nothing in it at all. And I'm going to say yes, proceed. And now, here we go. Here's our tips to get started. And we're at our initial screen. Now, here's what I'm going to say. We're going to try to do this in one shot, just one prompt. Now, it's going to take more than one, but with one prompt, we're going to see how much we can scale out and build something with cloud code. So I'm going to say create a complete authentication system for a React application. That's the first thing. Now that's kind of vague, but we want to say something like include user registration, login, password reset, JWT tokens. Let's see. Uh email verification. Uh what else do we want to put in there? Um a simple front end of course. Now basically what we're doing is kind of picture this like a funnel. And when we start out and we'll talk about this even more in the prompt section where we talk about prompts, but we want to start out with a very wide very open thing like create a complete authentication system. If we say that, if we just say create a complete authentication system, that could be anything, right? That could be C++, it could be whatever, but we're saying create it in React. So now we're saying complete an authentication system for React. So we've narrowed that down. Then we say here's what we'd like it to do because a complete authentication system is very subjective. I mean that could be anything really but we're saying include registration, login, password reset, JWT tokens etc. We're being very specific and we can also be specific about the technologies used. We already specified React. We could say use express MongoDB and we can say modern security best practices. Now before we we begin, let's look at what this prompt is. And this is where it kind of goes beyond vibe coding, right? Because if we were just vibe coding, we're not really specifying much, you know? We just say create an authentication system with a web app. So, but let's break this down to this prompt here that's saying it's authentication system for a React application. We've said all the things it needs. We're saying to use these technologies and to top it all off, we say use modern security best practices because by default, we can assume and we've talked about assumptions in this course and we'll talk about them more. We can assume as us that claude knows security best practices. But on the same token, claude code can assume that we don't need them, right? It's all assumptions. So you have to control assumptions as much as possible when you're building these types of prompts. Now, let's see how far this can get with just a single prompt. And here's where Cloud Code goes beyond code completion is it can create files. We know that. We've already seen that it can run commands in bash. We've seen that it can run test commands. It can do a lot of things. But can it do a npx create react app? We don't know yet. I'm going to assume again that it can. And I'm assuming that in this prompt. I'm assuming that it can do all of these things. And so let's go ahead and kick it off. Now, what we're going to see is what we've already seen before where it starts to do the thinking. It starts to talk things through with you and for lack of a better terms, and then it's going to come up with a to-do list. And here's our to-do list. Now, while this is working, let's check out the to-do list. If it doesn't run away from us, it's going to analyze the project structure, existing project structure, which is nothing. This is a blank folder. And then it says, "Set up ExpressJS backend with MongoDB connection. Install required security dependencies. BCrypt.js JSON." See, those are things that may not have been installed had we not added that last little bit on the end of using security best practices. It's going to create a user model with MongoDB. It's going to implement user registration endpoint with email verification, login endpoint with JWT token registration, all kinds of stuff here. And we can see it's going to go down through this list. And now it's come to the very first question, the bash command. So now it knows that it's running in bash on my Mac and it says, hey, this is what we need to do. Do you want to proceed? I'm going to say yeah. And now we can see backend front end already being created. And here we go. Okay. So I said a few minutes ago, is it going to know npx react app? And it does. And it goes even farther. It does template, typescript, etc. And I'm going to say yes. And don't ask again here. And we'll just keep doing that. And we're just going to let this thing fly and let it do whatever it thinks it needs to do to make this happen. Now, we've got another question here. And here it's saying, do we want to install express and mongoose and brypt and all this stuff that needs to be ex installed for the backend dependencies? Yeah. And I'm going to select here. Don't ask again for npm install commands. If you think I need it, then install it. Okay. Now it says, do you want to make this edit to package JSON? Now package JSON, if you're not familiar with Node, that's what manages all of the packages and dependencies in Node. Yes, and don't ask again this session. That way we can just let it set up the package JSON however it thinks it needs to be set up. And we'll uh we'll check it out once it's done. And if we look through here while it's creating, you can see it's already creating. We've got two separate applications here, backend and front end. It's creating all of these. And now it says, "Hey, do you want us to create the model directory?" Yep. And don't ask for make dirt commands. Make all the directories you need to make. So we're essentially just kicking back and letting Claude code do whatever it wants to do. Whether or not it ends up being what we want in the end, we don't know yet, but it is we're just letting it go. Here, let me create the user model and database schemas. Now we'll create the email service. Now, you might notice this takes quite a while, but when you think about it, it's doing a ton of work. So, is it really taking that long? If you were doing this by hand, it would take days. And now we can see we're getting down towards the end of our to-do list. So, we can expect this to be done any time. Okay. So, now we can see here that we have a summary of everything that it did. And this is a long summary, but hey, it's been running for 10 minutes, right? And so, we have our backend. And it says complete authentication system first off back end user model with secure password hashing, email verification and account lockout. All of this stuff, right? It shows the front end and all the stuff it did with the front end. And then security best practices, which is what we asked for in that original prompt. It has password complexity requirements, account lockout after failed attempts, all the stuff. There's key features here, and these features are things that we asked for. And it went a little bit further as I'm looking at it. Like there's password reset via email. We asked for that. Could we ask for a protected dashboard with user management? Not exactly, but it created one. Responsive modern UI. I didn't mention that, but it created it because why wouldn't you want a responsive modern UI, right? It makes assumptions. Complete error handling. That's another thing that I didn't say needed to be done, but Claude made that assumption that you're going to want complete error handling. And it decided to throw TypeScript in there for type safety, which is excellent. You know, that's great. So, we have some instructions here to get started, start MongoDB, configure email, run backend, run front end. It gives us all of stuff we need. So, it says here the system is production ready with proper security measures, comprehensive documentation, and a clean, maintainable codebase structure. Now, a lot of folks say, especially security people, do not generate production code with AI, right? So, we just violated that rule. So, I'm going to say it, too. As a disclaimer, if you're going to build things for production for your organization or even your personal projects, if you're going to build something that the world's going to see, you need to audit it by hand and audit it personally. Now, Claude code says this is production ready. And you know what? It might be production ready. Could be perfect, but you need to check and you need to verify and you need to make sure before you release this stuff out to the world for people to use. So, with that disclaimer out of the way, let's check this out. Okay. And I'm taking a look at my environment file here. And I can see that it's port 5000. Here's my MongoDB URI, JWT secrets, etc. All right. So, this is all my config information. So, let's go ahead and follow these instructions. Now, what I'm going to do is create another terminal here. We're going to leave this terminal open for cloud code. We're going to do cd backend and npm rundev. And it looks like we're having some issues with MongoDB. These are some warnings, but MongoDB is connected. I do have a MongoDB server on my Mac here. And we'll go back to our claude terminal here. And the next one is our front end. So I'll create another bash terminal for that. And it's asking if I want to let it access Google Chrome, which is fine. And look at this. We have a very nice looking application that we didn't have to build and sign up for an account. Now, I don't have my email set up, so I don't know if this will actually work, but h it says network error. So, there is a little bit of a problem because I don't have it set up to an email account. But it's nice to see that this is created. This looks really nice. And with a little bit of work, I think I can actually have an application which I can log into and authenticate with and work with MongoDB and Express and all this stuff. Now, what I really wanted to show here is, you know, we've got this backend application, we've got a front-end application, we have a ton of code here. Now, let's say that you are a React expert. You are a developer who uses React and every day. You could run this simple prompt, go get a cup of coffee or some orange juice, let this thing run, and come back and have it build out boilerplate that you would build any other time. And you could come look through the code and say, "Okay, this looks good. This looks good. I've done an audit. This is great." And something that may have taken a couple of days writing boilerplate code is instead done in 30 minutes. So what have we learned here about cloud code in this as far as autonomous building? Well, independent problem solving, right? It made a bunch of architecture decisions. Some of it with us, some of it asked us, and then some of it made assumptions and said, I think you want to do it this way. Multicomponent orchestration. I mean, there's a whole bunch of stuff going on in this back end. There's a bunch of stuff in the front end. The production readiness part where it says, "Hey, this is ready for production." Again, you know, there's that standard disclaimer that you don't want to just generate things and dump them into production. However, it does include in here testing and documentation and security things. You know, this can be adapted basically for creating apps from the very beginning. Like if you've got green field apps, this is a great way to create like a proof of concept where you go to your boss and you tell them, "Hey, I've got this idea to do this thing." And they're like, "Okay, show me." And they'll think about it. You can come back here to cloud code and say build this thing that's exactly like this. Show it to your boss and your boss says that's great. Let's do this. She signs off on it. Then you just go back and either modify what Cloud Code generated or you could generate it your way. Either way, this is one of the big benefits of Cloud Code is it's very autonomous. It's very independent and it can be super useful for doing things like this. So, I just wanted to show um kind of the autonomous task completion and how it all works and things like that. Now, in the next few videos, we're going to do even more with this, but thank you for watching. In this video, we're going to talk about Cloud Code's environment and some configuration, just kind of settings that we can work with. Now, user settings is in your settings. I'll show you where those are located. And these are going to be your personal settings. So I'm on a Mac, so it will be included settings.json. And it'll be the same for Linux. In Windows, it should be under uh program data cloud code and in that folder. So let's just open this up in code. Okay, we'll do a Vim. And here I don't have much, right? So I can add all kinds of stuff in here and we'll do that here in a little bit. But for the most part right now, it's just just some real basic stuff. Just shows the schema, what it's supposed to look like, etc. Now, there's another one here, another couple of places. So we'll go out of this. So settings.json is basically the settings that you use on your machine. Now if you want to create something in your project folder here you can create a cloud folder and in here you could create something like settings.json which is what we just had in my user folder. Now this is going to be the settings for the project. Now, these ones are settings that are checked into source control and shared with the whole team, right? So, I'll show you a good example of a settings JSON from Cloud's documentation just so you can see what it looks like. Here's a typical set JSON where we say we allow bash npm run lint. We allow npm run test. We can read the our Zshrc. Um, and then it says deny curl, can't read environment files, can't read secrets. Um, and then we have a couple environmental settings here. Now, there's a ton of different environmental settings that you can choose, but here, like we have cloud code, enable telemetry, hotel, metrics, exporter, etc. So, let's say this is a typical cloud code settings file. Now, what if you want something that's settings that aren't checked in? So, this is a little more for personal preferences. Now, settings.json that's in your root folder um is obviously going to be your personal settings for cloud code that you want to use everywhere. But you might want to use personal settings per project. And that's where this comes in. So, in here, we would create settings.local.json. Now, this won't be checked into source control and it's useful for things like personal preferences, experimenting, things like that. Um, and basically cloud code will configure git to ignore this uh file if it sees that it exists, right? So, it will put it in a git ignore and you won't see it. Now, for enterprise deployments of cloud code, they have enterprise manage policy settings. And so in there um I'll just show you the location where that would be located. On Mac OS it would be library application support cloud code manage settings. Linux or WSL will both be etsy cloud-code manage settings. And then Windows it's going to be manage- settings JSON located in program data cloud code. So that's if you want to set enterprise level stuff. Now there's a whole bunch of different settings that you can put in here, right? And let's let's copy our settings here. And we have things like permissions, allow, etc. Um there are different settings in here like we have environment keys. Now, we can just put base level settings in here, such as how long do we retain chat transcripts, for instance, in days. Default's 30 days, but you could put cleanup period days 20 or even seven. And we can actually we'll pull these out here and just make our personal file. Now, there are certain things that you can put in that that's in the documentation. There's things like the allow, right? So, we had permissions, allow for this. There's all kinds of different stuff you can do here. You can put in all the different tools that you can use, um, things like that. Web fetch, you know, curl, all these types of things that you could put in here if it's part of using that. Or if you decide you don't want folks to use that, you can go into the deny here. You can do a default permissions mode in here. Can say default mode and we can see here accept edits, bypass permissions, default and plan. So there's quite a few different things that you can do with this. Um you can also add additional working directories to this by saying additional directories some other project. Right? So you can put that in there. Um there's all kinds of cool stuff that you can do. If you go to this URL and I'll just put it on the screen. httpsdocs.anthropic.com/doc anthropic.com/en/doccks claude-code settings. You can see a whole bunch of different settings that you can do. Now, let's talk about the configuration system in a little bit more detail. So, there are some other files that you can do here. Um, you can do cloud.md, which has instructions and context that cloud loads at startup. So I can go in here, say new file, cloud MD. Um, and this thing you could actually tell Claude, create a claude.md file for me. That would be typical in a Python application. It starts to think about it. And it did say illegal operation on a directory maybe. Uh yeah, I've actually some of this out. But here it's created a Claude MD for me. So I'll say yes, I want to make this edit. Now let's check out our CloudMD that it created for us. We can drop that in the cloud folder if we like it. And here it says MIAR reader application. This is a Flask web application that decodes mear aviation weather reports. Um it shows how to set up the environment, how to run the application, how to test it, and then there's some code quality stuff here. So basically with this we're giving Claude some context and we're telling it so anytime you run cloud code it's going to go through this file and we're telling it look for code quality you can install these let's use this for linting right flake 8 etc. For code formatting, let's use black app. py test app etc. And it has the dependencies. So it tells cloud code. Here are the dependencies that we have here. Uh we have requests etc. Then the project structure basically telling cloud code this is what it looks like. So, this is what Claude Code calls a memory file, and it's basically instructions and context that loads at startup, and you can type in all kinds of stuff in here. Um, there's also the settings files that we just looked at. There's slash commands, too. And so, you can add different configurations with this. So, manage this list and manage background shells, things like that. Config theme. And this configures some preferences here. Use to-do list. True. Now, the to-do list, we've seen this in action, right? And I like the to-do list. Maybe you don't. You can actually turn it off here, but I've seen the to-do list where it goes through and it shows me all the stuff. I like it. Checkpointing. We want that to be true because you can run into some things where Cloud makes some changes and they break everything and you're like, "Ah, let's roll that back." That's where checkpointing comes in. Um, verbose output, auto updates, the theme, we had a dark mode, auto notifications, normal editor mode, model, this is pretty important, right? Because you can change between different models. We have a diff tool, just selecting auto and auto install ID extension. So, these are all configuration things that you can do. Now, here's another thing that we want to think about for when you're hiding sensitive files. So, we're going to go back to our permissions a little bit here. And in our settings, see how we have allow and deny, etc. Now, one of the best things you can do is this right here. Don't let it read a secrets folder, for instance, or a build folder, things like that. And these are sensitive files. I mean, that's why they call them secrets, right? So this is something that's very important to know is that you can allow cloud code to look at your entire application but you can say hey nothing in this folder or nothing of this file name etc things like that. So I just kind of wanted to show some of the configuration options and how you can do it. There's a ton of environment variables you can change here. You can change you can put in your API key. You can put in uh the model you want to use. You can do all kinds of stuff. Um you can tell it whether you want it to go to bash and do bash stuff or not. You can do all kinds of stuff. And again, that's at that URL docsanthropic.com/en/doccks/cod-code/ settings. Now, here's another cool thing to check out. You can type in claude config list. And it looks like we've got an error this time. But you'll have to trust me when I say that a lot of times this works. For some reason, it's not working great here. But you can do claude config list. You can do claude config set. So you can say cla what did we configure up in here that we could look at? Config set. And then you can type in different keys and different values. Like I can say cloud code enable telemetry. Put that to zero. And like I said, it looks like we're having a little bit of an error with this, but just know that most of the time you can list settings with cloud config list. You can see a setting with cloud config get and then whatever the setting is. We'll try that. We'll see if that part works. Cloud config get. Nope. None of these seem to be working right now. So, and it seems to really dislike this setting in particular. So, here's our different keys. Now, it should work where we can say cloud config list. There we go. And we can list some config things like allowed tools has trust dialogue accepted, etc. And this is based on this settings local JSON having basically nothing in it. But you can grab your settings. You can config settings, things like that. You can set a global configuration for something like auto updates. You would do claude config set-g, right? And then the key could be like auto updates true. And so that sets it so cloud auto updates. You can do the color theme and just set this global theme dark, which it already was set to dark, but let's set it to light. And now it looks a little different. So, that's the configuration settings. I just kind of wanted to show how these work and how the memory file works, things like that. And you can configure Claude Code to do a lot of really cool different things. So, thank you for watching. In this session, we're going to look at managing long sessions effectively. So, you'll might have short sessions where you just go in and ask a question or two and you pop out, but you'll also have longer ones. And so, we need to take a look at what that looks like. And the way that we're going to do that is by building a fairly complex application with a series of prompts. And we're really going to try to push that context envelope to its maximum. And so what we're going to do is we're going to build a web-based Flask application that does image optimization. So what we want to do is reduce the quality of an image, reduce the colors, things like that. And a lot of this is going to require OpenCV. It's going to require some different command line things. And it's going to be a somewhat long project. So we'll start with a prompt. Now, we're going to talk in the next session about managing effective prompts, writing effective prompts, and so we'll touch on some of the stuff that we do here. But for now, I'm going to drop in a prompt to show you exactly what I'm talking about when we say writing a very specific prompt and it's going to kick off this very long context type operation. Okay, so here's how we're going to put this together. First, we're going to start with requirements, right? Now, I have a list of requirements here that I'll just paste in. One of the first things I'm going to say is build a single image optimization web app using Flask. And then I'm going to hit control enter and I'm going to dump in my requirements. Now, let's take a look at these requirements. So, I want a Flask web UI with drag and drop upload. I want to support JPEG, PNG, WEBP. Uh, we'll reject SVG and GIF. We're going to rate limit this to 30 requests per minute per IP. Uh, because we're going to host this publicly, we don't want it to get flooded. Allow a maximum of 25 meg upload size. Autocle temp files. So, we don't want to keep the people's images that they're optimizing. We just want to optimize them, send them out the door. Show before uploaded image and placeholder after pane. Use pillow for image IO. Keep open CV available for future features. And docker guised with unicorn for production. And we might actually remove that one because we're going to do some deployment stuff later. Now we want to put in the deliverables. We want a complete flask app with HTML elements, the requirements text, things like that. So we will dump that in here and we're going to say we want a complete Flask app structure with routes, config, validators, and cleanup, HTML templates, static files, and requirements.ext. So since we've been so deterministic with this, we're basically saying this is exactly what we want. This should start kicking off and firing off things. And we can add more later. So, I'm going to press enter and let it go. You'll notice the to-do lists that are coming up here. And these to-do lists are pretty long. Now, we get our first question here that says, "Do you want to make this edit to app py?" I'm going to say yes. And don't ask again this session. Just create whatever needs to be created. Okay. Okay, now we're getting to the bash commands where it says, "Hey, do you want us to make templates?" Things like that. And I'm going to say again, yes, and don't ask again for maker commands. Make all the directories you need to make. Okay. Now, surprisingly, it says, "Hey, this app is ready to use at localhost 5000." So, let's take a look at what we have here. We have app. py. It's loading in flask request, render template, jsonify, senfa, a whole bunch of stuff here. But before we go and audit it, let's just run it. Right. It says that it's ready to use at localhost 5000. And when I bring it up in a browser, it says it's access denied. So, it's possible that this isn't running yet. So, I can put in here. I'll copy and paste this error message I am getting. And if you hold down shift and enter, you can do multiple lines. How do I run this? Now, we know how to run this, but this is one of the things I want to show to kind of add to the context of our conversation. And it says, "Yeah, pip install. Do you want to do this?" Sure. We'll do a pip install requirements.ext. And it doesn't look like it's creating a virtual environment, which could be a problem. So, we're going to go back and say, "Hey, we need you to create a virtual environment." Now, if we look at this here, and this is the first time that we've done this in this course, it says, "Now, let's run the Flask app. Python 3A app. py. Do you want to proceed?" Yes. Yes. And don't ask again. But now, we're going to select no and tell Claude what to do differently. This is, like I said, the first time we've done this in this course. We're going to say I want to create a Python virtual environment for this application. Now what it's going to do is it's going to create an environment and install the requirements from requirements.ext in it. And it says, "Hey, do you want to do Python 3-m VNV?" VNV. Yeah, that's exactly what I want you to do. It says, hey, do we want to activate and then install it requirements.ext? Yeah, we do. And it says, do you want to run it in a virtual environment? And yes, we do. And it looks like it's having a little problems with the output there. And it's kind of fixing itself. It's asking us, do you want to run it again? Let's try running it. And we've got some more issues here. So, we're just going to let Cloud Code work through those issues. and fix everything. Now it says, "Hey, everything should work perfectly." And look, we have a to-do list with a list of features, right? So, activate the virtual environment. And I'm assuming that that's something that we're going to have to do here. So, it's not going to do it for us automatically. Let's create another bash terminal. And in that bash terminal, we'll go down here and say source bnv bin activate. And if you're a Python developer, this is all pretty basic stuff, but we're just going to copy and paste exactly as it says to do. Python app.py. Oops. and it's going to be Python 3 on this machine. And we have a problem here. It says port 5000 is in use by another program, but it's not. So, what we need to do is find out why. So, we'll copy these warnings. We'll put it in here. Now, it's going to try to change it to a different port. Now, see, this is one of the things that I wanted to bring up in here and I wanted to kind of expose in this video is that when your context starts to get longer, now every tool will say we have the longest context and it'll have a huge amount, but as your context starts to get longer, you will notice a little bit of hallucination or weird things like this where it's saying, "Hey, if port 5000 is blocked, then let's just change it to port 50001." Now, we know that port 5000 is probably being locked by an older version of this application. Now, it's not coming up, so it's not working. But I'm going to say no and claude what to do differently. And I'm going to say, how do I find out what's running on port 5000 and stop it? And we can even say I am using Mac OSX even though it knows this. It knows what operating system I'm running, but it's it's kind of handy to throw it in there sometimes just in case Claude doesn't exactly know where it is. It's going to say, "Hey, we'll do lsof- i." Yeah, that sounds good. I'm familiar with that command. Let's see what it does. Next thing it says, hey, do you want to kill this process? Port 5000 used by control center. This is likely the AirPlay receiver mentioned in the error. Yeah, we'll proceed. I don't think I need AirPlay right now. And I was assuming it was actually our app locking up port 5000, but it doesn't look like it. But it's still saying let's do it on port 50001. So yeah, fine. We'll do it on port thou 50001. Okay. And says it's ready to use. So let's find out. We're going to take our browser here and say port 50001 instead of port 5000. And look at this. We've got an image optimizer. Awesome. Drop your image here or browse files. This is great. Let's try it out. Okay. So, one of the first things I'm going to do is go to my pictures here and drag and drop this picture of my family. That's my greatgrandfather and my grandfather and several great aunts and uncles. And it says image optimization feature coming soon. What does that mean? Well, we'll copy it and find out. But other than that, I mean, this looks pretty nice, right? Can browse files and probably go that. But the image optimization feature is not ready yet. So I can go in here and say I am getting the error optimization not ready yet. And that's all I'm going to say. This is Hey, it says it's not ready yet. Okay. Now we look at it and it says image optimization is now working. New features. We've got real image optimization using pillow with quality compression before after compression compression ratio display etc etc etc. Well, let's see if it's actually changed. We've got our image optimizer open here and we can browse and drop the image. So, I'm going to take this picture again, the Morgans and it says image optimization coming soon. So, we'll refresh it just to be sure. And now we do have some optimization options here. Now, this one is 99 by 704. It's 1,91 kilobytes. This one, we can see we saved 91.9%. And now it's 90.84. We can hit optimize image, which that button doesn't seem to do much, or download optimize, and that will download it to our downloads folder. So, we're getting somewhere. But now, we're going to put in even more prompts. We're going to add in some features to implement. And I'm going to say I would like to add the following features. And let's look at the features here. A quality slider for JPEG WEBP. Resize by percent, 200%, 1000, whatever. Strip metadata toggle. So we can strip out metadata that's in there. Strip out XF data. Speed versus quality presets. Update UI to show live preview of parameters. Produce a real after image and show it side by side with before. Keep no retention. Delete the temp files after the response. And then hit enter. So in here I'm basically putting in more features. And we're just going to keep adding more. And we're going to make this context as long as we possibly can to see if it starts spitting out some errors. Okay, now we've got a result here and it's showing all of the features that it added, right? So, advanced features now available, new controls, speed versus quality presets, smart features, backend improvements, how to use it, etc. So now, of course, we'll bring up our image optimizer and we'll refresh it. It says, "Drop your image here." We'll drop in this picture. And now we see a bunch of new options. We've got quality all the way down to one, all the way up to 95. We've got resize, percentage. We can say we want speed, we want max quality. So, for this one, I'm going to say max quality. We're just going to leave it at 100%. We have options to strip the metadata, the auto orient, and the quality. Let's set our quality to like five and see just how bad this image looks. So, we'll click on optimize image, and we can see that we don't have output. Now if we look at some of the console output we can see some evidence of a problem. So I can take this and copy console. It says failed Morgans.phd failed to load the server responded with a status of 500 internal service error. So I'll just dump that in there. And our text here says hey internal service error. The server responded with a status of 500, etc. And we'll see if Claude can figure this out. And it has. It's showing some stuff here where it's trying to uh looks like add a little bit more error correcting. Try uploading an image now. So, I'm just going to reload. We'll see if Claude has fixed the issue. So, I'm going to move that quality way down. Click optimize image. And there it is. Now, this is the reason I moved the quality down is to test it. If we put the quality at one and click optimize image, you can see it looks pretty terrible. If we do quality 95, and it looks like we're still having some errors here. So, I'll just do this one at a time. Now, this one we do quality 95. while the other one that we show is relatively the same quality. So, I'm going to copy this and let Claude know, hey, we're still getting an error. Okay, now it's saying that it made a bunch of changes. You can upload an image once, optimize multiple times with different settings, see realtime changes as you adjust sliders and presets, and compare different optimization results. So the problem was I was trying to optimize something after I'd already done it, right? So I had loaded this up, optimized an image, and I tried to optimize it again, and that didn't really work. So now Cloud Code knows what we're trying to do. So I can click optimize image. I can slide it back and click optimize image quality one. Well, quality one looks terrible. This looks like the pictures we used to see in the '9s, right? But if I go to 95, it's there. And if I want to make it bigger, I can make it bigger or smaller. Now we've made it into a little thumbnail. Look at that. Or we can make it bigger. So our application is getting really advanced and really good. So let's try to add a few more things to it. And again we're trying to build up this context to see how big we can get it and see what kind of things happen when we do that. Now the whole reason for doing this of course is you know we're building up this application. We're kind of starting out with a base level. We're adding more features etc. But what we want to do is put this into a session and think about it like a session. So it really is a session here that we're working with and it's goes all the way up to the very beginning where we kind of describe the application. Um but what we want to do is start taking notes on this and keeping track. Now why do we want to do this? There's two different reasons. For one, cloud code getting a large context will cause problems. So, one of the impressive things about Claude Code is that the context is enormous. I mean, relatively speaking, compared to other tools, you can carry on these conversations for a very long time. Um, I've built some random things where I've just tried to keep going and going and going and going and eventually it does start to have some issues and hallucinate a little bit, but it takes a really long time. But when we create the session notes, we're creating notes for us so that we can say, okay, this is what we did here. This is what we did here. But another reason to have session notes is claude code will look at these session notes. So one of the things I'm going to do is we're at a good place here in our image tools, right? So I'm going to say get add. We're going to add all of these files. And we've created quite a big application here. We're going to commit it initial application. Okay. And so we're committing that and we're saying at this point this is where we're at. Now I want to go over here to cloud code and say help me create a session notes.md for this project. And now it's puzzling. And like I said, there's always some kind of funny verbs that they come up with here. Now, what I'm doing is with this prompt is I kept it very simple and direct. And I'm assuming Claude knows what I'm talking about when I say I want to make a sessions session notes.md. Okay. And there it is. When I click on this first, we'll take a look at this. And it says, hey, I've created a comprehensive session notes MD file. And like I said, this is something that's for us and it's for other developers that are going to jump into your project and cloud code itself. Cloud code will look at this file and kind of know what it did in the past. So we can see here what's included. We have project overview and feature summary technical architecture breakdown. This is all of the stuff here that we have done. And when we look at session notes MD, we can see this is all the stuff that we've done in this single session. So we did some advanced optimization controls, user experience, backend, front end, file structure, all of the stuff was created in this session. It says project completed successfully. However, if we want to, we can start updating this cuz we're going to do some additional stuff. So I'm going to say up here I'll just put and this isn't really uh kind of carved in stone set in stone law about a way to do this but we can say session one completed here just to you know say and here it's trying to put in a date but here it just says session one completed and then all of this stuff. Now I can say down here session two and we could say something like session two focus what we want to do with session two implementing advanced features. Sorry can't really type today. Now, I want to add in some stuff here, like I want to add in sharpen controls. And we can even describe what we want it to do. Sliders for sharpening, blur, contrast, brightness. That actually sounds great. We want to add in something like format conversion. And what do we want to do for format conversion? Well, the ability to convert between formats. Looks like that's a pretty good suggestion there. And this will be kind of a stage three, right, of this just kind of adding some extra polish. Now I can keep this in the session notes and then go down here and I can just copy this in and say something like I would like to add in additional features outlined in session notes. And then I can put it in here too to be firm about it and say I want these sharpen controls. I want this format conversion and then we'll hit enter. So this is the first part of managing a session is actually using the session notes. And now that we have gotten pretty far with this thing, we can go back and look at some of our session information also. All right, looks like we're done. Well, at least Cloud Code is done with what we've asked it to do. Let's take a look at it. Session two advanced features complete. I've successfully implemented all the requested advanced features. New image enhancement controls. We have a sharp and blur slider, a contrast slider, brightness slider, and format conversion, enhanced UI layout, three column responsive grid for better organization. I didn't ask for that. But again, cloud code makes a lot of assumptions. And sometimes those assumptions are things that I should have put in. And a year ago with a different tool, if I didn't put that in, it wouldn't happen, right? So some of this is like cloud code can look at it and say this is a lot of features for this tiny window that we have right now. So we're going to redo it. Um and it made it mobile responsive format flexibility etc. I think we should try it out. But first I'm going to say this is great. Please add it. Well actually let's try it out before we add it to our session notes. So, we're going to try this out. Okay. So, we're going to reload our image optimizer and I'm going to click browse files. We're going to take that same file and we can see we have some additional settings and we have balanced speed max quality. Same as before. However, I can see here we now have a sharpen real sharp really blurry. Let's try that out. Optimize image. There is a very blurry version of it. We'll go over here to sharp optimize image and we can see that the sharp doesn't quite work. Now why is that? Well, it might be because it was unable to sharpen after we blurred it. Ah, we can see a problem here. Float object cannot be interpreted as an integer. So, I'm going to click that again. Copy this and we can go into cloud and say I'm getting an error when sharpening and dump in the air. And this is pretty basic stuff we've all done a million times at this point. Okay. And it says it should work smoothly now. So, we're just going to blindly trust that it will open up this image again. Sharpen optimize. There we go. And this is actually a sharper image here. So, let's try contrast. And we'll just go with extreme contrast. Doesn't seem to be doing much. We'll go with low contrast. And maybe we have to upload the image again. So, we'll load this up and say I want to do max quality, a little bit brighter, little more contrast, and a little more sharp. Optimize image. And then I say, okay, that looks good. I can click download optimize. And there we go. We can see our optimized image. So this is pretty good for this second set of features here. So the only thing I will say is I noticed when I apply one setting or I should say when I change one setting and apply it. Then I have to re-upload the image to make another setting change. Can we make it so that it and this is going to be a significant refactoring by my guess so that we can make several different changes that will take place anytime we hit optimize. So I hope I'm being fairly clear about that. Okay. And it looks like it's done here. Now, upload your image once, optimize multiple times, and see real time results. So, let's see. We'll reload our image optimizer with our image, and I'm going to say sharpen, optimize image. Okay, that is sharper. Then I'm going to go to blur, optimize image. Still doesn't quite work, but we can put that in like a to-do or something. and try to get Claude Code to do it again. Because it looks like now that we've done one change, we really can't do any other changes to it. It's kind of a oneshot deal. Just to make sure, I'll do a hard refresh. Do it again. But it still looks like you've got one shot basically. So, we'll reduce the quality. We'll blur it. We'll up the contrast. Up the brightness. If we do all these at the same time, then we get exactly what we look for. But if we try to undo that, we can't. And some of it is kind of the nature of images and that you can't really take add quality back to an image, right? So you can save an image high quality, but being the nature of the format, you can't just add the quality back in. So I think for now we could say it's okay that this is a oneshot thing and maybe it's something that we'll fix later. Now I can say this will work. Can you update session notes with this information? Now in here this technically is still session one right? So if we look here performance metrics etc. Now that I look at it, it looks like it already did update this for me. So if I go up here, it says session two completed advanced stamp and there's our sharpen blur slider, etc. So it did already do it for us. Now we'll look here and says here's what was added. Great. Now here's some takeaways I want to give you before we dive in even more with this. is just some kind of takeaways and pro tips. You want to break your work into logical chunks, right? So, what we did here is we've did this long basically very long session in claude all in one session. When we talk about sessions and claude, it means when you type in claude the first time to when you exit claude. So, that's one continuous session. It was a little confusing. We put session two in here. Technically, a session is when you start up Claude and then when you end it. So, you want to break it into logical chunks. You did notice that it didn't quite fix my bug here, and I don't want to dig too deep into this with this video because it's a little off topic to kind of get in the weeds, but there is a possibility that this context has become so large and so abstract that it's like not really understanding what it needs to do and it's not quite or it's just hallucinating or something like that. I can't really say for sure without spending a lot more time on this, but trust me when I say if you don't break the work down and you make really long sessions, you will start to see hallucinations and things like that. And one good thing that's best practice is to use the session notes and summarize the progress that you've made after you've made it. And then when you start new features, you want to come in and add those new features and say, "This is what I want to do." Now, when you're doing major refactors, you want to start fresh sessions, right? So, basically, if you're doing something as huge and big, it's really easy to just exit out of cloud code and go back in. And I'll show you how you can grab some of that session information, hint, session notes MD to when you create a new cloud session, it doesn't have to start from scratch, right? It doesn't have to reinvent the wheel. It can just read the session notes and keep going. So, here's some things that you don't want to do. You don't want to try to do an entire project in one session. We're doing this for demonstration because I wanted to show you, you know, a big long session, but don't do this. Don't try to do the entire project with one session. And don't assume that everything you know that you've done will be remembered by Claude, right? Don't assume assume that it's going to remember everything from hours ago or way back early in the session because that may not be true. Now, when you notice degraded performance, don't just keep going with that session and keep iterating. There's a couple of reasons. For one, it can burn up a lot of money. If you're paying for this with API calls, it can burn up a lot of money to kind of go in circles on a problem that may be solved if you just quit the session and start another session. And another thing that you don't want to do is you don't want to expect Claude to remember this across, say, a few days. So, if you have a session going and even if the session's open on your laptop and you leave it somewhere and you come back to that session a few days later, don't expect Claude to maintain that context. Highly, highly likely that it will not. It will probably then come back and try to attempt to figure it out. Right? So when you see performance problems like we started to see here that's a good time to kind of look at things and say is this session big is it too big etc do we need to trim this down and so cloud code works best with its own constraints and we'll talk about that a little bit but what you can do is you can ask claude to there's a few things you can do like a canary test And I'm going to do this in the same session before we close it. I'm going to say, can you recall what database we're using, which we're not using a database, but we're going to see if cloud knows that. And so it's starting to think now. And it says the app was designed as a simple stateless image processing tool without any database requirements. So that's correct. So that's some of the things that you can ask. And by asking these questions, you can tell how the context is doing, right? If it comes back and says, "You know what? I have no idea." Or if it comes back and says, "Oh, you have a Maria DB database, but we deleted it earlier." And you know that that's not true. Then it could be a chance that your sessions are getting a little bit long. So, you kind of want to do a health check once in a while, right? And it's basically this kind of looking at it asking it, hey, you know, what did we do here or something like that. Now if we look at this here is how we can free up our context. We can clear reset you see here which is clear conversation history and free up context. This is the same as exiting claude and restarting it again sort of. If you don't trust it then the best way of course is to shut off Claude and start it back up again. And there's another one that's compact clear conversation history but keep a summary in context. So we can just say compact compacting conversation and we can say you know this is pretty good. We've got a lot done with this super long set of instructions. So we can compact it. Now, another thing that we can do as soon as it's done compacting is we can start up another session that has new context, but we can give it a little bit of history with session notes MD. Okay. And now it says here previous conversation compacted read and it says here read in session notes read app py main.js stylejs etc to-do list compacted it see controlr to see full summary. So let's do controlr showing detailed scrant transcript. Let's go back and just kind of look at this. Implemented virtual environment for clean dependencies. All user messages. Here's my message. Build a single optimization web app using Flask with detailed requirements. Serving it up. There was an error. We fixed it. Some pending tasks. Current work. Optional next step. The user's immediate requests have been satisfied. No further development work was explicitly requested. So this is all stuff that we can rely on session notes for and we have our session notes here. So of course we can just do controlr go back to our prompt. We can exit out of cloud. Now we're completely out of cloud. So what are we going to do to do all this context? So obviously any question that we ask is going to jump back into the files but it's not going to have the context. It's not going to know everything that we did here. It's going to try to guess it. It'll try to reverse engineer and look at our code and say, "Okay, I see this. I see this. I think the point is this, etc." But an easy way to do it, of course, is to do claude and say, "Read in session notes MD and whatever you want it to do. All right. And so that will load up this history and give Claude a little bit of history. Another thing we could do is you could copy this whole summary that we had and put that and add that into an additional file and say, "Hey, here's another summary. Here's some more stuff you might want to look at." But basically, the easiest way is say read in session notes and create some features to X. So just for some kind of pro tips again break work into logical chunks. Don't do these huge long sessions like this. Try to summarize your progress before starting new features. So try to summarize things in session notes or some other place before you start new features and keep fresh sessions. Start fresh sessions for major stuff or just to be safe. Just start a session and say pull in session notes and let's go for it. Don't try to do a project an entire project in one session. Don't assume that cloud's going to remember this stuff just because it's in the same session, etc. But take control of it by using these session notes. So, I hope this is clear. Now, you can see that we have this set up. We can do things like we can deploy it, stuff like that. I think we're going to leave this application pretty good for now, but we might want to jump in and do some features later or something like that. And we're going to keep digging into Cloud Code and this amazing tool. So, thank you for watching. Let's go to the next task. Now, in this demo, we're going to talk about writing effective development prompts. So, writing the right kinds of prompts will get you the right kind of results. Now, we've talked a lot in this course about assumptions and how Claude will make assumptions based on what you say. Some of those assumptions are perfect and they're great and some of them maybe not so great. And that's not necessarily the fault of Cloud itself. For instance, we can say make a login screen. Now, this is an example of a bad prompt. And what do I mean by bad? Well, it's just not that great. It's not specific. It's not clear. It's very vague. All of these things will make for interesting results. So, if I say make a login screen, now it's made some assumptions here. And those assumptions could be based on my previous experience with cloud maybe things I've built in the past or maybe it's going to look at GitHub and say what is the most common thing. So it says here I'll create a login screen for your express application. Let me first explore the project structure to understand the current setup etc. Now actually I do want to make a login system with express. I'm not sure how it knew that, but in this case, we're really not going on the right path. So, we'll see here listed two paths and it says read illegal read operation on a directory. Let me check the contents. There are no contents. This is just an empty folder. So, then it says find and it wants to look for JS, JSON, HTML, CSS, etc. Now, the reason it inferred that we would want an express application is probably because the name of the project or the name of the folder that we're in is express login demo. And that's probably how cloud code guessed that we want to do this in express. But if you look at it, it says, hey, we want to look at some files. Now, I'm going to say no and tell cloud what to do differently because this is just kind of a silly request. Make a login screen. make a login system. It's just too vague. So Cloud will ask multiple clarifying questions. It'll create something generic and that might not meet what we want. Right? Since we've called this Express login demo, it says we'll use Express. But if we didn't name this folder that, maybe it'd try to create something in React or Vue or who knows. So we need to be specific. And so one problem here is if we let it assume what our intent is, it may create something wildly outdated or weird or something that we don't want, right? It might say, "Oh, maybe this person wants a DOSS app and we'll build that or maybe it wants a Go app or a Python app or whatever." And another problem is it probably won't throw in error handling, validation, security, all that because it's just going to try to make a guess of what you're trying to create. Now, here's another thing that we can do that we can make this better. Now, I did back out of this and say, "No, Claude, don't make something. I'll be more specific." So, I'll copy and paste this in here, and this will be an example of a better prompt. I'm going to say create a post slappi/off login endpoint using expressjs. Now that is what we're named here. So claude inferred that. But that's actually what I want with the following requirements. For our input we need an email and a password. Both are required. Must be a valid email. Must be a valid password. We want to validate that input using express validator. Check if the user exists in postgree SQL database. Compare the password using brypt. Generate a JWT token with 24-hour expiration. And then the response should be success or failure. And we'll define what those should look like. And then I say include error handling for database failures and validation errors. So I'm going to hit enter. Now this is what we would call a better prompt. Now, I said the last prompt was a bad prompt, and I kind of explained why. This is an example of a much better prompt. We're being very specific. We're saying we want to use ExpressJS, right? Here are the fields that we need. Here's what I want you to do with them. Here's the database that I want you to use. Here's how I want you to compare the password, and I want a JWT token, etc. We're getting very specific. And the more specific you are with your prompts, even the very beginning prompts, usually the better result you will get. So we will let this run. Now if we look at this, it says, I see this is a new project with only get initialization. I'll create the complete Express.js project structure with the following login endpoint. And we have a to-do list. Now in this course, we've seen a bunch of to-do lists, right? So, we've seen how they go through and cloud code will present this to-do list and it will go step by step and do all the things here. It says initialize NodeJS project with package JSON. Do we want to do that? Yeah, let's do that. And next, it says do we want to install required dependencies which are express and validator, brypt, json, etc. Yes. And now it says create basic express app structure and I'll select yes. Now here's something to notice. It says hey do we want to write this environment file where we have port 3000 a JWC secret etc. And yes we do and that is something that we will have to create. So we'll have to create a actual postgres database with a login and password etc. But it's going to create all of the software that's wrapped around that. And it says here, do we want to make routes? Yeah. As we go through, I can say yes for this session only and just let Claude go, right? Let it just make all the things that it wants to make and needs to make and then we can go back and test it later. Now, I mentioned that we're going to have create a PostgresSQL database. And you can see here that it's actually making a database schema file for us which will make things really easy because we can just run that into the Postgres database. Now one way that I could have been more specific with the prompt is to say the database backing that I want. I could have said SQLite my SQL Microsoft SQL whatever that would have been another way to specify things more. And so that's one of the things you want to think about your prompts. You want to look at them and say, "Is this specific enough?" Now, here's a pro tip that's really awesome is you can take the prompt that you want to use. You can dump it into an LLM like chat GBT, Gemini, Grock, Claude, whatever you like and say, "Act prompt engineer or act as an LLM and tell me how to make this prompt better." And it will go through all of the basic LLMs that are out there right now. will go through and it will ask you a few questions and it will tell you here's a better prompt to use. So that's something that you should always try as you're building your prompts to try to make them a little bit better. Now here it says we've got the whole to-do list is checked off. So it says the post API off login endpoint has been implemented with all the requested requirements. Email validation using express validator password 8 character minimum error messages we have postgres integration here we have JWT token generation we have a specified response format we have what to do on failure comprehensive error handling so 503 401 400 500 all of these are handled here's the files that were created to use this endpoint configure your PostgresSQL database credentials and run the schema SQL to create the required tables. Now, what is the difference between the two things that we did here? Well, the difference is in this case, cloud is building exactly what we need, right? We asked for a specific thing and it's delivered that specific thing. It includes all the security features, proper error handling, things like that. And there really are no clarifying questions needed most of the time when you get very specific with your prompts. and it's pretty awesome. So, this kind of goes into a formula that I like to use, right? I like to use this formula and I call it context action details examples. And what I'll do is I'll just create a little file here. We'll call it examples MD. And this is going to be context action details examples. And we didn't do all of these with this the initial prompt that we did here, but this is something that we can really utilize to our advantage. Now, context, right? What do we do with context? Well, we know that context sets the stage, right? It basically says here's the past information that you need to care about. So we'll say sets the stage. Now what's good and what's bad with context. Now bad is something like add a feature, add a new feature, add something. Good is I have an ExpressJS API with MongoDB. Current routes are slout API. add a feature that does blank. Now, as far as action goes, what does action do? Well, it will be specific. So, instead of just saying do this thing that you should do, with action, it will be clearly defined, right? So, a bad example would be make it better, right? So, the context would be look at my software. Action is make it better. good would be refactor this function to use as sync await instead of callbacks or something like that something very specific which ties into details. Now with details we want to include constraints. Now with action we're telling it exactly what it should do, right? We're saying here's what we'd like you to do with details. That's a good place to insert constraints. So instead of something like a bad example would be add validation for this, right? Cloud code could probably figure it out. So a good example would be add validation that ensures email is unique in the database and password meets OASP standards. So that's an example of good details. Now with examples, what are we doing with examples? We are showing desired patterns. Now, if you've worked with LLMs a lot, which you probably have, you'll notice that the patterns are everything. So, as you're going through and you're saying, "Please make this thing." As soon as you say, "Th looks like this." Now, the final step is examples, which is where you show your desired patterns. And that's where you're saying, "Hey, this is what this should look like." So, a bad one is make it like all the other applications out there, O applications out there. You could say something like make it a typical authentication app. Something like that is way too vague and it doesn't really give an example of what success looks like to the LLM. But if you say something like follow this pattern from our existing endpoints and type in your endpoints, something like that or follow this pattern from the OOWSP examples. And that basically says, "Hey, here's how we want it to look." And notice that sometimes if you're typing in these vague prompts, it will just waste a lot of time. Honestly, you will go through and say, "Make this thing like this." And you'll do these vague prompts and things won't really go the way you want. And so then you'll have to go back and get more specific anyway. So if you just remember this context, action details, examples, then you know you can say here I'm going to put in my context. I'm going to tell it what I want it to do. I want to tell it what I don't want it to do or what world I want it to live in. And in examples, this is what I want it to look like. And sometimes you can get this down to one prompt that will generate a ton of code. So, the big things here are the three C's of good prompts, and I'll put that here. And the first C is clear, which means no ambiguity. Don't leave things open for interpretation unless you want the LLM to get creative. Basically, you want to say this is what I want. The next C that we care about is complete, right? All the requirements are stated. All of the constraints are defined. All of the end results that you want are defined. And the last one is contextual. So what we're saying here with contextual is we want to include the relevant background. We're basically saying here's what we have now. Here's how we've built it. Here's how we'd like it to look moving forward. Now remember there's a time investment rule here. If you spend a minute writing a good prompt, you can save 10 minutes of revision. And that's no exaggeration. If you spend time upfront getting the right prompts as you're going through, those prompts will generate things that are more specific, more accurate, better for your intended goal. And if you want to save time and just put in vague prompts, you'll end up spending a lot of time refactoring those and saying, "Oh, that's not what I meant. I meant this." etc. So remember, there's kind of a Goldilock zone when it comes to prompts here that like we've put in. If you're too vague, Claude will guess. It will infer things and it will basically make assumptions, which we've talked about a bunch in this course. If it's too verbose, right, the other side of that where you have just a ton of words and a ton of explanations and tons of details, then cloud gets a little bit confused. And sometimes it's like, well, I hear what you're saying. I see that you have 53 things that you want me to do. So, I'm going to try to do 45 of them and then you never know what you're going to get right. So, just right, which is the middle is clear, structured with examples as we've shown here. So, these are some good prompting techniques that you should keep in mind and you should use while you're using Cloud Code and you'll see some amazing results. I've worked with a lot with claude code lately and I've noticed that when I put in the right prompts and I put in the right info, I get really good output. So, I wanted to include this demo as kind of a way that we can look at clear, complete, contextual prompts that will get you exactly what you're looking for. Thank you for watching. Now, in this demo, we're going to talk about using multiple files in your projects, project navigation, and how Cloud Code kind of handles that. And it's really cool. I mean, you can do things like say, "Show me the file structure of this application, right? It'll start kicking off and we'll go through and look at everything." And we have some of this stuff. We've got it documented in other places, but we can always look at this and say, "Oh, that's cool." Right? And you can say l as our project structure and tell me. What are the main components? How are the routes connected to controllers? We just come up with some different things like this. uh what database are we using and cloud will go through and answer a lot of questions about this. Now, where does this come in handy? Obviously, none of us really like to jump into giant legacy code bases that we don't know anything about. And this is where cloud can really help because it's not just focused on one file, one task, one function. It'll look at your entire project like this. And so we can see main components server.js. That's going to be our main application entry point. That's the PostgresSQL connection pool authentication routes schema.SQL. And then it says route controller architecture. It shows main server mounts off routes at API o off router handles etc. in a database is Postgre with a connection via PG library with connection pooling single users table email index for performance schema. Right? So we can go through and kind of look at this and we can even have it look at other projects. But one of the things we could do here is since we have these main components as names, we can say something like I would like to change the database. And we're actually going to do this in a future video, but I would like to change the database to Maria DB. And we have to say at some point, otherwise it'll start changing it for us. what files might be affected. Okay, we can see here based on the codebase analysis, these files would need changes for Maria DB migration. Direct changes required and it shows schema changes environment variables. This application used parameterized queries which helps but you'll need to update the placeholder syntax and connection pool configuration. So this is some good stuff to know and this basically shows how Claude knows things about your project, right? It can correctly identify relationships between files, what files do and things like that. Now one of the things that you can do here also is you can make changes to specific files by naming them. You can say add X to config database.js. You can say add something, refactor something in this file. So you do have file level access, but as we can see, Claude also looks at a bunch of different files and examines how they're all related. Now, where does this kind of thing come in handy? Well, when you're doing refactoring, you can specify the files that you want to refactor to change. Um, you can use this and the next step can be, okay, change it. And it could just be that you're saying, "Hey, analyze this codebase and tell me what to change." Maybe you know that all these things need to be changed, but you want to make sure that claude knows before they start making changes. Now, you can do this here in your queries. So, this is file clustering, right? So, based on the codebase analysis, etc., direct changes required, schema changes, you can say make changes to these files. And you could actually just copy this right here. Replace PG dependency with SQL tool or Maria DB. And then you can say schema changes change the schema here and so on and so forth. So this is just a cool pattern and a cool way to do this. You know, you can tell it what it's about. You could say something like file name package JSON purpose maintain registry of packages used change add in Maria DB B instead of PG or whatever, right? So these are things that you can go in and you can take this information and make it useful. So club is very useful as far as knowing the code when you're working in a file. You know, if you just crack open this code and start looking at it, you can ask Claude questions about it and say, "Hey, tell me what this does and add some comments here." or it'll also take a more meta view of the entire project as we can see and look at multiple files all over the place and how they're related and how they're kind of put together. So, this is really cool stuff and it's a cool feature in Cloud that I wanted to show you. Now, here's something else that you can do that's pretty interesting with Cloud Code is you can say do not I guess I don't have to yell. I don't have to capitalize it, right? But you can say do not modify these files and you can request changes and of course if the changes have to be modified in those files then cloud will say hey I need to modify that right but you can say do not modify these following files when you do something. This can be handy if you have something where you're working on a problem and it's just kind of spinning out of control and it's updating things that you don't want it to update or you can say that you just want you know this particular set of code to not be touched. You can say only create and modify and specify the files. And again, if the files do need to be if different files do need to be modified, Claude will let you know. Now, there's another cool thing here. The last thing I'll show you is you can just verify. You can say something like this. Verify these files were refactored. And you can say give it a list of files and say verify these ones because these are the ones that I wanted you to touch. So you can do a verification. Now here's a few dos and don'ts uh when it comes to files, right? So don't say uh here are all the files in our project and a massive paste of every single one. Uh Claude knows those are the files in your project and it's really kind of a waste of cycles. But you can say here are the three files related to user authentication. Please modify them. You don't want to just paste in file names with no relationship context and just say here's a list of files build an off system. Instead you want to say something like these files work together the list of files and these make up our off system. We want to make some changes. Um, some of the things that you don't want to do also is if you're doing mixed project context, you don't want to say like use the React components from project A and put it in here, right? Because we're not running React in here. So, you could say something like here's the logic from our React project for authentication. Adapt this pattern for Express, something like that. Those are just some kind of dos and don'ts. And this is a great feature with Claude, the way it's able to work with files. And it's something cool that I wanted to show you. So, thanks for watching. In this demo, I'm going to show you how Cloud Code can work with APIs in two different ways. First, we'll use Claude to help us call an existing API. And in this case, we'll look up a city's coordinates with the Nomatim service and grab the weather from Open Weather. Then, we'll flip it around and we'll use Claude to build our own API with fast API so anyone can type in a city and get back weather data. Now, the goal is to show that Claude doesn't just write code. It helps you connect different pieces together quickly and turn them into something that you can run. So, we're going to start with a basic API call. I have some prompts prepared and we're going to let Cloud Code just build this software based on what we're going to tell it. So for the first prompt, I'm going to say write a Python script that takes a city name, uses the nominatum API to get its latitude, longitude, then calls the open weather API, and the key will be in the open weather API key environment variable to fetch weather, print the city, coordinates, temperature, and conditions. So now we will let cloud code take off, and we'll see what it comes up with. Now, I did specify I wasn't super specific with this, but I did specify just basically the clear goals that we want to do, right? We want it to be in Python. We want it to take a city name, use an API, get the Latin longitude, then call the open weather. So, we basically have laid out how we want it to work, but we haven't gotten super detailed with it yet. And we can see here it has already created weather. py. And I'm going to say yes, go ahead and create that. And we'll take a look at it. Now if we look at weather py we can see we have a get coordinates function here we have a get weather and then our main. So let's look at get coordinates in here. We're going to call this nominatum openstreetmap.org search. We're going to use a JSON format search and we're going to search by a city name. Then we're going to use that response. We're going to get the URL parameter headers. We're going to format that response and take that Latin longitude here and return it. Now, if it doesn't work, we're going to say, "Hey, city name is not found. Return none." Um, if there's any other kind of errors with fetching coordinates, it will be produced here. So, this is good, clean code. I mean, we don't really need this try catch type thing going, but it's really nice that it has it in there. And I say we don't need it as in we don't necessarily need it to function, but we definitely should have it. And cloud code puts it in here for us. If we look at get weather, we're getting weather data using open weather API. We're sending that Latin longitude. We're sending our API key units metric, etc. Now, I'm not super familiar with this API with either of these APIs, so I'm not really sure it's going to work. However, we're going to see how well Cloud Code handles this. So, I'm going to save it. And it says created weather py script. We need to export an open weather API key. And then we just put in python weather py New York. So, let's try it out. I'm going to put in my API key in the environment variable and give it a shot. Okay. So, now I have the API key entered. And one of the things I'll do is create a Python environment for this. and we'll install the things we need. Now, if we go back to Cloud Code here, it says that you can just export the key and then do Python weather py. And I can see here that it might actually work. Weatherpy New York. But it needs to be Python 3 cuz I'm on a Mac. And we need to import requests. So we'll go ahead and do this. Python.mnb. We'll create a virtual environment again. Python 3. We'll activate that. And then we can do Python weather py New York. It's going to need at least requests, right? So, we'll say pip install requests. And it looks like it is unauthorized. So, I'm going to make sure that I have the right API key entered. Okay. Well, I have double checked and my API key is being populated and it's valid on the website. So, I'm going to go back to Claude here and say uh we'll say unauthorized for URL and let's see if cloud can help. I am getting an error and then we will submit the error. And now it's grooving. It says you want to check if this is set. It's going to run a bash command. says your API key isn't set, which is actually untrue because it is set. So let's try something else because if we go into bash and we echo out open weather API key, it's there. So clearly that isn't the problem. And it says if you have an API key and it's still not working, the key might be invalid or you might need to wait a few minutes. So, we'll wait a few minutes. Okay. So, we've waited a while here and it's just not working. So, I'm going to say I've waited and it still is not working. Can you check the API call? itself to make sure it is following open weather specifications. So this is one thing that you can ask claude and sometimes it will go out to the internet and it will examine documentation and things to kind of double check itself and that's what it's doing right here. Cloud wants to fetch this content. Yes. So, it's going to fetch this content and kind of look up and see how we're supposed to access this API because maybe it's changed since the training happened. And it says here that it wants to do some debug output. It says I'll check the Open Weather API documentation to determine it's correct. It looks correct. Let me test it with the debug version to see exactly what's happening. So yes, we want to put in this additional debug information. Now try running the script again. So we will run it again. And adding the debug information, it now appears to be working properly. as it should. Uh this is what we were trying to get earlier is these coordinates here. Put in something different. Now we have a response. So I am not sure exactly what happened there, but it looks like it's working now. And I'm going to leave this in the video because I've been leaving all the mistakes in the video with all of these things to show a more realistic process of how this really works. So, if I clip and edit this part out of here, then it makes it look like cloud code works perfectly and looks like everything went smoothly and great. And that's not always the case. So, we're going to leave this in here. Now, we need to move on to the next step. So, if we're able to get this information, we're even able to get this weather information, but we're going to do something a little different. Now, one thing we're going to do, so this put it into two functions, right? And that was one of the things I was going to do to improve readability. I was going to say, "Hey, please put this into get coordinates and get weather as two separate ones." But cloud code already did that for us. So it has some good structured results coming out of it. And now what we want to do is expose this as an API with fast API. And so what that's going to do is we're going to turn this into our own API that we can share with other people. And one of the things we could do is we could convert this temperature into Fahrenheit because we're in the United States and even though I don't necessarily agree with it, we use Fahrenheit here. So that's something that we can add in there as well. So I said turn this into a fast APA app with one endpoint, weather, city. It should return JSON with the city name, coordinates, temperature, and conditions. I would like to display Fahrenheit for the temperature. So, we're being pretty specific here, right? We're saying this is what we want to do with it. So, we're able to grab this API data. Now, we want to convert this into something else. We could even turn this into an MCP application if we wanted to, like we've done in our MCP course. But here we go. So now it says uh we need to import fast API. We need to change uh it looks like right now it's just importing the fast API. So we'll say yes and then we'll see now it's going to convert this script to a fast API application. So if you haven't used fast API as a Python developer, it is fantastic. So that's why I chose this. And we can see here we don't even have to do the conversion. So, when I said I wanted to display it in Fahrenheit, I was thinking maybe it would do the 9 by32 and do the conversion, pop it out. But it looks like we can just change our API call, which is even simpler and easier to do. So, I'm going to say, yeah, let's let's make this edit. And now we're getting into the the meat of the API application here. And it says, do you want to make these edits? So, it's going to pull some of this stuff out of Maine and it's going to move it around. We've got an asynchronous function here. Get weather per city and it's yeah, it's kind of shifting things around. All of this looks really good at a glance. And if it doesn't work perfectly the first time, we'll debug it and figure out why. But I think this is going to work. It says here, we're going to pull out this debug information. Now, this debug information when we added it and made it work. So, we'll go ahead and pull it out of there, but that may not be a great idea. Okay, it says here we can convert it to fast API. So, I need to install fast API and unicorn. We've already exported the key here. We need to do unicorn weather app reload. So, we'll just do that. Clear this. say pip install fast API. Awesome. And we're just going to copy this. We're going to pretend we've never used Unicorn before. Copy it to see if Claude gave us the right command to run it. And here we go. Now we have Unicorn running on 127800. So we can send this a request with a city. Let's see what it returns. Okay, now I've got my favorite API testing tool, Postman, open here, and we're just going to send a get request to localhost 8000/weather with the city name. And you can see here it brings back Forest Grove with coordinates latitude and longitude. Temperature 60.76 Fahrenheit. conditions overcast with clouds, which if I look outside, I can see that's pretty accurate. So, this is great. So, in this demo, I wanted to show how easy it is to work with APIs. Now, you can't plug in an API directly into cloud code like you can with some other generative AI tools. However, you can call APIs, use that data, make APIs, things like that. Very simple. So, Cloud Code is very aware of APIs and other services and how to create them. In this one, we had a little bit of a hiccup that may have been from the service that we signed up and maybe when I generated the API key, something like that, but Cloud Code was able to handle it, fix it for us, and get it going. So, thank you for watching. Now, in this section of the course, we're going to look at auditing for software quality, and we're going to do that with cloud code. Now, if you've worked in enterprise software development, obviously code reviews, code quality reviews, things like that are extremely common and they've been doing this for decades. Looking for things like architecture, design patterns, error handling, fault tolerance. All of these things are things that human beings have checked for for years. And sometimes that's their full-time job, right? where they go through and and look for particular bad patterns, bad smells, code duplication, things like that. And then sometimes we have tools that do it, right? Automated tools. Well, Claude Code just happens to be the ultimate automated tool for doing this as you'll see in this section because we're going to review our software package and we're going to look for very specific items. Now, first we're going to do a broadbased kind of overall type of report and then we're going to drill down. We're going to really hone in on some very particular things. Now, in order to do this, we are going to be using some pretty long prompts. Now, rather than saying, you know, watch along and type in these long gigantic prompts, I made them available here at github.com/jeremyorggan/claudecode reviewing prompts. And you'll find all the prompts here for uh both our software reviewing and our security reviewing. So let's get started with the first one. Now what I'm going to do is I'm going to dump the prompt in here. As you can see, it's 41 lines. And then as it's running and evaluating our software, we'll kind of walk through what we're doing in this prompt. So it's kicking off. Now here we're saying analyze the project architecture and identify is there clear separation of concerns. Which architectural pattern is used? Are there any god objects or modules doing too much? Is the dependency flow clean with no circular dependencies? Rate the modularity with justification. And it says create an architecture diagram showing layer dependencies, data flow, external service integrations, potential bottlenecks. Identify adder anti-patterns like spaghetti code, copy paste programming, god classes, modules, tight coupling, and missing abstractions. And then provide a structured finding report, a scale of 1 to 10 on how important each finding is, precise code level fix or config change, snippets, welcome, plus defense in-depth guidance. Now for constraints and style, we want to be concrete and site exact code locations and identifiers. We prefer minimal drop-in fix snippets over pros, which may not always be possible, right? This one is really important that we need to do. We need to put in this prompt. Do not invent files or functions that aren't present. If context is missing, Mark is unable to verify and say what code would prove it. Write this into a markdown file and place it in the audits folder. Now, we can see here that Claude is analyzing the project architecture, identifying design patterns, antiatterns, and areas for improvement. And it goes through and explores all of our code. We've got some to-do lists here. And we can see here that we already have software design architecture analysis. And I'm going to select yes because it's asking if it wants to write that. And then we'll take a look at it. Okay. And here we have in the audits folder software design and architecture analysis report. So let's take a look at it. Says here the express login demo follows a basic MVC inspired architecture but suffers from significant design limitations. The application demonstrates minimal separation of concerns with most business logic embedded directly in route handlers. It lacks proper abstraction layers and has no comprehensive error handling strategy. Now that's terrible news, right? We don't really like that much. But let's take a look at it goes even deeper. Minimal MVC inspired architecture. Model layer, view layer, controller layer. That's somewhat MVC. You know, it's pretty close. And then here, separation of concern score, we got three out of 10. Business logic is mixed with route handling. Data access logic is embedded in controllers. The whole skinny controllers thing, something that's often hard to stick with. No service layer abstraction and basic database configuration is separated. So that's good. Shows the project structure, modularity score, extremely flat structure with minimal organization. Single route file contains all authentication logic and no abstraction layers for business logic. Database schema is separate but not versioned. So that is something that's important. Now here we can take this and make a mermaid graph out of the data flow. Right? So it's provided that for us in case we want to crack this open and do something with the mermaid document. The key issues all business logic is concentrated in a single route handler. No service layer for authentication logic. direct database access from routes and no middleware abstraction for common operations. Here we have some anti-atterns that are identified right so we have a god object in module that is an 8 out of 10 severity it's an offjs and it makes testing difficult violates SRP hard to maintain right and SRP is single responsibility principle do one thing and do it well this is doing several things so we're not really sure how well it's doing all of those several things here's the remediation how we can separate it and we can put this off into services and have the router just point to the services. Number two, primitive obsession, it says. And this is an ojs. We have select where email equals that's a SQL injection point which we'll find in our security audits. This is a vulnerability for SQL injection here. Remediation. Here's how to fix it. We have copy paste programming, duplicated error response pattern, centralized error handling middleware. Number four, the concern magic numbers and strings, right? So here we have a lot of stuff that comes from constants is length is a magic number, magic status codes, magic time string, tight coupling, something we always try to avoid. Uh we do have tight coupling with direct database pool import, hard-coded express validator usage and direct brypt JWT dependencies. So these are tight coupling which means any change to either side of those is going to cause problems in the future. Shows how we can remediate that. We have an architecture diagram here which is pretty straightforward and then a list of our problems. No abstraction layers, no service layer, no data access layer, no error handling middleware. Now it also goes into potential bottlenecks, right? There's a single database connection pool. No connection limit management, which means we could have 100,000 people connect at once. And guess what's going to happen with our application? It's going to crash. We have synchronous password hashing blocks the event loop. We have no caching layer. So every request hits the database. Again, 10,000 people, probably less than that, probably a thousand people will crash our application right now. And there's no rate limiting. So we're vulnerable to brute force attacks, right? So brute force is basically putting in a username and password over and over and over and over. We have no rate limiting. So they can do that as much as they want. Here's some of the detailed findings with our high priority issues, medium priority issues, and low priority issues. Now next, this kind of is what takes it out of a standard report and it goes into recommended improvements. We should have a routes layer, controller, services, data access layer, and a models layer. Here's the proposed directory structure where we can put all of these things and then kind of shows the dependency flow, right? Controller, services, repositories, database, models, models, models. And that's kind of a neat little diagram for dependency. Now, it also adds some in-depth security recommendations, and we're going to go in depth with security soon, but this is saying input validation layer, service layer security, centralized error handling. It gives us a bunch of suggestions to make things a little bit more secure on that side of things. So our final assessment, it's a basic functioning application with significant architectural debt. What is architectural debt? Well, that means things that are small problems now, but after years of maintenance and updates and refactoring. After a while, you're going to have what's called architectural debt, which means, "I'm sorry, I can't change anything because it'll take us 3 days to fix everything that it breaks." That's architectural debt. Technical debt, same thing. Essentially technical debt is what people talk about the most which is any changes costs so much that after a while you stop uh making feature changes and bug fixes so fast because it'll break and this is high right refactoring is required for scalability maintainability is low it's a monolithic structure impedes development testability tight coupling makes unit testing difficult scalability architecture doesn't report feature growth. So, gives us a set of immediate actions here, some long-term architecture goals, and these are things we can put this entire report into cloud code and say, "Hey, help me with this. Help me make my score better." And then it will do that for you. So, this is our initial software design analysis. Let's dig deeper on some software design principles with our prompts and see what kind of results we get and some suggestions we get to make this a better application. So, in this section, we're doing reviews of software. And we're doing very common software reviews that you would often do with your code, whether it's legacy code or green field code. And these are just some basic reviews to make sure that your software that you're building is good and extensible and secure and all that fun stuff. So, next what we're going to do is reviewing the codebase for design pattern usage. We're going to look and see what kind of patterns are found. Is it appropriate? Is it being implemented correctly? That sort of thing. So, as I've done before here, I'm going to paste in the prompt, hit enter, and while it's working, we'll investigate this prompt, and we'll look and see what kind of report we're building. So, we have here the start of the prompt. Review the codebase for design pattern usage. Identify and evaluate creational patterns, structural patterns, behavioral patterns, and domain patterns. Now if we look at this like creational pattern are we using singletons database connections loggers etc a factory pattern for object creation a builder pattern for complex objects and are they implemented correctly very important we have the same thing for structural patterns where we have adapter facade decorator proxy we're just basically looking through and saying are these patterns being used and are they being implemented correctly and here we can say for each pattern found is it appropriate ate for the use case. Is it implemented correctly? Could a simpler solution work? Now, this is a big one, right? Because sometimes with design patterns, it's like, well, we could implement this really fancy, nice pattern, or we could just do X that's much simpler with less code and achieves the same thing. Sometimes that's the right call to make. And and here we're going to provide a structured finding report with a scale of 1 to 10. Um, just like we did with our previous report. And now we can take a look at it. And it is still forging. So, it's still analyzing all of our software at this time. Now, it says, "Do you want to make this edit to design pattern analysis MD?" Yes, I do. And we're going to take a look at that. We're going to see what it found. We're here in design pattern analysis report. Let's take a look at it. This report analyzes the design patterns implemented in the express login demo application, evaluating their correctness, appropriateness, and identifying areas for improvement. Now, it shows the project structure. This was kind of what our last one did and a lot of these reports will show you your project structure sometimes in a different context but it always shows you how your project structure is set up and for creational patterns well we found a singleton pattern in the PostgresSQL connection pool correctly implemented appropriate use case and proper connect and error event listeners so that's good working correctly no changes needed factory pattern n pattern patterns detected, but we could benefit from the JW token factory for different token types. User object creation could also use a factory pattern. So recommendation add the JWT token factory. Builder pattern also not present. Express validator chains show builder like pattern but from the library. No complex object construction requiring a builder pattern. Current application complexity doesn't warrant builder pattern. Now this is important and we see it. This comes into another, you know, we're going to throw out some different terms here and some different acronyms and Yagy is one of them. You aren't going to need it. We're going to see that here with Claude apparently because it says, "Hey, we don't have a builder pattern here, but we also don't need one." So, we're not going to, you know, Claude isn't going to suggest throwing in a builder pattern just for the heck of it. Now, if we look at structural patterns, the facade pattern, we found that with our Express router, and it's well implemented. It provides a clean interface to authentication operations. Simplifies HTTP handling complexity. And the O route acts as a facade for authentication complexity. That's great. It's working well. No changes needed. And we can see here we have a decorator pattern that's in our Express middleware chain. This one is also correctly implemented. Has good separation of concerns. And it says ears a caution. Missing O middleware. We don't have any JWT verification middleware. So that's a good way. It shows here how we can remediate that with the JavaScript. Now if we look at proxy pattern not implemented, but we could because it says there's no caching layer for database queries, we could add a query caching proxy and it shows how to do that. And that recommendation 6 out of 10. Now if we look at behavioral patterns, so we have the design patterns, how things are set up, how they're architected, but the behavioral patterns are also some patterns that this tool looks at. And it says chain of responsibility. We found it with the express metal alert chain properly implemented. Good error propagation working correctly. We're missing a strategy pattern because it's single authentication strategy only. So it says only email password authentication no multiple off strategies error handling uses conditional logic instead of strategy pattern. So it does recommend implement authentication strategy pattern here and shows a way that you can do that observer pattern. Here's another one that we're looking at here and we found that with emitter usage and it says it's correctly used. Database events are properly handled but it's limited scope. only database events, no application events, couldn't expand user authentication events. So, it says to add an application event system, which is obviously this is just a login app where you log in and log out. Uh, so we don't have an application event system yet, but we would want one if we were to make this a more complex application. Command pattern not implemented, not critical for current scope. So, again, you aren't going to need it. Now we can take a look at domain patterns in here for the repository pattern. We're missing this for direct database queries in routes. Now this is something that was called out in the previous one also. We have direct database queries in our routes which causes a bunch of problems. It's a violation of separation of concerns. There's no abstraction there. And abstraction is very important with software design. You know, you want to be able to take the end of your cord and plug it into a wall into a 110 interface and have your device turn on. You don't want to think about is it 110, is it singlephase, is amperage, etc. That's where abstraction comes in and there's no abstraction with this and it's hard to test because it's tightly coupled to the database. Meaning, if we were to switch databases, we got to go in and modify routes and do all kinds of stuff. So, n out of 10 critical refactoring needed. And here's how we can refactor it. Now here we can look at the service layer pattern. This one's missing and it's missing business logic and route handlers. Critical for maintainability, right? Authentication logic again is in the route handler. Direct manipulation and controllers and that's the database thing we just talked about. And logic is tied to the HTTP layer. All of this is critical for maintainability. So this stuff doesn't have uh business logic, you know, separated out into its own layer. And so this is how it's recommending we do that. Now the DTO pattern data transfer objects partially implemented manual object construction, but it's an informal implementation because it's manual. There's no validation, no type safety. It says improve data transfer objects and shows us how we can do that. And then we see the domain model pattern. It says anemic domain, which is not a great thing to read, right? No business logic in the entities. There's no domain entities. There's no business logic encapsulation. There's no domain validation. We don't really have a domain. It's just a login app where you log in with your name and password. But this has definitely come in here and said even with the minimal functionality that you have, you should have this pattern. So here's a summary and recommendation. So we have the critical issues. The biggest stuff is repository pattern missing, service layer missing, high priority stuff, authentication strategy, authentication middleware, factory pattern for tokens, and it goes down to medium priority, low priority, and recommended refactoring order. So it says, hey, here's how you should do it in the order you should do it. You should extract the repository layer, then create a service layer, etc. This refactoring would transform the application from a simple script-like structure to a wellarchchitected maintainable system following established patterns. And I've said this before and I'll say it again. This is something you can take this report and copy and paste it into cloud code and tell cloud code, help me make this software more like what you're suggesting here and make it pass better on this test. And again, all of these prompts, you're not going to have to try to type them out or copy them or transcribe them or something. Uh, they're all available here at github.com/jeremyorggan/cloudcode reviewing prompts. So, let's take a look at the next one. This one has been a really helpful one for design patterns. It's basically saying, what ones are you using? What ones should you be using? I think this kind of stuff makes your code better. It really does. It gives you the things to think about and the things to look for. And that's exactly what we're trying to do in this section of the course. All right. So, we've done a series of audits here that check our software quality. It checks things like our architecture, design patterns, domain patterns, etc. Now, this is one of my favorite checks. And this one is basically evaluating your application for how it adheres to solid principles, right? And so, solid principles, we'll explain that if you don't know what that is. We'll kind of go through it, but I am going to copy in the prompt here, which is 47 lines. And then while it's processing the prompt and it's looking at our application, I'll explain exactly what it is. So, we'll hit enter. We'll bring this up. And basically here we're saying evaluate this application and its adherence to solid principles. Solid principles are single responsibility, open closed principle, list substitution, interface segregation and dependency inversion. So the first thing it checks for is single responsibility. And the single responsibility principle is a class or module should only do one thing and do it well. Now the reason for this is because that way it only has one reason to change, right? So if the module only has one single responsibility, right, you had only one job. Well, if it has that responsibility, then it only has one reason to change. And this is very important for software design at both a macro level and a micro level. The opencloed principle. Now, this one's pretty important as software starts to grow and get big. code should be open for adding new features but closed to modifying existing core logic. Right? So in other words, you should be able to add new stuff to it, but you shouldn't be able to change the core logic because when you change the core logic, that's when you start to get regression and dependency problems and things like that. So the core logic of the module should always stay the same. Liskov substitution. If something works with a base class, it should also work with any of those subclasses without breaking. So, if you're familiar with object-oriented programming, you have a base class. Um, and it has a set of uh properties and methods. And that base class, anything that comes off of that base class should work with any of the subclasses. And that's basically just keeping a solid design. Interface segregation principle just means don't force things to depend on methods that they don't use. Right? So if you make something depend on something else somewhere else that it's not using then your interfaces can have problems and a lot of this comes in during testing and dependency inversion principle depend on abstractions right we've talked about abstractions in the last couple of videos you know and I used a electrical outlet as an abstraction you want to depend on abstractions which are basically general rules but not concrete implementations So code is more flexible and testable. So you're depending on an abstraction like a wall plugin. But if it's a concrete implementation and it's ultra specific, then you're going to run into problems. So these are the solid principles that we're looking for. And now how do we check it? Well, with our prompt here, we can say with single responsibility, does each module have one reason to change? I mean, that one really cuts down to kind of the core of what SRP is. And then it identifies modules that are violating that and it gives an example a user controller that also handles emails, payments and authentication. Now with the o openlo principle we say can we extend this without modifying it right? So can we add features to this without changing the core functionality? Are there hard-coded switch statements that should be polymorphic? Check for if else chains that could be strategy pattern. Now with Liskov substitution, do the derived classes properly extend the base classes? Now it sounds simple. It sounds like you know your application wouldn't work if that were the case. But if you've been in software engineering long enough, then you know that this is a very valid concern. Derived classes can extend base classes in funky ways and those funky ways cause problems when you go to scale. And we're saying are there any violations of expected behavior here? Now with interface segregation, are interfaces too large? This is a problem very common problem in software engineering that sometimes interfaces become enormous. And one way that I've described this in the past when talking about it is you have a remote control and it has 493 buttons and you have to press these buttons and all these different combinations, but really the person holding the remote only wants to watch TV. So you can easily get out of touch with what an interface is supposed to do. and over complicate it and you can make it so that there comes those weird dependencies again on functions you don't use. So in here we're saying are the interfaces too large which is somewhat subjective but cloud code knows what to look for and knows how to make an estimation and do clients depend on methods that they don't use. So that's one of the things where you can lock up an interface by saying it requires all these methods and if it doesn't use them then it can cause big dependency problems down the line. And for dependency inversion are we depending on abstractions or concretions? Is there proper dependency injection? This this gets really important during testing especially if we don't have proper dependency injection there's going to be a lot of stuff that we're not going to be able to test. And we want to check for new keyword uses versus injections, right? So we want to see if there's, you know, new stuff going on where we're creating things rather than injecting the things it depends on. We're hard coding it there in the methods. So here we're saying rate solid compliance 1 to 10 with specific violations and fixes. And then we have our standard report thing here where it says structured finding report, precise code level fix, etc. So we've seen that before. Now we can see it's gone through all of our files and it says, "Do you want to make this edit to solid compliance report?" Yeah. Yeah, we do. Let's check it out. So, we're going to go in here to audits, solid compliance report. Let's see what Claude found for us. Now it says this express authentication application demonstrates a basic understanding of separation of concerns but it has significant violations across all solid principles. So this wasn't something that I was expecting. However, we have to remember where this code is coming from and it's coming from samples of other people's code. So all these public GitHub repositories, public software all over the place, blog posts, YouTube videos, all of this code is ingested by these LLMs and it's averaged out and sometimes bad code can make it right to the top and say, you know what, this is how everybody does this method. And everybody could be doing it in a terrible way publicly and putting it on their GitHub and putting it on their blog and everything else. So that's one of the things to remember. So you might be saying, well, why is Claude code putting out code that it doesn't even approve of? Well, because these are two separate processes. When we ask it to generate code, it's generate based on what kind of code it's seen and how it's seen it used. When we're putting in these reports and we're doing these audits, it's basically saying, "Oh, now I need to look for these things based on what I know about these things." So this one goes into some pretty detailed stuff because as I mentioned we are violating all the solid principles. So let's take a look. Violations identified high severity monolithic o route handler. Again we're talking about our o handler which seems to be ostensibly terrible at this point and it's a single function that handles validation, authentication, database queries, JWT generation and error handling. Now earlier we did an audit where it talked about the database queries in in the routes and how that was a bad thing. This is giving us more detail which is exactly why I ran the first kind of overall look at the software stuff and then now we're going down into detail. Now we can find out that yeah there were definitely database queries and raw SQL in our routes but this is digging down even deeper and saying there's one function that has authentication database queries JWT generation and error handling all things that should be abstracted. So the reasons to change input validation changes authentication logic changes anything changes this method breaks and so that's exactly why this one is a high severity and they're wanting to address it and it shows some ways to address it. Now let's look at a medium severity one database module mixing concerns. Database connection handles both connection management and logging. This is not something that was brought up in a previous audit. So this is very helpful and this is exactly why we're kind of drilling down and doing these more detailed audits. It's basically saying the database connection handles connection management and logging and there's a lot of mixing concerns there and that violates the opencloed principle. The issue is adding new database error types requires modifying existing code. So again, we're modifying the core functionality of the code whenever we try to add anything new. And it shows a remediation for that and how to fix it. Here's another one. No authentication strategy abstraction cannot extend to support OOTH, LDAP, or any other O methods without modification. Now, this is super important because if this were a real application that we're building and deploying into the enterprise, then we're going to want OOTH. We're going to want LDAP. We're going to want things like that. And this isn't possible without coming up with some kind of strategy pattern. I mean, it's possible, but it's not possible in a clean way. So, that's one of the things that we want to look at here in a Liskoff substitution principle. Our score of 6 out of 10 limited inheritance in the codebase but some issues present and then here's a bunch of different issues that kind of relate to that list of substitution principle pool connection interface direct instantiation of pool prevents substitution with mock or different database clients. Now why are we going to use a mock? Obviously for testing so testing is going to be very difficult with the way this is designed right now. If we're going to do thorough testing with 100% code coverage, this is going to be a problem. But the great thing is here's our remediation. It shows how we can solve that problem. Now, the interface segregation principle, it says JavaScript's duct typing limits traditional interface violations, but conceptual issues exist. So, in other words, this could work and there's not a lot we can do when it comes to JavaScript. You know, this isn't something like Java or C. So there is some definite limits here, but it says, you know, route handlers depend on the entire express wre objects when they only need specific properties. Handlers are tied to express specific methods that they may not use. So once again, we're talking about dependency on methods that we don't use and it offers some remediation here. Now, dependency inversion principle, this is the the final one. They talk about major violations. It says here 10 out of 10 direct database dependency again it's very upset about the database connections in the authentication routes right so putting things into routes this is very poor I took a few tutorials and put it together type of design here um and I'm not trying to insult cloud's output because it's based on what it's seen but we can see here the issue is highle o off module depends on low-level database implementation right directly in the O module. What's the point of abstracting that database implementation and taking it out of the O module? The biggest most brightest reason for doing that is switching database providers. So if you have PostgreSQL and you've got a bunch of code with it and you want to change it to Mariab or you want to change it to Firebase or something, you're going to have to go in and blow that route apart and possibly affect your routing. Whereas if you separated it out and abstracted it into its own class with a set of methods, you could take the new database right in those implementation methods using that same method signature, same interface and you can plug it right in with a couple of lines of code changed. You plug in this new module, it's good to go. We can't do that with our existing application. That's why it's a 10 out of 10 direct database dependency problem. And it shows here's how to fix it. You know, we can create a repository pattern here with PostgresSQL that extends user repository. So if you wanted to put in something for Mariab, you guessed it, Maria user repository extends user repository. So on and so forth. Here's another high severity 9 out of 10 direct environment variable dependencies. So we're accessing process.anv. You can't test with different configurations without environment manipulation. Now, you want your tests to be encapsulated pretty much independent of the environment entirely if possible. And so, this is a way to basically say you need to get away from these dependencies on the environment. We want to containerize this in a way either formally containerize it in Docker or containerize it conceptually and move away from that. and it shows how to do that where you can inject a dependency instead. And so that's great. We've got a few more here. We've got a high severity hard-coded crypto dependencies, direct brypt and JWT imports. That's also a security concern, but in this case, we can't mock or substitute crypto implementations for testing. So, this one is another one that will throw us some problems if we try to make tests. Now the idea is you want to make tests and you want to have good test coverage which means you want tests to cover the majority of the code you've written. And in our case with these problems that we found from the software audit we have work to do before we can get to that point. Specifically critically immediately we need to extract the authentication service implement the repository pattern and create a configuration service. After that high priority which means we better get this done pretty quick. We want to implement an error handler strategy, right? Replace this switch statement with an extensible pattern um that we can take these errors and form them into objects that we can use and put them into other areas. We want to extract that JWT service. We don't want that hardcoded in there like it is right now. Same thing with the validation service. We want to separate that logic. And then medium priority. This one, you know, after we get everything else done, we want to create some authentication strategies. Support multiple off methods. When's the last time in 2025 you've come across an application that only had a single method for authentication? Most of the time there are several. You want to implement service containers for proper dependency injection. That's really going to help you with your tests. And you want to reduce the coupling between layers, which helps with tests and expanding your software. Here's the recommended architecture where it says this is how we should set it up file-wise etc. And code quality metrics. It talks a little bit about how it came to this conclusion. Cyclomatic complexity. That's something that software engineers talk about all the time. What is your cyclomatic complexity? Well, in our case, it's high. We have a login function that has eight plus decision points from a switch statement. We know from earlier. So, yeah, that's messy. That's not optimal. Lines per function excessive. Login function is 79 lines long. Now, there's a few idioms out there and kind of quotes that they say like keep your controller skinny and things like that. And one of those things is lines per function is huge. Keep your function small. Do one thing and do it well. When it needs to change, it should only be that one thing to change. That comes into lines per function. Personally, 79 lines of function seems very excessive to me because it's not doing one thing and doing it one well if it takes 79 lines to do that thing, right? So, we know that it's doing multiple things and this report actually shows that, you know, earlier it's doing multiple things in one function. We don't want that. Uh we've got some high coupling direct dependencies, the five plus modules and it's dependencies to stuff that we're not necessarily using. Testability is poor. Like I said, if we want to get to 100% test coverage, this will be very difficult and we've got a lot of work to do. This report tells us that. So, I'm really glad that Claude can go through and kind of go through all of these different principles. And this is just a solid test, right? There's a bunch of other tests that we're going to go through, but this is just a solid test that I think you should run on every single application you generate with Cloud write yourself. I did some personal stuff where I grabbed some of my old repositories and started running some of these audits and I found, wow, I missed a lot of things and there's a lot of work to do. So, this is one of those things in an enterprise, I guarantee you're going to find it. And once again, if you're just watching this video and you haven't watched our previous videos, you don't have to type these giant prompts in because they're all available here at github.com/jeremyorggan reviewing prompts. Thank you for watching. Now let's jump into the next part which is error handling and resilience. A huge part of software engineering that cloud code can really help you out with. Okay, let's talk about a very important audit here. Now, we've been doing audits on our software quality, and we've gone from here's an abstract like tell me generally what's wrong based on these principles and now we're starting to narrow it down to very detailed principles because we want to know. And when we do this, you know, by taking this approach, we're going to see some repeated information cuz we're basically saying, look at this entire software project and tell me what's wrong with it. And then we start to narrow down, you know, tell me, does it violate these principles? Does it violate these design patterns etc? And now we're talking about one that's very important which is error handling and resilience. How resilient is our application? Well, error handling is a big part of it. Error handling can be a big problem because it can result in unsaved data. It can result in frustrated users and it can have security implementations. So, this one is pretty big. And this prompt is specific towards JavaScript and API applications. So, keep that in mind. And again, I'm going to paste this in. Hit enter. And then we're going to look at the prompt while it chews through our software and takes a look at it. Now, in this prompt, we're saying evaluate this entire software package and perform a comprehensive error handling review on these subjects. Error handling consistency. Is there a centralized error handler? You know, are we just console logging this? Are we logging it to a file? Are we just exploding on the screen and telling the user, "Sorry, but here's a bunch of information. Are errors handled uniformly? Do we have custom error classes versus generic errors?" And then we have error categories here. And these are all pretty specific to web-based stuff, right? 400, 401, 403, etc. Are they properly categorized? Now, this one's important. Sometimes people like to just kind of dump everything into that server 500. I've seen that before with APIs where they're like, "Well, we'll just give them a 400 and call it a day." But there are definitely other errors that need to be considered, specifically rate limit errors. I've seen rate limit errors dumped into just general server errors. Same with authentication and authorization. So, this is basically saying, are we splitting it into categories and are we doing that properly? Async error handling. Now, asynchronous functions are all over the place, especially in web applications. Are we handling unhandled promise rejections? That's something that if you've developed a web app at any point in your life, you've probably seen a bunch of those. Async middleware wrapper usage, little less common. Callback error handling, very common. Event emitter error handling, very common. We're just trying to see, are we doing this properly? Are we doing this in a sane and simple way? Error recovery. And this kind of goes back to the losing data, exposing secrets for security issues. You know, how are we recovering? Are we doing a graceful degradation of our errors, retry mechanisms, circuit breakers, fallback strategies, or are we just dumping a big dump of information on the screen? Hopefully not. And error information, we have development versus production error details. This is very important because the needs of each are quite different. Stack trace exposure. Are we doing that? Do we want to expose a stack trace? Perfectly fine in development. No can do in production. Error logging completeness. User friendly error messages. So this kind of goes back to a little bit with security and user interface. The user friendly error messages. Are we just throwing a stack trace up there? The user is not going to know what to do with that, but an attacker will. So this is where the error information, who gets what type of information is very important. And of course, we're providing a report. And if we scroll down here, it says, "Do you want to make this edit to error handling comprehensive review?" Yes. And we do want to check out that comprehensive review. Now, if we look at this executive summary, our overall score is 3.5 out of 10, which is not great. The express login demo exhibits severe error handling vulnerabilities that create significant security risks and operational challenges. So as I said earlier, we're risking losing data, frustrating the customer and security risks. And according to this audit, we are not doing well. We're failing on error handling consistency. We're partially failing in error categories. We have basic HTTP codes, but we're missing categorization. Async error handling, we're failing that. There's no unhandled rejection protection. Uh error recovery fail. There's no retry fallback or circuit breaker patterns. These are all important things because sometimes a glitch is a glitch and it just happens. And there are times where there are timing issues or there's some service that's just doesn't put out the right thing at the right time, but if we retry it, everything is great. And that's where this basically comes in is we need a retry, we need a fallback. If something fails, we'll try this or the circuit breaker pattern to just make sure cuz sometimes a small glitch can completely take down the user and what they're trying to do and they'll get frustrated and close out and stop using your application. Error information partial. there's sensitive data exposure and logs which is a security problem and we're going to do a lot of security editing and auditing in our next module. Let's just take a quick look at the problems that we're having here. Critical no centralized error handler errors are just kind of, you know, sometimes they're going here, sometimes they're going there, and the error responses are inconsistent. But here we go. Current state and remediation. So here's how we can fix it. Medium inconsistent error response format. This is another one. If you don't have a consistent error response format, you know, there's really it really makes logging in presentation quite difficult, especially when you get an error that you're not anticipating and it just dumps a bunch of random stuff on the screen. So this is basically saying the remediation is a standardized error response utility. Here's another one here that's kind of medium. Basic HTTP status code usage. We talked about this a little bit. Current status. Yeah, we've got a 400 bad request, which is great. 401 unauthorized, which is great. So, those two are separated out. The 500 internal server error is great for generic stuff. And then we have a 503 service unavailable, which in this case it says used for database errors, which that can usually be true. Usually, it's database that causes that. But we don't have a 403 forbidden if you're not supposed to be looking at the resource that you're trying to access. We don't have a 404 not found, which can be pretty important. We don't have a 429 too many requests. So if somebody sends too many requests, it's just going to get a 500 error. And we have a 409 conflict where we don't have anything there. If we have a conflict error, here's how we can remediate that. gives us a nice full explanation. Now, async error handling, like I said, with everything web-based these days, async is super important. Uh, we have no unhandled promise rejection protection, which comes up quite frequently. We're missing global handlers, handlers for unhandled rejections. So, when we have a promise rejection, it just dumps out into the console and the application doesn't work. Now we're missing async wrapper middleware which that was mentioned in an earlier audit here. So we have manual try catch blocks and async routes. We're basically we don't have any middleware. We don't have anything that's really handling this async with the respect that it deserves. Another critical one, no retry mechanisms, which we know about that. It's not trying to, you know, redo if there's a timing issue, if there's a race condition, if there's something like that. Our application just gives up and says, couldn't work where it should try to retry and make things happen again. Another critical one, no circuit breaker pattern. So, there's no protection against database cascade failures. What does that mean? Well, we can have a failure happen that can go across and rip our database apart. Basically, there's no circuit breaker and a circuit breaker pattern essentially says, "Oh, if these certain things have gone wrong, then just cut it all off and stop the operation." We don't have that here. So, the operation will continue and may cause some pretty severe damage. But, we have remediation here. So, these reports are fantastic. We have sensitive information disclosure. This one is pretty big for security. It'll say full error objects and database details log. So if somebody's trying to figure out how our database is set up, what database we're using, they can just check our logs, right? If we've had any errors, it gives them everything they need to know. We have no structured logging, by the way. So our logs are going to be a bunch of random stuff dumped into a text file and or console.log. And here it says applicationwide. It only uses console log error statements. So in this case, we may not even be logging this in an actual file that you can look at. It's just going in the console on all the clients that are connecting to it. Not great, not optimal. Development versus production error handling. Again, during development, we want to expose everything, right? So if there's an error, we want to show the stack trace. We want to show the log entries. We want to show every bit of information so that the developer, he or she can look at that and say, "Okay, here are the problems. Let's dig into it." We don't want that in production. In production, we want that to say, "Something went bad. Let us try it again." Or, "Something went bad. Please contact support." We don't want it to dump out all this stuff that attackers can use. So, that's what that one's all about. And it gives us a plan. We need to implement centralized error handler. We need to add unhandled promise rejection protection and sanitize error logging as soon as possible. Then we can implement async wrapper middleware structured logging. Create some error response standards which there are tons of them available on the internet that you can look up or cla itself I'm sure can come up with a pretty good framework for that. We want to implement database retry logic. Add a circuit breaker in there or many circuit breakers. Implement graceful degradation, comprehensive error categories and environment specific error handlings shows us how to do that. What do we get from this? If we run this and we fix all these things, we get improved system reliability, reduce security risk, better debugging capabilities, and production readiness. We're starting to realize after doing these software audits that this is not a production ready application. When you saw the application earlier, it probably looked pretty good. Maybe it works pretty good, but it's not quite production ready. And that's the whole point of these audits is we want to make sure that this is production ready software. Now, we've taken a look at error handling and how errors are handled, but what about exceptions? There's a difference between exceptions and errors. And if you're a software developer or software engineer, you already know that. So let's see how we handle exceptions and whether that's acceptable and we can do that with another cool prompt that we can send cloud code. Thank you for watching. I'll see you in the next one. Okay, so we've talked about errors in a program and we all know what errors are and how they're defined. Exceptions are a little bit different. And exceptions are basically when the software is going to try to do something and if all the cards aren't lined up and all of the things aren't exactly how they should be, then it catches that and says, "Hey, something's wrong. Here's what it is." And it writes it out to a log or it writes it out to the screen or something like that. And not all exceptions are, you know, big deals where they stop everything. Sometimes they're just kind of small things where we retry. And so what we're going to do here is we're going to do an audit of how our application handles exceptions. Basically, how does it catch the errors? What does it do with them? Is it consistent? Things like that. So we're going to dump the prompt in here as we have before. And while Claude is processing and going through our app, we'll take a look at this prompt. And it says, "Evaluate this entire application. Trace error flow through the application." And so we have some critical paths to analyze. Database connection failure, third-party API timeout, invalid user input, authentication failure, and file system errors. Now, this is just kind of a generic type of thing for applications like this. We're looking through these things. They may not all be applicable to this particular application, but these are the things that we're going to look for. We're going to look for what happens when one of these things happens for each bath. We want to verify where's the error caught, how's it transformed, you know, what do we do with the error? Do we pretty print it somewhere? Do we log it? Do we strip out all the PII stuff like that? What gets logged? Uh what does the user see? So, that's usually two different things, right? Because we don't want to give away things to the user that might expose how things work underneath or exposes PII or something like that. So sometimes we log things that we wouldn't necessarily show the user. And finally, is the system state consistent? This is a big one because the system state sometimes you can catch exceptions and it can say, "Okay, we're shut down now. Please log out and log back in later or something like that." And then sometimes an exception can just take down the whole thing and the whole service stops and you're in a bad spot. So we're asking all these questions with this audit here. And it says create an error flow diagram showing error origin points, transformation layers, final handling points, recovery mechanisms. And we want to take a look at some anti-atterns, right? Some swallowed exceptions, which are empty catch blocks. If you've been programming for any amount of time, you know exactly what an empty catch block is. It's basically like, hey, if there's an exception, do nothing and just keep going, keep moving through. uh not a great situation to have that set up. Uh generic catch all handlers that hide specific errors. So that's always a problem if you dump all of your errors into the same bucket. Um you don't have any kind of differentiation between them. Sometimes you can miss things and in many languages you need to catch specific errors to get specific info from the exception. We have errors used for flow control. Now this one we are I remember looking through this code I know that we're going to find this and basically what errors use for flow control is if this is an error 400 do this if it's error 404 do this if it's error 200 do this the problem with that is you were tightly bound to the actual error codes and text not really good we have missing error boundaries and what that is is basically where an error happens somewhere down in a child component and the error comes back somewhere else upwards in the tree and it's not really specific. And we have inconsistent error formats which is obviously you know some errors have this plain text message in the code some of them don't etc. We want that standardized and we want to provide a standardized error handling template. Meaning what can we build with JavaScript in this case that can just catch errors as they come out and catch exceptions and handle them in a consistent and solid way that we can depend on that we can use for testing and knowing what to expect. And then of course we're doing this report that we've done throughout our other ones where we say provide a structured finding report, code level fix, etc. So let's scroll down here. Yes, we want to build the error flow audit document. And this one is going to be errorflow comprehensive analysis MD. Let's scroll up and take a look at it. This report provides a complete analysis of error handling patterns throughout the express login demo application. Now, this evaluation traces error flows from origin points through transformation layers to final handling, identifying critical gaps in error management and system resilience. Just a big paragraph that says we're going to check and see how you handle exceptions and make sure it's consistent. Now the critical finding is this application exhibits multiple high severity error handling vulnerabilities that can lead to service disruption, information disclosure and inconsistent state. Now these are the three things that we talked about right when we're talking about displaying errors. You know we can have error problems that will stop the service. If we're not handling an exception properly it can break everything, break the service. we have information being shown to users or in logs that should not be shown and an inconsistent system state means you know sometimes an exception does nothing and sometimes it takes everything down we want a little bit more uh security than that right so in our entry path analysis we've got an HTTP server without timeout limits we've got a single post login endpoint postgres SQL pool without a timeout configuration the timeouts are big. We've already seen reports where they're talking about timeouts. They're super easy to add, but we don't have any in our current application. And it says dependencies, Express 4212, JWT authentication, PostgresSQL Express validator. What's missing is thirdparty API clients, file system operations, and comprehensive middleware stack. And that's because this application doesn't really do anything right now. It's just basically a login app. But that's good to know that you know it's suggesting that we do these things and it's not finding it here. We're finding here in database connection failure. So whenever the database fails we have something here where we have pool creation without connection limits. So that can make it create a pool that can be overwhelmed that can take down the whole application. We have a database query without timeout protection. That can be bad because the way this works is you have a database query doesn't have a timeout right? So it hangs for some reason. Uh the user closes their browser, opens it again, tries it again, the next one hangs, and the next one and so forth. And multiply this by a thousand users and all of a sudden you've got a problem. You've got a service that's ending. So this again is a single line of code. It's easy to implement. Uh but we need some timeouts for sure. The error flow trace postgres SQL connection error pull query routes off goes into a catch block goes into an error code switch. We know what the audit's going to find next right specific error response generic fallback lines. So for transformational analysis this one says good for specific postgres SQL error code handling we get e connection refused if the database connection fails we get 28p01 and that is transformed into a 503 which is database authentication failed or 3D00 which transforms to 503 database does not exist. Now, here are some critical gaps that's showing. That's no timeout handling. So, we talked about that. No connection pool exhaustion protection. We've talked about that. No retry logic for transient failure. So, if something just, you know, all the cards didn't line up, everything wasn't timed properly, something failed, it doesn't go back and retry to see if it can try a second time. And oftent times, you can have a system that does that thousands of times a day. you know, things the timing just isn't right and something doesn't quite work, but you try it the second time and it works. Person gets what they need and everything's great. It says error details are logged but potentially sensitive. Now, let's look at system state consistency. It's inconsistent, right? Failed authentication temps are not tracked. No circuit breaker pattern for database failures. And a circuit breaker pattern is basically something that breaks early, resets things, and it doesn't go down a path. You know, once a certain execution doesn't work, right? So, a certain execution fails, then in some cases it will just keep going and it'll try the next thing and the next thing and the next thing and it just piles up errors. If you have a circuit breaker pattern, basically you're saying, "Hey, if this one part fails, then stop everything. Stop the process. We're done until we figure that out. Third party API. We don't have any thirdparty API integrations. So, skipping over that. Invalid user input error path. So, if somebody puts in some invalid data um here, it kind of shows error origin points, the flow trace, and it says there's some good stuff that we're doing here. Email format validation with his email, password length validation, and email normalization. These are all things that we should be doing that we are doing. However, we're not doing input sanitization for cross- sight scripting prevention. We're not doing any rate limiting for validation attempts. Detailed validation errors are exposed to our client. And we have no input length limits. So that's another area where potential denial of service, right? Somebody's sending in terabytes of text. Authentication failure handling. We're not doing great in this department. User not found in database is coming back. invalid passwords coming back. JWT signing process. Basically here the good stuff that we're doing is consistent error message for user enumeration prevention. So we're not saying bad username if somebody puts in the wrong username. We're using the proper HTTP status codes and brypt compare for password verification. However, what we're doing wrong, we're not using any JWT secret validation or fallback. No algorithm specification in JWT signing. No rate limiting for authentication attempts. No account lockout mechanism and JWT expiration depends on an environment variable without validation. So we are not doing great in that department. File system error handling. How does this handle errors when dealing with file system? Well, we don't actually work with the file system. It says here no file system operations detected. error handling anti-atterns. Remember that list of anti-atterns? Well, here it found some. So, it found the generic catch all handler, which means it's catching a whole bunch of different stuff and just saying internal server error. It swallows all unhandled errors and it masks critical system issues. We have console error logging only logging to the console, which if you're logging to the console, you're kind of logging to nobody, right? because the user may not even look at the console and we can't read the user's console and we can't see this stuff. So the errors just kind of go out into a place where someone might see them and we definitely won't see them. We're missing a global error handler. So that's, you know, some type of middleware or to something globally that can handle all of the errors and keep track of them. We don't have that. We have a single point of failure because the entire application crashes on unhandled errors. And we have some inconsistent error formats. We have invalidation failed with details. We have invalid credentials. Database connection failed. So, some of these are a little bit inconsistent. You know, we don't have an error code and then details and a name, etc. like we should. Here's our error flow diagram where we can see we have an HTTP request that goes into an express app off route. It shows some of the error origin points that we can come up with in those first two steps. So we can come up with input validation authentication database or JWT. Then it goes through a transformation layer validation details. Does some final handling HTTP status code error JSON response console log which again is not a great place to put our stuff. And then for recovery mechanisms if any of these errors happen we don't have retry logic circuit breakers or graceful degradation. So, we're just basically exploding on the screen and expecting the user to figure out why that happened. So, we're missing a global error handler, database connection without timeout. All of these we've looked through. These are all put into a nice list and prioritized. Here's the detailed remediation guide that we asked for. And this is saying, you know, here's the way you can fix it. It's giving us a fix for our global error handler. Database connection timeouts. Those are super easy to add. Secure JWT configuration showing us how we can secure that. Here's how we can implement a circuit breaker pattern. Right? And this one, if circuit breaker is open, then we've got an issue here, right? So, we have rate limiting, which is a great thing to put on there. If somebody is attacking you, doing an attack, we are able to at least rate limit that and slow them down a little bit. Structured logging implementation. Here's a suggestion for that. And this is just a logger, you know, creating a logger and sending it some data and getting that all consistent. Building consistent log messages is just really good practice for a lot of things. It's not just one of those, oh, maybe we should do it because it's the best thing to do, but we won't. It's definitely one of those things you need to really focus on. Um here for priority three, we've got some input validation enhancements, standardized error handling template, and a timeline for implementation. Right? You should probably get all this done in 4 weeks. Here's some testing recommendations that it throws in. And sometimes I've noticed that cloud code will do this. It'll throw in some testing stuff. Here we can test database connection timeout. We can test connection exhaustion, malformed input. We can test rate limiting. all of this stuff. So basically this analysis here says hey this is you know exhibiting significant error handling vulnerabilities that pose immediate risks to system reliability and security. The recommended remediation plan addresses critical gaps in error management etc etc. Basically, it says we've got a lot of problems with how we handle errors and exceptions, but it does not criticize without a solution, right? And so, it gives us a bunch of solutions to things that we can modify and update. So, next we're going to talk a little bit about resilience and fault tolerance. So, all of this stuff with error handling is great. when we have errors, we need to figure out, you know, how can we get things cleaned up and back on the road as quickly as possible with our application and we're going to do an audit of that and see how that does. Thank you for watching. Okay, so we've gone through some initial project analysis, we've looked at design patterns, we've looked at some solid principles for putting things together, and then we got into error handling and resilience and exception flow analysis. Basically, when something goes wrong, how are we handling it? Well, there's another part of that, and that's resilience and fault tolerance. What does that mean? Well, it basically means how well does this program stand up to a heavy load or major problems. So, that means things like services locking up, things becoming unavailable, data being overwritten. These are all problems that can happen when there's too much of a load and you don't have enough resilience to kind of help pick up when things break. You know, how hard is it trying to recover itself from a major error? And that's what this section is about. And that's what we are going to cover with an audit with cloud code. Okay, for this next audit, we're going to look a little bit more into some abstract things for software quality. We're looking at a lot of things here and we've looked at errors, how we handle them. We've looked at some design patterns things and maybe some architecture considerations. This is going to get a little bit deeper into the actual code itself. So, I'm going to paste this in and we'll talk about the prompt while it's running. And as a reminder, you can get all of these prompts at github.com/jeremyorggan reviewing prompts. That way you don't have to try to copy and paste these or figure it out. Now let's take a look at what we are examining with this particular audit. We're saying analyze code complexity across the codebase. So this one might take a while, right? But it says look for complex functions and methods. Also look at functions and methods and calculate or evaluate these following things. cyclatic complexity, cognitive complexity, lines of code metrics, coupling metrics, cohesion analysis. Now, some of this is it's a little subjective, right? It's kind of depends on errors and and how you do things. So, things like cyclomatic complexity, those are pretty deterministic for the most part. You can kind of look at it and you can put some metrics to it. Sometimes you can say, here's how much nesting you have. Here's complexity that you have with your switch statements etc. Cognitive complexity is much more subjective than cyclomatic complexity because cognitive complexity is for human beings like how hard is this code to understand. Well, for some people they might look at spaghetti code and say this is perfect that it completely makes sense to me. It's usually the author, right? Uh but sometimes things you know are a complete mystery by people who look at them even if they have tons of programming experience and cognitive complexity is something you want to reduce for the human side of things. Cyclomatic complexity is mostly around performance and reliability but cognitive complexities for the human beings. lines of code metrics. This kind of goes back to some of the principles that we talked about earlier that we were auditing for. Functions over 50 lines, that usually means that function is doing too many things. Files over 300 lines, that's mostly a human type of thing where we don't want our humans to have to look at code files that are enormous, that are doing too much. Um, classes over 500 lines, same thing. That class is probably doing too much at that point. And you can identify candidates for splitting things up, subclassing it, things like that. There's coupling metrics, right? So, you know, epherent coupling where how many dependencies are on this model, efferent coupling, dependencies of this model, how many is it depending on uh instability index? And we want to identify tightly coupled modules. Cohesion analysis. This one is a little bit more for a human being also. So, are related functions grouped? you know, are things all kind of grouped together and and separated in ways that make sense. That's good for humans that are crawling through the code and looking at it. Single responsibility adherence. That one is a little bit human being and it's a little bit software design. And then module focus clarity is kind of this very similar to similar responsibility. you know, is a module focus is what it's supposed to do pretty clear and is it only doing what it's supposed to do and nothing more, which is generally how we want to do this. So, we're going to go down here to we'll do code complexity analysis audit and let's take a look at it. This report analyzes code complexity metrics across the express login demo codebase. Overall assessment, this codebase demonstrates low to moderate complexity, which is good with some areas requiring attention. So we do have some high complexity functions. We've got a login route handler with high cyclatic complexity. This one says main login function has 12 decision points. So that's one of those places where we can see that we are putting a solid number on this. 12 decision points. It makes it pretty clear that's for one function. That's not great. Multiple conditional branches for validation, user lookup, password verification, complex error handling with a switch statement. We pointed that out in an earlier audit as well. Nested if else structures always something that's frustrating to work with. Here has a code path breakdown. Some remediations. Here's a bunch of remediations. Low complexity functions. We have cyclomatic complexity of 1 to three. So well ststructured simple functions. These functions demonstrate good single responsibility principle. Cognitive complexity login handler has a high cognitive load. Says here we've got conditionals that are three levels deep. We've got database queries mixed with business logic which that's mixed abstraction. That's always a confusing thing. Switch statement with multiple cases. 80 lines doing multiple responsibilities in a function. That's not good. So we want to break that into smaller focused functions as shown above. Error handling complexity, we do have a little complexity there. The switch statement with four cases plus default that in itself, some of these are subjective, right? As a software engineer of many years, a switch statement with four cases plus a default is not that bad. However, this audit is showing issues and that one is an issue that could become something much more problematic later. Mix database specific and generic error handling that I agree is a problem. Nested inside try catch block. Yes, nesting is always bad. Sometimes necessary always bad. And our remediation is to use error handler function that I gave. Line of code analysis. We've already seen this. There are some huge offjs at 98 lines. That's under 300 line threshold but it's approaching moderate complexity. single large function that exceeds the 50 line threshold. It's 80 lines long. That's too long for a function. That's how you know that it's doing more than it should or you're writing really verbose code. Either way, that's not great. Coupling metrics. So, we have some coupling here that we need to look at. Importantness, five out of 10, right? We have five external modules. A reasonable coupling level for an authentication module, which I would agree with. Uh there's you don't write your own for a lot of this stuff, right? You don't reinvent the wheel. You don't build your own authentication. Uh so you're going to have some coupling to libraries here. Good separation of concerns. We like that. Let's see. For stable database module, ideal stability for infrastructure component, moderate instability route module, acceptable instability for business logic layer. uh kind of goes into the cohesion analysis here. All functions relate to database connection management, which is great. In authentication route, all code relates to user authentication through the single function. Yeah, that's something that should be broken up and cleaned up a little bit. Login handler does validation, authentication, token generation, and error handling. Yikes. That's definitely a violation of the single responsibility principle that we talked about in a early module where it's just do one thing and do it well. Clearly, we don't have that happening here. Here's our refactoring recommendations. High priority, that cyclomatic complexity, splitting the login handler up, reducing cognitive load by breaking down nested conditionals, and it did suggest some code for that, which is great. All the way down to low priority stuff like monitor file growth as features are added. Uh, consider dependency injection for better testability, something we already know was necessary and needed. And then there's an implementation plan here that gives us code step by step how we can fix this which is great and it ends with this summary where files pretty good functions need improvement cyclomatic complexity cognitive complexity any improvement but our coupling is acceptable and our code cohesion is good. So we're at 6 and a half out of 10 which actually isn't bad. You know, lower is better, but the code base shows architectural decisions with room for improvement in function level complexity management. I honestly thought this would be a 10 out of 10. So, this is good. But this code analysis is something again we could take this and put it back in the cloud and say, "Help me fix this to get a better score for this." Or we could send it to a human being who can do the same thing. But this is just one of the cool ways to use cloud code for auditing purposes like this. and wanted to show you that. Up next, we're going to look at code duplication, which is another problem with code that uh can cause some problems. So, I'll see you there. Okay. Now, we've gone through a lot of audits and a lot of them are kind of generalized. We started generalizing. Now, we're starting to dig down deeper into things and and get really specific code problems we're looking for. And this one is no exception. We're looking for duplicate code here. So, as we've done before, I'm going to dump this in. This prompt is 47 lines. And then we'll take a look at the prompt while Cloud Code is auditing our software. Now, this one says, "Examine all the code in our application. Identify and analyze code duplication in our project and look for similar looking functions. Check for exact duplicates, near duplicates, structural duplicates, data duplication, and for each duplication found." So, these are the four that we're looking for. And we're looking for like copypasted code. You know, we've all been guilty of it before where you'll come in and say, "Oh, well, I'll just copy this here and I'll I'll abstract this to a method later or I'll make a general utilities class later. For now, we'll just copy it through." And so that's what we're looking for. And I don't expect to find much here from cloud code, but because Cloud Code actually generated the software we're looking at, I don't expect to find a lot of this. But I think in a regular uh production application written by humans or mostly by humans I think you will find a lot of this. So when it finds each duplication it says we'll calculate the duplication percentage. You know how similar is it to these other methods. You know sometimes the methods can just be a tweak here and there variable renamed and it's the same thing that sort of thing. suggest an extraction method, right? Whether we're going to extract it into a function, a class or an entire module and provide a dry solution, which is don't repeat yourself. Estimate the refactoring effort. So, we want to say, you know, is this going to be a very large undertaking? If so, you know, maybe you don't want to fix it right now. And then we're going to create a utilities module for common functions. So we're going to take some of these functions if it finds them put it into a common utilities module for you and then of course build this report. So looks like this one is already done. Code duplication analysis. Now remember LLMs are text processing engines. They generate text primarily the function of an LLM is to generate text that it thinks is statistically possible to be true. So on the flip side it analyzes text very well. Also, so if we look here, we have just a short report here that says uh you know overall duplication store very low. Good. Yeah, I didn't expect a lot of this. I expect this out of humans more than claude. Let's look at the audit code duplication analysis and let's see what it has to say. Now it says this report analyzes code duplication patterns in the express login demo application. The codebase is relatively small, right? There's four main application files and generally follows good DRI principles, but several opportunities for improvement were found. Okay, got this. So, it looked at serverjs, ojs, database.js. Uh, those are the files that we've been examining through these audits all over the place. We did find some stuff here. So, let's look at it. Exact duplicates. No exact duplicates were found in the application code. This indicates good development practices. That's great news. Uh, sometimes exact duplicates happen. When I was working back in the PHP world, I worked at a place where developers were only there 2 or 3 months each and found it all over the place. So, it's good that we don't have exact duplicates. I used Grep said and to find this back in the day. And trust me when I say this is much easier. Near duplicates three out of 10. Some minor issues. So, we do have some near duplicates. similar error response patterns. Well, that's exactly what we want. However, we don't want it broken into several functions, right? So, we do want similar response error responses. We covered that in a module earlier, but we don't want a bunch of functions with those similar responses because if one of them changes, then all of a sudden we're we're out of whack. So, we want to combine those. And the remediation for this, of course, is to create a utility function called create error response. So this part of the audit that's coming out is actually tied into a former audit that we did that said, "Hey, you should take all this and put it into a common function." So that was when we were talk we're deep diving on our error handling. Well, now this particular audit is suggesting the same thing. So it's pretty safe to say that creating this error response function is a good idea. Database error handling pattern potential for reuse if more routes are added. Yeah, this one uses a switch case pattern, which a lot of these tools that we've been building to do the audience audits don't really like switch case. You know, they don't like switch statements. That's fine. I like switch statements. Uh they have their place. I'll put it that way. But in here, it says there's a potential for reuse if more routes are added. Here's a way that we can fix it by making a map, an error map. That way when you need to add more routes, you can add in stuff to your error map. That's a good idea. Structural duplicates. Well, here potential future routes. Again, this application uses consistent express router patterns, which is good practice. As the application grows, consider creating a base router class or middleware factory. So, routes are just like any other objects in object-oriented programming. There are times where you want to build a good solid base class and extend off of it. If you have a ton of routes, in our case, we've only got a few, so it doesn't really matter. And you know we can build an application that can have you know less than 10 routes for the entire thing and we can build one that has hundreds. So it's one of the things to consider. Database connection pattern consistent event handler pattern for database connections. If multiple database connections are needed extract it to a factory function. This one is fantastic advice mostly because as it says if you want to do concurrent database connections which can be tricky of course always something to to watch out for. You would want to do a factory function. This creates a new connection does this thing creates another connection does another thing. You definitely don't want to stack it all into that same function. Data duplication a little bit of that. 25% of constants are environment dependent. So this does not like the fact that we're using a bunch of environment variables for stuff. Remediation will do it in a process environment variable. And the effort I forgot to mention is showing effort on a lot of these. And some of these are effort one hour. You know, worth an hour almost always to fix something that's important like this recommended utilities module. So here's where it's going to create this. Now if we look here the magic number strings thing this we're going to see this in a lot of audits magic values that should be constants these things this is a 45minute effort so this is definitely something that you would want to consider taking a look at creating a constants file that contains all of your constants. So we're looking here at the recommended utilities module. This is what I said. Hey, recommend something that puts all this together and utilities so that we can just call that method and get the same result from the same data we put in. And here it is. And looks pretty nice. Create error response. We've got a database error map which is great. This is super extendable or we can add more errors in here if we want to get more granular. We have a function to handle a database error so that we have that consistent error handling which is something that we touched on in the previous audit. Here we have handle database error. That's fantastic validation result handler. So that will go into the validations and this just makes everything more consistent. Right? We have our constants that it was suggesting the config files all of this stuff to say implementation priority centralize those envir variables create error response utilities which that's something if we went by the old audit we'd already done extract constants do some mapping improvements the code demonstrates good DY principles overall the main improvements would centralize configuration management and create reusable error handling utilities to support future growth it it didn't take very long either but this is a very useful tool to run because like I said, if this were written by humans, you would find a lot more duplication. It's something we've all done as a junior programmer. I definitely copied and pasted methods and put things in places and said, "Yeah, we'll fix this later. It compiles. We're good to go." And so, we want to get rid of those remnants of bad habits in our software. And so, that's what exactly what this audit does. Next, we're going to take a look at something that is mostly for the humans. So in all of these audits that we've been doing, most of them have been structured around the design of the software uh whether we're following good principles and most of the stuff with the exception of a few like resilience and fault tolerance. Most of the stuff is for humans really. We do have some of the things like exception flow and error handling and resilience. Those things are for the machine. That's to make the machine run good, make the service run good. Everything else is pretty much for a human and for when other humans come in and read your code or work with your code or in the age of AI. If an LLM is going to read your code, we want it to be readable, clean, and good. So the next one that we're going to take a look at is naming conventions and readability. And this one is strictly for the humans. Let's see if Claude code can do a good job of determining what kind of code you want to look at. So that's naming conventions of readability and we'll do that next. Okay, we're back in our IDE and we're going to do another audit that will be very helpful for the human beings that are reading your code. And like I said, maybe the LLMs, too. As a reminder, uh if you're skipping around through the videos, all of these prompts that we're using here are available at github.com/jeremyorggan/codcode reviewing prompts. These will all be available here so you don't have to try to copy or paste or try to guess what I'm doing. Uh you can take these prompts and use them to review your own software projects. Now let's go ahead and dump in our prompt for and this one's pretty simple for readability and naming. So we're going to review naming conventions, naming consistency, code readability, and function signatures. And each of these has a set of principles that we want code to follow. Right? So naming conventions, we want descriptive versus cryptic variables. We want verbased functions with clear intent. Nounbased classes, single responsibility principle. We've been looking at that earlier with earlier audits. Constants, uppercase consistency, private methods, etc. Now underscore convention. It all depends on the language. You might have to tweak these a little bit. Same thing with naming consistency. Camel case, snake case, depends on the language you're using. And of course, it depends on the organization that you work for. You can put in your own code rules in here. And as we saw earlier, we can put the code rules into Claude and make Claude follow those same rules. Uh for code readability, self-documenting code. That one is subjective. Some folks say there is no self-documenting code. You need to always do code comments. Some people say if you write good enough code, you don't need comments. So remember, a lot of this stuff is subjective. Uh need for comments. If there's too much of a need, that's a code smell that I agree with. Magic number strings, complex boolean expressions, turnary operator abuse, etc. And then function signatures. We want the function signatures to be pretty consistent like the parameter count. More than three is a smell. I agree. If you have to put in more than three parameters, you're probably violating single responsibility principle as well. But it's very complicated. Boolean parameters, something to avoid optional parameter handling and return type clarity. So we already have a response from this. So I'm going to select yes. We're going to take a look at naming here. Naming reability audit. And let's see what it has to say. This audit evaluates the codebase for naming conventions, code readability, and function signature quality. So the first one, variable naming. Excellent. We got a 9 out of 10. And this is consistent use of descriptive camelc case variable names. Good semantic clarity throughout the codebase. So this is great. And it shows an example. Here's an example of some good practice. Here's some good stuff that we found. All variables follow camelc case naming consistently. So good job cloud code who actually wrote this because this is good stuff. Function naming good and this is eight out of 10 importance. We have arrow functions with clear actionoriented intent. We have event handlers that follow descriptive patterns. We're doing good. There's a minor issue here though. Anonymous async function could benefit from named function for debugging purposes. So in offjs we do have an anonymous async function that we could probably change, right? And that's pretty easy. Here we have current async. We just instead create a actual function login handler. Not a big deal. Something worth looking at for debugging. And that's mostly because if a debugger pops in a certain area, it's not going to tell you which function it's in unless you do that. So that's good. Constance naming. Excellent. We did a great job of that. Naming consistency. Case convention. Excellent. findings, examples. So, we're using consistent camel case usage everywhere. We're not mixing up snake case or uh sentence case or anything weird like that. Terminology usage, excellent consistent domain terminology, clear authentication, authorization language, proper HTTP status code usage. So, all of this is looking really good for cloud code. They've investigated themselves and found that they're doing great in this category. Self-documenting code is good. Variable names clearly express intent. The function structure is logical and readable and minimal comments needed. So that's awesome. Magic and numbers and strings. Here we go. We brought this up in a previous audit. Needs improvement. Issues found. HTTP status codes. Here's a remediation. You know, just putting that into a constance file. Not a big effort there. That's pretty small effort for the most part. Here's some password length requirements is another one. Default port and how to remediate that. Now complex boolean expressions. Excellent. This one simple readable boolean logic. No turnary operator abuse. So when turnary operators were introduced to most people, they started to use them everywhere, myself included. And so turnary operator abuse is something that's pretty common. We have clear conditional structures here. So that's great. We're also doing excellent when it comes to function signatures. Parameter count, we're not overloading parameters with, you know, this huge list shows there boolean parameters. Excellent. We're not using any of that. Return type clarity is good because we're using a consistent JSON response structure instead of, you know, returning a bunch of different data types. Clear async await usage, etc. There is a minor issue here. We could benefit from explicit return type annotation on that same async function here. little anonymous function that we slipped in there. That one could be better. And it created a naming convention guide here for variables and functions, constants, database fields, and HTTP responses. This is all stuff you could pipe into cloud code and have cloud code start doing it for you. So, primarily the biggest thing is we want to create a constants file, add some named functions. This is all uh not very new. Uh HTTP status, all of this stuff has been coming up in these audits. So sometimes as we're doing this audit, like I said, you'll see repeated information, but that usually generally means it's something valid to look at. It's valid concern. So here's our strengths, areas for improvement. And this is a good quick audit that took us, you know, 5 minutes and could actually help the readability and help the programmers who are working. So, you know, he or she doesn't go crazy trying to figure out what's going on in the application. So, it's all human benefit for this one. So, thank you for watching. We've got one more to look at. Test coverage and quality analysis. And we're running this knowing that we don't have tests, but I just want to want to show how it works, what it looks for, and things like that. So, we'll see you there. Okay. Now, we're at our final one, and testing because testing is already last. We made this one last and we actually don't have any testing going on in this application. We haven't built it yet. Um, and that will be a part of this course, right? So, we're right now we are going to do an audit to analyze the testing just so we can see what it's all about. And as a reminder, github.com/jeremyorggan claude code reviewing prompts if you want copies of all these prompts. Now, it's thundering. I think it's been a different verb every time we've done it through this course, which is cool. So, evaluate testing implementation for this software project. Analyze test coverage, test quality, test patterns, missing tests. You know, that's where we're really going to see it. But if this were a larger software development project, this is an important audit. This arguably one of the most important, if not the most important, because look at what we're checking for here. We're checking for test coverage. Do we have unit tests? How much of our code is covered by those unit tests? Do we have integration tests? Those are always tricky. Are they present? Are they functional? End to end testing also extremely important. Do we have any endend tests? Uncovered critical paths. So what does that mean? That means a path that a user could take through the software and get untested code. Guess where the problem will probably arise in that path? test quality. We want things we want it named well. We want the arrange act assert pattern. Uh we want test independence meaning you know this test shouldn't rely on another test to get it done. We want mock usage when it's appropriate. And we want to test data management. Uh test pyramid adherence unit integration and to end testing anti patterns implementation versus behavior brittle test identification and test speed issues. So, and then it's going to look for missing tests, which of course is what we have now. It's already gone through. We're going to select yes. We're going to take a look at this report on our testing or lack thereof. And this is the first time we've done an audit and we got a zero out of 10. So each of these audits I asked to rate us on a scale of 1 to 10. We are at zero. So it says this express login demo project currently has zero test coverage. The application contains critical authentication functionality but it lacks any testing infrastructure or test cases. So no unit tests for the component. Here are all the files with zero test coverage. Integration test non-existent. No database connection validations, no end toend flows, no middleware, end to-end test coverage non-existent. Here's what we're missing. A complete login flow, authentication token validation, error handling, test quality analysis, our test infrastructure. What framework are we using? We're using none. However, package JSON contains a placeholder where it says no test specified. So, recommendations, remediations, just can put in there for test patterns. We don't have any missing critical tests. We're missing all the critical tests. The reason I wanted to show this is basically to show what it's going to suggest, what it's going to do, what we're looking for with this prompt. All of these things here, you can start to see some edge cases that it's suggesting that we're missing. These are the things that Cloud Code's going to suggest that we put in here. Empty request body. How do we handle that? SQL injection attempts. How do we handle that? We have some injectable SQL in this application. We have found it. Uh malformed JSON payloads, missing required fields, etc. How are we checking for those edge cases? Security tests, JWT secret validation, we've got lots of issues with that in the way that it's implemented right now. Our token expiration testing, tokens do not expire in our application currently. Password hashing verification, timing attack, etc. And the timing attack we'll talk about a little bit more in our security module. But a timing attack is basically when it sends a username and password. If it sends a bunch of garbled up weird usernames and it comes back in 5 milliseconds, but then it sounds sends in Jeremy Morgan, which might be a valid username, and it comes back in 10 milliseconds, then they know that they found a valid username. No SQL injection testing, SQL injection testing, etc. No load testing. Test improvement plan. Here we go. Phase one. Start just doing just for everything. Create a basic test structure. Configure just core tests that it wants us to do. Advanced testing priority immediate action items risk assessment etc. So what do we know about this? We know that we don't have any testing. And we know that's bad. What can we do with this? We can follow this key plan to get testing set up. In fact, we could copy and paste this report into Cloud and say, "Build us a test coverage suite." That's what's so great about Cloud Code. We're going to do something similar to that. Um, but I wanted to show all of these software audits to basically show the things you're looking for. And here's how I built them and how you can build yours. Let's say you want to do one on commenting. Commenting is a little subjective. However, there are tons of rules out there about code comments. Pick all the rules that you like. Pick the principles that you want to follow. Pick the most important things you want to look for and build one of these prompts like we've built here. You know, this prompt here is basically just saying, here's a bunch of best practices that I know about testing, and you know, go through and and look at these. So, here's a step-by-step path of how you can start your own audit. And I'll use comments as an example. You will come in and say, "What are the core things we want from the comments?" Break it down. What are the best practices that we want our software to follow with the comments? Break it down. Take that and send it into Claude or Chat GPT or any other LLM and ask, "What am I missing?" Sometimes it will come up with suggestions for things and you're like, "Oh, yeah, that's great. I forgot about that. Add that in there. Then take it and do exactly like we've done throughout this. Say, evaluate my software, analyze it, build a report, tell me what to fix, tell me how to fix it, give me a plan, tell me what's important, what's not important, all of these things. And it runs in five minutes. And you get this great thing that it could have taken a whole group of people to create for you. So, that's the whole reason I'm showing this is to not only show you the cool things that Cloud Code's capable of, but to show you a good structured way of how to do these audits and how to save yourself tons of time with boring stuff. You can take it, put it into Cloud Code, make Claude Code be your code review agent, and it will go through all of these things and look for them, and it looks for whatever you tell it to look for, tells you a better way to do it, and it's a great way to refactor your software and make it overall better. Next, we're going to take a look at something very important in the next module, and that's security, keeping your application secure. Cloud Code can help with that, too. Um, there's a bunch of stuff to look for. So, we have talked before about how you don't want to vibe code your way into a production application and put it out on the web. We've already seen here in this module how the software isn't that great, but maybe it's production ready. Maybe it can go out. In the next module, we're going to see why you shouldn't just take Cloud Code and have it build an app and throw it up on AWS and expose it to the world because there are security concerns. Can you take a vibe coded cloud code app and put it up there? Absolutely. And you're going to find out how in the next modules where we look at security. Thank you for watching.

Generated algorithmically for Search Engine Indexing.

Summarize Another Video