Resource mentioned in this lesson: SourceTree App
Handling Changes
00:00
On the left side, you see my terminal where we are in the project folder. Currently, Claude Code is not started, and on the right side, you see the CLAUDE.md file that Claude Code created for us in the last lesson.
00:12 We haven’t committed the new file yet. So let’s do this first. On the left side in the terminal, we will use normal Git commands, so no Claude Code here.
00:23
Here I’m using git add . to add all the files that are in the current directory. I could also write git add CLAUDE.md to directly address CLAUDE.md, but I’m a bit lazy here, so I’m just using the dot.
00:37
We’re adding the CLAUDE.md file and adding a commit message after staging it.
00:49 I mentioned in one of the former lessons that it makes sense to work with a Git repository when working with Claude Code. The advantage of that is that you can see the changes that Claude Code does to your code.
01:02
And with Git, similarly like when you’re normally working with code, you have those little milestones that you can go back to. So here, for example, you can use git log to see the one commit that you did.
01:16
And with that, you can safely work with Claude Code. Again, use the claude command to jump into Claude Code. And what I want Claude Code to do now is to make some edits to our CLAUDE.md file.
01:30
In the last lesson, we haven’t looked that much into the CLAUDE.md file in the Python coding best practices that Claude Code came up with. In the meantime, I had a closer look, and I want to do two changes.
01:42 One is about tabs and spaces, and the other is about type hints. If you have a look at line 7, it says never mix tabs and spaces. And actually, I want Claude Code to never use tabs.
01:55 So I want to be clear here and say to always use spaces. And if you scroll down,
02:03 there is this part about type hints, and type hints generally are a good idea, but I don’t want to have them here. So I will ask Claude Code to remove both of them.
02:14 And this is probably also a good moment to point something out here, which I personally experienced with working with AI. And you might have experienced this yourself as well.
02:25 There are situations where you could just do the thing yourself. We were going over this file. I could just remove the mention of tabs and the type hints there myself, and I would probably be faster.
02:37 But there is this tendency to also be a little bit lazy as a programmer. So I just wanted to point this out here. We’ll change the file in a moment, but let’s let Claude Code do the work for us.
02:51 Now the reason why I want to do this is not just because I’m lazy, but when you’re asking AI, in this case Claude Code, to do something for you, sometimes it saves you work because the machine doesn’t complain about all the files that it needs to go through or all the lines it needs to go through.
03:11 But sometimes you can be a surgeon yourself and quickly do the changes, and it’s good to try both things out to see which situations fit for you and which situations don’t.
03:24
Please update CLAUDE.md to always use spaces, never tabs, and remove the section about type hints.
03:33
Once you press Enter, Claude Code gets to work, saying that they’ll update CLAUDE.md,
03:39 and then Claude Code will show you a diff about the first change. So there it’ll add in bold, always use spaces for indentation, never tabs, and then remove the line never mix tabs and spaces, and replace it with configure your editor to insert spaces when pressing tab.
03:57 That is a fine change. So I say yes, then it goes on to the next change, removing that import part, and instead of going through every change, I will say now yes, allow all edits during the session, and let it do the rest.
04:12 Again, you’ll see the edits run by and the tokens run up, and in the end there will be a summary message about what Claude Code did.
04:20 I haven’t looked at the edits in particular. Instead, I want to show you how I usually do it, and that’s using a diff tool.
04:29 So what you can see now is my Git tool that has a diff view so to see the changes that I did in files, as long as there is a Git repository, and you have those diff views in editors in dedicated tools.
04:43 So the tool itself doesn’t matter that much, but what I like is to see the actual diff in a nice GUI view.
04:53 In case you’re wondering what software I’m using here, it’s called Sourcetree. You can find it at sourcetreeapp.com. It’s a free client for Windows and macOS.
05:03 But basically, any other Git client works as well.
05:07 If we scroll down, we see all the changes that Claude Code made, and that is usually a nice view to control if what Claude Code did is fine for you. And this is also a moment to remind you that you are still in control.
05:23 So although Claude Code did those changes, you can still add changes yourself. The changes here are not committed yet. They’re not even staged. So we are just looking at the diff.
05:33 So jumping back to the editor, you see that the changes were done here as well. In line 6, you see, for example, that bold statement. And then in line 8, this information about configure your editor to insert spaces when pressing tab.
05:49
Looking at this line now, although I accepted it before when Claude Code was presenting it to me, it doesn’t make so much sense to have this in your CLAUDE.md file.
05:59 So if I would talk to another developer, that might make sense, but Claude Code doesn’t work in its own editor. So actually, I can remove this line. So one important bit here, that’s why I’m doing this right now, is that you shouldn’t forget that you’re in control.
06:16 So although you’re working with Claude Code and letting Claude Code do things, and that’s generally with AI, you are still in the driver’s seat. So if there is any change that you accepted formally but you don’t like anymore, go into your editor, change those things, save the file, and then check the diff.
06:35 And if everything is fine,
06:38 then you can either create a commit yourself or let the AI do it for you. And that’s the last thing I want to show you here in this lesson, and that is letting Claude Code do the commits for you.
06:50 You saw me writing a commit before which was rather short. And one nice thing with Claude Code is that you can ask it to create commits, and usually you have nice long commit messages then.
07:03 So still in Claude Code, write
07:07 please create a commit with the latest changes.
07:10
Once you press Enter, Claude Code will check what changes it did. The nice thing here is it doesn’t just rely on the things it actually did and knows about, but it checks with a Git diff and the Git log what actually changed, and then showing you the command that it would use.
07:28
So, adding the CLAUDE.md file, creating the commit with a nice long message in your Git commit. Before I press Enter though, I want to point you to this Generated with Claude Code line that you see in Git commits, and by standard, Claude Code will always add something like this if it creates the commits for you.
07:48
If you don’t like that, check out the documentation for Claude Code, and there in the settings, you have the settings bit IncludeCoAuthoredBy, and you can set it to false.
08:00 That way you are removing this byline in the Git commits here. Honestly, I don’t care so much about it. So I’ll press yes, and then Claude Code will create the commit
08:15 and give you a nice summary in the end.
08:22 and check the Git log. And now you see my rather small message down here and the nice long message that Claude Code wrote for you. All right, and that’s everything I wanted to show you in this video course.
08:37 What you ended up with is basically a nice repository to start working with Claude Code and create a Python project with Python coding best practices. Always remember that you’re in the driver’s seat.
08:49
So if there’s anything you want to add to the CLAUDE.md file, always do. And if you want to steer Claude Code in a different direction, always do as well.
08:59 In the next lesson, I will wrap up this course and give you some additional resources to dive in deeper in the AI topic, the terminal, and Git.
Become a Member to join the conversation.
