AI-Assisted Coding · Module 4Lesson 3

Study explanation · Lesson 03 · 16 min

The CI pipeline

Continuous Integration runs the tests on every push and pull request. Let Claude Code draft .github/workflows/ci.yml, inspect it line by line for shortcuts that hide failure, and prove it with a green run, a deliberate red run and a restored green run.

Listen to this lesson

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

Narrated by an AI voice.

The project starts protecting itself

Local tests only help when someone remembers to run them. Continuous Integration runs the test suite automatically on push and pull request, so broken code is harder to merge unnoticed. The module asks for a simple test workflow, not deployment automation. Claude Code generates the file; you inspect the YAML line by line.

Key ideaA green check only matters if failure turns it red. CI is not proved by one passing run; it is proved when a deliberate test failure makes the workflow fail.

The expected workflow shape

The notes describe what the generated workflow should look like, area by area.

Expected workflow shape · Lecture notes pp. 7-8
Workflow areaExpected behavior
Location.github/workflows/ci.yml at the repository root.
TriggersRun on push to branches and pull request to main.
JobOne job named test running on ubuntu-latest.
Python setupUse the exact project Python version from CLAUDE.md or the repo configuration. In the demo context, this is Python 3.11.
DependenciesInstall the project requirements, including test dependencies such as pytest and httpx when the test suite needs them.
Test commandRun pytest in a way that returns a non-zero exit code when tests fail.

Reject these immediately

Each of these patterns can make a workflow look healthy while it hides the one thing CI exists to show. The prompt library adds one more: piping pytest output in a way that swallows its exit code.

False-green red flags · Lecture notes p. 8
Red flagWhy it is dangerous
continue-on-errorAllows a failing test step to appear acceptable.
|| trueTurns a failing command into a successful shell command.
--exit-zero or similar flagsCan force a tool to exit successfully even when problems exist.
latest Python or vague versionMay test on a different version than students run locally.
Missing push or PR triggerThe workflow may not run when it actually matters.
Deployment stepsThis module is not deploying the app; deployment adds risk and scope that the lecture did not ask for.

Generate with the shortcuts already ruled out

Prompt C1 names the exact artifact and blocks every false-green shortcut in advance. C2 then reviews the file against a nine-point checklist and returns Pass or Concern with evidence for each, which you compare against your own manual search of the file.

Prompt C1 from the libraryCreate .github/workflows/ci.yml for the Module 4 Task Tracker. Project context: - Python 3.11 FastAPI backend. - Tests run with pytest -v. - Dependencies are installed from requirements.txt. - This module is not deploying the app. Requirements: - Run on push and pull_request. - Use actions/checkout and actions/setup-python. - Use Python 3.11, not latest or an unspecified version. - Install dependencies with python -m pip install --upgrade pip and pip install -r requirements.txt. - Run pytest -v. - Do not include deployment steps. - Do not use continue-on-error. - Do not use || true. - Do not use --exit-zero. - Do not hide pytest failures behind pipes or summary steps. Constraints: - Show me the diff before applying. - If .github/workflows does not exist, create it at the repository root, not inside app/ or another subfolder. Output format: First summarize the workflow. Then show the YAML diff.

The green-red-green proof

One passing run proves only that the workflow can pass. To prove it catches failures, break one test on purpose, watch CI turn red for the reason you intended, then revert and watch it return to green without touching the workflow.

CI is proved by the red run, not the first green one · Lecture notes p. 8
  1. 1Greennormal suite passes
  2. 2Redbreak one test on a branch; CI fails for that reason
  3. 3Green againrevert; workflow unchanged
The green-red-green proof · Lecture notes p. 8
StepWhat to doWhat proves it worked
GreenPush the workflow and confirm the normal test suite passes.GitHub Actions shows a successful run.
RedDeliberately break one test on a branch and push.The CI run fails and the log shows the same kind of test failure you would expect locally.
Green againRevert the deliberate break and push again.CI returns to green without changing the workflow to hide the failure.

Read with careBreak only a test or a test expectation, never production code, and keep the red run intentional and reversible. Save links or screenshots of all three runs as your evidence.

When the demo goes wrong

The notes say the recording shows realistic friction. The workflow can land in the wrong folder, or CI can fail because test dependencies such as pytest or httpx are missing from requirements. Both are real problems in the repository. Fix the repo truthfully, by moving the file or adding the dependency, and do not hide the failure with one of the red-flag patterns.

Key ideaA red run you did not plan is information. Fix its cause; never silence it.

Key takeaways

  • CI should run on push and pull request, on the project’s exact Python version, and fail when pytest fails.
  • continue-on-error, || true, --exit-zero and vague versions are reasons to reject the file.
  • Prove CI with green, an intentional red, and a restored green.
  • When CI fails for a real reason, fix the repo; do not hide the failure.

Built from the Module 4 lecture notes, prompt library and additional readings; page references are to the supplied PDFs.

Your study checkpoint

Ready to continue?

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

Next · Lesson 4