Course · Codex · Getting started
Ship your first reviewed change with Codex
You have a failing test suite and a concrete bug to fix. budgetcli here is the same illustrative project as elsewhere in this chapter: a small FastAPI personal-finance API with pytest, AGENTS.md at the repo root, CSV import in app/importers/csv.py, and money stored as integer cents. To follow along you need Codex installed and authenticated, plus a disposable project with the stated starting files. The authoring fixture is not published with the site; use a course-host copy if one is provided or adapt the task to your own repo. Install its development dependencies and run pytest to record the real baseline before continuing.
After pytest, a typical failure looks like three tests dying on one line: ValueError: time data '2024-03-15' does not match format '%d/%m/%Y'. The importer uses day-first parsing while the data is ISO. If you already ran the loop lesson, you know where parsing lives; you do not need to paste paths or dictate keystrokes.
Trusting the loop’s shape is not trusting every diff. This lesson is outcome-first prompting plus review before commit.
Describe the outcome, not the steps
Section titled “Describe the outcome, not the steps”Illustrative reconstruction, not a captured run:
> the CSV importer is crashing on ISO dates - the rows are 2024-03-15 but it parses "%d/%m/%Y", and three tests are failing on the ValueError. Make ISO exports import cleanly and pin it with a regression test.You stated the what, not the how. A plausible continuation:
• Read app/importers/csv.py, tests/test_import.py (2 files)
The importer parses each row's date with "%d/%m/%Y", but the CSV data is ISO - and AGENTS.md says dates are ISO 8601, never locale-dependent. I'll parse ISO dates and add a regression test that rejects a day-first row instead of silently reinterpreting it.
• Edited app/importers/csv.py (+2 -2) - date = datetime.strptime(row["date"], "%d/%m/%Y") + date = datetime.strptime(row["date"], "%Y-%m-%d")
• Edited tests/test_import.py (+9 -0) • Ran pytest 7 passedIt read first (including existing tests for style), cited the ISO rule from auto-loaded AGENTS.md, edited the parser, added a test, ran the suite.
In the recommended Auto posture (workspace-write + on-request approvals), edits inside the workspace and commands like pytest usually run without a y/n. A network reach such as pip install would pause at the boundary. See approval modes for the dial.
Four beats closed: read, propose, apply, verify - with approve silent because nothing crossed the fence. A green summary is a claim; the diff is the verdict.
Read the diff before you believe the summary
Section titled “Read the diff before you believe the summary”Ask for the full change set if the UI did not already show it:
> show me everything you changedCheck: does it do what you asked, and only what you asked? For this ticket you expect two files - date line and tests.
Read the lines the agent did not touch. Two lines below the date fix you may still see:
amount_cents = int(float(row["amount"]) * 100)AGENTS.md says money is integer cents, never floats. That line routes amounts through float. On sample CSV amounts it may look fine; on others it does not. Checked arithmetic on CPython (run this yourself):
python3 -c "print(int(float('0.29') * 100))"28 - truncation loses a cent. The suite may stay green because samples never hit the bad case.
The agent was right not to expand scope beyond the date ticket. The rules file informed the session; it did not enforce the float parse. Name the defect (TODO, issue), leave the line alone for this commit, and harden the money path in a later lesson. Control in this course eventually means gates that can say no, not only guidance in context.
Commit the moment it is right
Section titled “Commit the moment it is right”Commit only what you reviewed, with explicit paths:
> stage the two files you changed and commit: importer now parses ISO dates, regression test added
• Ran git add app/importers/csv.py tests/test_import.py • Ran git commit -m "Parse ISO dates in CSV import; add regression test"Prefer named paths over git commit -am, which stages every modified tracked file. Run git status before committing so nothing you did not review rides along.
Until you commit, the agent’s work sits in the working tree one bad step away from loss. Git is the floor that does not vanish - commit at green, reviewed checkpoints so the next experiment’s downside is bounded by git reset to the last good commit.
The date fix is in git with a regression test; the float money path remains a known open defect. Put Codex where you already code - editor integration.