Skip to content

Course · Pi · Context

Context

Last chapter attacked one slice of the enemy this whole course keeps circling: the finite window, and every default that spends it without asking you first. You won the right to see what Pi was doing with it - the four tools, the sub-1,000-token prompt, the live meter stacking up turn by turn. That’s real. It’s also not the whole problem, because a window you can read is still a window that fills.

Here’s the slice this chapter attacks: the session outlives the window. Something must be dropped, and you pick what. stash isn’t a one-sitting job - it’s a week of real work, spread across mornings you didn’t plan for and a refactor that runs longer than you expected. Watching the meter fill was last chapter’s win. Staying in charge of what happens when it’s full is this one’s.

Nothing here is exotic - a handful of session commands, one file convention, and the judgment of when to reach for each. To make that judgment concrete, we’ll follow one thread of stash work through all three lessons rather than list features in the abstract.

You’ve shipped one fix to stash and you understand the loop. Real work on it now looks like this:

  • This morning, you come back to yesterday’s session about the extractor bug and pick it up without re-explaining a thing.
  • Full-text search on stash misses accented characters - a real, open rough spot - and there are two reasonable ways to fix it. You fork the session so you can try both without betting on one upfront.
  • You settle on an approach and keep going, but the readability-extractor rewrite that follows runs long. The window fills, Pi compacts the thread mid-refactor, and you learn what survives that and what doesn’t.
  • By the end of the week you’re tired of typing the same three stash-specific rules into every new session - don’t touch .env, use stash migrate instead of raw SQL, the extractor’s tests live in tests/extractor/ - so you write them down once, in a file Pi reads on every session before you say a word.

Each lesson leaves you with the problem the next one solves. Read them in order and it’s a story; drop into one from search and it still stands on its own.

By the end you’ll treat Pi’s context window the way you treat memory in any long-running program - a resource you watch, spend on purpose, and reclaim before it runs out. You’ll also have the next three rows of this course’s running ledger: what a session file costs you, what compaction’s defaults cost you, and what writing your rules down costs you. Every row ends the same way - something in the window, paid for by someone, and by the close of this chapter most of that someone is you.

Start where the week does - picking up yesterday’s session, and forking today’s real decision.