CS 334: Lab 10: Getting Started with Claude Code

Overview

In this lab, you will get hands-on experience with AI coding assistants. We'll use Claude Code, Anthropic's command-line assistant, as our example. You will install it on an Ubuntu machine and use it to build a small Python program through a short series of prompts, watching how a sketch can grow into something with real structure and tests.

Consider working with a partner on this one --- there's a bit of a steep learning curve, and it will make this all more fun.

Part 1: Chatting with Gemini

Before installing anything, let's see what a "plain" chat assistant gives you when you ask for code. You'll use Google's Gemini for this. We all have access through our college Google accounts.

1. Sign in to Gemini

  1. Open https://gemini.google.com in your browser.
  2. Sign in with your Williams Google account.

2. Ask for a tic-tac-toe game

In the Gemini chat box, type:

Make a simple tic-tac-toe game in Python.

Read the response. Then save the code: make a directory ~/lab10-gemini, paste Gemini's code into a file there (e.g., tictactoe.py), and try to run it:

mkdir ~/lab10-gemini
cd ~/lab10-gemini
# paste Gemini's code into tictactoe.py using your editor
python3 tictactoe.py

Did it run on the first try? What data structure did it use for the board? Can you read it all easily?

Part 2: Install Claude Code

Claude Code runs in your terminal. Open a terminal on your Ubuntu machine and follow the steps below.

Claude Code ships with an install script that drops the claude binary into ~/.local/bin --- no sudo required.

1. Run the install script

curl -fsSL https://claude.ai/install.sh | bash

You should see output like:

✔ Claude Code successfully installed!
  Version: 2.1.142
  Location: ~/.local/bin/claude

2. Verify the install

You can run the binary directly from ~/.local/bin/:

~/.local/bin/claude --version

You should see the version number print. Everything lives under your home directory; nothing was installed system-wide. We'll use the full path ~/.local/bin/claude throughout this lab.

Part 3: Sign In

The instructor will provide credentials for an Anthropic account that you can use for this lab. Do not share these credentials outside the class.

Launch Claude Code from any directory:

~/.local/bin/claude

On first launch, Claude Code prompts you to sign in. Choose the browser sign-in option and follow the link it prints. In the browser, log in with the credentials the instructor provided. When sign-in completes, return to the terminal --- Claude Code should report that you are authenticated.

Type /exit (or press Ctrl-D) to quit. You only need to sign in once per machine.

Part 4: Build a Tic-Tac-Toe Game with Claude Code

You will now reproduce a short coding session. Each step is a single prompt to Claude. After each prompt, read what Claude produced before moving to the next step.

1. Set up a working directory

mkdir ~/lab10
cd ~/lab10
~/.local/bin/claude

2. Open a second terminal

Leave Claude running and open a second terminal window (or tab). cd into the same directory:

cd ~/lab10

You'll chat with Claude in the first terminal and run the code Claude writes (Python, tests) in the second. Having both open side-by-side makes it much easier to iterate: tweak via chat, run via shell, repeat.

3. Open the directory in an editor

Open ~/lab10 in your favorite editor (VS Code, Emacs, vim, gedit --- whatever you like). Keep it open alongside the two terminals.

This is the most important habit in this lab: every time Claude writes or changes a file, switch to the editor and read what it wrote. Don't just trust the summary Claude prints in the chat --- look at the actual code. Ask yourself:

  • Does this do what I asked?
  • Are there obvious bugs, missing cases, or weird choices?
  • Would I have written it this way?

If something looks wrong, say so in the chat and ask Claude to fix it before moving on.

4. First prompt: build the game

At the Claude prompt, type:

Make a simple tic-tac-toe game in Python.

Claude should create a file (for example, tictactoe.py) with a working two-player console game. Try running it:

python3 tictactoe.py

Play a quick game to confirm it works.

5. Second prompt: improve the data representation

Many AI-generated solutions represent the board as a flat list of nine squares. Ask Claude to do better:

Revise it to use a real data structure for the board.

Look at the diff. Did Claude switch to a 2D grid? Did it add helper functions for rows, columns, and diagonals? Run the game again to confirm it still works.

6. Third prompt: add tests

Add tests using the unittest package.

Claude should create a test file (for example, test_tictactoe.py). Run the tests:

python3 -m unittest test_tictactoe -v

All tests should pass.

7. Fourth prompt: generalize to N×N

So far the game is hard-coded to a 3×3 board. Ask Claude to make it work for any size:

Make the game support NxN grids.

Look at the diff. Did Claude take the size from the command line? Did it update the helper functions (rows, columns, diagonals, winner check) so they no longer assume a 3×3 board? Did it update the tests to cover larger boards?

Run the tests again, then try a 4×4 game:

python3 -m unittest test_tictactoe -v
python3 tictactoe.py 4

Part 5: Build Something Fun

Now that you've seen the basic rhythm --- prompt, read the diff, run the code, prompt again --- it's your turn to drive. Pick a small project and grow it with Claude Code the same way we grew tic-tac-toe.

Pick a project

Choose something you'd actually enjoy playing with. A few ideas to get you started:

  • Wordle clone. A command-line version that picks a secret five-letter word and shows green/yellow/grey feedback after each guess.
  • Conway's Game of Life. A grid-based cellular automaton. Ask Claude to animate it in the terminal.
  • Snake. An old-school snake game using the curses library.
  • Text adventure. A small game with a few rooms, items you can pick up, and puzzles. See how Claude organizes the world.

Or, if you'd rather build something you can open in a browser, ask Claude for a single self-contained index.html with the JavaScript embedded in a <script> tag. Some ideas:

  • Bouncing-ball playground. A <canvas> with a few balls that bounce off the walls and each other. Add sliders for gravity and friction.
  • Particle fountain. Click anywhere to spray particles that fall and fade. Easy to make beautiful in surprisingly few lines.
  • Drawing app. A <canvas> you can draw on with the mouse, with a color picker, clear button, and save-as-PNG.
  • Memory / matching game. A grid of face-down cards; flip two at a time, find pairs. Track a score and a timer.
  • Reaction-time tester. Wait a random interval, flash the screen, measure how fast the user clicks. Keep a leaderboard in localStorage.
  • Pomodoro timer. A simple 25/5 timer with start/pause/reset controls and a sound at the end.
  • Lissajous / spirograph toy. Sliders for frequencies and phase, drawing the resulting curves on a <canvas> in real time.

To view a single-file page, just open index.html (macOS) or xdg-open index.html (Ubuntu) from the terminal --- no server required.

Start from a fresh directory (e.g., ~/lab10-fun), launch Claude there, and open a second terminal and an editor as before.

Set yourself up for success

  • Start small, then grow. Don't ask for the finished thing in one prompt. Begin with a sketch (like "make a single-room text adventure in Python"), get it running, then add features one at a time.
  • Read every diff. Same habit as in Part 4. If you don't understand a line, ask Claude to explain it.
  • Ask for tests. Once the structure stabilizes, ask for unittest tests for the trickier functions. Run them.
  • Push back. If you don't like a choice Claude made, say so: "use a dictionary instead of two parallel lists" or "split this into a separate module."

Try a few Claude Code features

While you build, try at least three of the following. Note in your write-up what each one does and whether it was useful.

  • /help --- list the built-in slash commands.
  • /clear --- start a fresh conversation when the context gets cluttered. Useful when you switch tasks.
  • /rewind --- undo Claude's recent work and roll the conversation back to an earlier point. Great when a prompt sent things in a wrong direction and you'd rather retry than try to patch your way out.
  • /init --- have Claude scan your project and write a CLAUDE.md summarizing it. Useful on bigger projects so future sessions start with context.
  • @filename --- reference a specific file in your prompt (e.g., "look at @game.py and add a save/load feature").
  • Show it an error. When a run fails, paste the traceback into the chat and ask Claude to fix it. Notice whether it changes the right thing.
  • Ask for a plan first. Before a big change, prompt: "Don't write any code yet --- just describe how you'd approach this." Then review the plan before letting it implement.
  • Refactor on demand. Ask Claude to rename a class, split a long function, or extract a helper. Check that the tests still pass.

One More Thing

I'll leave the Claude credentials active until Saturday morning, so if you'd like to keep playing around after lab --- finish your project, try another idea, or just poke at Claude's features --- feel free.