Work effectively with AI coding agents. Understand them as language models running in a tool loop with limited context, which is why they guess, game the visible signal and report confidently. Recognise the shortcut and correctness tells in their code across Python, TypeScript/JavaScript, Rust, Java and Go, and know the damage each one does later. Verify changes instead of trusting them, review diffs fast for quality and security, judge when work is truly finished, and choose, design and steer tasks so agents can finish them well.
When to stop, reset or take over
card 4 of 6
A reset that carries facts, not history
builds on: Long sessions: lost instructions and drift, Patching the symptom instead of the cause
You run `git reset --hard` to the commit before the session, or `git stash` to set the mess aside. Also delete any new files the agent created, because neither command removes them. Then you open a fresh session:
> Goal: `rows()` type-checks with no casts or ignores. Fact: `r.date` is `string | number` because the CSV loader declares it so. Tried: casting, skipping rows. Both rejected; rows must never be dropped. Done: `npm run build` green and the tests in `report.test.ts` pass.
Now the agent starts from the real type and where it comes from, not from its old guesses.
Terms on this card
- green
- A test or check that is passing.
- git reset --hard
- Git command that moves the branch to a given commit and discards all changes to tracked files. New untracked files the agent created are not deleted.
- git stash
- Git command that saves changes to tracked files aside so they can be reapplied later. New untracked files stay unless you add -u.
- fresh session
- A new agent conversation that starts with an empty context, carrying none of the old session's attempts.
- type-checks
- Passes the static type checker (here the TypeScript compiler) with no type errors.
Lesson goal: Recognise a session going bad: the agent repeats a failed fix, the diff keeps growing, suppressions pile up or it contradicts itself. Then revert to a clean commit, start a fresh session with a distilled summary, or do the change yourself. ·
the whole lesson