Last updated 13 October 2026
Handle Claude Code waiting for input
Identifying the hidden input hang
You are working in the terminal with Claude Code and everything stops. The command line shows no new output for several minutes. You might think the model is thinking about a complex problem, but the reality is simpler. A background process is waiting for you to say yes or no to a question you cannot see. This happens when a tool opens a sub-shell or a prompt that does not reach the main interface. You see a blinking cursor or a status message that says it is still running, but no progress happens for minutes.
This situation is common during package installations or database migrations. You see a message that the tool is running a command, but the progress bar stays at zero. Your computer fans might spin down because the CPU is not doing any work. It is sitting in a wait state for a keyboard event. This creates a loop where the AI waits for the command to finish and the command waits for a user who does not know a prompt exists. The tool might not show you the specific question because it is buried in a sub-shell or a piped command.
To confirm this is the problem, check your system process monitor. Look for the command that Claude Code started. If the process is alive but shows zero percent CPU usage and no disk activity, it is likely waiting for input. You can also try to run the same command manually in a standard terminal window. This often reveals a confirmation prompt about disk space, file overwrites, or license agreements that the AI interface is not displaying correctly.
Why shell abstraction causes blocks
Claude Code runs scripts by spawning a shell process on your machine. This process is often a non-interactive shell by default. Some tools detect this and fail immediately, but others try to be helpful and prompt anyway. If the tool sends its prompt to the standard error stream instead of the standard output stream, the AI might not relay that text to you. You are left looking at a blank line while the system waits for a confirmation that you can never see.
Terminal multiplexers and pseudo-terminals can complicate this even more. If the underlying shell expects a TTY and does not get one, it might hang. Tools like git or npm often check if they are running in a terminal. If they think they are, they might try to open an editor like Vim for a commit message or a login prompt for a registry. If the AI cannot handle that specific interactive mode, the process locks up until you manually intervene by killing the task.
We do not know exactly how Claude Code handles every possible TTY request across different operating systems. However, we do know that any tool that expects a secret password or a passphrase will typically hang. These tools usually bypass standard output for security reasons. They attempt to read directly from the keyboard buffer. Since the AI is the one controlling the shell, the keyboard buffer is empty, and the process sits in a permanent wait state.
Forcing non-interactive mode with flags
The most effective way to prevent these hangs is to tell your tools not to ask questions. Most command-line interfaces have a flag for this. For example, when using the apt package manager on Linux, you should always include the -y flag. This tells the system to assume a yes answer to all prompts. Without it, the installation of a simple library can halt the entire AI workflow until the session times out or you force a restart.
Package managers for other languages have similar requirements. Use the --yes flag with npm or the --noconfirm flag with tools like pacman. If you are using pip for Python, consider using the --quiet flag to reduce the amount of output that might confuse the terminal buffer. These flags ensure that the tool makes a decision on its own instead of waiting for a human. This allows Claude Code to see the final result of the command and move on to the next step of your project.
When you ask the AI to run a command, explicitly include these flags in your prompt. If you tell it to install a list of dependencies, tell it to use the non-interactive or force-yes flags. This proactive approach prevents the AI from generating a command that will eventually freeze. It is a good habit to treat every command as if it were running on a remote server where you have no keyboard access. If the command would hang there, it will hang here too.
Setting environment variables for silent runs
Environment variables are your first line of defense against hidden prompts. Many modern CLI tools check for a variable named CI. Setting CI=true often tells programs to skip interactive prompts and use default values. You can prefix your commands with this variable or set it in your shell profile. This is a standard practice in automated testing and it works just as well for AI-driven development. It signals to the software that no human is present to answer questions.
For Debian-based systems, the DEBIAN_FRONTEND variable is essential. Setting it to noninteractive tells the system to use the default configuration for all new packages. This is particularly useful when Claude Code is helping you set up a new server environment or a Docker container. Without this variable, the system might try to open a blue configuration screen inside the terminal, which will definitely break the AI session and force you to start over.
You should also consider variables for specific tools like git or compilers. For example, setting GIT_TERMINAL_PROMPT=0 tells git to fail immediately if it needs to ask for a password. It is better for a command to fail with an error message than to hang forever. A failure gives the AI something to work with. It can see the error, understand that it needs credentials, and ask you to provide them or use a different method. A hang gives the AI no information at all.
Handling git and authentication blocks
Git is a frequent source of terminal hangs in AI sessions. If you have not configured a credential helper, git might prompt for your username and password every time you push or pull. Since the AI cannot see this prompt, it looks like it is taking a long time to communicate with the server. You should ensure that your SSH keys are added to your agent or that your credential manager is working before you start a Claude Code session.
Another common git issue is the GPG signing of commits. If you have commit signing enabled, git will call a program like gpg-agent to ask for your passphrase. This often opens a graphical window or a terminal prompt. If that window appears on a different desktop or is hidden behind your editor, you will not see it. The AI will wait until the GPG agent times out, which can take several minutes. Disable signing for AI sessions if you do not want to deal with this block.
We do not know the exact timeout limits for every git operation. We do know that git hooks can also cause issues. If you have a pre-commit hook that runs a linter or a test suite, that hook might wait for input if it finds a problem. Check your hooks in the .git/hooks directory. If any of them are interactive, modify them to use default answers or skip them during AI-driven tasks to keep the process moving.
Visualizing status with adhdTerminal
Keeping track of multiple active sessions is hard when one of them might be stuck. You need a way to see at a glance if a process is actually doing work or just sitting there. adhdTerminal helps here because each Claude Code session is a tile on a wall. Each tile shows whether it is working, waiting for you, done, or idle. If a tile stays in the working state for too long without any new headlines or numbers appearing, you know it is time to check that specific session for a hidden prompt.
This visual feedback prevents you from wasting time on a frozen task. You can give each tile a name and a color to keep your projects separate. When you see a tile that should have finished a simple task still showing as active, you can jump in and fix the input block. This is better than having one single terminal window where you lose the context of what was supposed to happen in each background job. You can see the last exchanges of the conversation directly on the tile.
The wall of tiles gives you a high-level view of your entire development environment. If one tile is waiting for you, it is clearly marked. This is especially useful for those of us who get distracted while waiting for a command to finish. Instead of checking back every few minutes, you can glance at the wall and see exactly which session needs your attention. It turns a mystery of a frozen terminal into a visible status that you can manage.
Scripting the response with the yes command
When a tool does not provide a non-interactive flag, you can use the Unix yes command. This command outputs a continuous stream of the letter y followed by a newline. You pipe this into the command that is hanging. For example, running yes | my-command will automatically answer yes to every question the command asks. This is a blunt tool, but it is very effective for scripts that are poorly designed and demand human interaction.
Be careful when using this approach. Answering yes to every question can lead to unintended consequences, such as overwriting important files or deleting data. Only use it when you are certain that the default yes answer is safe. If the command requires a specific word instead of just y, you can provide that as an argument, like yes no | my-command. This will send the word no repeatedly instead, which might be safer for destructive operations.
You can also use more advanced tools like expect scripts. An expect script allows you to define specific strings to look for and specific responses to send. This is useful for complex setups where the first question needs a yes but the second question needs a password or a path. While writing an expect script takes more time, it is the most reliable way to automate a command that was never meant to be run without a human.
Recovering from a frozen state
If a session becomes completely unresponsive, you may need to force it to close. Killing a process in the terminal sometimes leaves orphan processes behind. You should check your activity monitor or use the top command to find any processes that are still running after you think you closed them. Look for git, node, or python processes that are consuming no CPU but are still tied to the previous session. Terminate these manually to clear the way for a new attempt.
When you have to restart your environment to clear a hang, you want to get back to work quickly. adhdTerminal reopens your tiles in the same place after a restart. It resumes the same session so you do not lose the history of what you were doing before the input block happened. This persistence makes it easier to recover from the frustration of a frozen command and lets you try the task again with the correct non-interactive flags or environment variables.
A final tip for recovery is to use the iPhone app that mirrors your tile wall. If you are away from your desk and a long-running command hangs, you can check the status on your phone. The app can answer a prompt or send the next task over an encrypted link. This means you do not have to sit at your computer just to wait for a potential confirmation prompt. You can handle the interruption from anywhere and keep your development pipeline moving.
Questions people ask
How can I tell if Claude Code is stuck or just thinking?
Check your system activity monitor for the underlying process, such as node or a specific compiler. If the CPU usage is zero and there is no network or disk activity, the process is likely waiting for input. You can also look for stalled child processes that have no terminal output associated with them.
Can I fix a hang without restarting the whole session?
Sometimes you can fix it by sending a signal like SIGINT using Ctrl-C, which may force the sub-process to exit and return control to the main shell. If that fails, you might need to find the specific PID of the child process and kill it manually. If the AI is still responsive, you can ask it to stop the current task and try a different approach.
What should I do if a command always requires a password?
You should use a credential manager or an SSH agent to handle the password before starting your AI session. If the password must be entered manually, run that specific command in a separate terminal window. Once the authentication is cached, you can return to the AI interface to continue the rest of the work.
Read next
- Access git submodules in Claude CodeFix issues where Claude Code cannot see or modify code located inside nested git submodules within your main repository.
- Allow Claude Code to run shell scriptsResolve tool execution errors by adjusting permission settings to let Claude Code execute local bash or powershell scripts in your terminal.
- Break a linter error loop in ClaudeWhat to do when Claude Code fixes one linting error only to create another, leading to a circular set of edits.
- Change the Node version for Claude CodeResolve compatibility issues by switching the Node.js version used by Claude Code without breaking your other local development tools.