Implement a link-shortener task
Follow these steps in order. Stop and ask if the task is unclear or needs something listed
under "Ask a person before" in AGENTS.md.
-
Read. Open
AGENTS.md, the chosen task indocs/TASKS.md, andtests/AGENTS.md. Work on that one task only. -
Inspect. Read
main.py(the table,encode(), the request model and both routes) andtests/test_main.py. Note anything the task interacts with, for example how codes are generated or how the database is shared between runs. -
State the plan. Before editing, write down:
- the expected behavior, including status codes and response bodies for success and each failure;
- the files you will change;
- edge cases (empty or odd input, collisions with existing codes, values that repeat).
-
Write a failing test. Add behavioral tests in
tests/test_main.pyfollowingtests/AGENTS.md: at least one success and one failure case. Run them and confirm they fail for the right reason (the feature is missing, not a typo):pytest tests/test_main.py -k <new_test_name> -
Implement the smallest change in
main.pythat makes the tests pass. Keep existing behavior and response shapes. If the table needs a new column, add it so an existinglinks.dbstill works (or explain why it must be recreated). -
Run everything.
pytestAll original and new tests must pass. Fix and re-run until they do.
-
Summarize in this shape:
Task: Behavior: Files changed: Tests added: pytest result: Remaining risks: