OfCourse by AgileIdeas.dk
Course outline

Agents That Write Code You Can Live With

Getting started 7 pages · 1 h 1 min
Free taster: the one-hour quality harness 5 pages · 1 h 10 min
Part 1: Habits Coming soon 4 modules · 5 h 45 min
Part 2: Measure and guard Coming soon 2 modules · 2 h 40 min
Part 3: Going deeper Coming soon 3 modules · 4 h 45 min

Reading, about 10 minutes

The course robot holding out a ring to a tree, asking "Will you commit to it?"

Git: commit to it

An agent can change twenty files in a minute. Git is your undo button, and it only works if you press save first. So the one habit:

Commit before you give the agent a task. Then everything it does is easy to look at, keep or throw away.

Use Git every day? Make the branch below and move on.

Do everything on this page in your project folder: FridgeLister or your own code. Make sure that you have your codebase ready.

Once: tell Git who you are

git config --global user.name "Your Name"
git config --global user.email "you@example.com"

In a codespace, GitHub has done this for you.

Make your course branch

A branch is your own line of work that leaves main alone. Do the whole course on one called course:

git switch -c course

Later: git switch course to get back to it, and git branch --show-current to see where you are.

Look, then save

git status   # which files changed since the last commit
git diff     # the changes, line by line (q to quit)

Run them after every agent task. It's the quickest way to see what it touched.

git add .
git commit -m "Add best-before date to items"

add picks up the changes, commit saves a snapshot. Write the message as what the change does.

Undo: try it now

Make a mistake on purpose, then make it vanish. Open README.md in your editor, type a line at the end, such as "a mistake", and save. Then:

git status
git diff
git restore README.md
git status

macOS / Linux

You can also make the mistake from the terminal, as the video does: echo "a mistake" >> README.md.

Windows

In Git Bash you can also make the mistake from the terminal, as the video does: echo "a mistake" >> README.md. Not in PowerShell, though: its echo writes the line in a format Git can't show as text, and git diff only says "Binary files differ".

The last git status no longer lists README.md: the mistake is gone. git restore . does the same for every changed file at once. That's the move whenever an agent goes the wrong way.

Two more cases:

  • New files the agent created are left alone by git restore. git status lists them as "Untracked files"; delete the ones you don't want.
  • Already committed? git revert HEAD makes a new commit that undoes the last one. Safe even after you've pushed.

Push

git push -u origin course

Sends your branch to GitHub. You need it for the CI exercises in modules 4 and 6, and to keep codespace work safe. After the first time, plain git push does it. In a codespace it just works; elsewhere Git asks you to sign in through the browser. Permission denied (publickey) means the address starts with git@; clone the https:// one instead.

Want more?

Pro Git is free. Chapters 2 and 3 cover all this and a bit more.

Next: ready, set, agent.

You've marked this page as done.

Kept in this browser. Sign in to keep it on every device.