AI-Assisted Coding · Module 2Lesson 1

Study explanation · Lesson 01 · 12 min

The editor as the AI workspace

Module 2 moves the assistant into the editor, because the work now happens inside real project files. Before any code is generated, you prove the assistant can read app/main.py and explain the /health endpoint correctly.

Listen to this lesson

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

Narrated by an AI voice.

From a skeleton to a backend

Module 1 left you with a FastAPI skeleton and a working /health endpoint. Module 2 makes it a working backend: a strict Pydantic data model, five CRUD endpoints, status-transition business rules, and a pytest suite you prove with a Break Test. The notes treat it as one continuous build in one repository. Each part creates the foundation for the next prompt and the next verification step, so a mistake you let through early is carried into everything after it.

Module at a glance: one repo, five connected parts · Lecture notes p. 2
PartFocusMain outputVerification gate
2.0Define the toolCursor can read the repo and explain app/main.py./health returns 200.
2.1Generate the data modelapp/models.py and app/storage.py.tests/verify_a.py prints every check as PASS.
2.2Scaffold CRUD endpointsPOST, GET list, GET by id, PATCH, DELETE.curl and /docs confirm expected status codes and schemas.
2.3Add business logicapp/business_rules.py and PATCH transition validation.Transition matrix returns 200, 200, 422, 200, 422, 200.
2.4Write API teststests/conftest.py and tests/test_tasks.py.pytest passes, then the Break Test causes the right tests to fail.

Read with careThe notes say they are meant to be used while watching the Module 2 videos and completing a hands-on guide. Neither the videos nor the guide were supplied, so this lesson follows the notes and the prompt library only.

The thread through the whole module

Every part of Module 2 runs the same loop. You write a strict prompt, review what comes back before applying it, run a verification step, and if something fails you send a targeted correction rather than a broad request to fix everything. The notes put the reason plainly: don’t let errors compound. The prompt library adds its own version of the same loop: ask, inspect, run, test, refine.

The loop every part of the module runs · Lecture notes p. 2
  1. Strict promptExact files, names, status codes and a DO-NOT list.
  2. ReviewRead the draft before Apply in Editor.
  3. VerificationImport check, script, curl, Swagger or pytest.
  4. Targeted correctionFix only what the evidence points at.

Do not let errors compound. Cursor can draft code, but you own correctness.

Key ideaCursor can draft code, but you own correctness.

Why the AI moves into the editor

Browser-based assistants were useful in Module 1 for planning, requirements, architecture and scaffolding. In Module 2 the assistant needs access to the actual codebase. The notes describe four ways the editor changes the work.

  • File references Cursor Chat can work with file references, so a prompt can include real files such as app/main.py, app/models.py and app/storage.py.
  • Less invented structure File-aware prompting reduces hallucinated project structure, because the assistant can inspect the code you attach.
  • Apply in Editor Generated code can be inserted into the project, but only after you have reviewed it.
  • Inline completions Useful for boilerplate, but they should not replace deliberate prompting for new logic.

Read with careThe notes describe Cursor as it appeared in the recorded demo, and say the file picker may show @ references or file chips depending on setup. The prompt library adds that GitHub Copilot Chat in VS Code uses # instead of @. Treat these as the documents’ description of the tools at their date.

Setup checklist

Before generating anything, the notes ask you to confirm the workspace and the assistant are both ready.

  • Open the Module 1 task-tracker repository as the workspace.
  • Open Cursor Chat and confirm it responds.
  • Confirm the file reference picker can see your project files.
  • Attach app/main.py and ask Cursor to explain the existing /health endpoint.
  • Run the app and confirm GET /health still returns HTTP 200.

Command from the notesuvicorn app.main:app --reload --port 8000 # In another terminal or browser, verify /health returns 200.

The first verified interaction

The gate for this part is simple and strict: don’t continue until Cursor can read app/main.py and correctly explain what the /health endpoint is doing. Prompt T0.1 asks for observable facts, the route path and method, what it returns, whether it uses the existing app instance, and one check you can run, and it forbids code suggestions. The weak version, “What does this project do?”, gives the assistant nothing to read and invites a guess. Prompt T0.2 goes one step further before any code generation: it asks the assistant to restate the app variable name, existing routes, which files already exist, and what structure to preserve, so you can catch a wrong assumption before it becomes code.

Prompt T0.1 from the libraryYou are helping me work inside my existing FastAPI project for Module 2. Context file: @app/main.py Explain the existing /health endpoint in this file. Please include: 1. The route path and HTTP method. 2. What the route returns. 3. Whether it uses the existing FastAPI app instance. 4. One simple command or browser check I can use to verify it returns HTTP 200. Do NOT suggest code changes yet. I only want to confirm that you can read the real file.

Five principles for prompting in the editor

The prompt library opens with five principles that every later prompt in the module follows.

  1. One task per prompt: one file pair, one endpoint, one business-rule update, or one test suite at a time.
  2. Name the exact files, so the AI works from the current project and not from a generic FastAPI tutorial.
  3. Specify exact outcomes: route, status code, response model, imports, function names, and what not to change.
  4. Verify immediately: import checks, verify_a.py, curl, Swagger UI, pytest and Break Tests are part of the workflow.
  5. Treat AI output as a draft. You own review, correction and proof.

Key takeaways

  • Module 2 is one continuous build; each part’s verification gate protects the next part.
  • The editor matters because the assistant can now read the files you attach instead of guessing.
  • Apply in Editor only after review; keep inline completions for boilerplate, not new logic.
  • Don’t generate code until the assistant has correctly explained /health from the real app/main.py.

Built from the Module 2 lecture notes and prompt library; page references are in the source notes below.

Your study checkpoint

Ready to continue?

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

Next · Lesson 2