{"id":"04-context","number":4,"slug":"context-engineering","title":"Context is everything","short":"Context is everything","module":"Working with one agent","summary":"Almost every best practice for coding agents comes from one constraint: the context window fills up fast, and quality drops as it fills. Learn the smart zone and the dumb zone, why fresh sessions beat long ones, and the four moves of context engineering.","voice":"Eric","scenes":[{"template":"title","chapter":"Intro","narration":"If you remember one lesson from this course, make it this one. Almost every best practice for working with coding agents comes from a single constraint.","params":{"kicker":"Lesson 4","module":"Module 2 · Working with one agent","title":"Context is *everything*","subtitle":"The smart zone, the dumb zone, and how to stay smart.","bubble":"My memory is… limited.","mood":"think"},"start":0.5,"dur":10.108,"words":[{"text":"If","s":0.8,"e":0.96},{"text":"you","s":1,"e":1.04},{"text":"remember","s":1.12,"e":1.52},{"text":"one","s":1.68,"e":1.84},{"text":"lesson","s":1.92,"e":2.24},{"text":"from","s":2.32,"e":2.4},{"text":"this","s":2.48,"e":2.56},{"text":"course,","s":2.64,"e":3.36},{"text":"make","s":3.44,"e":3.6},{"text":"it","s":3.68,"e":3.76},{"text":"this","s":3.88,"e":4},{"text":"one.","s":4.08,"e":4.52},{"text":"Almost","s":4.8,"e":5.28},{"text":"every","s":5.36,"e":5.6},{"text":"best","s":5.68,"e":5.84},{"text":"practice","s":5.92,"e":6.4},{"text":"for","s":6.48,"e":6.56},{"text":"working","s":6.64,"e":6.88},{"text":"with","s":6.96,"e":7.04},{"text":"coding","s":7.12,"e":7.36},{"text":"agents","s":7.44,"e":7.84},{"text":"comes","s":8,"e":8.16},{"text":"from","s":8.24,"e":8.32},{"text":"a","s":8.4,"e":8.48},{"text":"single","s":8.56,"e":8.8},{"text":"constraint.","s":8.88,"e":9.76}]},{"template":"quote","chapter":"The constraint","narration":"Anthropic's own guide to Claude Code says it plainly. Most best practices are based on one constraint: the context window fills up fast, and performance degrades as it fills.","params":{"text":"Most best practices are based on one constraint: the context window fills up fast, and *performance degrades as it fills*.","who":"Anthropic","role":"Best practices for Claude Code","src":"code.claude.com docs"},"start":10.608,"dur":12.183,"words":[{"text":"Anthropic's","s":10.908,"e":11.628},{"text":"own","s":11.708,"e":11.868},{"text":"guide","s":11.948,"e":12.188},{"text":"to","s":12.228,"e":12.268},{"text":"Claude","s":12.348,"e":12.588},{"text":"Code","s":12.668,"e":12.908},{"text":"says","s":12.988,"e":13.148},{"text":"it","s":13.228,"e":13.308},{"text":"plainly.","s":13.468,"e":14.348},{"text":"Most","s":14.428,"e":14.668},{"text":"best","s":14.748,"e":14.988},{"text":"practices","s":15.068,"e":15.628},{"text":"are","s":15.708,"e":15.788},{"text":"based","s":15.908,"e":16.028},{"text":"on","s":16.108,"e":16.348},{"text":"one","s":16.428,"e":16.508},{"text":"constraint:","s":16.588,"e":17.628},{"text":"the","s":17.708,"e":17.788},{"text":"context","s":18.028,"e":18.268},{"text":"window","s":18.348,"e":18.668},{"text":"fills","s":18.748,"e":18.908},{"text":"up","s":18.988,"e":19.228},{"text":"fast,","s":19.468,"e":19.868},{"text":"and","s":19.948,"e":20.028},{"text":"performance","s":20.308,"e":20.588},{"text":"degrades","s":20.668,"e":21.148},{"text":"as","s":21.188,"e":21.228},{"text":"it","s":21.308,"e":21.468},{"text":"fills.","s":21.668,"e":22.188}]},{"template":"formula","chapter":"Working memory","narration":"Karpathy offers a helpful picture. The model is like a CPU. The context window is its RAM, a small working memory. And unlike a new colleague, the model doesn't get smarter as it works with you. So you are the operating system, deciding what goes into that memory.","params":{"parts":[{"text":"Model","icon":"brain","sub":"the CPU","tone":"ink","at":"CPU"},{"op":"+"},{"text":"Context","icon":"layers","sub":"the RAM: small working memory","tone":"soft","at":"RAM"},{"op":"+"},{"text":"You","icon":"user","sub":"the operating system","tone":"human","at":"operating system"}],"caption":"It doesn't learn as it goes. You program its memory directly.","caption_at":"smarter"},"start":22.791,"dur":18.348,"words":[{"text":"Karpathy","s":23.091,"e":23.651},{"text":"offers","s":23.731,"e":24.051},{"text":"a","s":24.091,"e":24.131},{"text":"helpful","s":24.211,"e":24.531},{"text":"picture.","s":24.611,"e":25.291},{"text":"The","s":25.571,"e":25.651},{"text":"model","s":25.731,"e":26.051},{"text":"is","s":26.131,"e":26.211},{"text":"like","s":26.291,"e":26.371},{"text":"a","s":26.451,"e":26.531},{"text":"CPU.","s":26.611,"e":27.331},{"text":"The","s":27.811,"e":27.891},{"text":"context","s":27.971,"e":28.371},{"text":"window","s":28.451,"e":28.771},{"text":"is","s":28.851,"e":28.931},{"text":"its","s":29.011,"e":29.171},{"text":"RAM,","s":29.251,"e":29.811},{"text":"a","s":29.851,"e":29.891},{"text":"small","s":29.971,"e":30.291},{"text":"working","s":30.371,"e":30.691},{"text":"memory.","s":30.891,"e":31.331},{"text":"And","s":31.571,"e":31.811},{"text":"unlike","s":31.971,"e":32.211},{"text":"a","s":32.291,"e":32.331},{"text":"new","s":32.371,"e":32.531},{"text":"colleague,","s":32.611,"e":33.331},{"text":"the","s":33.371,"e":33.411},{"text":"model","s":33.491,"e":33.731},{"text":"doesn't","s":33.891,"e":34.131},{"text":"get","s":34.211,"e":34.291},{"text":"smarter","s":34.451,"e":34.851},{"text":"as","s":34.931,"e":35.011},{"text":"it","s":35.091,"e":35.171},{"text":"works","s":35.251,"e":35.491},{"text":"with","s":35.571,"e":35.651},{"text":"you.","s":35.731,"e":35.891},{"text":"So","s":36.371,"e":36.531},{"text":"you","s":36.771,"e":37.011},{"text":"are","s":37.091,"e":37.171},{"text":"the","s":37.251,"e":37.331},{"text":"operating","s":37.411,"e":37.811},{"text":"system,","s":37.891,"e":38.451},{"text":"deciding","s":38.531,"e":39.011},{"text":"what","s":39.091,"e":39.171},{"text":"goes","s":39.251,"e":39.411},{"text":"into","s":39.491,"e":39.651},{"text":"that","s":39.731,"e":39.891},{"text":"memory.","s":40.091,"e":40.531}]},{"template":"context","chapter":"Smart zone, dumb zone","narration":"Here's the catch. Quality doesn't hold steady until the window is full. Dex Horthy calls the early part the smart zone. Past it comes the dumb zone, where the agent forgets instructions and contradicts itself. His rule of thumb for beginners: try to stay under about forty percent, and start wrapping up around sixty.","params":{"title":"One session's context window","cap":"200K tokens","blocks":[{"label":"system + tools","kind":"sys","w":0.1,"at":"early"},{"label":"memory","kind":"mem","w":0.04},{"label":"your task","kind":"you","w":0.04},{"label":"files read","kind":"file","w":0.18,"at":"smart zone"},{"label":"test output","kind":"out","w":0.14,"at":"dumb zone"},{"label":"retries","kind":"junk","w":0.16,"at":"contradicts"}],"zones":[{"from":0,"to":0.4,"label":"smart zone","tone":"good"},{"from":0.4,"to":0.6,"label":"wrap up","tone":"warn"},{"from":0.6,"to":1,"label":"dumb zone","tone":"bad"}],"zones_at":"smart zone","rot":{"at":"forgets","from":0.45}},"start":41.139,"dur":20.986,"words":[{"text":"Here's","s":41.439,"e":41.719},{"text":"the","s":41.759,"e":41.839},{"text":"catch.","s":41.919,"e":42.599},{"text":"Quality","s":42.879,"e":43.359},{"text":"doesn't","s":43.519,"e":43.759},{"text":"hold","s":43.839,"e":44.079},{"text":"steady","s":44.159,"e":44.559},{"text":"until","s":44.679,"e":44.799},{"text":"the","s":44.879,"e":44.919},{"text":"window","s":44.959,"e":45.199},{"text":"is","s":45.279,"e":45.359},{"text":"full.","s":45.519,"e":45.839},{"text":"Dex","s":46.319,"e":46.559},{"text":"Horthy","s":46.599,"e":46.959},{"text":"calls","s":47.039,"e":47.279},{"text":"the","s":47.319,"e":47.359},{"text":"early","s":47.519,"e":47.759},{"text":"part","s":47.839,"e":48.159},{"text":"the","s":48.239,"e":48.319},{"text":"smart","s":48.479,"e":48.799},{"text":"zone.","s":48.879,"e":49.199},{"text":"Past","s":49.679,"e":49.999},{"text":"it","s":50.079,"e":50.239},{"text":"comes","s":50.319,"e":50.559},{"text":"the","s":50.599,"e":50.639},{"text":"dumb","s":50.799,"e":51.039},{"text":"zone,","s":51.119,"e":51.599},{"text":"where","s":51.679,"e":51.759},{"text":"the","s":51.799,"e":51.839},{"text":"agent","s":51.919,"e":52.159},{"text":"forgets","s":52.239,"e":52.639},{"text":"instructions","s":52.999,"e":53.359},{"text":"and","s":53.439,"e":53.599},{"text":"contradicts","s":53.679,"e":54.239},{"text":"itself.","s":54.319,"e":54.799},{"text":"His","s":55.279,"e":55.439},{"text":"rule","s":55.519,"e":55.679},{"text":"of","s":55.719,"e":55.759},{"text":"thumb","s":55.839,"e":55.999},{"text":"for","s":56.039,"e":56.079},{"text":"beginners:","s":56.159,"e":57.119},{"text":"try","s":57.239,"e":57.359},{"text":"to","s":57.399,"e":57.439},{"text":"stay","s":57.519,"e":57.679},{"text":"under","s":57.759,"e":57.919},{"text":"about","s":57.999,"e":58.239},{"text":"forty","s":58.399,"e":58.639},{"text":"percent,","s":58.719,"e":59.359},{"text":"and","s":59.479,"e":59.599},{"text":"start","s":59.679,"e":59.919},{"text":"wrapping","s":59.999,"e":60.319},{"text":"up","s":60.399,"e":60.479},{"text":"around","s":60.599,"e":60.719},{"text":"sixty.","s":60.879,"e":61.519}]},{"template":"terminal","chapter":"Smart zone, dumb zone","narration":"You'll recognize the dumb zone when you see it. Deep into a long session, the agent starts trying more and more extreme things to make a test pass. Dex's favorite example: let me just delete your env file and try again. That's your cue to stop.","params":{"title":"180K tokens in…","lines":[{"k":"err","text":"FAIL  auth.test.ts (attempt 6)"},{"k":"agent","text":"Let me try mocking the whole auth module."},{"k":"err","text":"FAIL  auth.test.ts (attempt 7)","at":"more and more"},{"k":"agent","text":"I'll disable the token check for now."},{"k":"err","text":"FAIL  auth.test.ts (attempt 8)"},{"k":"agent","text":"Let me delete your .env file and try again.","at":"delete"},{"k":"warn","text":"← time to stop and start fresh","at":"cue"}]},"start":62.125,"dur":16.336,"words":[{"text":"You'll","s":62.425,"e":62.665},{"text":"recognize","s":62.865,"e":63.225},{"text":"the","s":63.265,"e":63.305},{"text":"dumb","s":63.465,"e":63.625},{"text":"zone","s":63.705,"e":63.945},{"text":"when","s":64.025,"e":64.105},{"text":"you","s":64.185,"e":64.265},{"text":"see","s":64.345,"e":64.425},{"text":"it.","s":64.505,"e":64.945},{"text":"Deep","s":65.225,"e":65.465},{"text":"into","s":65.585,"e":65.705},{"text":"a","s":65.745,"e":65.785},{"text":"long","s":65.945,"e":66.185},{"text":"session,","s":66.265,"e":66.985},{"text":"the","s":67.065,"e":67.105},{"text":"agent","s":67.145,"e":67.465},{"text":"starts","s":67.625,"e":67.785},{"text":"trying","s":67.985,"e":68.185},{"text":"more","s":68.265,"e":68.505},{"text":"and","s":68.585,"e":68.745},{"text":"more","s":68.825,"e":68.985},{"text":"extreme","s":69.145,"e":69.545},{"text":"things","s":69.705,"e":70.025},{"text":"to","s":70.105,"e":70.145},{"text":"make","s":70.185,"e":70.265},{"text":"a","s":70.345,"e":70.385},{"text":"test","s":70.425,"e":70.665},{"text":"pass.","s":70.745,"e":71.425},{"text":"Dex's","s":71.705,"e":72.105},{"text":"favorite","s":72.265,"e":72.425},{"text":"example:","s":72.665,"e":73.145},{"text":"let","s":73.385,"e":73.465},{"text":"me","s":73.505,"e":73.545},{"text":"just","s":73.625,"e":73.785},{"text":"delete","s":73.865,"e":74.185},{"text":"your","s":74.265,"e":74.345},{"text":"env","s":74.425,"e":74.665},{"text":"file","s":74.825,"e":74.985},{"text":"and","s":75.025,"e":75.065},{"text":"try","s":75.145,"e":75.305},{"text":"again.","s":75.385,"e":75.985},{"text":"That's","s":76.265,"e":76.585},{"text":"your","s":76.665,"e":76.745},{"text":"cue","s":76.825,"e":76.985},{"text":"to","s":77.025,"e":77.065},{"text":"stop.","s":77.145,"e":77.865}]},{"template":"list","chapter":"What poisons context","narration":"Size isn't the only problem. Dex lists four things that matter in a context window. Its size. Its quality, meaning wrong or outdated information. What's missing. And the trajectory, the history of what the agent has done. Models continue patterns, so a history full of mistakes and corrections invites more mistakes.","params":{"title":"Four things that matter in a context window","style":"num","items":[{"text":"Size","sub":"how many tokens","at":"size"},{"text":"Quality","sub":"wrong or outdated information","at":"quality"},{"text":"Missing information","sub":"what it needed but never saw","at":"missing"},{"text":"Trajectory","sub":"a history of mistakes invites more","at":"trajectory"}]},"start":78.461,"dur":23.076,"words":[{"text":"Size","s":78.761,"e":79.241},{"text":"isn't","s":79.321,"e":79.561},{"text":"the","s":79.641,"e":79.721},{"text":"only","s":79.801,"e":79.961},{"text":"problem.","s":80.041,"e":80.801},{"text":"Dex","s":81.081,"e":81.401},{"text":"lists","s":81.601,"e":81.801},{"text":"four","s":81.881,"e":82.121},{"text":"things","s":82.201,"e":82.521},{"text":"that","s":82.601,"e":82.681},{"text":"matter","s":82.761,"e":83.001},{"text":"in","s":83.041,"e":83.081},{"text":"a","s":83.161,"e":83.201},{"text":"context","s":83.241,"e":83.641},{"text":"window.","s":83.721,"e":84.121},{"text":"Its","s":84.601,"e":84.761},{"text":"size.","s":84.841,"e":85.561},{"text":"Its","s":85.801,"e":85.961},{"text":"quality,","s":86.041,"e":86.761},{"text":"meaning","s":86.841,"e":87.161},{"text":"wrong","s":87.321,"e":87.721},{"text":"or","s":87.801,"e":87.881},{"text":"outdated","s":87.961,"e":88.441},{"text":"information.","s":88.521,"e":89.161},{"text":"What's","s":89.641,"e":89.881},{"text":"missing.","s":89.961,"e":90.441},{"text":"And","s":90.841,"e":91.081},{"text":"the","s":91.241,"e":91.281},{"text":"trajectory,","s":91.321,"e":92.361},{"text":"the","s":92.441,"e":92.481},{"text":"history","s":92.521,"e":93.001},{"text":"of","s":93.041,"e":93.081},{"text":"what","s":93.161,"e":93.241},{"text":"the","s":93.321,"e":93.361},{"text":"agent","s":93.401,"e":93.721},{"text":"has","s":93.801,"e":93.881},{"text":"done.","s":93.961,"e":94.281},{"text":"Models","s":94.761,"e":95.161},{"text":"continue","s":95.241,"e":95.721},{"text":"patterns,","s":95.801,"e":96.601},{"text":"so","s":96.681,"e":96.921},{"text":"a","s":97.001,"e":97.081},{"text":"history","s":97.281,"e":97.481},{"text":"full","s":97.641,"e":97.801},{"text":"of","s":97.841,"e":97.881},{"text":"mistakes","s":97.961,"e":98.441},{"text":"and","s":98.481,"e":98.521},{"text":"corrections","s":98.601,"e":99.241},{"text":"invites","s":99.401,"e":99.801},{"text":"more","s":99.881,"e":100.041},{"text":"mistakes.","s":100.161,"e":100.921}]},{"template":"quote","chapter":"What poisons context","narration":"He describes it from the model's point of view. If I read the history, I should probably make another mistake, so the human can yell at me. When a session reaches that point, more corrections won't help.","params":{"text":"If I read the history, I should probably make another mistake so the human can *yell at me*.","who":"Dex Horthy","role":"founder, HumanLayer, on a poisoned trajectory","src":"Context engineering with Dex Horthy · The Pragmatic Engineer","t":4421},"start":101.537,"dur":12.339,"words":[{"text":"He","s":101.837,"e":101.997},{"text":"describes","s":102.117,"e":102.477},{"text":"it","s":102.557,"e":102.637},{"text":"from","s":102.717,"e":102.797},{"text":"the","s":102.877,"e":102.957},{"text":"model's","s":103.037,"e":103.437},{"text":"point","s":103.517,"e":103.597},{"text":"of","s":103.677,"e":103.717},{"text":"view.","s":103.757,"e":104.277},{"text":"If","s":104.557,"e":104.637},{"text":"I","s":104.717,"e":104.797},{"text":"read","s":104.877,"e":104.957},{"text":"the","s":105.037,"e":105.117},{"text":"history,","s":105.197,"e":105.917},{"text":"I","s":105.957,"e":105.997},{"text":"should","s":106.077,"e":106.237},{"text":"probably","s":106.317,"e":106.717},{"text":"make","s":106.797,"e":106.877},{"text":"another","s":106.957,"e":107.277},{"text":"mistake,","s":107.357,"e":107.837},{"text":"so","s":107.917,"e":107.997},{"text":"the","s":108.037,"e":108.077},{"text":"human","s":108.157,"e":108.477},{"text":"can","s":108.557,"e":108.637},{"text":"yell","s":108.717,"e":108.877},{"text":"at","s":108.957,"e":109.037},{"text":"me.","s":109.117,"e":109.477},{"text":"When","s":109.757,"e":109.837},{"text":"a","s":109.917,"e":109.997},{"text":"session","s":110.157,"e":110.317},{"text":"reaches","s":110.397,"e":110.717},{"text":"that","s":110.797,"e":111.037},{"text":"point,","s":111.197,"e":111.677},{"text":"more","s":111.757,"e":111.917},{"text":"corrections","s":111.997,"e":112.477},{"text":"won't","s":112.557,"e":112.717},{"text":"help.","s":112.797,"e":113.277}]},{"template":"compare","chapter":"Fresh beats long","narration":"Which leads to the most practical habit in this course. Anthropic's guidance: if you've corrected the agent twice on the same thing, clear the session and start over with a better prompt that includes what you learned. A clean session with a better prompt almost always beats a long one full of corrections.","params":{"left":{"title":"One long session","items":["Corrections pile up","Failed attempts stay in view","Quality keeps sliding"],"at":"corrected"},"right":{"title":"Fresh session, better prompt","items":["Starts in the smart zone","Includes what you learned","Usually finishes faster"],"at":"clean session"}},"start":113.876,"dur":18.818,"words":[{"text":"Which","s":114.176,"e":114.416},{"text":"leads","s":114.576,"e":114.736},{"text":"to","s":114.776,"e":114.816},{"text":"the","s":114.856,"e":114.896},{"text":"most","s":114.976,"e":115.136},{"text":"practical","s":115.296,"e":115.776},{"text":"habit","s":115.856,"e":116.096},{"text":"in","s":116.136,"e":116.176},{"text":"this","s":116.256,"e":116.336},{"text":"course.","s":116.416,"e":117.096},{"text":"Anthropic's","s":117.376,"e":118.016},{"text":"guidance:","s":118.096,"e":118.656},{"text":"if","s":119.136,"e":119.296},{"text":"you've","s":119.336,"e":119.456},{"text":"corrected","s":119.536,"e":119.936},{"text":"the","s":119.976,"e":120.016},{"text":"agent","s":120.096,"e":120.416},{"text":"twice","s":120.496,"e":120.976},{"text":"on","s":121.016,"e":121.056},{"text":"the","s":121.136,"e":121.216},{"text":"same","s":121.296,"e":121.536},{"text":"thing,","s":121.616,"e":122.336},{"text":"clear","s":122.416,"e":122.656},{"text":"the","s":122.696,"e":122.736},{"text":"session","s":122.816,"e":123.296},{"text":"and","s":123.336,"e":123.376},{"text":"start","s":123.536,"e":123.776},{"text":"over","s":123.856,"e":124.096},{"text":"with","s":124.176,"e":124.256},{"text":"a","s":124.336,"e":124.416},{"text":"better","s":124.536,"e":124.656},{"text":"prompt","s":124.736,"e":125.056},{"text":"that","s":125.136,"e":125.216},{"text":"includes","s":125.456,"e":125.696},{"text":"what","s":125.776,"e":125.856},{"text":"you","s":125.896,"e":125.936},{"text":"learned.","s":126.016,"e":126.416},{"text":"A","s":126.896,"e":127.056},{"text":"clean","s":127.216,"e":127.376},{"text":"session","s":127.456,"e":127.776},{"text":"with","s":127.816,"e":127.856},{"text":"a","s":127.936,"e":128.016},{"text":"better","s":128.096,"e":128.256},{"text":"prompt","s":128.336,"e":128.736},{"text":"almost","s":128.816,"e":129.296},{"text":"always","s":129.496,"e":129.696},{"text":"beats","s":129.776,"e":130.016},{"text":"a","s":130.056,"e":130.096},{"text":"long","s":130.176,"e":130.416},{"text":"one","s":130.496,"e":130.656},{"text":"full","s":130.816,"e":130.976},{"text":"of","s":131.016,"e":131.056},{"text":"corrections.","s":131.136,"e":132.096}]},{"template":"chat","chapter":"Hand off, then clear","narration":"Here's how to restart without losing progress. Ask the agent to summarize the session for a fresh agent: the goal, what was decided, what failed, which files matter. Review it, clear, and paste it in. As Brendan O'Leary says, AI is really great at writing prompts for AI.","params":{"messages":[{"from":"you","text":"Summarize this session for a fresh agent: goal, decisions, what failed and why, key files, next step. Under 200 words.","at":"summarize"},{"from":"agent","text":"**Goal:** fix flaky auth test. **Decided:** keep real token check. **Failed:** mocking the module (hides the bug). **Files:** auth.ts, session.ts. **Next:** fix the clock skew in session.ts.","tone":"good","at":"decided"},{"from":"you","text":"/clear  → paste the summary","label":"fresh start","at":"clear"}]},"start":132.694,"dur":19.784,"words":[{"text":"Here's","s":132.994,"e":133.274},{"text":"how","s":133.314,"e":133.394},{"text":"to","s":133.434,"e":133.474},{"text":"restart","s":133.554,"e":134.034},{"text":"without","s":134.114,"e":134.514},{"text":"losing","s":134.594,"e":134.834},{"text":"progress.","s":134.914,"e":135.794},{"text":"Ask","s":136.114,"e":136.354},{"text":"the","s":136.394,"e":136.434},{"text":"agent","s":136.594,"e":136.834},{"text":"to","s":136.874,"e":136.914},{"text":"summarize","s":137.074,"e":137.474},{"text":"the","s":137.554,"e":137.634},{"text":"session","s":137.714,"e":138.034},{"text":"for","s":138.114,"e":138.194},{"text":"a","s":138.274,"e":138.354},{"text":"fresh","s":138.434,"e":138.674},{"text":"agent:","s":138.754,"e":139.474},{"text":"the","s":139.554,"e":139.594},{"text":"goal,","s":139.634,"e":140.274},{"text":"what","s":140.354,"e":140.434},{"text":"was","s":140.514,"e":140.594},{"text":"decided,","s":140.714,"e":141.474},{"text":"what","s":141.554,"e":141.634},{"text":"failed,","s":141.794,"e":142.434},{"text":"which","s":142.514,"e":142.594},{"text":"files","s":142.674,"e":142.994},{"text":"matter.","s":143.074,"e":143.474},{"text":"Review","s":143.954,"e":144.274},{"text":"it,","s":144.354,"e":144.754},{"text":"clear,","s":144.954,"e":145.394},{"text":"and","s":145.434,"e":145.474},{"text":"paste","s":145.554,"e":145.794},{"text":"it","s":145.874,"e":145.914},{"text":"in.","s":145.954,"e":146.194},{"text":"As","s":146.754,"e":146.834},{"text":"Brendan","s":146.914,"e":147.234},{"text":"O'Leary","s":147.274,"e":147.714},{"text":"says,","s":147.874,"e":148.114},{"text":"AI","s":148.514,"e":148.914},{"text":"is","s":148.994,"e":149.154},{"text":"really","s":149.314,"e":149.634},{"text":"great","s":149.714,"e":149.954},{"text":"at","s":150.034,"e":150.114},{"text":"writing","s":150.274,"e":150.434},{"text":"prompts","s":150.514,"e":150.834},{"text":"for","s":150.914,"e":150.994},{"text":"AI.","s":151.074,"e":151.874}]},{"template":"stat","chapter":"Clear or compact","narration":"What about compaction, where the agent summarizes itself automatically when the window fills? It works, but it's lossy, and it decides what to forget on its own. Matt Pocock's advice: clear should be your default. Compact only when you want to keep the gist. Better yet, write the important state to a file before you need to.","params":{"items":[{"value":"/clear","label":"your default","sub":"known, clean starting point","tone":"good","at":"default"},{"value":"/compact","label":"keep the gist","sub":"lossy: it chooses what to forget","tone":"ink","at":"gist"}],"src":"Advice from Matt Pocock and Anthropic's Claude Code guide"},"start":152.478,"dur":21.639,"words":[{"text":"What","s":152.778,"e":152.938},{"text":"about","s":153.058,"e":153.178},{"text":"compaction,","s":153.258,"e":154.298},{"text":"where","s":154.378,"e":154.458},{"text":"the","s":154.498,"e":154.538},{"text":"agent","s":154.618,"e":154.938},{"text":"summarizes","s":155.018,"e":155.578},{"text":"itself","s":155.658,"e":156.058},{"text":"automatically","s":156.138,"e":156.858},{"text":"when","s":156.938,"e":157.018},{"text":"the","s":157.058,"e":157.098},{"text":"window","s":157.258,"e":157.418},{"text":"fills?","s":157.498,"e":157.898},{"text":"It","s":158.378,"e":158.538},{"text":"works,","s":158.778,"e":159.258},{"text":"but","s":159.378,"e":159.498},{"text":"it's","s":159.578,"e":159.738},{"text":"lossy,","s":159.818,"e":160.618},{"text":"and","s":160.738,"e":160.858},{"text":"it","s":160.938,"e":161.018},{"text":"decides","s":161.138,"e":161.498},{"text":"what","s":161.578,"e":161.658},{"text":"to","s":161.698,"e":161.738},{"text":"forget","s":161.818,"e":162.138},{"text":"on","s":162.218,"e":162.298},{"text":"its","s":162.378,"e":162.458},{"text":"own.","s":162.538,"e":162.778},{"text":"Matt","s":163.418,"e":163.578},{"text":"Pocock's","s":163.658,"e":164.058},{"text":"advice:","s":164.138,"e":164.618},{"text":"clear","s":165.098,"e":165.498},{"text":"should","s":165.578,"e":165.738},{"text":"be","s":165.818,"e":165.858},{"text":"your","s":165.898,"e":165.978},{"text":"default.","s":166.058,"e":166.618},{"text":"Compact","s":167.018,"e":167.498},{"text":"only","s":167.578,"e":167.818},{"text":"when","s":167.898,"e":167.978},{"text":"you","s":168.058,"e":168.138},{"text":"want","s":168.178,"e":168.218},{"text":"to","s":168.298,"e":168.378},{"text":"keep","s":168.458,"e":168.538},{"text":"the","s":168.618,"e":168.698},{"text":"gist.","s":168.778,"e":169.418},{"text":"Better","s":169.658,"e":169.818},{"text":"yet,","s":169.898,"e":170.458},{"text":"write","s":170.538,"e":170.698},{"text":"the","s":170.778,"e":170.818},{"text":"important","s":170.858,"e":171.258},{"text":"state","s":171.338,"e":171.578},{"text":"to","s":171.618,"e":171.658},{"text":"a","s":171.738,"e":171.818},{"text":"file","s":171.898,"e":172.218},{"text":"before","s":172.418,"e":172.618},{"text":"you","s":172.698,"e":172.778},{"text":"need","s":172.858,"e":173.018},{"text":"to.","s":173.138,"e":173.418}]},{"template":"list","chapter":"Four moves","narration":"Lance Martin sums up context engineering in four moves. Write things down outside the window, in notes and plans. Select only what's relevant for this step. Compress what you keep. And isolate work in separate contexts, like subagents, so one task doesn't pollute another. We'll use all four throughout the course.","params":{"title":"The four moves of context engineering","style":"num","items":[{"text":"Write","sub":"notes, plans, progress files outside the window","at":"write"},{"text":"Select","sub":"only what this step needs, just in time","at":"select"},{"text":"Compress","sub":"summaries instead of raw logs","at":"compress"},{"text":"Isolate","sub":"separate contexts, like subagents","at":"isolate"}]},"start":174.117,"dur":22.188,"words":[{"text":"Lance","s":174.417,"e":174.737},{"text":"Martin","s":174.817,"e":175.137},{"text":"sums","s":175.217,"e":175.497},{"text":"up","s":175.537,"e":175.617},{"text":"context","s":175.697,"e":176.177},{"text":"engineering","s":176.257,"e":176.817},{"text":"in","s":176.937,"e":177.057},{"text":"four","s":177.137,"e":177.377},{"text":"moves.","s":177.457,"e":178.177},{"text":"Write","s":178.497,"e":178.737},{"text":"things","s":178.857,"e":178.977},{"text":"down","s":179.057,"e":179.297},{"text":"outside","s":179.457,"e":179.857},{"text":"the","s":179.897,"e":179.937},{"text":"window,","s":180.017,"e":180.577},{"text":"in","s":180.657,"e":180.737},{"text":"notes","s":180.817,"e":181.137},{"text":"and","s":181.217,"e":181.297},{"text":"plans.","s":181.377,"e":182.177},{"text":"Select","s":182.417,"e":182.817},{"text":"only","s":182.977,"e":183.217},{"text":"what's","s":183.297,"e":183.457},{"text":"relevant","s":183.537,"e":183.937},{"text":"for","s":184.017,"e":184.097},{"text":"this","s":184.177,"e":184.257},{"text":"step.","s":184.337,"e":184.737},{"text":"Compress","s":185.137,"e":185.697},{"text":"what","s":185.777,"e":185.857},{"text":"you","s":185.937,"e":186.017},{"text":"keep.","s":186.097,"e":186.657},{"text":"And","s":186.897,"e":187.137},{"text":"isolate","s":187.617,"e":188.097},{"text":"work","s":188.217,"e":188.337},{"text":"in","s":188.417,"e":188.577},{"text":"separate","s":188.657,"e":188.977},{"text":"contexts,","s":189.337,"e":189.857},{"text":"like","s":189.937,"e":190.017},{"text":"subagents,","s":190.097,"e":190.897},{"text":"so","s":190.977,"e":191.137},{"text":"one","s":191.217,"e":191.377},{"text":"task","s":191.457,"e":191.857},{"text":"doesn't","s":191.937,"e":192.177},{"text":"pollute","s":192.257,"e":192.497},{"text":"another.","s":192.697,"e":193.137},{"text":"We'll","s":193.377,"e":193.537},{"text":"use","s":193.617,"e":193.857},{"text":"all","s":193.937,"e":194.097},{"text":"four","s":194.177,"e":194.417},{"text":"throughout","s":194.497,"e":194.817},{"text":"the","s":194.857,"e":194.897},{"text":"course.","s":194.977,"e":195.697}]},{"template":"quiz","chapter":"Quick check","narration":"Quick check. You've corrected your agent three times on the same bug, and it keeps making it. What's the best move? Tap your answer.","params":{"q":"You've corrected the agent three times on the same bug. What's the best move?","options":["Correct it again, more firmly","Switch to a model with a bigger context window","Get a summary of what you learned, then start a fresh session","Paste in the whole codebase so it has more context"],"answer":2,"explain":"The trajectory is poisoned. A clean session with a better prompt beats more corrections, and a bigger window just extends the dumb zone."},"start":196.305,"dur":13.781,"words":[{"text":"Quick","s":196.605,"e":196.845},{"text":"check.","s":196.925,"e":197.245},{"text":"You've","s":197.725,"e":197.885},{"text":"corrected","s":198.045,"e":198.285},{"text":"your","s":198.365,"e":198.445},{"text":"agent","s":198.525,"e":198.845},{"text":"three","s":198.925,"e":199.245},{"text":"times","s":199.325,"e":199.725},{"text":"on","s":199.765,"e":199.805},{"text":"the","s":199.885,"e":199.965},{"text":"same","s":200.125,"e":200.365},{"text":"bug,","s":200.445,"e":200.925},{"text":"and","s":200.965,"e":201.005},{"text":"it","s":201.045,"e":201.085},{"text":"keeps","s":201.165,"e":201.405},{"text":"making","s":201.565,"e":201.805},{"text":"it.","s":201.885,"e":202.125},{"text":"What's","s":202.525,"e":202.725},{"text":"the","s":202.765,"e":202.805},{"text":"best","s":202.845,"e":203.005},{"text":"move?","s":203.085,"e":203.485},{"text":"Tap","s":203.885,"e":204.125},{"text":"your","s":204.205,"e":204.285},{"text":"answer.","s":204.485,"e":204.925}]},{"template":"exercise","chapter":"Try it","narration":"Practice the handoff. Next time a session feels long, paste this prompt, save the summary, clear the session, and start again from the summary. Notice how much sharper the agent feels.","params":{"title":"Try it with your agent","intro":"In a long session, before you clear it:","prompt":"Summarize this session for a fresh agent who knows nothing:\nthe goal, decisions made, what failed and why, the files that\nmatter, and the exact next step. Under 200 words.\nSave it to notes/handoff.md."},"start":210.086,"dur":12.679,"words":[{"text":"Practice","s":210.386,"e":210.866},{"text":"the","s":210.906,"e":210.946},{"text":"handoff.","s":211.026,"e":211.666},{"text":"Next","s":212.226,"e":212.386},{"text":"time","s":212.466,"e":212.626},{"text":"a","s":212.666,"e":212.706},{"text":"session","s":212.786,"e":213.106},{"text":"feels","s":213.186,"e":213.426},{"text":"long,","s":213.506,"e":214.226},{"text":"paste","s":214.386,"e":214.546},{"text":"this","s":214.626,"e":214.706},{"text":"prompt,","s":214.786,"e":215.506},{"text":"save","s":215.586,"e":215.746},{"text":"the","s":215.826,"e":215.866},{"text":"summary,","s":215.906,"e":216.626},{"text":"clear","s":216.706,"e":216.946},{"text":"the","s":216.986,"e":217.026},{"text":"session,","s":217.106,"e":217.746},{"text":"and","s":217.826,"e":217.906},{"text":"start","s":217.986,"e":218.226},{"text":"again","s":218.426,"e":218.626},{"text":"from","s":218.706,"e":218.786},{"text":"the","s":218.826,"e":218.866},{"text":"summary.","s":218.946,"e":219.626},{"text":"Notice","s":219.906,"e":220.146},{"text":"how","s":220.226,"e":220.306},{"text":"much","s":220.426,"e":220.546},{"text":"sharper","s":220.626,"e":220.946},{"text":"the","s":221.026,"e":221.106},{"text":"agent","s":221.266,"e":221.426},{"text":"feels.","s":221.506,"e":222.146}]},{"template":"recap","chapter":"Recap","narration":"Recap. Context is the agent's working memory, and quality drops as it fills. Stay in the smart zone. When a session goes bad, hand off and start fresh. And write, select, compress and isolate. Next, the core workflow that puts all of this to work: explore, plan, implement, verify.","params":{"items":["Context = the agent's *working memory*","Stay in the smart zone (≈ under 40%)","Poisoned session? Hand off and start fresh","Write, select, compress, isolate"],"next":"The core loop: explore, plan, implement, verify","next_at":"Next"},"start":222.765,"dur":24.496,"words":[{"text":"Recap.","s":223.065,"e":223.625},{"text":"Context","s":224.105,"e":224.665},{"text":"is","s":224.745,"e":224.825},{"text":"the","s":224.905,"e":224.985},{"text":"agent's","s":225.065,"e":225.465},{"text":"working","s":225.545,"e":225.865},{"text":"memory,","s":225.945,"e":226.505},{"text":"and","s":226.585,"e":226.665},{"text":"quality","s":226.825,"e":227.145},{"text":"drops","s":227.305,"e":227.705},{"text":"as","s":227.785,"e":227.865},{"text":"it","s":227.905,"e":227.945},{"text":"fills.","s":228.105,"e":228.825},{"text":"Stay","s":229.145,"e":229.385},{"text":"in","s":229.465,"e":229.545},{"text":"the","s":229.585,"e":229.625},{"text":"smart","s":229.705,"e":230.025},{"text":"zone.","s":230.185,"e":230.425},{"text":"When","s":230.825,"e":230.905},{"text":"a","s":230.945,"e":230.985},{"text":"session","s":231.065,"e":231.305},{"text":"goes","s":231.385,"e":231.545},{"text":"bad,","s":231.625,"e":232.265},{"text":"hand","s":232.385,"e":232.505},{"text":"off","s":232.585,"e":232.825},{"text":"and","s":232.905,"e":232.985},{"text":"start","s":233.145,"e":233.385},{"text":"fresh.","s":233.465,"e":234.105},{"text":"And","s":234.345,"e":234.665},{"text":"write,","s":235.225,"e":235.785},{"text":"select,","s":236.025,"e":236.505},{"text":"compress","s":236.785,"e":237.065},{"text":"and","s":237.225,"e":237.385},{"text":"isolate.","s":237.465,"e":238.105},{"text":"Next,","s":238.745,"e":239.305},{"text":"the","s":239.385,"e":239.465},{"text":"core","s":239.585,"e":239.705},{"text":"workflow","s":239.785,"e":240.265},{"text":"that","s":240.305,"e":240.345},{"text":"puts","s":240.425,"e":240.745},{"text":"all","s":240.825,"e":240.905},{"text":"of","s":240.985,"e":241.065},{"text":"this","s":241.145,"e":241.225},{"text":"to","s":241.305,"e":241.385},{"text":"work:","s":241.465,"e":242.185},{"text":"explore,","s":242.265,"e":243.145},{"text":"plan,","s":243.345,"e":243.945},{"text":"implement,","s":244.225,"e":244.825},{"text":"verify.","s":244.905,"e":245.705}]}],"total":247.661,"audio":"/audio/04-context.mp3"}