You reach flow with AI by treating the agent as a junior engineer you trust in small windows, not a slot machine. Cal Newport calls this attention residue: every prompt-wait-judge loop fragments deep work unless you batch them. Pick a 90-minute block, write the spec yourself first, then let the agent execute while you stay in the architecture.

The Hacker News thread that prompted this question — “How do you get into a flow state when using AI to code?” — landed near the top of the front page in early June 2026, and the comments revealed the same split I see in my own week. Half of the working engineers said AI agents finally gave them the deepest flow of their careers; the other half said the constant prompt-judge-redirect loop killed every focus session they tried to start. Both groups are telling the truth. The difference is structural, not personal, and it lines up almost perfectly with Cal Newport’s research on what he calls attention residue in Deep Work and Slow Productivity.

Here is the mechanism. Flow, in Mihaly Csikszentmihalyi’s original definition, requires a stable challenge-skill ratio, a clear goal, immediate feedback, and — critically — uninterrupted absorption. The way most developers use Cursor, Claude Code, or GitHub Copilot in 2026 violates the last condition systematically. You type half a thought, hit tab, judge the suggestion, accept or reject, retype, prompt again, watch a 40-second agent run, scan a diff, approve, repeat. Newport’s research shows that even a five-second context switch leaves residual attention on the previous task for up to twenty minutes. AI coding tools serve up a micro-switch every few seconds. No wonder people surface from a four-hour session feeling like they sprinted nowhere.

What I do — and what most of the engineers in that HN thread who reported genuine flow described — is the opposite of conversational, turn-by-turn prompting. I write the spec myself, in plain text, before I open the agent. Not a vibe, not a sentence. Three to ten lines of: here is the function signature, here is the failing test, here is the constraint, here is the file structure. Then I hand the whole thing to Claude Code or Codex in one shot and walk away from the screen until it finishes. While it runs, I read the next requirement on paper. When it returns, I judge the diff as a code review, not as a conversation. That collapses the loop from twenty micro-decisions to two or three macro-decisions per block — and that is exactly the shape Newport prescribes.

The Stanford CS336 AI agent guidelines that hit the HN front page last week say the same thing in academic dress: students are told to write a clear plan first, run the agent in long autonomous tasks, and only intervene at checkpoint reviews. The reason is not style; it is that constant intervention destroys both the agent’s reasoning trajectory and the human’s attention. The 2026 Show HN game Continue? Y/N, a sixty-second simulation of agent approval fatigue, made the same point as a joke. It is not a joke. There is real data behind it — the Forge project that trended this week showed an 8-billion-parameter model going from 53% to 99% reliability on agentic tasks just by adding deterministic guardrails so the human stops having to babysit every step.

The honest part: this only works if the spec is good. I have wasted entire mornings handing a half-formed prompt to an agent, watching it produce a confident wrong answer, and then trying to debug my way to clarity through more prompting. That is not flow. That is gambling. Naval Ravikant’s line about judgment over hard work applies directly to AI-assisted coding — the leverage is enormous, but the leverage multiplies whatever judgment you put in. If your judgment about what to build is fuzzy, the agent will amplify the fuzziness at machine speed.

So my actual rule is sequential. First block of the morning: no AI. Pen, notebook, or markdown buffer. Write the problem, the constraints, the success criteria. This is the architecture phase, and it is irreducibly human because the agent cannot help you decide what the right thing to build is. Second block: AI-augmented execution. Hand the spec to the agent, let it run, review the diff, ship. Phone in another room, Slack closed, agent in autonomous mode with a long timeout. Third block, after lunch: integration and tests, which I do mostly by hand because that is where I learn what the agent missed.

The engineers I know who hate coding with AI are almost all stuck in the conversational mode — chatting with the model, accepting completions one at a time, never leaving the loop. The engineers who love it have, almost without exception, separated the two phases. Ethan Mollick in Co-Intelligence calls this the “jagged frontier” — knowing where the AI is super-human and where it is sub-human, and structuring your work so you stay on the human side of the jag during the parts that matter. Flow, it turns out, is a planning problem. Treat the agent as a junior engineer you trust for ninety minutes at a time, and the flow comes back.


Related: How to Find Your Passion · Best Self-Improvement Books · How to Make Better Decisions · AI Coach App — Building It in 8 Hours