Coding with AI Assistants · Capstone

Capstone: Build a Small CLI Tool With an Assistant

Plan, test, build and review a small command-line tool with an AI assistant, and document how you verified it.

Create a free account to save this page, take notes and track your progress. Sign in

Scenario

You are building expenses, a small command-line tool for a team that tracks shared expenses in a CSV file. You will build it with an AI coding assistant, using the workflow from this course.

Requirements

  • expenses add "Lunch" 42.50 --paid-by ana --split ana,ben,cy appends a row.
  • expenses balance prints who owes whom, with the fewest possible payments.
  • Amounts are stored as integer cents; invalid input gives a clear error and exit code 1.

Constraints

  • Python standard library only (no new dependencies).
  • The CSV format must stay readable in a spreadsheet.
  • Every behaviour has a test; the assistant may not change agreed tests.

Deliverables

  1. Your project instructions for the assistant.
  2. The plan you approved and the tests you agreed before implementation.
  3. Your review notes: what you checked and what you changed in the generated code.
  4. Security and data considerations.
  5. A short reflection: where the assistant helped most and where it was wrong.

Hints

  • Rounding when splitting 10.00 three ways is a business decision; decide it in the tests.
  • "Fewest payments" has a simple greedy solution; test it with a few groups.
  • Try the edge cases yourself: one person, nobody owes anything, unknown names.

Draft each deliverable below before revealing the model answer and rubric.

Further reading: Claude Code best practices · Python argparse · Python csv

Deliverables

Write the project instructions.

Model answer

  • Python 3.12, standard library only; entry point expenses.py using argparse; data in expenses.csv with header date,description,amount_cents,paid_by,split.
  • Money is always integer cents; parse user amounts with Decimal, never floats.
  • Run tests with python -m unittest -v; all tests must pass before a task is done; never edit existing tests without asking.
  • Errors print a one-line message to stderr and exit with code 1.

Rubric

Look for stack and constraints, data format, money rules, test command and an explicit rule about not changing tests.

Describe the plan and the agreed tests.

Model answer

  • Plan: (1) money parsing and CSV storage, (2) add command, (3) balance calculation, (4) settle-up algorithm, (5) balance command output, each with its own tests.
  • Tests agreed first include: parsing 42.50 -> 4250 and rejecting abc; splitting 1000 cents three ways as 334/333/333 with the payer's share absorbing the remainder (a documented decision); balances summing to zero; settle-up producing at most n-1 payments; one-person groups and unknown names giving errors.

Rubric

Strong answers build in small steps and decide business rules (rounding, remainders) in tests before implementation.

What did your review check?

Model answer

  • Ran the tests and tried extra inputs by hand (negative amounts, empty split list, duplicate names).
  • Read every line: replaced a float conversion the assistant used in one place with Decimal; removed an unused import; confirmed no new dependencies.
  • Checked the settle-up function on a group where two people owe exactly the same amount.
  • Confirmed exit codes and error messages match the instructions.

Rubric

Look for evidence of running and reading the code, edge cases beyond the given tests, and specific corrections rather than a general 'looked fine'.

What security and data considerations apply?

Model answer

  • The CSV may contain names and amounts: it is kept out of the repository (.gitignore), and no real data was pasted into the assistant; test data is fictional.
  • CSV injection: descriptions starting with =, +, - or @ are escaped so spreadsheets do not execute them as formulas.
  • File writes use a temporary file and rename, so a crash cannot leave a half-written CSV.

Rubric

Good answers mention keeping personal data out of prompts and Git, CSV formula injection, and safe file writes.

Reflect on where the assistant helped and where it was wrong.

Model answer

  • Helped most with argparse boilerplate, test scaffolding and explaining the settle-up algorithm.
  • Was wrong about rounding (used floats) and initially wrote a settle-up that produced extra payments in some groups; the agreed tests caught both.
  • Lesson: deciding the rules and tests myself made the assistant's mistakes cheap to find.

Rubric

Look for an honest, specific account that links the course's practices (tests first, review) to the problems they caught.

Open in the app to mark lessons complete, take notes and track your progress.

Was this page helpful?