Chapter 5 · Quality, Release and the Future
Software Engineering with AI Coding Assistants
- Page 17 of 18
- 16 min read
Farhan types half a sentence into his editor and an AI coding assistant offers to finish the whole function. Aiko asks a chat assistant to explain an error message and gets a clear answer in seconds. Kwame asks one to suggest test cases for the booking rules. These tools are now part of everyday software work, and they change how code gets written. They do not change who is responsible for it.
On the previous page, Releasing and Maintaining Software, ClinicQueue reached real patients. This page is about using AI assistants well across the whole life cycle you have studied: where they help, where they mislead, the rules that keep a team safe, a workflow with a worked example of catching a plausible but wrong suggestion, and how to keep learning while a tool can write code for you. Note the difference from ClinicQueue's own AI feature (the drafted reminder text): that is AI inside the product; this page is about AI in the way the team builds it.
What you will learn
- Where AI coding assistants help across the software life cycle, and the typical ways they mislead.
- Five rules: you own the code, review everything, run the tests, never paste secrets or personal data, and stay aware of licences.
- A small workflow (plan, ask small, review, test, commit) and how it catches a plausible but wrong suggestion.
- How to keep and grow your own skills while using an assistant.
What assistants are good and bad at
An AI coding assistant is a tool built on a large language model that suggests code, tests, explanations or text from your instructions and the code it can see. It works by predicting a likely continuation of what it was given, based on patterns in the text it learned from. That is why its answers are usually fluent and often useful, and also why it can be confidently wrong: sounding right and being right are different things.
Provider note: this page deliberately names no product. Assistants differ in where they run, what they store and their licence terms, and these change often. Before using one at work, read its current data and licence terms and your organisation's policy.
Across the life cycle
The same strengths and weaknesses show up in every activity of the SDLC you met at the start of this tutorial:
| Activity | Where it helps | How it can mislead | Your check |
|---|---|---|---|
| Requirements | Draft questions for Nadia; spot missing cases in a user story ("what if the patient has no phone?") | Invents requirements that sound reasonable but nobody asked for | Every requirement still comes from a stakeholder; ask Nadia, not the tool |
| Design | Explain options (a table per entity or one shared table) and their trade-offs | Proposes a complex design for a small clinic app; ignores your constraints | Compare with the design checklist from Software Design Basics: From Requirements to Modules |
| Code | Boilerplate, small functions, regular expressions, explaining unfamiliar code and error messages | Plausible code with subtle bugs; functions or packages that do not exist; outdated ways of doing things | Read every line; run it; check that every library it uses really exists and is maintained |
| Tests | Suggest test cases and edge cases; write repetitive test code | Tests that only confirm what the code already does, including its bugs | Derive expected results from the requirement, not from the code (partitions and boundaries, as on Software Quality, Testing and QA) |
| Documentation | First drafts of a README, docstrings, release notes | Describes features that do not exist, or steps that do not work | Follow the README steps yourself on a clean machine |
| Review and maintenance | Summarise a large diff; suggest a refactoring; explain old code | Misses the one line that matters; refactors and changes behaviour | A human reviewer still approves; the tests must still pass after a refactoring |
Five rules for using an assistant
1. You own the code
Code an assistant suggested and you committed is your code. If it sends a reminder to the wrong patient, "the tool wrote it" is not an answer Nadia will accept, and it should not be one you would give. Commit only code you can explain line by line to a reviewer.
2. Review everything
Review suggested code at least as carefully as a colleague's pull request, using the same review checklist from Code Review, Version Control and Team Workflow. Be extra careful with the parts that look boring: comparisons (< or <=), date and time handling, error handling, and anything touching security or personal data. A long, tidy suggestion is not more likely to be right than a short one.
3. Run the tests
A suggestion is a hypothesis until the tests pass. Run the existing tests after accepting any change, and add tests for new behaviour. If there are no tests for that area yet, write a few first; then the assistant's code has something to prove itself against.
4. Never paste secrets or personal data
What you type or paste into an assistant may leave your computer and may be stored, depending on the tool and its settings. Treat a prompt like an email to a stranger.
| Never paste | Use instead |
|---|---|
| Real patient names, phone numbers, appointments or notes | Invented sample data ("Mitu", "+000 0000 0000") |
| The SMS provider's API key, database passwords, tokens | A placeholder name ("read SMS_API_KEY from the settings") |
| A copy of the production database or its logs | The table structure only, with invented rows |
| A client's confidential code, if your contract forbids sharing it | A small, rewritten example of the problem |
If a secret is pasted by mistake, treat it as leaked: tell the team lead and change the key or password. Hoping nobody saw it is not a plan.
5. Stay aware of licences
Suggested code can closely resemble existing code that is under a licence, and the libraries a suggestion imports each have their own licence terms. You do not need to be a lawyer, but do three things: follow your organisation's policy on assistant use; check the licence of every new dependency before adding it (as you would without an assistant); and be careful with long suggestions that look copied from somewhere, especially in a client project where you promise that the code is yours to hand over.
A workflow: plan, ask small, review, test, commit
The rules become habits through a simple loop. It is the same discipline as the rest of this tutorial, with the assistant in one step of it.
Example:
1 PLAN 2 ASK SMALL 3 REVIEW 4 TEST 5 COMMIT
+-----------+ +---------------+ +----------------+ +----------------+ +---------------+
| what, why |-->| one function, |--->| read each line,|--->| run old + new |-->| small commit, |
| acceptance| | with context, | | can I explain | | tests, add | | clear message,|
| criteria | | no secrets | | it? edge cases?| | boundary tests | | normal review |
+-----------+ +---------------+ +----------------+ +----------------+ +---------------+
^ | wrong or unclear |
+-------------------------------------+-----------------------------------------+
go back: refine the plan or the request, or write it yourselfPlan first: know what the change must do and how you will know it works, before you ask. Ask small: one function or one test at a time, with the relevant context, gives you something you can actually review. Review and test as in the rules. Commit in small steps through the normal pull request and review, so a bad suggestion is easy to find and undo.
Worked example: a plausible but wrong suggestion
ClinicQueue needs to refuse a new slot for a doctor if it overlaps an existing one. Farhan plans first: the acceptance criteria say slots are 15 minutes and back-to-back slots are allowed (09:00 to 09:15 and 09:15 to 09:30). Then he asks small:
Example:
Write a Python function overlaps(a_start, a_end, b_start, b_end) that returns True if two
appointment slots overlap. Times are "HH:MM" strings on the same day. Back-to-back slots
(one ends exactly when the other starts) do NOT overlap. Standard library only, no comments.The assistant returns a neat one-line function. It looks right, and it would pass a quick glance in review. Farhan does not trust a glance: he writes his own checks from the acceptance criteria, at the boundaries, exactly as on the testing page.
def overlaps(a_start, a_end, b_start, b_end):
"""Suggested by the assistant: do two slots overlap? Times are 'HH:MM' strings."""
return a_start <= b_end and b_start <= a_end
# Farhan's own checks, chosen at the boundaries (start of one slot = end of the other)
cases = [
("09:00", "09:15", "09:10", "09:25", True), # real overlap
("09:00", "09:15", "09:15", "09:30", False), # back to back: both allowed
("09:15", "09:30", "09:00", "09:15", False), # back to back, other order
("09:00", "09:15", "09:30", "09:45", False), # clear gap
]
def check(function):
for a_start, a_end, b_start, b_end, expected in cases:
got = function(a_start, a_end, b_start, b_end)
verdict = "ok" if got == expected else "WRONG"
print(f"{a_start}-{a_end} vs {b_start}-{b_end}: expected {expected!s:<5} got {got!s:<5} {verdict}")
check(overlaps)09:00-09:15 vs 09:10-09:25: expected True got True ok
09:00-09:15 vs 09:15-09:30: expected False got True WRONG
09:15-09:30 vs 09:00-09:15: expected False got True WRONG
09:00-09:15 vs 09:30-09:45: expected False got False okThe suggestion treats back-to-back slots as overlapping, so the clinic could never book 09:15 after 09:00, the most common case of all. The cause is <= where < is needed: the same boundary slip as the booking bug on the testing page. Note that the request even said "back-to-back slots do NOT overlap"; following an instruction in the prompt is likely, not guaranteed. A test with a middle value (09:10) passed, so only the boundary cases exposed it.
Farhan does not ask the assistant to "try again" until the tests happen to pass. He reasons it through himself: two slots overlap only when each one starts before the other ends. Then he fixes it and runs the same checks:
def overlaps(a_start, a_end, b_start, b_end):
"""Two slots overlap only if each one starts before the other ends."""
return a_start < b_end and b_start < a_end
check(overlaps)09:00-09:15 vs 09:10-09:25: expected True got True ok
09:00-09:15 vs 09:15-09:30: expected False got False ok
09:15-09:30 vs 09:00-09:15: expected False got False ok
09:00-09:15 vs 09:30-09:45: expected False got False okHe moves the four cases into the unittest suite, so they run on every push, and commits with the message fix: back-to-back slots no longer count as overlapping. In the pull request, Aiko reviews the function and the tests together. Total cost of the mistake: a few minutes, not a week of patients unable to book.
Keeping and growing your skills
An assistant can produce code faster than you can understand it. If you only accept, you stop learning, and you lose exactly the skill you need to catch its mistakes: Farhan found the bug because he understands boundaries and could write the checks himself.
Habits that keep you learning
- Understand before you accept. If you cannot explain a line, ask the assistant to explain it, then check the explanation against the documentation or a small experiment.
- Try first, then compare. For practice tasks, write your own version, then ask for one and compare. The differences teach you more than either version alone.
- Write the tests yourself. Deciding what correct means is the core engineering skill; keep it.
- Work without it sometimes. Solve some problems with only the documentation, the way you will in an interview or when the tool is down.
- Keep a list of its mistakes. Patterns (dates, boundaries, outdated library calls) tell you where to look hardest next time.
Where practitioners disagree
| View | Argument | What it suggests for you |
|---|---|---|
| Use it widely | It removes routine work and explains unfamiliar code; refusing a useful tool is not a virtue | Use it, inside the five rules, for routine code and explanations |
| Restrict it for learners | Beginners cannot yet judge its output and may skip the struggle that builds skill | On new topics, learn the basics without it first, then use it to go further |
| Restrict it for some work | Security code, personal data and client contracts carry special risks | Follow your team's and client's policy; when unsure, ask |
A reasonable middle path for a learner: use an assistant to explain and to review your thinking, use it to generate code mainly for things you could write yourself, and never for things you could not check. The wider questions, such as fairness, privacy, honesty about AI use and who is accountable, are covered in AI Ethics and Responsible Use: Beginner, and how to write clear requests and check AI output in Prompt Engineering for AI: Beginner.
Where this shows up at work
- Many teams write a short policy on assistant use: which tools are approved, what data must never be pasted, and whether to mention assistant use in pull requests.
- Code review is the same for every change, whoever or whatever wrote it; reviewers ask "how did you test this?"
- Interviews and probation periods still test whether you can reason about code yourself.
- Freelancers check their contracts: some clients restrict sharing code with outside services or ask to be told about AI use.
Common mistakes
- Accepting a suggestion because it looks professional. Fluent code can be wrong in one character. Fix: review every line and test the boundaries.
- Asking for a whole feature at once. The result is too big to review properly. Fix: plan first, then ask for one small piece at a time.
- Pasting real data or keys to "give context". Fix: use invented data and placeholders; if a secret leaks, rotate it at once.
- Letting the assistant write both the code and the only tests. The tests may simply confirm its bug. Fix: derive the expected results from the requirements yourself.
- Re-asking until the tests pass. You get code that passes these tests without anyone understanding why. Fix: understand the failure, then fix or rewrite it yourself.
Try it yourself
- Easy: Aiko wants help with a bug and writes this request: "Here is our settings file with the SMS key SMSKEY-1234-EXAMPLE and three real bookings from today's log (Mitu Akter, +880 17..., 10:30). Why does the reminder fail?" List what is wrong with it and rewrite it safely.
- Medium: An assistant suggests code for the rule "a patient can book from 1 to 14 days ahead" and imports a package called
clinic_date_utilsthat nobody in the team has heard of. List the checks you would make before accepting it, in order. - Hard: Write a short policy (five rules, one line of reason each) for using AI coding assistants on ClinicQueue, which handles patient data. Then say how a reviewer could check in a pull request that the policy was followed.
Answers
- Wrong: it pastes a live secret key (which must now be treated as leaked and replaced), and real patient names, phone numbers and appointment details (personal data). It also gives the assistant a whole file instead of the relevant part. Safe rewrite: "Our Python reminder job fails with this error: [the error message, with any keys or names removed]. It reads the SMS key from a setting called SMS_API_KEY. Here is the function that sends the SMS, with invented sample data (patient 'Mitu', phone '+000 0000 0000', 10:30). What are likely causes?" A good answer removes all secrets and personal data, replaces them with placeholders or invented values, gives only the code and error that matter, and says that the leaked key must be rotated.
- In order: (1) check that the package really exists in the official package index and is the one you think it is (assistants sometimes invent names, and a look-alike package can be malicious); (2) check that it is maintained and its licence allows your use; (3) ask whether you need it at all: this rule needs one comparison, and the standard library is enough, so the best fix is usually to drop the import; (4) review the code line by line, especially
<versus<=; (5) run the boundary tests 0, 1, 14 and 15 from the testing page. A good answer puts existence and need before anything else and ends with tests derived from the rule. - Model answer: (1) Use only the assistant the clinic has approved, because its data terms were checked. (2) Never paste patient data, keys or production logs; use invented data, because prompts may be stored outside our control. (3) Ask for small pieces and commit only code you can explain, because you are responsible for it. (4) Every change needs tests written or checked by a person from the requirements, because generated tests may confirm generated bugs. (5) Check the licence and existence of any new dependency, because suggestions may name unknown or unsuitable packages. Reviewer checks: the pull request is small; it contains tests for the boundaries of the rule; no keys, real names or phone numbers appear in the diff or the description; new dependencies are listed with their licence; the author can answer "why does this line work?" A good answer has rules with reasons, covers data, ownership, testing and licences, and gives checks a reviewer can actually see in a pull request.
Summary
- AI coding assistants help in every activity of the life cycle, from requirement questions to documentation, but they can be fluent and wrong at the same time.
- Five rules: you own the code; review everything; run the tests; never paste secrets or personal data; stay aware of licences and of what each new dependency is.
- Work in a loop: plan, ask small, review, test, commit; boundary tests written by you catch plausible but wrong suggestions.
- Keep your skills by understanding before accepting, writing your own tests and sometimes working without the tool.
- Responsibility does not move to the tool: the team, through its normal review and release process, decides what reaches users.
Next: Practice Lab and Capstone: Plan a Small Project End to End: five short exercises that reuse the whole tutorial, and a capstone where you plan your own project from problem statement to release plan.

