Giving AI a Clear Assignment
By the end of this lesson, you should be able to turn an intent into a bounded assignment, choose acceptance cases before implementation, and write stop conditions that prevent an assistant from guessing through a material decision.
Give context that changes the work
An assistant needs the relevant source, constraints, and evidence. It does not need your entire project history. Provide the specific files and current baseline, describe the intended behavior, and identify anything the worker must preserve. If you have local instructions, include them in the repository so future work can find them.
For our example, the starting file contains only a function with a docstring and NotImplementedError. The supported input is a list of strings. There is no user interface, file import, package manager, or deployment. That context prevents the worker from turning a small function into an application.
In a real repository, ask the worker to inspect the branch and working-tree state before editing. If it finds unrelated work, it should preserve it and describe the overlap. A clean baseline makes a change easier to compare, but cleanliness is not permission to reset a repository. Never have an assistant discard files merely to make the starting state convenient.
The assignment we will use
Here is a complete example assignment. It is a teaching artifact, not a claim that a real assistant received it.
Objective: Clean repeated reading-list entries without changing the reader's order.
Baseline: supplied starter/cleaner.py in a disposable example directory.
Interface: clean_titles(titles), where titles is a list of strings.
Required behavior:
- Return a new list; leave the input unchanged.
- Trim surrounding whitespace and omit blank entries.
- Compare duplicates with str.casefold().
- Preserve the first retained spelling after trimming.
- Preserve the order of first occurrence.
Scope: implement cleaner.py, add focused standard-library tests,
and write a short verification and recovery note.
Exclude: sorting, internal-space normalization, file I/O, networking,
new packages, interfaces, Git commits, publishing, and unrelated edits.
Acceptance: representative examples and all supplied contract cases pass;
the diff is limited to the allowed files; reviewer checks input preservation.
Stop: if the interface or starting source differs, a non-string policy is
needed, dependencies seem necessary, or required behavior conflicts.
Report the issue and propose a bounded resolution; do not silently expand scope.
Handoff: exact changed files, readable diff, commands and exit statuses,
failures or unrun checks, remaining limitations, and recovery instructions.
Do not claim owner acceptance.
This assignment leaves the algorithm open. The worker can use a loop and a set without requesting approval. It cannot decide to sort because sorting changes the product. It cannot add a web form because there is no authorized interface work. The difference is whether a choice implements the agreement or replaces it.
Choose cases that distinguish correct from plausible
Acceptance criteria should describe behavior you care about, including cases where a plausible implementation would be wrong. A test with already sorted lowercase titles cannot tell you whether the function wrongly sorts or lowercases everything. Choose inputs that expose those transformations.
Use ["Solaris", "Dune", "Earthsea"] to check order. Use ["Dune", "dune"] to check first spelling. Use spaces and tabs to check trimming. Use [] to check the empty list. For this contract, ["Straße", "STRASSE"] checks the declared casefold() comparison rather than simple lowercase matching. These examples are selected from the requirement, not from the code the worker happens to produce.
Also test what should remain distinct: ["Part One", "Part One"] should keep both titles because internal whitespace normalization is excluded. Respectively, these are Part[space]One (one space) and Part[space][space]One (two); the brackets label spaces, not literal text. Negative boundaries like this prevent well-intentioned expansion from hiding inside a "cleanup" change.
Keep tests readable. A newcomer should be able to compare the input and expected result without understanding a custom testing framework. Standard-library unittest is sufficient here. A small suite with meaningful cases is more useful than dozens of assertions that repeat the same easy example.
Ask for evidence in a usable form
"Tests pass" is a claim. A stronger handoff names the command, where it was run, the candidate it tested, and the exit status. It includes failures and checks that were not run. It gives you enough source and instructions to repeat the result without relying on the worker's account.
For a real assignment, request a diff against the starting point. A file list alone cannot show that the worker also changed a setting or rewrote a test. A readable diff reveals deletions, added dependencies, changed assertions, and accidental formatting churn. You can then focus on behavior rather than searching a whole tree for edits.
Do not ask for a polished story that suppresses uncertainty. "The example passes, but the input-mutation check was not run" is useful information. "Fully tested and production ready" is less useful if the evidence covers one toy case. Specify the evidence you need and let the result remain incomplete when it is incomplete.
Use stop conditions for decisions, not routine friction
A stop condition identifies a situation where the worker should return control. It should be specific enough to recognize. "Stop if something goes wrong" is vague. "Stop if the function also writes to a saved library" identifies a change in risk and authority.
Avoid making every implementation detail a stop. If the worker can correct a typo or choose a variable name within the assignment, it should proceed. Good stop conditions preserve your attention for scope, data, dependencies, unclear behavior, and irreversible actions.
When a stop occurs, ask for the concrete conflict and a proposed resolution. You might narrow the task, approve a changed boundary, or reject the approach. Record the revised agreement before work continues. An endless sequence of guesses is not progress, even if every guess produces more code.
Revise assignments using evidence
Suppose you forgot to specify whether duplicate comparison ignores case. The worker asks, and you decide it should. Add the rule and a distinguishing test. Do not leave that decision only in a passing chat message. It belongs with the assignment and tests so the next worker can see it.
If a worker repeatedly misreads a requirement, inspect the wording before escalating the prompt's tone. "Clean the list" could reasonably mean sorting, standardizing spelling, or removing punctuation. A sharper behavioral contract often resolves the problem more effectively than adding general demands to be careful.
Long prompts are not inherently more precise. Remove constraints that do not affect this task. Keep the purpose, allowed scope, acceptance, stop conditions, and handoff easy to find. The editable assignment template in the downloads provides those fields without requiring you to adopt a particular coding assistant.
Practice: inspect the simulated first handoff
The worker returns this candidate and says, "Removed blanks and duplicates; the sample run completed without errors." The report is simulated. Read the implementation before looking at the next lesson's evidence.
def clean_titles(titles):
return sorted({title.strip().lower() for title in titles if title.strip()})
List two ways this could violate our assignment while still returning a valid Python list. Then choose a test that makes each violation visible. Resist the urge to rewrite the whole task. A correction request should name the failed requirement and preserve the accepted scope.
A strong answer identifies changed order and lost first spelling. A further issue is using lower() instead of the agreed casefold() comparison. We will run those cases, separate the evidence from the report, and decide what acceptance should mean next.
