AI-Assisted Coding · Module 1Lesson 9

Study explanation · Lesson 09 · 13 min

Hands-on C: scaffold, run and reflect

The first real code you run is a minimal FastAPI skeleton with one endpoint. Ask for it with your ADR as context, inspect every file, run the server, test /health and /docs, and refine with exact errors. Then write the reflection log from your own notes.

Listen to this lesson

Hear the lesson read aloud, with each sentence highlighted as you go.

Narrated by an AI voice.

The first real code you run

Part C is not the full Task Tracker. The goal is a minimal FastAPI foundation with one working endpoint. You apply the whole loop: ask for the scaffold with your ADR as context, inspect every file, run the server, test /health, and refine using exact errors when something fails.

Key ideaMinimal, runnable, scoped and verifiable: one endpoint that you have seen work.

What the skeleton includes, and what waits

The notes draw the line for you.

Skeleton should include, and should not include yet · Lecture notes p. 15
Skeleton should includeSkeleton should not include yet
Folders such as app/, app/api/routes/, app/core/, app/models/, app/storage/, and tests/.Full CRUD task endpoints.
requirements.txt with FastAPI/Uvicorn dependencies.Authentication or user accounts.
app/main.py creating the FastAPI app.A production database or deployment setup.
GET /health returning HTTP 200 with JSON such as {"status":"ok", "timestamp":"..."}.Full business logic or data persistence behavior.
.env.example, .gitignore, and README.md.Docker/cloud/microservice complexity in Module 1.

Read with careThe folder list includes app/storage/ even though persistence behavior waits for a later module. Read it as structure only: an empty home for storage code, not storage itself.

Run and verify

These are the notes’ typical commands. Activation differs by operating system, so the notes leave that line to you. Then open the Swagger page in a browser and confirm the endpoint appears and responds.

Commands from the notes# Typical run and verification flow python -m venv venv # activate the environment for your OS pip install -r requirements.txt uvicorn app.main:app --reload curl http://localhost:8000/health # Then open http://localhost:8000/docs in the browser.

The loop on the scaffold: C1, C2, C3

The library gives one prompt per hard step. C1 asks with the ADR pasted in and the full list of files, constraints and a five-step output format. C2 turns inspection into its own review task before you create anything. C3 is for the moment something actually fails.

  1. C1 · Ask: paste your ADR; require app/main.py, GET /health with status and timestamp, requirements.txt, .env.example, .gitignore and README; forbid CRUD, auth, database, Docker and frontend files.
  2. C2 · Inspect: check scope creep, missing dependencies, import paths, likely runtime errors, hallucinated APIs, Pydantic version risks, the /health shape, and whether README commands match the folders.
  3. Run the server and test /health and /docs yourself.
  4. C3 · Refine: give the exact command, the exact output, and the relevant files, and ask for the likely root cause and the smallest fix.
Scaffolding with the full loop · Lecture notes p. 15 · Prompt library pp. 12-15
  1. C1Ask with the ADRSkeleton, /health, no CRUD
  2. C2Inspect before creatingScope, imports, fake APIs, Pydantic
  3. Run and testuvicorn, curl /health, open /docs
  4. C3Refine with exact evidenceCommand, error, files

When it fails, give exact evidence

The assistant can’t see your terminal, so a paraphrased error gives it nothing to reason with. C3 is the core habit: the exact command, the exact error or response, the file tree and the relevant files. If a fix doesn’t work, its follow-up asks the assistant to compare the new error with the old one before suggesting anything else. The library adds three optional diagnostics for errors you may meet, to use only when you hit them.

  • E1 · Missing dependency, such as ModuleNotFoundError: No module named dotenv.
  • E2 · Import path or project root, when the server can’t import the app or a route module.
  • E3 · Pydantic v1 versus v2 syntax, when generated code fails on your installed version.

The reflection log

The fourth output records, for Requirements, Architecture and Scaffold, one thing AI got right, one thing you corrected, and one assumption AI made. Keep notes as you work. Prompt D1 can organize them, but only from what you wrote: if a note is missing, it must say “Missing - add your own note” rather than invent one. A reflection that sounds plausible but didn’t happen defeats the point.

  • Requirements: right, corrected, assumed.
  • Architecture: right, corrected, assumed.
  • Scaffold: right, corrected, assumed.

Read with careAs an illustration only: the author’s own reflection log, kept in their project, records the assistant assuming the generated scaffold was sufficient as-is, and the author checking imports, router registration and the timestamp format themselves. The lesson stands on the course documents; this is one real run of it.

Before you move to Module 2

The library’s end-of-module checklist is slightly stricter than the notes about corrections. Use it as your exit check.

End-of-module checklist · Prompt library p. 18
DeliverableWhat to check
Reviewed user stories6–8 stories with specific acceptance criteria; at least one scope correction and one edge case correction.
Architecture Decision RecordOne paragraph in your own words, explaining the chosen architecture and assumptions corrected.
Running skeletonFastAPI starts; GET /health returns HTTP 200 JSON; Swagger /docs opens.
Reflection logFor Requirements, Architecture, and Scaffold: one thing AI got right, one correction, and one AI assumption.

Key takeaways

  • The skeleton is one working endpoint, not the app.
  • Inspect the scaffold before you create or run anything.
  • When it fails, give the exact command, error and files.
  • The reflection log comes from your notes, never from the assistant’s imagination.

Built from the Module 1 lecture notes, prompt library and additional readings; the videos they accompany were not supplied.

Your study checkpoint

Ready to continue?

Mark the lesson complete once you have read it and tried its idea on something real.

Next · Summary