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.
Long sessions: lost instructions and drift card 5 of 6

The rewrite that broke all three rules

builds on: What the agent sees: its context
The removed lines obeyed your rules, and the added ones break all three. `Query` drops `ctx`, so cancellation and deadlines no longer reach the database. The error is no longer wrapped with `%w` and returned, so callers never get to handle it. `log.Fatal` logs and then calls `os.Exit(1)`, so deferred cleanup never runs and the whole process exits. **Later cost:** one transient DB error during a sync takes the service down, and a hung query can no longer be cancelled.
// Go
--- a/store/sync.go
+++ b/store/sync.go
@@ -12,4 +12,4 @@ func (s *Store) Sync(
-	rows, err := s.db.QueryContext(ctx, q)
-	if err != nil {
-		return fmt.Errorf("sync: %w", err)
-	}
+	rows, err := s.db.Query(q)
+	if err != nil {
+		log.Fatal(err)
+	}
Terms on this card
Later cost
The concrete damage a shortcut does after merge, such as a hidden bug, data corruption or maintenance burden.
DB
Database.
`ctx`
The conventional Go name for a context.Context value. It carries cancellation signals and deadlines through a chain of calls.
%w
A Go fmt.Errorf verb that wraps an error, so callers can still inspect the original with errors.Is and errors.As.
`Query`
Go database/sql method that runs a query without a caller-supplied context, so the caller's cancellation and deadlines cannot stop it.
Learn this step by step on Bytewise
Lesson goal: Explain how a filling context weakens attention to early constraints, how summarising or compacting the context can drop them, and how a pile of failed attempts pollutes later reasoning. Recognise drift when the agent starts violating rules it followed at the start. · the whole lesson