Vibe coding with Claude Code course Β· Module 1: Claude Code and Cursor

The safety net: Esc, /rewind and Git as the logbook

9 min read Β·
In this lesson11

Ahoj! Your page has a greeting and a crew section with parchment cards. That is cargo you would hate to lose. In the last lesson of this location you will spread a safety net below deck, thanks to which almost every mistake of the crew can be undone.

The problem: one request and nothing works

The page worked. You gave the next request, Claude changed several places, and now the cards have drifted apart and the heading has vanished. Do you remember what the version that worked looked like? Do you know which lines changed? Without a net you are left with a laborious reconstruction from memory. With a net you are back in port in a few seconds.

Three ropes

The net is made of three ropes. Each catches something different, so you need all of them:

RopeWhat it doesWhat it will not do
Escinterrupts Claude while it works and keeps what it already diddoes not undo changes Claude has already saved
/rewindrolls back files, the conversation or both to the moment before a chosen requestdoes not undo files changed only by a terminal command, or anything outside files
Gitrecords a lasting history of the project that you can return to even after a weeksaves nothing by itself: you make the commit, or Claude does it at your request

You know Esc from lesson 0_2: it is the brake. When you see Claude sailing the wrong way, press it right away, and then write what it should do differently.

Checkpoints and /rewind up close

Before each of your requests Claude Code remembers the state of the files it changes with its editing tools. Such a remembered state is called a checkpoint. You open the undo menu with the /rewind command (the shorter name /undo works too) or by pressing Esc twice with an empty request field. In the list you pick a request, and then an action: restore code and conversation, only the conversation, or only the code. The code restore options appear only when some tracked files changed after the chosen request.

Checkpoints have limits, though, which you need to know before you rely on them:

  • terminal commands: a file changed only by a command, for example rm or mv, is not tracked and stays as it is;
  • effects outside files: data sent to a database or another service, deploying a page to a server, or commits pushed with git push will not come back, because a checkpoint remembers only files;
  • subagents: a subagent is a helper that Claude can send off on a separate task, usually in the background; you will meet them in later locations. Changes a subagent makes in files not touched earlier in your conversation stay after /rewind;
  • your manual changes: what you change in files yourself outside Claude Code usually does not land in checkpoints.

The documentation says it plainly: checkpoints are for quick undoing within a session and do not replace a version control system such as Git.

Git: the logbook

In lesson 0_3 you met four Git commands in a nutshell. Now you will start using it for real. Two words to begin with: a repository is a folder whose history Git keeps, and a commit is a saved state of the files with a description, which you can always return to. You do not have to type the commands yourself: Claude Code drives Git through conversation, and you read what it runs.

First check that you have Git: type ! git --version in the session. If you see a version number, all is ready. If you see command not found, ask Claude how to install Git on your system and read every command before you agree. On Windows it will be Git for Windows, mentioned in lesson 0_2.

Request for Claude Code:

Initialise a Git repository in this folder and make a first commit
with a description of what is on the page. Before you run each command,
say in one sentence what it will do.

What Claude did

In Manual mode Claude will ask for permission for every command that changes something. You will read roughly these three:

git init
git add pirate.html
git commit -m "Page pirate.html: greeting and Our Crew section"

git init creates a hidden .git folder in the folder, where Git keeps the whole history; it does not change your files. git add marks files for saving: Claude may point to one file or use git add . from lesson 0_3. git commit -m saves the state with a description in quotes. Nothing goes to the internet: without git push the history stays on your computer.

Git adds the author's name and e-mail address to every commit. If you have never set them, Claude may ask for them or propose these two commands:

git config --global user.name "Anna Smith"
git config --global user.email anna@example.com

The --global option saves these details once for the whole computer, so in later projects Git no longer needs them. Enter your own details, not the example ones.

What you see in Cursor

Open the Source Control view in Cursor, for example through the command palette (Cmd+Shift+P on a Mac, Ctrl+Shift+P on Windows and Linux): type Source Control and choose the view of that name. Right after the commit the list of changes is empty, because everything in the folder has been saved.

Now ask Claude for a small change, for example a fourth card for the boatswain. When Claude saves it, pirate.html appears on the list in Source Control. Click it and Cursor shows a comparison of the version from the last commit with the current one, usually with removed lines in red and added lines in green. This comparison, called a diff, is what you read before every next commit. When the diff suits you, tell Claude: "Make a commit with a description of this change". You can also check it by conversation: ask "what has changed since the last commit?" or "show the latest commits".

The work loop with a checkpoint

From now on every change on the ship goes through the same loop:

1. commit: save the state that works
2. request for Claude Code
3. check: the diff in Source Control and the page in the browser
4. good? commit with a description. bad? /rewind and a better request

The loop starts with a commit, because that is the point of return. If in step 4 the problem lies beyond the reach of /rewind, for example in a file changed by a command, ask Claude to restore that file from the last commit and read the command before you agree.

Test the net in practice. Give a deliberately bad request, for example "replace the whole page with one huge word TREASURE". When Claude finishes, type /rewind, choose that request and Restore code. In Source Control the list of changes is empty again: the file is back to the state from the commit.

When you read every line

Vibe coding with open eyes means you always read the changes. But there are places where you read every line before you use the code, and if you do not understand something, you ask Claude until you do:

  • secrets: passwords, API keys and everything that gives access to accounts;
  • payments: any code that touches money;
  • other people's data: names, e-mail addresses, messages, photos;
  • commands you do not understand: rm -rf, sudo, curl with an unknown address joined to bash, and others from lesson 0_3.

Here a mistake does not end in an ugly page, but in a leak or a loss that no rope can undo.

Secrets outside the repository

Projects that connect to other services keep secrets, such as API keys, in a .env file. That file must never land in the repository, because Git history travels with the code everywhere you send it. A .gitignore file protects against that: a list of files that Git should skip. Create it right away, before any .env exists:

Request for Claude Code:

Create a .gitignore file with the entry .env, so that Git never saves
the file with secrets. Make a commit with a description of this change.

The finished .gitignore has only one line for now, the name of the file to skip:

.env

From now on Git will skip every file named .env in this folder and its subfolders. If you also see .claude/settings.local.json in Source Control, that is your personal Claude Code settings, for example the answer style from lesson 0_5: ask Claude to add that file to .gitignore too.

Note: .gitignore does not work on files that Git already tracks. If .env landed in a commit earlier, the entry alone is not enough, and you need to remove the file from the repository with a command that leaves it on disk:

git rm --cached .env

After this command and another commit Git stops tracking .env, but old commits still contain it. So treat a key that has once landed in the history as burned and generate a new one. In later locations you will add a rule that forbids Claude from reading .env at all.

Captain's review

  1. A commit before a bigger change: before you give a big request, the list in Source Control should be empty and the last good state saved.
  2. Secrets: .gitignore with the .env entry is in the repository, and .env does not appear in Source Control.
  3. The commit description: a typical agent mistake is a description like "update files", from which you will learn nothing in a week. Ask for a concrete description: what changed and why.
  4. Proof: after the commit, ask Claude for the list of the latest commits and check that yours is on top.

Next step

You have the full set: Claude Code as the crew, Cursor as the spyglass, requests made of four blocks, plan mode and the safety net. At the end of this location you will show your mentor your ship ready for sailing. In the next location you will set up your first Next.js project with Claude Code and repeat the same loop for every feature.

Remember: the logbook is written before the storm, not after it.

Code for this lesson: work-loop.md
# The logbook: the work loop

1. Commit: save the state that works.
2. Request for Claude Code: goal, place, constraints, check.
3. Check: the diff in Source Control and the page in the browser.
4. Good? Commit with a concrete description. Bad? /rewind and a better request.

## What /rewind will not undo

- files changed only by a terminal command,
- effects outside files: a database, a deployment, git push,
- subagent changes in files Claude had not edited earlier.

## I read every line when the code touches

- secrets: passwords, API keys, the .env file,
- payments,
- other people's data,
- commands I do not understand.

Spotted a mistake in this lesson?

Check yourself

Answer the questions from this lesson. Pick an answer to see right away whether it is correct.

  1. 1. What is Git?

  2. 2. What will /rewind not restore?

  3. 3. Where in Cursor do you see the files changed since the last commit?

  4. 4. What does the git status command do?

  5. 5. What does the git push command do?

  6. 6. When do you read every line of code from Claude before you use it?

  7. 7. Why do you put .env in the .gitignore file before the first .env file exists?

Hands-on tasks in the game

  • Click in order

    Click the elements in order to build the command that commits changes with a description:

  • Click in order

    Click the elements in order to build the command that adds all files to Git:

  • Vertical ordering

    Arrange the Git commands that save and send changes (one under another):

  • Vertical ordering

    Arrange the steps of the work loop with a checkpoint:

  • Horizontal ordering

    The .env file has already landed in a commit. Assemble the command that removes it from the repository but leaves it on disk (on one line):

  1. QuestionQuiz: What is Git
  2. QuestionQuiz: What /rewind will not restore
  3. Click in orderClick in order: saving changes in Git
  4. QuestionQuiz: Changed files in Cursor
  5. Click in orderClick in order: adding files to Git
  6. QuestionQuiz: The git status command
  7. Put in orderSorting: Git - saving changes
  8. Put in orderSorting: The loop with a checkpoint
  9. QuestionQuiz: The git push command
  10. QuestionQuiz: When to read every line
  11. QuestionQuiz: The .env file and .gitignore
  12. Put in orderAssemble: Removing .env from the repository
  13. Project to submitShow your ship ready to sail
  14. VideoModule Summary

Useful articles