Coding with an AI assistant: spec → generate → verify
medium 14 minAn AI assistant writes code fast, but it stops when the code looks done, not when it is done.
Spec, generate, verify in 90 seconds
1:25Reel coming soon
Catch the bug the assistant missed
9:30Lesson coming soon
How it works
Step through the idea, or press Play.
Spec. Inputs, outputs, edge cases and errors, written down before any code
Understand it

A coding assistant predicts plausible code. Plausible is not the same as correct. The output compiles, reads well and often passes the happy path, while an edge case or a security hole sits underneath.
- 1SpecSignature, edge cases, errors, constraints, examples
- 2Failing testsEncode the spec; check they fail for the right reason
- 3GenerateThe assistant writes the implementation
- 4VerifyRun the checks, read the diff, probe the edges
When verification finds a gap, fix the spec or the tests first, then go round again.
Step 1
Write a spec the model cannot misread
- Name the function, its inputs and their types, and what it returns.
- List the edge cases: empty input, zero, negative numbers, the last page, duplicates, very large values.
- Say what happens on bad input: raise which error, or return what.
- State the constraints: no new libraries, follow the pattern in an existing file, keep the public API the same.
- Give two or three concrete input → output examples. Examples remove more ambiguity than prose.
Write chunk(items: list, size: int) -> list[list] in utils/lists.py.- Split items into consecutive lists of length size; the last may be shorter.- Empty items -> [].- size < 1 -> raise ValueError("size must be >= 1").- Do not modify items. No new dependencies. Follow the style of utils/strings.py.Examples: chunk([1, 2, 3, 4, 5], 2) -> [[1, 2], [3, 4], [5]] chunk([], 3) -> [] chunk([1], 0) -> ValueErrorStep 2
Generate, ideally test-first
Ask for failing tests that encode the spec, check that they fail for the right reason, then ask for the implementation.
import pytestfrom utils.lists import chunkdef test_splits_with_short_last_chunk(): assert chunk([1, 2, 3, 4, 5], 2) == [[1, 2], [3, 4], [5]]def test_empty_input(): assert chunk([], 3) == []def test_rejects_size_below_one(): with pytest.raises(ValueError): chunk([1], 0)def test_does_not_modify_input(): items = [1, 2, 3] chunk(items, 2) assert items == [1, 2, 3]Step 3
Verify
Give the assistant (and yourself) a check that returns pass or fail: a test suite, a type checker, a linter, a build. Then do the parts a test run cannot:
Do
- Ask for evidence: the command that ran and its output.
- Read the whole diff.
- Probe the boundaries the tests skipped: off-by-one, empty input, None, unicode, time zones.
- Get a second opinion from something that did not write the code: a colleague, or a fresh review session with no memory of the reasoning.
Don't
- Accept a summary saying all tests pass.
- Miss changed tests, deleted assertions, skipped tests and files you did not expect to change.
- Trust that the happy path passing means the edges work.
- Let the same session that wrote the code be its only reviewer.
Security needs its own pass
cur.execute(f"SELECT * FROM users WHERE email = '{email}'") # injectablecur.execute("SELECT * FROM users WHERE email = %s", (email,)) # parameterisedAI-enabled interview rounds test this loop
In 2025 Meta confirmed it was piloting coding interviews where candidates can use an AI assistant. Public details on scoring are thin, so prepare for what such a round can see:
- How you break down the problem.
- How clearly you prompt.
- Whether you test and question the output.
- The quality of the final code.
- How you explain your choices.
Key points
- Plausible is not correct: you define what correct means and prove the code meets it.
- A spec names the signature, edge cases, error behaviour, constraints and concrete examples.
- Tests first, checked to fail for the right reason, then the implementation.
- Verify with evidence, a full read of the diff, and your own edge probes; get a second opinion.
- Give security its own pass and vet every new dependency by name.
Sources
- Claude Code docs: Best practices (give Claude a check to run; ask for evidence)
- GitHub Docs: Responsible use of GitHub Copilot Chat (review and test generated code)
- 404 Media: Meta is going to let job candidates use AI during coding tests (July 2025)
- Business Insider (via AOL): Meta will let some job candidates use AI in their coding interviews (July 2025)
