Agentic Coding: Autocomplete, Chat and an Agent on One Feature
One small feature, an overdue badge on a to-do list, given to three helpers: autocomplete finishes a line, chat drafts and you carry, and a Claude Code agent reads, edits, runs pytest and reports. Then the loop it works in, a what-if slip caught by one test, and how to review the diff before you keep it.
What you will learn
- Compare autocomplete, chat and a coding agent on the same small feature
- Describe the agent loop: read, plan, edit, run, check, and what the agent can and can't know
- Review an agent's work yourself with git status, git diff and pytest before you commit
- Explain why a test for the edge case matters: green tests are evidence, not proof
Before you start
- Testing with pytest
- Checking AI-written Python code
- Basic git (status, diff, commit)
Let's take one small feature and give it to three kinds of AI helper: autocomplete, chat and an agent. We'll see what each one does, what it costs you, and what's left for you to do. Then we'll look inside the agent, at the loop it works in, and review its work ourselves.
One small feature
tasks.py holds a small to-do list. To keep it simple, the due day is just a day of the month:
TASKS = [
{"title": "Pay the bill", "due": 20, "done": False},
{"title": "Book dentist", "due": 22, "done": False},
{"title": "Send report", "due": 21, "done": True},
{"title": "Call plumber", "due": 25, "done": False},
{"title": "Water plants", "due": 28, "done": False},
]
show_tasks.py only prints the titles:
from tasks import TASKS
for task in TASKS:
print(task["title"])
Pay the bill
Book dentist
Send report
Call plumber
Water plants
The wish: put an overdue badge on every task that isn't done and whose due day is before today, and today is the 25th. Pay the bill (20th) and Book dentist (22nd) get the badge. Send report is late but done, so no badge. Water plants is due on the 28th. And Call plumber is due today, so it isn't overdue yet. Keep an eye on the plumber, because that's the case that matters.
So "done" means three things: the rule, the badge in the list, and tests that prove the rule, even for a task due today.
Helper one: autocomplete guesses the next line
You get this from something like GitHub Copilot or your editor's own completion. Type def is_overdue(task, today): and in grey it may suggest the next line, something like return not task["done"] and task["due"] < today. That's only an example suggestion: it guesses from the code around your cursor. Press Tab and the grey text becomes your code.
But the badge in show_tasks.py and the tests are still your job. Autocomplete is fast and costs almost nothing, but it only finishes the spot you're on. It doesn't change other files and it doesn't run anything.
Helper two: chat answers, you carry
Paste tasks.py into a chat app and ask "how do I mark tasks as overdue?". A fair answer comes back in three pieces: the function, the badge line and a test. Now who does the work? You do. You carry the function into tasks.py, the badge into show_tasks.py and the test into a new file. You run pytest yourself, and if something's red you paste the error back and ask again. Chat explains and drafts, but it only knows what you paste in, and it never touches your files or runs your tests.
Helper three: the agent
This part is a real Claude Code session in a terminal, in the project folder. It was started in safe mode (personal add-ons off), with one standing instruction: change files with its own file tools and run one command at a time. It could edit files without asking each time, but it still asked before any command that hadn't been allowed.
The goal went in as one message: mark a task overdue when it isn't done and due before today, show a badge in show_tasks.py, add pytest tests that include a task due today, and run them. Today is the 25th; plan first; don't commit.
Before touching anything, it wrote a plan: read the two files, add an is_overdue helper and the badge, then write the tests and run pytest. Then it worked through that plan by itself: read show_tasks.py, wrote tasks.py, then show_tasks.py, then a brand new test file, then ran pytest and the script. Nobody pasted anything.
Here's what it wrote in tasks.py (the project keeps these files in agent_run/):
TODAY = 25
TASKS = [
{"title": "Pay the bill", "due": 20, "done": False},
{"title": "Book dentist", "due": 22, "done": False},
{"title": "Send report", "due": 21, "done": True},
{"title": "Call plumber", "due": 25, "done": False},
{"title": "Water plants", "due": 28, "done": False},
]
def is_overdue(task, today=TODAY):
"""A task is overdue when it isn't done and its due day is before today."""
return not task["done"] and task["due"] < today
Look closely at the comparison: <, not <=, so a task due today isn't overdue. And the test we asked for:
def test_due_today_is_not_overdue():
assert not is_overdue({"title": "a", "due": 25, "done": False}, today=25)
Then it reported back: two shell commands run (pytest and the script), five tests passed, nothing committed. Its printed list gave Pay the bill and Book dentist an [OVERDUE] badge and left Send report, Call plumber and Water plants without one. It even explained the plumber: due today, so not overdue yet. The first lap went green.
What if it had slipped?
Agents do slip. Say the draft had used <=, an easy mistake any of the three helpers could make:
def is_overdue(task, today):
return not task["done"] and task["due"] <= today
Run that slipped draft against four tests:
from tasks import is_overdue
TODAY = 25
def task(due, done=False):
return {"title": "x", "due": due, "done": done}
def test_past_task_is_overdue():
assert is_overdue(task(22), TODAY)
def test_done_task_is_not_overdue():
assert not is_overdue(task(22, done=True), TODAY)
def test_task_due_today_is_not_overdue():
assert not is_overdue(task(25), TODAY)
def test_future_task_is_not_overdue():
assert not is_overdue(task(28), TODAY)
..F. [100%]
================================== FAILURES ===================================
_____________________ test_task_due_today_is_not_overdue ______________________
def test_task_due_today_is_not_overdue():
> assert not is_overdue(task(25), TODAY)
E AssertionError: assert not True
E + where True = is_overdue({'title': 'x', 'due': 25, 'done': False}, 25)
E + where {'title': 'x', 'due': 25, 'done': False} = task(25)
test_tasks.py:19: AssertionError
=========================== short test summary info ===========================
FAILED test_tasks.py::test_task_due_today_is_not_overdue - AssertionError: as...
1 failed, 3 passed in 0.17s
Three of the four tests passed with the bug still in there. Without the today test, nobody would have seen it. With <=, 25 <= 25 is True, and the plumber gets a badge he shouldn't have. An agent reads that red test the same way you would, and the fix is one character:
- return not task["done"] and task["due"] <= today
+ return not task["done"] and task["due"] < today
Run pytest again and it's 4 passed in 0.02s.
How an agent loops
Read the files, plan the change, edit, run a command, check the result. If a test fails, go back to edit. When everything passes, leave the loop and report. Here's the important point: an agent only knows what it has read. Your goal, the files it opened, and the output of the commands it ran. Anything else, it guesses. With no tests, the check step has much less to read.
Three kinds of help, side by side
Autocomplete is like spell check: it suggests the next word and you keep writing. Chat is a friend you ask: they tell you how, and you still run the errand. The agent is an assistant you send on the errand: they go, do it, and come back with a receipt. You still check the receipt before you pay, and with an agent, the receipt is the diff.
| Autocomplete | Chat | Agent | |
|---|---|---|---|
| What it sees | Code near your cursor | What you paste in | Project files it opens |
| What it does | Guesses the next bit | Answers and drafts | Reads, edits, runs, retries |
| What it costs | Almost nothing | Your copy and paste | Time, usage and a bigger review |
| Your job | Accept or ignore | Copy and check | Read every changed line |
The more a helper does on its own, the more there is for you to review. So pick the smallest helper that does the job: the obvious next line goes to autocomplete, a question or an error you don't understand goes to chat, and a change across files that must pass the tests goes to the agent. A one-line fix could go to the agent, but that's slower, not smarter.
Review it yourself
The receipt is in your hands, so check the work in your editor. The lesson saves each command as a PyCharm run configuration, but they're plain git and pytest commands:
git status
git add -N .
git diff
pytest -q
python show_tasks.py
git status should show exactly what you asked for: show_tasks.py and tasks.py modified, and one untracked file, test_tasks.py. Nothing else. git add -N . marks the new file so git diff shows it too. In the diff, red lines are removed and green lines added. Read the comparison yourself, every time. And if an agent ever turns a test green by editing the test, send it back.
Then run the tests on your side and see the same five pass, and run the script to see the badges. Everything checks out, so keep it with git add . and git commit. If you didn't like the change, you could throw it away instead and send the agent back with a clearer prompt. (Git basics are in Git and GitHub fundamentals.)
The agent drafts, you decide
The agent reads, plans, edits, runs the tests and proposes a diff. You set the goal, read the diff, try the case it missed, and keep it or send it back. It's the same habit as checking AI-written code, and the pytest habit stays too, because tests are what the agent checks against. One warning: green tests are evidence, not proof. They only check what someone wrote a test for, as the what-if showed with three passing tests and a bug.
Try it yourself: give an agent one small task, then read its diff before you keep it. For a map of the coding agents you'll hear about, see coding agents compared.
StudyEasy AI Community
Learn AI engineering, share what you build, and connect with other learners.
Free resources: lesson files, notebooks and code
Ask questions and join engineering discussions
Meet real people learning and building with AI
Related course on Udemy
The Python Architect Masterclass: Full Stack to AI Engineer
Python, Django, FastAPI, React, Docker, AWS, LLMs, RAG, agents and MCP, from first steps to AI engineer.View on Udemy ↗: The Python Architect Masterclass: Full Stack to AI Engineer (paid course, opens in a new tab)Related posts
CLAUDE.md, settings.json and Plugins: Which Claude Code File Advises, Which Enforces, Which Packages
Three needs in one repo: a test command, a rule that Claude must never read .env, and a shared deploy skill. See which file each belongs in, how the settings layers merge, and what a plugin manifest carries.
Authoring a Claude Skill: SKILL.md, Frontmatter, Progressive Disclosure and the Description That Triggers It
Pack a support team's ticket-triage routine into one skill folder, then watch three requests load one, two or all three levels: the catalog, the SKILL.md body, and a script whose code never enters the context.
One Change, Four Environments: Where a Claude Config Edit Lands in Dev, Staging, Prod and CI
Change one line in a repo and ask where it lands. A small resolver for bookshop-bot shows that a new model id in settings.json reaches only CI, a prompt bump reaches dev and CI, and a prod block edit reaches only prod.
Claude in the SDLC: Prompts in Git, a Change Gate by Path, a Claude Review That Advises and a Person Who Merges
Follow one prompt edit from a branch to a merge: version prompts and the model pin like code, keep the API key in GitHub Secrets, gate changes by path, let Claude review the diff, and leave the merge to a person.
