Try free

Last updated 13 October 2026

Claude Code state after system sleep

System sleep interrupts the active terminal connection

Your terminal session hangs when you wake your computer from sleep. You see a blinking cursor or a frozen line of text where Claude Code was working on a complex refactor or a multi-file search. This happens because the operating system suspends active processes and pauses the network stack to save power. When the lid opens again, the terminal emulator often loses its connection to the shell or the underlying process. You might try to type, but nothing happens, and you eventually have to force a close of that window.

The interruption occurs because the command line interface depends on a continuous stream of data between your local machine and the agent services. When the hardware enters a low power state, the operating system stops the execution of the claude process. This pause is usually fine for a standard text editor, but a coding agent that manages a stateful conversation and a list of pending tasks can find itself in an inconsistent state. You are left wondering if the last file edit was saved or if the agent is still waiting for a response from a tool.

Network sockets time out during hardware suspension

Network stability is the biggest factor when your computer goes to sleep. If you run the claude command over an SSH connection or while connected to a company VPN, the session will almost certainly break. The remote server or the VPN gateway expects a heartbeat signal that stops the moment your machine enters a sleep state. When the network stack wakes up, the socket is already dead. Even on a local machine, the terminal environment might send a hangup signal to the running agent, causing it to stop its current task immediately.

The loss of a network connection means the agent cannot receive the output from its tools or send its next thoughts to the server. If you were using the WebSearch or WebFetch tools, the process might be stuck waiting for a response that will never arrive. The terminal might not even show an error message. It just remains unresponsive. You must understand that the process is technically still alive in the background, but it is no longer connected to the interactive interface you are looking at.

The claude process remains in the process table

The claude process does not always die when the computer sleeps. If you are working locally on macOS or Windows, the process stays in the process table in a suspended state. However, the interactive interface of Claude Code relies on a constant flow of data between the agent and your display. Sleep often corrupts this stream. If the agent was in the middle of a Bash tool execution, the interruption might leave temporary files or lock files in your repository. You must know how to clean these up and jump back into the flow without losing your previous context.

When the system wakes up, the operating system tries to resume the process. If the terminal emulator handles the transition well, you might see the agent attempt to continue. More often, the terminal loses the link to the sub-process. This is common in environments like VS Code or standard terminal apps that do not have specialized session recovery. If you find yourself in this situation, you should not try to force the current session to work. It is safer to terminate the terminal window and start a new one to ensure you have a clean environment.

Reconnecting with the resume and continue commands

You can recover your work using the built-in session management tools. If you were working in a specific project folder, you should run "claude --continue" to pick up exactly where the last session ended. This command looks for the most recent session metadata in your local environment and attempts to restore the conversation history. This is the fastest way to get back to work after a sleep-induced crash. The agent will remember the files it was looking at and the task it was trying to complete.

If you had multiple tasks running in different windows before the sleep occurred, you can use "claude --resume" instead. This command provides a list of previous sessions so you can pick the specific one that was interrupted. This is particularly useful if you were working on different branches or separate parts of a large monorepo. It ensures that you do not accidentally merge the context of two different tasks. Using these commands is better than starting fresh with the "claude" command, as it preserves the expensive context you have already built.

Dealing with unfinished file operations

File operations require careful verification after a sudden interruption. If the agent was using the Edit tool or the Write tool when the power state changed, the file might be in a partially written state. Claude Code is generally good at checking the current state of the file system when it restarts. When you use "claude --continue", the agent reads the current files and compares them to its last known memory. It may use the Read or Glob tools to scan the directory and ensure nothing was corrupted during the sleep cycle.

You should use the /status command once you are back in the session to see what the agent thinks the current progress is. If the state looks wrong, you can use the /review command to see the recent changes and verify their integrity. This is a critical step because an interrupted Write tool might leave a file with missing brackets or incomplete logic. If you find a problem, you can simply tell the agent to fix the file it was just working on. It will use its conversation history to understand what the final state of the file should have been.

Managing context after an interruption

Long sessions that survive several sleep cycles can become heavy and slow. Every time you reconnect to a session, the conversation history grows, and the context window fills up with the logs of your previous attempts. To keep things efficient, you should use the /compact command after a reconnection. This summarizes the session so far and frees up space in the context window. It also helps the agent focus on the current task rather than getting confused by the technical noise of the disconnection and reconnection events.

You can also check /cost or /usage to see how much the resumed session has used so far. Large sessions consume more tokens because the entire history is sent with each new prompt. If you find that the cost is rising quickly after several interruptions, it might be better to use /clear and start a fresh session in the same folder. This resets the context window but keeps your files intact. You can then provide the agent with a quick summary of the remaining work to be done, which is often more cost-effective than carrying a bloated session history.

Visualizing session state on a wall

Managing many sessions across different projects becomes difficult when sleep affects them all at once. This is where adhdTerminal provides a clear advantage for developers. The app runs many Claude Code sessions side by side as tiles on a wall. Each tile has a color, a number, and a name. When your computer wakes up, you can see the state of every project at a single glance. You do not have to manually check every terminal tab to see which ones are still alive and which ones need a "claude --continue" command to get back to work.

A tile in adhdTerminal shows whether it is working, waiting for you, done, or idle. It also displays the last exchanges of its conversation. This visual feedback is vital after a system sleep because you can instantly identify which agent was interrupted in the middle of a Bash command and which one was simply waiting for your input. Tiles reopen in the same place after a restart and resume the same session, which maintains your spatial layout and mental focus. This removes the friction of hunting through terminal history to find where you left off.

Monitoring tasks with a mobile mirror

Reliability is better when you can monitor your tasks without sitting at your desk. The adhdTerminal iPhone app mirrors your wall of tiles over an end to end encrypted link. If you are away from your computer and it goes to sleep, you can check the app to see the last exchanges of the conversation. You can even answer a prompt or send the next task from your phone. This ensures that even if the physical hardware pauses, your mental model of the project remains current and you can resume work as soon as you are back at your machine.

The mobile app allows you to stay informed about long-running tasks that might span across a lunch break or a commute. If the agent finishes a task while you are away, the tile on the iPhone app will show the status as done. If the computer sleeps before the task is finished, you will see the last known state. This level of visibility prevents the common frustration of returning to a computer only to find that a task failed ten seconds after you walked away. The mirror link ensures you are always in the loop.

Best practices for long running tasks

You can customize how the agent behaves during long tasks by editing the configuration files. The project instructions in CLAUDE.md can include specific steps for the agent to take if it detects a timeout or an interrupted tool use. You can also modify .claude/settings.json to adjust how permissions are handled. For example, setting certain tools to bypassPermissions can prevent the agent from getting stuck waiting for your input while you are away from the keyboard. This allows the agent to finish more of its plan before the system eventually sleeps.

Global settings in ~/.claude/settings.json can also be used to define your preferred environment for all projects. If you frequently deal with sleep interruptions, you might want to configure your terminal setup to handle signals more gracefully. Use the "claude doctor" command if you suspect the installation itself was corrupted by a hard system crash or a power failure. This command checks the health of the agent and ensures all components are working correctly. Maintaining a clean set of configuration files is the best way to ensure that your agent remains reliable across many days of work.

Questions people ask

What happens to a running Bash command when the lid closes?

The command typically continues to run until it requires user input or attempts to write to a terminal that is no longer responsive. If the terminal emulator closes the session upon sleep, the process may receive a signal to terminate. You should use the /status command after restarting with claude --continue to see if the previous task completed successfully.

Does Claude Code save my progress automatically?

Yes, the agent logs the conversation and tool outputs to its local session storage on your machine. You can use "claude --continue" to return to the last active state even if the terminal window was closed or the computer crashed. The file changes made by tools like Edit or Write are permanent and remain on your disk regardless of the session state.

How do I stop an agent that is stuck after a sleep cycle?

If the terminal window is frozen and does not respond to the Escape key, you should force the terminal application to close. Once you open a new terminal, you can run "claude --continue" to re-establish the session. If the agent starts performing unwanted actions upon resumption, press Escape once to interrupt the current tool or twice to go back to an earlier message.

Read next

More on when it goes wrong·All posts