Steering long sessions
Prompting Claude to knock out a quick task is easy. You ask, it works, you check the result. But long tasks are a different game. Refactoring across a dozen files or building out a new feature can take hours. And the more you have to steer Claude along the way, the longer it drags on.
The good news is that you have a lot of tools to help Claude during these long sessions. It really comes down to two habits: scope the work before Claude starts, and steer it while it runs. Let's walk through both.
한국어 대본
- 00:00Claude에 프롬프트를 보내 짧은 작업을 끝내는 모습을 지켜볼 수 있지만, 긴 작업을 실행하는 것은 훨씬 어렵습니다.
- 00:06열두 개 파일에 걸친 리팩터링이나 새 기능 구현은 몇 시간씩 걸릴 수 있고,
- 00:10Claude의 방향을 올바르게 잡고 있다면 더 오래 걸릴 수도 있습니다. 하지만 이러한 긴 세션 동안 Claude를
- 00:14도울 방법은 많습니다. 중요한 습관은 두 가지입니다. 첫 번째는 Claude가 시작하기 전에 작업 범위를 정하는
- 00:21것입니다. plan 모드를 사용하면 Claude가 읽기 전용
- 00:26모드로 조사한 뒤 계획을 전달합니다. 계획을 받으면 실제로 처음부터 끝까지 읽어 보세요.
- 00:31계획이 철저할수록 Claude가 실행할 때 문제가 생길 가능성이 줄어듭니다.
- 00:35계획을 수정할 때는 원하는 위치에 내용을 추가해 달라고 Claude에게 요청하세요. 최선의 결과를 단순히
- 00:39바라는 것보다 계획을 반복 개선하는 편이 훨씬 빠릅니다. 두 번째 습관은 Claude의 방향을
- 00:45올바르게 잡는 것입니다. 방법은 다음과 같습니다. `/compact`는 대화를 요약하고
- 00:50이를 새 컨텍스트로 사용하면서 이전 내용을 삭제해 컨텍스트 창의 공간을 확보합니다.
- 00:56하지만 중요한 내용이 삭제되어 Claude가 잘못된 방향으로 벗어날
- 01:01수 있습니다.
- 01:02`/compact` 명령을 실행할 때는 원하는 변경 사항을 함께 추가하세요.
- 01:04명령 뒤에 지침을 추가하면 Claude에 요약 방법을 알려 줄 수 있습니다.
- 01:08예를 들어 한참 전에 디버깅을 끝냈지만 API 변경 사항에만 집중하고
- 01:12싶다면 여기에서 그렇게 할 수 있습니다.
- 01:15Claude가 잘못된 경로로 가더라도 프롬프트를 계속 보내 빠져나오게 할 필요는 없습니다.
- 01:20Rewind를 사용하면 마지막 체크포인트로 돌아갈 수 있습니다.
- 01:21Rewind를 열려면 빈 프롬프트에서 Esc를 두 번 누르면 Rewind 메뉴가 표시됩니다.
- 01:26사용자 프롬프트를 입력할 때마다 체크포인트가 생성되며, 여기에서 여러 옵션을 사용해 되돌릴 수 있습니다.
- 01:30첫째, 코드나 대화 또는 둘 다를 복원할 수 있습니다.
- 01:34둘째, Summarize from here는 체크포인트 이후의 모든 내용을 요약합니다.
- 01:38곁가지 대화를 나눈 뒤 공간을 조금 확보하고 싶을 때 유용합니다.
- 01:41Summarize up to here는 체크포인트 이전의 모든 내용을 요약합니다.
- 01:45긴 설정 단계를 요약하고 싶을 때 특히 유용하지만, 구현
- 01:49부분은 유지할 수 있습니다.
- 01:51방향을 잡는다고 말할 때는 직접 개입한다고 가정합니다.
- 01:55조금 더 자율적인 작업을 원한다면 goal과 loop가 있습니다.
- 01:59Goal은 완료 조건을 설정합니다.
- 02:02완료 상태가 어떤 모습인지 설명하면 Claude는 여러 턴에 걸쳐 계속 작업하고, 빠른 평가기가
- 02:06해당 조건이 충족되었다고 확인할 때까지 진행합니다. Claude가 처음으로
- 02:10완료되었다고 생각하는 순간에 그냥 멈추는 방식이 아닙니다.
- 02:12예를 들어 `/goal`을 실행해 source billing의 모든 테스트가 통과하고 타입
- 02:16검사기 보고서에 오류가 0개라고 지정할 수 있습니다.
- 02:18`/goal clear`를 실행하면 목표가 취소됩니다.
- 02:20여기서 한 가지 제약은 평가기가 대본만 읽는다는 점이므로, 조건은 Claude가 생성하는 출력에서 확인할 수 있어야 합니다.
- 02:24예를 들어 Claude가 실행한 테스트 결과처럼 말입니다.
- 02:29Loop는 턴 사이의 일정한 간격으로 또는 자체 속도에 따라 프롬프트를 실행합니다.
- 02:33이를 사용해 CI 실행이나 배포처럼 외부 상태를 확인하고, 상태가 바뀌면 조치를 취하세요.
- 02:38Esc를 누르면 중지할 수 있습니다.
- 02:41따라서 방향을 잡는다는 비유에서는 자동차 한 대에 운전대 하나가 있다고 가정합니다.
- 02:44하지만 같은 코드베이스에서 여러 에이전트와 작업할 때
- 02:48자동차 한 대에 운전대 두 개가 있는 상황은 원하지 않습니다.
- 02:51그건 안전하지 않습니다.
- 02:52이때 워크트리가 사용됩니다.
- 02:54워크트리는 저장소의 파일을 두 개 이상의 Claude 세션이 두고 다투는 일을 막습니다.
- 02:58세 개의 독립적인 파일 트리를 만들어 충돌을 방지합니다.
- 03:01종료할 때 깨끗한 워크트리는 자동으로 제거됩니다.
- 03:04저장소 루트의 `.worktreeinclude` 파일에는 각 워크트리에 복사할 gitignore된 파일이 나열됩니다.
- 03:09이는 환경 변수 파일이나 로컬 설정처럼 필요하지만
- 03:15버전 관리에 커밋하고 싶지 않은 파일에 유용합니다.
- 03:18긴 Claude Code 세션을 다룰 때는 먼저 작업 범위를 정한 다음 방향을 잡고,
- 03:27compact를 직접 지시해 요약이 중요한 내용을 유지하도록 하세요. Rewind 메뉴로 방향을 바로잡고,
- 03:31단계를 설명하는 것보다 완료 상태를 더 잘 설명할 수 있을 때 목표를 설정하세요.
- 03:34병렬 작업과 워크트리를 실행하면 그렇게 할 수 있고, 긴 실행을 지켜보지 않아도 신뢰할 수 있습니다.
Scope the work first with plan mode
Before Claude writes a single line, get it to lay out a plan. In plan mode, Claude does its research in read-only mode. It reads the code, figures out what needs to change, and hands you a plan to review.
When you get that plan, actually read it. Don't skim it. The more thorough the plan, the fewer surprises you'll hit once Claude starts executing. If something's off or missing, just ask Claude to add it where you want. Iterating on a plan is much faster than letting Claude run and hoping for the best, then cleaning up the mess.
Steer while Claude works
Once Claude is running, you have a few ways to keep it pointed in the right direction. The first is compaction.
Compact
Compact summarizes your conversation, uses that summary as the new context, and deletes the old messages. This frees up your context window so Claude can keep going. The risk is that something important gets dropped in the summary, and Claude drifts off course.
So don't just run /compact on its own. Add instructions after the command to tell Claude how to summarize. For example, if you finished debugging a while back and now you only care about some API changes, say so:
/compact Focus on the --version flag implementationAnything you write after the command shapes what the summary keeps. That's your steering wheel for context.
Rewind
When Claude heads down the wrong path, you don't have to prompt your way back out. Rewind takes you to your last checkpoint. Every user prompt creates a checkpoint you can revert to. To open the menu, double tap escape on an empty prompt.
From the rewind menu you get a few options:
- Restore code and conversation - roll back both together.
- Restore conversation - roll back just the chat.
- Restore code - roll back just the files.
- Summarize from here - summarizes everything after the checkpoint. Great if you had a side conversation and just want to free up some space.
- Summarize up to here - summarizes everything before the checkpoint. Great when you had a long setup phase you want to compress, but you want to keep the implementation parts intact.
Let Claude run more autonomously
Everything so far assumes you're hands-on, watching and correcting. If you want something more autonomous, there's goal and loop.
Goal
Goal sets a completion condition. You describe what "done" looks like, and Claude keeps working across turns until a fast evaluator confirms those conditions are met. It won't just stop the first time it thinks it's finished.
For example:
/goal all tests in src/billing pass, and the type checker reports zero errorsTo cancel it, run /goal clear. One important constraint: the evaluator only reads the transcript. So your condition has to be checkable from the output Claude actually produces, like the results of a test run.
Loop
Loop runs a prompt on an interval between turns, either fixed or self-paced. Use it to pull something external, like a CI run or a deploy, and act when the state changes.
To stop a loop, just press escape.
Run parallel work with worktrees
The steering metaphor so far assumes one steering wheel in one car. But when you're running multiple agents on the same codebase, you don't want two steering wheels in one car. That's unsafe. Two Claude sessions fighting over the same files leads to conflicts.
That's where worktrees come in. Instead of sessions stepping on each other, each one gets its own independent file tree.
Because each agent has its own tree, they can't clobber each other's changes. When a session exits, a clean worktree is automatically removed.
There's one helpful file to know about. A .worktreeinclude file at the repo root lists git-ignored files to copy into each worktree. This is useful for things like an environment variable file or a local config that you need in every worktree but don't want to commit to version control.
Putting it together
Handling long Claude Code sessions comes down to a handful of habits:
- Scope your work first, then steer.
- Direct your compaction so the summary keeps what matters.
- Use the rewind menu to course correct when Claude drifts.
- Set a goal when you can describe "done" better than you can describe the steps.
- Run parallel work in worktrees.
Do that, and you can trust a long run without babysitting every step of it.