Goal

You are given TeamBoard, a small task tracker for student project teams, about 150 lines of Python. An AI wrote it. It contains five intentional bugs. The test file catches four of them. The fifth has no test: you will have to find it and write the test yourself. You will debug the same code twice:

  1. Part 1 (20 min), chat window: you use Claude in your web browser (claude.ai), the way most people use an AI chat: you paste code and error text, read the answer, and apply every change by hand. The model sees only what you paste.
  2. Part 2 (15 min), Claude Code: you start again from the original, unfixed code and let Claude Code read files, run tests and edit code, while you supervise.
  3. Part 3 (10 min): you take one problem of your own through the whole testing loop: a failing test, a fix, green, the whole suite, and a check that your test would catch a bad fix.
  4. Part 4 (10 min): you answer three comparison questions.

In every part you use the same testing loop (below), and you record it in a small table.

The point is not to fix the most bugs. The point is to notice what each way of working gives you and what it takes away. Spend your time on the questions “how did I know that was right?” and “who decided that?”
This lab connects to your project. The bugs are the kinds that AI-written code tends to contain in real projects. Your team is about to merge a lot of AI-assisted code (merge day is this week, CP2 is next Monday).

What You Submit (read this first)

WhoIndividual. Each student submits their own file
WhatOne PDF document with the contents listed below
WhereE3, under “Week 11 Lab”
WhenBy the end of Wednesday, November 18 (23:59)
File nameWeek11_Lab_<your student ID>.pdf
GradingGraded on completion (1%), like the earlier labs. We encourage you to be specific, because the detail is what makes the lab useful to you

Your PDF should contain, in this order:

  1. Header: your name, student ID, team number, the chat tool and model used in Part 1, the Claude Code model shown in /status
  2. Bug report: one row for each of the five bugs (attempted is enough; fixed is better). Template in week11_lab_submission_template.md, available with the required lab files on E3. Include your loop tables: one row per fix, for Part 1 and for Part 2 (see “The testing loop”)
  3. Chat log, Part 1: at least three exchanges that mattered (your prompt and the key part of the answer, copied from the chat), each with your note: what you asked, whether the answer was right, and how you checked. At least one entry must show a diagnosis you checked before applying a fix (see Part 1)
  4. Claude Code notes: a short list of what Claude Code did, in order, and which of its requests you approved, changed or declined
  5. Your own loop (Part 3): the test, the red output, your fix, the green output, the whole-suite result, and the result of undoing the fix; plus one line on whether the problem was a bug or a decision
  6. Three comparison questions (Part 4), answered in writing

Do not include passwords, keys, or screenshots that show them.

Time Plan

PartWhatMinutes
Setupinstall Claude Code if you have not yet, check all requirements, copy the code, run the tests5
Part 1debugging in a chat window20
Part 2the original code again, with Claude Code15
Part 3one problem of your own, through the whole loop10
Part 4three comparison questions10

That is 60 minutes. Use a timer. When Part 1 ends, stop and move on, even if you did not fix all five.

Before Class

Download the student package from the required lab files on E3. Complete week11_claude_code_setup.md, then run python week11_setup_check.py. If Claude Code does not work, tell a TA before Monday.

Setup (5 minutes)

If you have not installed Claude Code yet, do it now with week11_claude_code_setup.md (doing it before class is safer: if the installer has a problem, 5 minutes is not enough to fix it). Then run python week11_setup_check.py and fix anything marked PROBLEM, or tell a TA.

The student package (from the required lab files on E3) has a folder teamboard/. Do not edit it. Make two copies, so each part starts from the original code:

macOS / Linux / WSL:

cp -r teamboard teamboard_chat
cp -r teamboard teamboard_cc

Windows PowerShell:

Copy-Item -Recurse teamboard teamboard_chat
Copy-Item -Recurse teamboard teamboard_cc

Now look at the failing tests, in the chat copy:

cd teamboard_chat
python -m unittest

You should see 4 problems out of 10 tests (2 failures, 2 errors). Remember there are five bugs: one has no test. You may also run the demo with python -m teamboard.cli. Do not read the code closely yet. Write down your first impression of what you think the five bugs might be, in one line each. This is your “before” guess.

The Testing Loop (use it in every part)

1. Red      a test that fails because of the bug (a given one, or one you write)
2. Fix      the smallest change
3. Green    that test now passes
4. Suite    run ALL the tests: did anything else break?
5. Keep     the test stays in the suite, so the bug cannot come back unnoticed

Record it. For every fix, add one row to your loop table (in the template):

BugTest that shows it (given, or mine)Red before the fix?Fix (one line)Whole suite after (passing / total)Anything else break?

It takes seconds per row. It is the evidence that you ran the loop and did not just fix things.

The bug with no test (hint). It is a security problem in db.py. To find it, ask for a security review of that file. Then, before you fix it, write a test that fails because of it (red), and only then fix it (green). This is the “no trace? write a test first” habit from the lecture.

Part 1 — Debugging in a Chat Window (20 minutes)

This is debugging the way most people do it with AI: in a chat window, copying text back and forth. (The course outline calls this the “raw API” approach: the model gets only the text you send it, and nothing else.)

How You Work in This Part

A Way to Work

  1. Run the tests. Pick one failing test.
  2. Build a prompt with: the failing test, the full error text (the traceback, or the assertion message), the function it points to, and one sentence about what the code should do.
  3. Ask for a diagnosis before a fix: “What is wrong, and why? Do not write code yet.” You can also ask: “Give me three possible causes, and how I could check each one.”
  4. Get a check before you get a fix. Ask:

    “Before any fix: give me one command or a short test that would show your diagnosis is wrong if it were wrong. Tell me exactly what output you expect if you are right.”

    Then:
    • Judge the check. Would it come out differently if the diagnosis were wrong? A check that does not touch the code (for example print(3 < 3)) proves nothing. If it would pass either way, ask for a better one.
    • Run it yourself, in your terminal, from the project folder.
    • Compare the predicted output with what you got. If they differ, the diagnosis is in doubt: tell the model what you saw.
  5. If the check confirmed the diagnosis, ask for the smallest fix. Apply it yourself. Run the tests.
  6. Repeat. If the tests are green but you do not understand why, that is not finished.
Required: at least one entry in your chat log must show this pattern: the model's diagnosis, the check, the output it predicted, the output you got, your answer to “would this check have failed if the diagnosis were wrong?”, and only then the fix. Mark it CHECKED DIAGNOSIS.

Two Other Ways to Check (optional; try one if you have time)

Things to Think About While You Work (write answers in your notes)

At minute 20, stop. Run the tests one last time and write down: bugs attempted / bugs fixed / tests passing (out of 10, plus any you added). Check that your loop table has a row for each fix.

Part 2 — Claude Code (15 minutes)

Start again from the original code. Use the second copy. In your terminal (if you set ANTHROPIC_API_KEY for an earlier lab, unset it first; see the setup guide):

cd teamboard_cc
git init
git add .
git commit -m "original unfixed code"
claude

(If git asks who you are, run git config user.name "your name" and git config user.email "you@example.com", then repeat the commit.)

The git commit matters: it lets you see exactly what Claude Code changed (git diff), and undo it if you want to (git checkout .).

How You Work in This Part

A Way to Work

  1. Ask: Run the tests and tell me what is failing. Do not change anything yet.
  2. Ask it for a diagnosis of each failure and read it. Do you agree? Then ask, as in Part 1: Before changing anything, show me a check that would prove your diagnosis wrong if it were wrong, and run it. Read the check before you approve running it, and compare its output with what it predicted.
  3. Ask it to work test-first: For each bug: show me a failing test first (write one if no test catches it), then fix it, then run the whole test suite. Stop after each bug so I can check. Read the diff for each change; after each one, run git diff and look at what actually changed. Fill in a loop-table row for each fix, as in Part 1.
  4. Ask it to find problems the tests do not show: Review the code for problems the tests do not cover. Compare its list with your five bugs.
  5. When it says it is done, run the tests yourself and read the final git diff.

Look for These (write down any you see)

At minute 15, stop. Write down: bugs fixed / tests passing / number of changes you declined or edited.

Part 3 — One Problem of Your Own, Through the Whole Loop (10 minutes)

Real bugs usually do not come with a test. In this part you find one, write its test, and take it all the way round the loop.

  1. Work in teamboard_cc (it has git). First save Part 2's work: git add . then git commit -m "Part 2 fixes".
  2. Find a problem that no test covers (not the 10 given tests, and not the one you wrote for the security bug). Look at the code with the four lenses from the lecture, or try odd inputs in the Python shell. Some places to look: what happens with a due date that is not a valid date; whether names match regardless of capital letters or spaces; empty titles; an assignee that is only spaces. You may ask an AI tool for ideas, but you decide which one to test.
  3. Decide what the right behaviour is. Write one line: is this a bug (the code breaks its own docstring), or a decision (the docstring does not say, so you are choosing)? If it is a decision, say what you chose.
  4. Red. Write one test for that behaviour in tests/test_teamboard.py (copy the style of the existing tests). Run it. It must fail. If it passes, the problem is not real or the test does not check it: change the test or pick another problem. Then commit the test: git add . and git commit -m "Add failing test".
  5. Fix. Make the smallest change that should make it pass (with the chat, with Claude Code, or by hand).
  6. Green. Run your test: it passes.
  7. Suite. Run all the tests: python -m unittest. Everything passes? If something else broke, that is a finding: write it down, then fix it.
  8. Would your test catch a bad fix? Undo the fix for a moment with git stash, run your test (it should be red again), then bring the fix back with git stash pop. (Without git: put the old line back by hand, run, and restore it.)

Paste into your PDF: the test, the red output, your fix (the diff), the green output, the whole-suite result, and the result of step 8.

Part 4 — Three Comparison Questions (10 minutes)

Answer in your own words, 4 to 8 sentences each. Refer to specific moments from your two parts. “It was faster” is not an answer unless you say what was faster and by how much.

  1. What did Claude Code do that the chat window could not?
  2. Where did Claude Code make a decision you should have made yourself? (If it made none, say what it did that came closest, and why you were comfortable with it.)
  3. What context did Claude Code have automatically that you had to provide by hand in the chat window? And what context did you have that Claude Code did not?
Optional extensions (not required).
  • Pick the one bug you are least sure the AI fixed correctly, and write one more test that would catch a wrong fix.
  • Let tools check first. In a fresh copy of the original code, run pip install mypy ruff, then ruff check --select S teamboard and mypy --check-untyped-defs teamboard. Which of the five bugs does each tool find? Which does neither find? Then run mypy teamboard without the option and compare.

Submission Checklist

Upload it on E3 under “Week 11 Lab” by Wednesday, November 18 (23:59).

If Things Go Wrong

ProblemWhat to do
python -m unittest says no tests were found, or No module named 'teamboard'You are not in the project folder. cd into teamboard_chat (or teamboard_cc), the folder that contains the teamboard and tests folders
The chat says you have reached a usage limitTell a TA and write down when it happened. You can continue Part 1 by reading the code and the test output yourself
The chat's answer stops in the middleAsk it to continue, or ask about one function at a time
The model's code does not run, or mixes up the filesYou probably pasted too little context. Paste the whole file the error points to, and say which function is wrong
The model keeps suggesting the same fixTell it what happened when you applied the fix (paste the new output). Do not just say “that did not work”
Claude Code asks you to log inSign in with the account in the setup guide. If it asks about using an API key, choose not to
Claude Code is slow, or says a usage limit was reachedTell a TA. Write down what happened; it is part of the comparison
Claude Code made a messgit checkout . in teamboard_cc returns the files to the original commit. Say in your notes what you restored
Claude Code will not install on your computerTell a TA. You can still do Part 1; ask a neighbour if you can watch their Part 2 and write your answers from what you saw, saying so

Connection to the Course

← Back to Calendar