Module 00: Projects
Starter projects are guided step by step and suit freshers. Stretch projects are open-ended, add production concerns, and suit experienced readers.
Six projects: three starters and three stretches (the open-source contribution is optional and needs a free GitHub account). Every project runs with no API key and no paid service — the only accounts anywhere are a free GitHub account for the optional parts marked below. Everything lives in or beside the ai-path workspace from lesson 00.1: ~/code/ai-path/ on macOS/Linux/WSL ($HOME\code\ai-path on native Windows PowerShell — though the path recommends WSL 2 there). Commands are shown in bash/zsh form; PowerShell alternatives appear where they differ.
The projects deliberately reuse each other: Starter A makes ai-path a real repository, Starter B drops tickets.db and a report into it, Starter C adds a scripts/ folder of shell tools, and the stretches extend the same folder. Do them in order and each one gets easier.
First time here? Do lesson 00.1 first — machine, editor, git, uv, Python 3.11+ and ~/code/ai-path itself — then read the lessons each project names. Python work uses python3 from the standard library only; there is nothing to pip install in this module.
Each project carries a time estimate for a fresher typing the code themselves; experienced developers will be faster. The estimates assume the lessons each project names are already done — reading them is extra.
Starter: The ai-path workspace, end to end#
Goal: Turn ~/code/ai-path into a proper git repository — scaffolded, committed, branched, merged through a pull request, and pushed to a remote — with a verification script that proves the repo state, exactly the way a real project starts.
Time: ~4–6 hours.
What you'll practise:
- Verifying your machine before you trust it:
check_setup.pyand the troubleshooting table (lesson 00.1, 7.2, 7.4) - Folder discipline and naming rules (00.1, 3.1–3.2)
git config,init, the daily loop, atomic commits and good messages (00.3, 2.2–2.4, 3.2, 3.6).gitignoreand the secrets rule (00.3, Part 4)- Branching, merging and resolving a planted conflict (00.3, Part 5, 5.3)
- Remotes, pushing, and the PR workflow — on GitHub or fully offline (00.4, 3.2, 3.7, 4.3, 4.6)
Setup: git and Python 3.11+ from 00.1. The GitHub route (steps 5–6 online) needs a free account at github.com and the GitHub CLI (brew install gh / winget install --id GitHub.cli / the apt or dnf commands in 00.4's Setup). The offline route needs nothing but git — a bare repository stands in for GitHub, exactly as in 00.4 §3.2.
Steps:
- Verify the machine. Save
check_setup.pyfrom 00.1 §7.2 into~/code/ai-path/and runpython3 check_setup.py. Fix everyFAILbefore continuing — the troubleshooting table maps each one to a cause. - Scaffold the repo. In
~/code/ai-path, createREADME.md(a title, one paragraph on what the folder is for, and a "Status" section),.gitignore(copy the Python block from 00.3 §4.1 plus.env,.venv/,__pycache__/),notes/withapi-facts.md, andcheck_setup.pyfrom step 1. Thengit init -b main, set your identity withgit config user.name/user.email(00.3 §2.2) and make the first commit:git add README.md .gitignore notes/api-facts.md check_setup.py && git commit -m "chore: scaffold ai-path workspace". - Make the history real. Make at least nine more atomic commits — one logical change each, imperative mood, Conventional Commits style (00.3 §3.6). Good candidates that the later projects fill in: a
.gitattributesfile (00.3 §4.3),notes/setup-notes.mdrecording your OS route and editor choice, anotes/tickets-schema.mdsketching the tables Starter B will create, and — if you've done Starter C — thescripts/folder, one commit per script. Ten commits total is the floor; more is better if the changes are real. - Branch and conflict.
git switch -c docs/api-notes, edit the same line ofnotes/api-facts.mdon the branch (e.g. change a verified fact's wording), commit,git switch main, edit that same line differently onmain, commit, thengit merge docs/api-notes. Read the<<<<<<</=======/>>>>>>>markers, resolve to the correct merged fact,git addandgit commit(00.3 §5.3). First rehearse the abort path once: redo a throwaway conflict andgit merge --abortto see the file return clean. - Push it — pick your remote.
- GitHub (free account):
gh auth login, thengh repo create ai-path --private --source . --remote origin --push(00.4 §3.7). Or create the repo on the website andgit remote add origin <url>thengit push -u origin main. - Offline: in a scratch folder run the bare-remote flow from 00.4 §3.2 —
git init --bare origin.git, add it asorigin,git push -u origin main. The lesson'sbare_remote_demo.sh(Exercise 1 solution) automates the whole teammate simulation.
- GitHub (free account):
- Open and merge a pull request. Push a second branch (
git switch -c docs/readme-polish, commit a README improvement,git push -u origin docs/readme-polish). Online:gh pr create --fill, read your own PR as a reviewer (00.4 §4.3–4.4), thengh pr merge --squash --delete-branch. Offline: simulate the merge withgit switch main && git merge --no-ff docs/readme-polish -m "Merge branch 'docs/readme-polish'", push, delete the branch (00.4 Exercise 2). - Verify it. Write
verify_repo.pyin the repo root — stdlib only,subprocesscalls to git — checking:.gitexists;git rev-list --count HEAD≥ 10;maincontains the merged feature branches (git branch --merged main); a remote namedoriginexists (git remote);git ls-filesdoes not list.env;README.md,notes/api-facts.mdandverify_repo.pyitself are tracked. Print onePASS/FAILline per check and exit 1 on any FAIL — the same contract ascheck_setup.py.
Verify it, and what you should see:
python3 verify_repo.py[PASS] .git repository present
[PASS] 12 commits on HEAD (need >= 10)
[PASS] docs/api-notes merged into main
[PASS] remote 'origin' configured
[PASS] no secrets tracked (.env absent from git ls-files)
[PASS] README.md, notes/api-facts.md, verify_repo.py tracked(Counts and branch names are yours; the shape is the contract. Commit counts, remote URLs and branch lists differ per machine, so treat this as illustrative.) Then prove the conflict lesson stuck: git log --oneline --graph --all should show the merge commit joining your branch, and git status should be clean.
Done when:
verify_repo.pyprints PASS for every check and exits 0.git logshows at least ten meaningful commits acrossmainand your feature branches — not ten edits to one file.- You resolved a real merge conflict by hand and can explain what the markers meant.
- The repo exists on a remote (GitHub or your bare
origin.git) andgit status -sbshowsmain...origin/mainwith nothing ahead or behind. - A pull request (real or simulated) was merged and its branch deleted.
notes/api-facts.mdcontains at least three verified API facts, each with a source and a date — the habit 00.8 §5.4 formalises.
Stretch ideas: Tag the merge v0.1.0 (annotated) and write release notes from the commit log with the whats_changed.py approach in 00.4 Exercise 15. Add CONTRIBUTING.md, CODE_OF_CONDUCT.md and .github/pull_request_template.md per 00.4 §6.1. Rehearse leak response safely: commit a .env containing only an obvious placeholder, run the local secret_scan_local.py from 00.4 §8.6, then fix the repo so a second scan is clean. Needs a free GitHub account: write the profile README and pick your pinned repos per 00.4 §9 — Module 14B builds on this.
Common problems:
git commitfails with "Please tell me who you are" → setuser.name/user.emailper 00.3 §2.2; do it repo-locally, not--global, if practising in scratch repos.git pushasks for a password or fails after enabling 2FA → HTTPS git auth needs a token orgh auth login, not your password (00.4 §3.5).- Merge conflict markers left in a file →
git statuskeeps showing "both modified"; finish bygit add+git commit, or back out entirely withgit merge --abort. verify_repo.pyfails on the secrets check →.envgot committed before.gitignoreexisted; untrack it withgit rm --cached .env, commit, and remember the file still lives in history (00.3 §4.2).- Commits all say "update" or "fix" → rewrite the habit, not the history: 00.3 §3.6 is the standard your future self (and reviewers) will thank you for.
Starter: tickets.db — build it, query it, report on it#
Goal: Build the support-ticket database from the lesson's script, answer fifteen questions in SQL that between them use the whole lesson, prove an index changes a query plan, and finish with a Python report that queries the database the safe way.
Time: ~4–6 hours — the fifteen hand-written queries are the bulk of it.
What you'll practise:
- The relational model,
CREATE TABLEand every constraint, andexecutemanyseed data (lesson 00.7, 1.2, 2.2–2.3, 2.5) SELECT,WHERE, NULL's three-valued logic,ORDER BY/LIMIT(00.7, Part 3)- Aggregation,
GROUP BY,HAVING, expressions andCASE(00.7, Part 5) - Subqueries, CTEs and window functions (00.7, 5.4–5.6)
- Every JOIN shape, many-to-many and self-joins, anti-joins (00.7, Part 6)
- Indexes and
EXPLAIN QUERY PLAN(00.7, 7.3) - JSON functions and FTS5 inside SQL (00.7, 9.1–9.2)
- Safe Python access:
row_factory, parameterised queries,executemany,with con:(00.7, Part 8)
Setup: Python 3.11+ only — sqlite3 ships in the standard library, so there is nothing to install and no server to run. Work inside ~/code/ai-path/ (Starter A's repo, or create the folder per 00.1 §3.1 if you're doing this standalone).
Steps:
-
Build the database. Save the complete
make_tickets_db.pyscript from 00.7 §2.3 into~/code/ai-path/and runpython3 make_tickets_db.py. It prints the row counts it wrote and is safe to re-run — it rebuildstickets.dbfrom scratch. Sanity-check withpython3 -c "import sqlite3; print(sqlite3.sqlite_version)", and compare the row counts it printed with the lesson's listing under the script (customers 10, agents 4, tickets 20, tags 6, ticket_tags 24, messages 40, ticket_events 12). -
Answer the fifteen questions. Create
questions.sql— one comment line per question, the query beneath it — and run each againsttickets.db(thesqlite3CLI if you have it, or a tiny Python runner; 00.7 §2.4 shows the shell). Type every query yourself before checking the lesson exercises and drills it resembles — the goal is fluent composition, not recognition (00.7 Exercises, drills).# Question Lessons it exercises 1 Subject and status of ticket 7. §3.1 2 Every openticket with priorityhighorurgent, with the customer's name; urgent first.§3.2, §3.4, JOIN 3 How many tickets each agent holds — including agents with none and unassigned tickets. §5.1, LEFT JOIN, COALESCE4 Average rating of resolvedtickets, grouped by the customer's plan.§5.1–5.3, AVG,ROUND5 How many opentickets have no rating — and why doesn'tWHERE rating > 3find them?§3.3 NULL logic 6 Ticket counts per channel. §5.1 GROUP BY7 Which tickets carry both the bugandoutagetags?§6.3, EXISTS/self-join onticket_tags8 Every agent's name and their manager's name (Lena has none). §6.3 self-join, LEFT JOIN 9 ticket_eventscounts bykind.§5.1 10 For status_changeevents, group by the JSON payload'stovalue.§9.1 json_extract11 The three customers with the most tickets, using a CTE and ROW_NUMBER.§5.5–5.6 12 Tickets with the longest message threads (top 3). §5.4 subquery, JOIN 13 high/urgenttickets grouped by status.§5.1–5.2 HAVINGvsWHERE14 Agents' messages vs customers' messages — totals by author.§5.1 15 Every openorpendingticket: id, customer, agent (or "(unassigned)"), priority, subject — urgent first, then high.everything above combined -
Add an index and watch the plan change. Pick the query from question 2 (it filters on
statusandpriority). RunEXPLAIN QUERY PLANon it before creating an index — expect a fullSCANof the tickets table (SCAN tif you aliased it ast) — thenCREATE INDEX idx_tickets_status ON tickets (status)(oridx_tickets_priority), re-run the plan, and compare (00.7 §7.3). Write the before/after pair intonotes/tickets-db.mdwith one sentence on the trade-off (faster reads, slower writes). Drop the index when done if you like — or keep it and note that in your commit. -
Write the report. Create
report.py— the open/pending digest — using the §8.1 pattern:sqlite3.connect,con.row_factory = sqlite3.Row, a parameterisedWHERE t.status IN (?, ?)(never f-string SQL, §8.2),COALESCEfor the unassigned agent, andORDER BYmatching question 15. Accept the statuses assys.argvsopython3 report.py open pendingworks. -
Prove the safe/unsafe difference. In a scratch copy (or on
scratch.db— §8.2's warning applies: don't mutate the demo data you want to keep), run the lesson's injection demo:lookup("7 OR 1=1")unsafe returns all rows; the parameterised version returns[]. Paste both results intonotes/tickets-db.md. -
Commit it. If Starter A is done, commit
make_tickets_db.py,questions.sql,report.py,notes/tickets-db.md(andtickets.dbonly if you decide binary data belongs in git — 00.3 §4.5 explains why it usually doesn't;.gitignoreit and keep the script as the source of truth).
Verify it, and what you should see:
python3 make_tickets_db.py && python3 report.py open pendingThe script's own output ends with Wrote tickets.db. The report prints one row per open/pending ticket — the lesson's verified run on the seed data (Python 3.14, SQLite bundled):
id=2 customer='Alan Turing' agent='Priya Nair' priority='urgent' subject='Export to CSV times out on large reports'
id=15 customer='Dennis Ritchie' agent='Lena Fischer' priority='urgent' subject='SSO login broken after IdP certificate rotat.'
id=12 customer='Grace Hopper' agent='Priya Nair' priority='normal' subject='Search returns stale results after edit'
id=18 customer='Frances Allen' agent='Lena Fischer' priority='normal' subject="Cannot delete workspace — 'in use' error"
id=5 customer='Margaret Hamilton' agent='(unassigned)' priority='low' subject='How do I add a second admin user?'
id=8 customer='Barbara Liskov' agent='Lena Fischer' priority='low' subject='Request: dark mode for the admin panel'
id=4 customer='Katherine Johnson' agent='Tom Becker' priority='high' subject='Webhook deliveries failing with 500'
id=11 customer='Ada Lovelace' agent='Tom Becker' priority='high' subject='Two-factor codes not arriving by SMS'
id=13 customer='Katherine Johnson' agent='(unassigned)' priority='high' subject="Bulk import fails with 'row 47: bad date'"
id=17 customer='Ken Thompson' agent='Tom Becker' priority='high' subject='Webhook signature validation failing'(The exact dict formatting depends on how you print rows; the set and order of rows is fixed by the ORDER BY. Note priority DESC sorts alphabetically — urgent, normal, low, high — which is why high lands last; a CASE rank would fix that, per lesson exercise 1's note.) Spot-checks with verified answers: question 3 gives Priya Nair 7, Tom Becker 4, Sam Rivera 4, Lena Fischer 3, (unassigned) 2; question 5's answer is 7; question 7 returns tickets 2 and 6; the index plan flips from a SCAN of tickets to SEARCH … USING INDEX idx_tickets_status (status=?)-style output.
Done when:
tickets.dbbuilds from the script and all fifteen questions return sensible, verified answers — several match the lesson's own exercise/drill outputs exactly.- Your
questions.sqluses at least one JOIN of each kind the lesson covers (inner, left, self) plusGROUP BY/HAVING, a CTE or window function, a subquery,json_extract, andEXISTSor an anti-join. - The before/after
EXPLAIN QUERY PLANpair is recorded innotes/tickets-db.mdwith the trade-off sentence. report.pyruns parameterised queries only, accepts statuses as arguments, and its output matches the digest above.- The injection demo is reproduced once, safely, and explained in your notes.
Stretch ideas: Add an FTS5 virtual table over ticket subjects and compare MATCH vs LIKE results (00.7 §9.2). Write the same digest as a single CTE chain instead of one big join (§5.5). Add a VACUUM INTO 'backup.db' backup step and a tiny migration note for the next schema change (§7.5). Going further: this is the shape of the cost/usage tables in 11A.2 and the eval-results tables in 10A.2 — same GROUP BY/SUM muscles.
Common problems:
no such table→ you ran the queries in the wrong folder;tickets.dbis a file — checkpwdand thatmake_tickets_db.pyprintedWrote tickets.db(00.2 §1.7).- Counts that don't match the lesson → the database was mutated by a demo (
UPDATE/DELETE/executemanyexercises); re-runpython3 make_tickets_db.py— it rebuilds cleanly by design. PRAGMA foreign_keys = ON"not working" → you set it after other statements inside an open transaction; set pragmas immediately afterconnect()(§8.3).report.pyreturns everything or errors on quotes → you interpolated the status into the SQL string; use?placeholders (§8.2).- The index "did nothing" → SQLite correctly chose
SCANanyway on a 20-row table — indexes pay off on larger tables; check the plan text and tryWHERE customer_id = 3like the lesson does.
Starter: Shell toolkit — five scripts that earn their keep#
Goal: Write five small, safe, documented shell scripts — a log summariser, a bulk renamer, a backup script, a JSON report and a project scaffolder — that you will actually reuse, with a README explaining each.
Time: ~3–4 hours.
What you'll practise:
- Command anatomy, exit codes, quoting and globs (lesson 00.2, Part 1–2)
- Pipes and redirection,
grep,sort,uniq,cut,wc(00.2, Part 4) jqfor JSON at the command line (00.2, 4.8)- Safe file operations:
mkdir -p,cp,mv, rehearsedrm(00.2, Part 3) - Variables,
set -euo pipefail, arguments, when to stop and use Python (00.2, Part 8) - The macOS/Linux ↔ PowerShell mapping habit (00.2 cheat sheet)
Setup: A terminal and bash/zsh (macOS, Linux, WSL). jq is required for script 4 — install per 00.2's Setup (brew install jq, sudo apt install jq, or winget install jqlang.jq). No Python needed, though script 5 may call git init if present. All scripts live in ~/code/ai-path/scripts/ (create it; add it to git per Starter A if that project is done).
Starter data — create ~/code/ai-path/data/ with these two files so the scripts have something real to chew on:
data/app.log (a web server's log; the same shape as the lesson's demo log):
2026-11-01T09:00:01Z INFO server started
2026-11-01T09:00:14Z DEBUG cache hit
2026-11-01T09:01:02Z ERROR db connection refused
2026-11-01T09:01:03Z WARN retrying db connection
2026-11-01T09:02:10Z INFO request served
2026-11-01T09:02:11Z ERROR db connection refused
2026-11-01T09:03:00Z INFO request served
2026-11-01T09:03:01Z ERROR db connection refuseddata/tickets.json (the lesson's demo shape — request_id plus a tickets array):
{"request_id":"req-1042","tickets":[
{"id":"T-101","subject":"cannot log in","status":"open","priority":"high"},
{"id":"T-102","subject":"invoice question","status":"resolved","priority":"normal"},
{"id":"T-103","subject":"site down","status":"open","priority":"urgent"},
{"id":"T-104","subject":"feature request","status":"pending","priority":"low"}]}Steps:
summarize.sh LOG_FILE— for each ofDEBUG INFO WARN ERROR, print the level and its line count (grep -c " LEVEL "), then total lines (wc -l). Loop over the levels,set -euo pipefail, quote"$LOG_FILE". This is 00.2 §8.3'ssummarize_errors.shgeneralised — compare yours with the lesson's.bulk_rename.sh DIR PREFIX— rename every*.jpginDIRmatchingimg_NNN.jpgtoPREFIX_NNN.jpg. Rehearse safely first: print eachmvas a dry run unless--applyis passed (00.2 §9.3 and thermrehearsal rule in §3.5). Use aforloop and${name##*/}-style parameter expansion orbasename; handle the "no matches" case gracefully.backup.sh SRC_DIR DEST_ROOT— copySRC_DIRtoDEST_ROOT/backup-YYYYMMDD-HHMMSS/(timestamp viadate +%Y%m%d-%H%M%S), then prune backups keeping the newest 5. CheckSRC_DIRexists andDEST_ROOTis creatable before copying; never delete anything outsideDEST_ROOT(00.2, file-safety rules).ticket_report.sh JSON_FILE— withjq: printrequest_id; the ticket count; counts perstatus(jq -r '.tickets[].status' | sort | uniq -c); and theid+subjectof everyopenticket (jq -r '.tickets[] | select(.status=="open") | "\(.id) \(.subject)"'). Guard withcommand -v jqand a friendly error if it's missing.new_project.sh NAME— scaffold~/code/NAME/withmkdir -p, a minimalREADME.md(title + one-line purpose placeholder), a.gitignorefrom 00.3 §4.1, anotes/folder, and — ifgitexists —git init -b main. Refuse to run if the folder already exists (no silent overwrites). Heredocs (cat > file <<'EOF') are the tool; quote the delimiter so$isn't expanded (00.2 §8.2).- Write
scripts/README.md— one paragraph per script: what it does, usage line, one example, and which lesson section taught each technique. Note honestly which parts are bash and which would become Python if they grew (00.2 §8.5). - Rehearse the dangerous one. In a scratch folder, create fake
img_001.jpg–img_003.jpg, runbulk_rename.shdry-run then--apply, and prove a typo'dDEST_ROOTinbackup.shfails before deleting anything.
Verify it, and what you should see:
chmod +x scripts/*.sh
scripts/summarize.sh data/app.log
scripts/ticket_report.sh data/tickets.jsonsummarize.sh prints the per-level counts and total — for the sample app.log above: DEBUG 1, INFO 3, WARN 1, ERROR 3, total 8 (order follows your loop). ticket_report.sh prints req-1042, 4 tickets, the status counts (open 2, pending 1, resolved 1) and the two open tickets T-101 cannot log in / T-103 site down. new_project.sh demo-app creates the folder tree and git status inside it reports a fresh repo on main. Every script exits non-zero with a readable message when given bad input — test summarize.sh /nonexistent.log.
Done when:
- All five scripts run on your OS, are executable, and pass
bash -n(syntax check) cleanly. summarize.shandticket_report.shproduce the outputs above on the starter data.bulk_rename.shdefaults to dry-run and only mutates with--apply;backup.shprunes to 5 and refuses unsafe destinations.new_project.shrefuses to overwrite an existing folder.scripts/README.mddocuments usage and cites the lesson sections.- (If Starter A is done) each script was committed separately with a real message.
Stretch ideas: Add --help to each script (case "$1" in -h|--help) and a set -u-safe ${VAR:-default} pattern (00.2 §8.2). Make backup.sh verify the copy (diff -r or checksums) before pruning. Port summarize.sh's counting to jq over a JSONL log — the same skill that reads LLM traces in 11A.1. Honest limit: when a script needs real data structures or others must maintain it, that's the signal to move to Python — 00.2 §8.5 names the triggers, and Module 01A teaches the language.
Common problems:
Permission deniedrunning./summarize.sh→ missing execute bit and shebang;chmod +xfixes the first,#!/usr/bin/env bashas line 1 the second (00.2 §6.3).set -ekills the script ongrepfinding nothing →grep -cexits 1 on zero matches; use|| trueorgrep -c ... || n=0deliberately.- Filenames with spaces break loops → quote everything:
"$f","$DIR", and preferwhile IFS= read -roverfor f in $(ls)(00.2 §2.7). jq: command not found→ install it per Setup, or add acommand -v jqguard with a clear message.- macOS vs Linux differences bite (
sed -i,date,stat) → the lesson's BSD-vs-GNU callouts and cheat sheet exist for exactly this; test on your target OS.
Stretch: A JSON API client, built from docs alone#
Goal: Integrate a service you have never used — the fictional ParcelPost shipping API — using only its documentation: read the reference like a professional, write a standard-library Python client, prove it against a fake server you write yourself, and keep a dated notes file of verified facts.
Time: ~4–6 hours — the fake server and the client are each roughly half the work.
What you'll practise:
- The docs-site map and which page to read first (lesson 00.8, Part 1)
- The reference-entry checklist: endpoint, parameters by location, request/response, errors, limits — and what the docs don't say (00.8, 2.1, 2.6)
- Percent-encoding, headers, JSON bodies, status codes and error envelopes (00.6, Parts 1–2)
- A stdlib
urllib.requestclient and a stdlibhttp.serverfake (00.6 §5.4, 00.8 §8.4–8.5) - Cursor pagination and the
next_cursor: nullend signal (00.6 §3.3) - Reading an OpenAPI document and diffing it against the prose docs (00.8, Part 3)
- The source-reliability checklist, volatile facts and the notes-file habit (00.8, Part 5)
Setup: Python 3.11+ standard library only — urllib.request, json, http.server, threading. No API key: the "API key" is a placeholder the fake server accepts. Work in a scratch folder (e.g. ~/code/api-practice/parcelpost/) — this project deliberately lives outside ai-path until it works, then you may move it in.
The documentation (a condensed copy of 00.8 §8.2 with the same contract — the full text, including the error type table, is there; the essentials are reproduced here so the project stands alone):
ParcelPost API — Base URL
https://api.parcelpost.example/v1; every request needsAuthorization: Bearer <key>(pp_test_keys); JSON in and out.
Method & path Purpose Parameters GET /quotesPrice a shipment query: to_postcode(required),weight_gint grams (required),service(optional, defaultstandard)POST /shipmentsCreate a shipment body: to_postcode,weight_g(1–30000),service(optional) →201+ shipment object{id, to_postcode, weight_g, service, status, price_pence, currency, tracking_url}GET /shipmentsList shipments query: limit(default 2, max 5),cursor(optional); returns{items, next_cursor}— passnext_cursorback until it isnullGET /shipments/{id}Fetch one path id
service∈economy,standard,express. Errors are{"error": {"type", "code", "message", "request_id"}}:400malformed,401auth,404unknown route/id,422field violation (codenames the rule). Rate limit 60 req/min;429→ wait and retry. The vendor also publishes/openapi.json(00.8 §8.6 has the full document).
Steps:
- Read before you write. Spend fifteen minutes on the reference alone and write
notes/reading-notes.md: the four endpoints, every parameter with its location and constraints, the error table, and — the important part — a "what the docs don't say" list (00.8 §8.3 models this: isprice_pencetaxed? istracking_urlstable? whatstatusvalues exist beyondlabel_created?). - Write the client from the docs.
parcelpost_client.py:get_quote,create_shipment,get_shipment,list_shipments— stdlib only,urllib.parse.urlencodefor query strings (postcodes contain spaces), a timeout on every call, and anApiErrorcarryingstatus/type/code/request_id(00.8 §8.4 has the full worked version to compare against after you've tried). ReadPARCELPOST_URL/PARCELPOST_API_KEYfrom the environment, defaults for local testing. - Write the fake server.
parcelpost_server.py: ahttp.server.BaseHTTPRequestHandleron127.0.0.1with an ephemeral port (("127.0.0.1", 0)), in-memory shipment store starting empty, deterministic IDs (ship_0001,ship_0002, …), the documented validation (weight_g1–30000 on both quote and create — the docs only restate it on POST, a real docs gap the lesson's spec reveals), cursor pagination honouringlimit≤ 5 andnext_cursor: null, and the four documented error envelopes with incrementingrequest_ids. Compare with the lesson's server afterwards — yours should enforce the same contract. - Prove it.
demo.py: start the server in a daemon thread, setPARCELPOST_URLto its actual port before importing the client, then exercise every endpoint — a quote, three shipments to postcodes with spaces (SW1A 1AA,M1 1AE,EH1 1YZ), a fetch, two pages oflist_shipments, and the three error paths (422 bad weight, 404 unknown id, 400limit=99). Shut the server down at the end (00.8 §8.5). - Diff prose vs spec. Save the OpenAPI document from 00.8 §8.6 as
parcelpost_openapi.json, run theread_openapi.pyscript from 00.8 §3.2 on it, and write down every place the machine-readable spec says something the prose didn't (or vice versa). - Keep the notes file.
notes/parcelpost.mdin the 00.8 §5.4 format: facts you verified against the running fake (with the date), facts taken from docs only, and an explicit "NOT verified" section. This file is the deliverable that transfers to real APIs later. - Stretch within the project: add
DELETE /shipments/{id}to your docs (write the reference section first, then implement server and client) — the exercise of writing docs before code is the skill.
Verify it, and what you should see:
python3 demo.pyThe lesson's own verified run of the same exercise produced (deterministic — your IDs and prices should match if you implemented the contract faithfully):
quote: {'price_pence': 360, 'currency': 'GBP', 'eta_days': 3, 'service': 'express'}
created: ship_0001 label_created -> SW1A 1AA
created: ship_0002 label_created -> M1 1AE
created: ship_0003 label_created -> EH1 1YZ
track: https://track.parcelpost.example/ship_0001
page1 next_cursor: 2 ids: ['ship_0001', 'ship_0002']
page2 next_cursor: None ids: ['ship_0003']
error: 422 invalid_fields (request_id=req_0001)
error: 404 shipment_not_found (request_id=req_0002)
error: 400 bad_limit (request_id=req_0003)If your output differs, the difference is information: a wrong price_pence means your quote formula differs from the spec; a next_cursor that never ends means you're looping on items instead of next_cursor; a missing request_id means your error envelope is incomplete.
Done when:
demo.pyexercises all four endpoints plus the three documented error paths and prints the shape above.- Pagination stops on
next_cursor: null— exactly two pages for three shipments atlimit=2, with no extra empty-page request. - The client percent-encodes query parameters, sends
Authorization: Bearer, setsContent-Type: application/json, uses a timeout, and raises a typed error carryingrequest_id. - Your fake server enforces the documented constraints — including the
weight_gbound onGET /quotesthat the prose never restated. notes/parcelpost.mdseparates verified facts, docs-only facts and unverified questions, each dated.- You can name, from your reading notes, three things the documentation did not tell you.
Stretch ideas: Add the DELETE endpoint end-to-end (docs first). Add a retry-with-backoff wrapper for 429 using the four timeout types from 00.6 §1.9 — the real engineering is 01B.9 and 03.8. Generate a typed client skeleton from parcelpost_openapi.json and compare it with your hand-written one (00.8 §3.4). Point the same client code at a real free API later — the discipline is identical; only the docs URL changes.
Common problems:
URLError/Connection refusedon import →PARCELPOST_URLmust be set beforeparcelpost_clientis imported (it reads env at module load); the lesson's demo ordering exists for this reason.- Postcode with a space breaks the URL → use
urllib.parse.urlencode, never string-concatenate query params (00.6 §1.4). list_shipmentsloops forever → you're checkingitemsfor emptiness; the contract isnext_cursor: null(00.8 §8.3).POST"fails" with 201 → 201 is success; only 2xx matters, and your client must accept it (00.6 §1.5).- The server port collides → bind
("127.0.0.1", 0)for an ephemeral port and readserver_port— never hardcode 8765 in tests (00.2 §6.6).
Stretch (optional): Contribute to an open source project#
Goal: Make one real, small contribution to an open-source project — ideally a documentation fix — following its CONTRIBUTING.md and issue conventions, and open a pull request a maintainer can actually merge.
Time: ~2–4 hours of your own work — plus maintainer latency, which you don't control (days to weeks is normal for a first-time contributor).
What you'll practise:
- Fork vs branch-and-PR, and the upstream-remote dance (lesson 00.4, 4.2)
- Writing a PR reviewers can review: what/why/how-I-tested (00.4, 4.3)
- Code review as a skill, including reviewing generated code critically (00.4, 4.7)
- Issues: labels, linking
Fixes #N, good bug reports (00.4, Part 5) - Licences and provenance when touching other people's code (00.4 §6.6, 00.9 §5.4)
- Asking well: minimal reproducible examples and the good question (00.9, 4.3–4.4)
Setup: needs a free GitHub account and gh (00.4 Setup). Everything else is the git you already know.
Steps:
- Pick the right first issue. Search GitHub for
is:issue is:open label:"good first issue"in a project you genuinely use — documentation fixes, broken links, small test additions. Prefer issues with a linkedCONTRIBUTING.mdand recent maintainer activity. Read the issue and its comments before committing to it; if someone claimed it, pick another. - Read the governance files first.
CONTRIBUTING.md,CODE_OF_CONDUCT.md, the PR/issue templates in.github/, the licence, and one recently-merged PR to learn the house style (00.4 §6.1, §5.5). If the project asks you to open an issue before a PR, do that — some do, and skipping it is the fastest way to get ignored. - Fork and branch. Fork on GitHub,
gh repo cloneyour fork,git remote add upstream <original-url>, and branch offupstream/main(git fetch upstream && git switch -c fix/docs-typo-42 upstream/main) — never commit to your fork'smainfor the contribution itself. - Make the smallest correct change. One issue, one PR, one logical change — atomic commits (00.3 §3.6). If you used an AI assistant for any of it, say so in the PR and verify every line yourself (00.9 §5.2); check the licence implications of copied code.
- Write the PR properly. Title in the project's style; body with What (links
Fixes #42), Why, How I tested (00.4 §4.3). Attach screenshots or command output where relevant. Request review only if the project uses that flow. - Respond to review like a professional. Maintainers may request changes, ask questions, or close the PR. Reply to every comment, push fixes as new commits (don't force-push over review feedback — 00.4 §4.5), and thank people. A graceful response to a rejected PR teaches you more than a merged one.
- Write it up. Add a
notes/open-source-first-pr.mdinai-path: the issue, your PR link, what review taught you, and what you'd do differently. This is portfolio material for Module 14B.
Verify it, and what you should see: the verification is the PR itself — gh pr status shows it open (or merged/closed), CI checks (if the project has them) run on it, and at least one maintainer or bot interaction happens. A merged PR is the gold standard; a politely-reviewed-and-closed one still counts as done if you followed the process.
Done when:
- You found the issue yourself via labels/search, read the governance files, and followed them.
- Your PR is small, focused, well-described, and links the issue correctly.
- You responded to every review comment professionally — including "no".
- Your notes file records the lesson, not just the link.
Stretch ideas: After the first PR merges, pick a second, slightly larger issue. Review someone else's open PR and leave one genuinely useful comment (00.4 §4.7) — reviewing is the faster way to learn what good code looks like. If the project is AI-adjacent (an SDK, a docs site, an eval tool), say so — relevant open-source history is exactly what AI-engineering hiring managers look for.
Common problems:
- PR ignored for weeks → you skipped
CONTRIBUTING.md, picked a contested issue, or the PR is too big; read the merged-PR history to calibrate size. - CI fails on a docs typo → check the project's lint rules (markdownlint, link checkers) before pushing; run their checks locally first.
- "Please open an issue first" → some projects require it; open the issue, wait for a maintainer's go-ahead, then PR.
- Accidentally committed to the wrong remote/branch →
git remote -vandgit branch -vvare your friends; fix with a new branch, not history surgery, until you know 00.3 Part 6.
Stretch (optional): Dotfiles and automation#
Goal: Turn your machine's configuration into a versioned, shareable repo — dotfiles with symlinks, a task runner for common commands, and a CI workflow that checks the repo on every push — the "adult" version of the setup habits from 00.1 and 00.2.
Time: ~3–4 hours, mostly in the sanitisation and the CI debugging.
What you'll practise:
- Dotfiles as config you version (00.1 §3.3)
- Startup files and what each shell reads (00.2, 5.4)
set -euo pipefaildiscipline and when scripts become Python (00.2, Part 8)- Makefile/task-runner thinking (00.2 §8.6)
- GitHub Actions anatomy:
on,jobs,steps,uses,run, secrets vs variables, pinning (00.4, Part 7) - Safe, reviewable automation instead of
curl | sh(00.2 §9.3)
Setup: git and your shell of choice. The Makefile/just part works fully offline; the Actions part needs a free GitHub account and a repo to push to (reuse ai-path or make dotfiles public/private as you prefer — public gets secret scanning free, per 00.4 §8.1).
Steps:
- Inventory your dotfiles. List the config files your shell and tools actually read:
~/.zshrcor~/.bashrc,~/.gitconfig,~/.gitignore_global, editor settings,~/.ssh/config(structure only — never commit private keys or tokens). Read 00.2 §5.4 to know which file your shell reads when. - Create the repo.
git init dotfiles(in~/code/or a scratch area first), copy sanitised versions of your dotfiles into ahome/subfolder mirroring their real paths (home/.zshrc,home/.gitconfig, …). Add aREADME.mdexplaining the layout and the symlink strategy, plus an install scriptinstall.shthat creates symlinks (ln -sfn) from~/to the repo files — with a--dry-runflag that only prints what it would link. - Move real config gradually. Start with the safest file (
.gitignore_globalor a shell alias block), symlink it, open a new terminal, verify it loads, then commit. One file per commit — atomic and reversible (00.3 §3.6). Never symlink.sshwholesale; review every file for secrets before it enters git (00.4 §8.5–8.6). - Write the task runner. A
Makefile(installed everywhere) orjustfilewith targets for your real repeated tasks:make setup(runinstall.sh),make test(your project's checks),make lint,make clean. Each recipe is one shell command — this is whereset -euo pipefailthinking applies to automation. Compare with theMakefile/justawareness in 00.2 §8.6; when recipes grow logic, that's the Python signal (§8.5). - Add the CI workflow.
.github/workflows/check.ymlfollowing 00.4 §7.2–7.3's anatomy:on: push+pull_request, one job, steps that check out the repo and run your checks — for this repo, a shellcheck-style syntax pass (bash -non every*.sh), a "no secrets" grep for obvious placeholder patterns, andinstall.sh --dry-runsucceeding. Pin actions by tag/SHA per §7.4; never echo secrets. - Push and watch. Push the repo, open the Actions tab, and read a real run — green first try is rare; debug the workflow YAML itself (indentation,
runvsuses, shell quoting) until it's green. This is your first CI loop, and it's deliberately tiny.
Verify it, and what you should see: locally, install.sh --dry-run prints the symlink plan without touching ~/; after install.sh, ls -la ~/ shows the symlinks and a new shell picks up your aliases. On GitHub, the Actions run for your latest commit shows a green check, and git log shows the workflow file itself versioned like everything else.
Done when:
- At least three real dotfiles are versioned and symlinked, with
install.shreproducing the setup on a fresh account (test in a scratch$HOMEif possible). Makefile/justfiletargets run your common tasks and are documented in the README.- The CI workflow is green on GitHub and actually checks something (syntax, secrets, dry-run) — not a no-op.
- No secrets, keys or machine-specific paths are committed; the sanitisation is explained in the README.
Stretch ideas: Add a second machine profile (home-linux/ vs home-macos/) selected by uname. Add a bootstrap target that installs prerequisites idempotently (with the official install commands from 00.1, never curl | sh). Encrypt the truly-private dotfiles with git-crypt or age and document the key handling. Wire check_setup.py from 00.1 §7.2 into CI so a fresh Codespace self-verifies (00.1 §2.5).
Common problems:
- New terminal doesn't see changes → startup files are read at shell start; open a new one, or
source ~/.zshrcdeliberately. - Symlink loops or wrong targets →
install.shmust resolve the repo path absolutely and useln -sfn; test with--dry-runfirst. - Workflow YAML fails with cryptic errors → YAML is whitespace-sensitive; validate indentation and check the run logs line by line — 00.4 §7.2 annotates every key.
- Accidentally committed a token → rotate it first (00.4 §8.5), then clean history; the repo being private doesn't make it safe.
- "It works on my machine" for the dotfiles themselves → that's the whole point of the project: if
install.shcan't reproduce your setup from a clean checkout, the repo isn't done.