Course ES

Chapter 1 of 21 · basic

Set up your AI coding tools

What this session covers

Every other week in this book ends with you running a Python script that calls a model. I'm not going to make you type all of that code by hand — I don't, and you shouldn't either. This first hour sets up the AI coding tools I use to write the rest of it: Claude Code as the driver, Antigravity when an IDE-style surface makes more sense, and a three-step loop that turns a one-paragraph spec into a runnable file. By the end of the hour you've run the loop once and you trust it.

The tools you'll use

Claude Code is a command-line tool. You hand it a prompt; it edits your files or prints a result to stdout. In --print (non-interactive) mode it behaves like a normal unix command — stdin in, stdout out, non-zero exit on failure — and that is the mode the rest of this book leans on. Every example file in the next twenty weeks can be drafted by piping a precise spec into Claude Code, saving what comes back, and running it. I write almost none of the boilerplate myself anymore.

Install and authenticate per the official docs (link in the README in this folder). Verify with claude --version. The smallest useful invocation is below — it asks Claude Code for a tiny Python file, saves it, runs it.

#!/usr/bin/env bash
# week21 - claude-code-quickstart.sh
#
# The smallest useful Claude Code invocation: ask, save, run.
# Uses --print (non-interactive); behaves like a unix command.

set -euo pipefail

command -v claude >/dev/null || {
  echo "Claude Code CLI not found. Install:" >&2
  echo "  https://docs.claude.com/en/docs/claude-code/quickstart" >&2
  exit 1
}

# Pipe a precise spec in, save what comes out, then run it.
claude --print \
  "Write a Python script that prints exactly 'Hello from Claude Code' and nothing else. Output only the code. No fences, no commentary." \
  > hello_from_claude.py

echo "--- hello_from_claude.py ---"
cat hello_from_claude.py
echo "--- running ---"
python3 hello_from_claude.py

Antigravity is the other coding tool I keep on the bench. It runs as a workspace, not a CLI, so it's the one I reach for when several files are in flight at once and I'd rather not babysit a single command line. The book does not depend on it — every example here can be done in Claude Code alone — but if you already use Antigravity, point it at the same loop and the steps below don't change. Its docs move faster than this book; check them for the current setup.

A real coding loop

The loop is three steps and it is the same every week:

  1. Write a precise spec for the thing you want — three or four sentences, no more. Language, input shape, output shape, and any constraint that matters (no external deps, must include a self-test, no prose around the code).
  2. Send it to the coding tool with --print (or its equivalent) and pipe the result to a file. Do not paste; pipe. The whole reason to work this way is that the spec, the file, and the run all stay reproducible.
  3. Run it. If it fails, read the failure, refine the spec by one sentence, and repeat.

That's the whole workflow. The hour goes into writing the spec and judging the output, not into typing boilerplate.

Put it to work

The showcase script wires the loop into something you can use right now: pass it a spec as the first argument, it generates the code, it runs the code. The default spec writes a SHA-256 utility with a built-in self-test, so the script proves itself the first time you call it without arguments.

#!/usr/bin/env bash
# week21 - ai-pair-workflow.sh
#
# The "spec -> code -> run" loop you'll use every week to write the
# OpenAI / Gemini examples in this book. Hand the coding tool a precise
# spec on stdin, save what it returns, run it. Substitute Antigravity
# (or any other coding agent that accepts a non-interactive prompt) for
# `claude --print` and the loop does not change.

set -euo pipefail

command -v claude >/dev/null || {
  echo "Claude Code CLI not found. Install:" >&2
  echo "  https://docs.claude.com/en/docs/claude-code/quickstart" >&2
  exit 1
}

SPEC="${1:-Write a small Python program that, given one CLI argument, prints its SHA-256 hex digest. Use only the standard library. If no argument is given, run an assert-based self-test against the digest of the string 'hello' and print 'ok'. Output only valid Python code: no fences, no commentary.}"

ARG="${2:-}"

echo "spec: $SPEC"
echo
claude --print "$SPEC" > generated.py

echo "--- generated.py ---"
cat generated.py
echo
echo "--- running ---"
python3 generated.py "$ARG"

The one switch that matters is --print. Without it the CLI opens an interactive session and any shell pipeline that depends on it hangs. With it, you have a unix command you can compose in a Makefile, a shell script, or a CI step. Try it with your own spec next. The way to make the next twenty weeks feel routine is to write each week's example by handing the tool a one-paragraph spec instead of typing the file by hand.

Run it

See README.md in this folder. It has install pointers for Claude Code and Antigravity, the environment variable Claude Code expects, and the exact commands to run both scripts.

Takeaways

This book is going to ask you to write code in twenty more weeks. You'll write it faster, and more honestly, if you treat the AI coding tool as part of the toolchain instead of a chat window you copy-paste from. The spec is the unit of work. Save the spec next to the generated file, put both under version control, and you can rebuild any week's examples by re-running the loop. Everything that comes next assumes you already work that way.