HANDS-ON TASK · 1 OF 1

Find and fix the bug until the test passes

Task: Fix a broken repo with Claude Code

Goal

A small repo ships with a failing test. Use Claude Code to find the bug, fix it, and confirm the test goes green. This is the everyday debugging loop: reproduce, understand, fix, verify.

Set up the project

Run this to drop the broken repo at /root/brokenrepo/:

bash
curl -fsSL https://raw.githubusercontent.com/Esc-Bash/project-init-scripts/main/claude-code/project-2/init.sh | bash

The folder holds stats.sh (a script that is supposed to sum the numbers in a file) and test.sh (a self-contained test). The test is failing right now.

Reproduce it first

Always confirm the failure before you change anything:

bash
bash /root/brokenrepo/test.sh

You will see it report a wrong sum and exit non-zero.

Practice

Let Claude read the code and the test, then reason about the mismatch. Start the console in the repo:

bash
cd /root/brokenrepo
claude

A good prompt hands it the evidence and asks for a diagnosis first:

test.sh fails against stats.sh. Read both, explain why the sum is wrong, then fix stats.sh. Do not change test.sh.

Review the change, then run the test yourself again to verify:

bash
bash /root/brokenrepo/test.sh

Expected Result

stats.sh reports the correct sum, so test.sh prints PASS and exits 0. Only stats.sh should change: the test defines correct behavior and stays as is.

Ready To Continue

Press Submit once bash /root/brokenrepo/test.sh passes.


Your lab setup

This VM comes with Claude Code preinstalled and signed in - just run claude to start.

Start the lab on the right to run checks.

Pass the checks to continue
Spin up a fresh environment and practice live.
claude-code-ubuntu · fresh machine · ready in under a minute