Try free

Last updated 13 October 2026

Force Claude Code to skip y/n prompts

The frustration of the idle agent

You step away from your terminal to grab coffee while Claude Code works on a complex refactor or a large scale search. When you return ten minutes later, you expect to see a completed task, but instead, you find the agent has done nothing. It is stuck on a single y or n prompt, waiting for you to confirm a file write or a shell command. This stall breaks your professional flow and defeats the purpose of using an autonomous coding agent. The tool is designed to save you time, but it becomes a bottleneck when it requires constant manual approval for every minor action it takes.

This problem usually stems from the default security settings which prioritize safety over speed. While asking for permission is a good safeguard for new users, an experienced developer needs the agent to run independently. You need a way to tell the command line tool to proceed without asking for permission every time it wants to touch a file or execute a bash script. Configuring the software to skip these interactive prompts allows you to treat it as a background worker rather than a chat bot that requires your constant attention to move forward.

Changing interaction levels with permission modes

Claude Code uses four distinct permission modes to control how much it interacts with you. The default mode is the most restrictive, asking for approval for almost every tool use that modifies your environment. If you want to reduce the frequency of these interruptions, you can cycle through the modes while you are inside an active session. By pressing Shift-Tab, you can move from the default mode to the plan mode. The plan mode allows the agent to think through a series of steps and present them to you as a cohesive strategy rather than asking for approval at every individual micro-step.

As you continue to press Shift-Tab, you will see the status indicator change. The most important mode for developers who want to avoid y or n prompts is the bypassPermissions mode. In this state, the agent operates with full autonomy and will use tools like Write, Edit, and Bash without waiting for your confirmation. This is the fastest way to work if you trust the agent to handle the task correctly and you have a solid git history to revert any changes that do not meet your standards. Using this mode effectively turns the agent into a true background worker that only stops when the task is finished or when it hits a logical wall it cannot overcome.

Configuring permanent automation in settings files

Switching modes manually using Shift-Tab is useful for a single session, but you often want this behavior to be the standard for your environment. You can achieve this by editing the configuration files that the tool reads upon startup. The primary file for these changes is found at .claude/settings.json within your project root. If you want the settings to apply to every project on your machine, you should edit the file at ~/.claude/settings.json instead. These files allow you to define a permissions object that specifies which tools are allowed to run automatically and which ones still require a manual y or n response.

Inside your settings.json file, you can explicitly set the permission levels for individual tools. For example, you can set the Bash tool to allow, which means any shell command the agent generates will execute immediately. You can do the same for the Write and Edit tools to ensure file modifications happen without a prompt. If you share a repository with a team but want your own local overrides for these permissions, you can create a .claude/settings.local.json file. This file is usually ignored by git and allows you to run in a more automated way than your colleagues without forcing your preferences on the whole team. This granular control ensures that you only skip the prompts that you find redundant.

Handling interactive shell commands via the bash tool

Sometimes a prompt does not come from Claude Code itself but from a command that the agent tries to run in your shell. If the agent executes a package manager command or a script that asks for a yes or no confirmation, the process will hang in the terminal stream. The agent might not realize that the command is waiting for a user to type y and hit enter. To solve this, you must provide clear instructions in your project documentation so the agent knows how to handle these specific shell interactions. This prevents the Bash tool from getting stuck on an external process that expects a human to be at the keyboard.

The best place to store these instructions is in the CLAUDE.md file located at the root of your repository. You should add a section that tells the agent to always use non-interactive flags when running common commands. For example, you should instruct it to use the -y flag with apt-get or the --yes flag with other CLI tools. If a command does not have a non-interactive flag, you can tell the agent to pipe the yes command into the process. By setting these expectations in CLAUDE.md, you ensure that the agent proactively avoids creating the very prompts that lead to a stalled session. This file acts as a permanent guide for the agent and is read every time a session begins.

Using non-interactive mode for single prompts

There are times when you do not need a full conversational session and simply want to run one command and get the result. The tool provides a specific flag for this purpose which is claude -p followed by your prompt. When you use this flag, the agent runs the prompt and prints the output directly to the terminal without opening the interactive UI. This mode is inherently non-interactive for the user, as it does not provide the same y or n interface found in the main shell. It is a powerful way to integrate the agent into your own scripts or build pipelines where a human is not present to provide input.

When using the -p flag, the agent still respects the permissions defined in your settings files. If your settings are configured to require approval for the Write tool, the command might fail or skip the write action entirely because there is no way for you to answer the prompt. Therefore, if you plan to use this single-prompt mode for tasks like automated documentation updates or generating boilerplate code, you must ensure your ~/.claude/settings.json is set to allow those specific tools to run without confirmation. This combination of the -p flag and permissive settings allows for a completely hands-off developer experience where tasks are triggered and completed in the background while you focus on other things.

Monitoring automated sessions with adhdTerminal

When you configure the agent to skip prompts and run in bypassPermissions mode, you might start running multiple sessions at once to handle different parts of a large project. Keeping track of four or five automated terminal windows is difficult and often leads to missing an important error message or a completed task. This is where adhdTerminal provides a significant advantage for your workflow. It allows you to run many Claude Code sessions side by side, with each session appearing as a tile on a wall. You can see at a glance whether a tile is actively working, waiting for a rare input, or finished with its task, all without having to click through multiple terminal tabs.

Using adhdTerminal also gives you the freedom to step away from your desk while your automated sessions are running. The free iPhone app mirrors your wall of tiles over an end to end encrypted link, so you can check the progress of your background tasks from another room. If an agent does hit an unexpected snag that requires a prompt, you can answer it or send the next task directly from your phone. This setup ensures that your bypassPermissions sessions stay productive even when you are not physically sitting at your computer. Each tile on your wall can be assigned a color and a name, making it easy to distinguish between a session that is running tests and one that is refactoring a legacy module.

Automating workflows with hook events

Advanced users can further refine how the agent behaves during long-running tasks by utilizing hook events. These are specific triggers that happen during a session, such as SessionStart, PreToolUse, and Stop. While these hooks are primarily used for notifications or logging, they can also be used to prepare the environment so the agent is less likely to encounter a prompt. For instance, you could use a SessionStart hook to clear old lock files or temporary directories that might otherwise cause a shell command to ask if you want to overwrite an existing file.

You can also use the UserPromptSubmit hook to run a script that checks the validity of a prompt before the agent even sees it. This allows you to catch potential issues that would lead to an interactive prompt later in the process. By combining these hooks with a well-maintained CLAUDE.md file, you create a robust environment where the agent has all the information and permissions it needs to work without interruption. If you ever find that your automation is behaving unexpectedly, you can run the claude doctor command to check your installation and ensure that your configuration files are being read correctly by the system.

Managing session context and memory

As an agent runs in a non-interactive mode for a long time, its context window can fill up with the history of the conversation and the files it has read. This can sometimes lead to the agent becoming less efficient or more prone to making errors that might trigger a warning prompt. To prevent this, you can use the /compact command to summarize the session history and free up space in the context window. This ensures the agent stays focused on the current task and does not get bogged down by irrelevant details from earlier in the session. You can even automate this by setting a hook for the PreCompact event if you want the agent to handle its own memory management during long runs.

If a session becomes too cluttered or the agent gets into a loop where it keeps trying the same failing command, you can use the /clear command to start fresh in the same folder. This is often better than quitting and restarting because it keeps the agent in the right directory and preserves your current permission mode. When running in an automated fashion, it is also wise to occasionally use the /cost and /usage commands to see how much you are spending on these background tasks. Automated sessions can consume a lot of tokens if they are left to run on complex problems, so keeping an eye on the spend ensures that your quest for efficiency does not result in an unexpected bill.

Safety measures for non-interactive coding

Skipping prompts is a powerful way to increase your output, but it requires a safety net to prevent the agent from causing damage to your codebase. The most important safety measure is to always run the agent on a clean git branch. This allows you to use the /review command to look at every change the agent made while you were not watching. If you find that a bypassPermissions run has gone off the rails, you can easily discard the changes and try again with more specific instructions in your CLAUDE.md file. You should never run a fully automated session on a production environment or a branch that has uncommitted work.

Another useful feature for managing automated runs is the ability to go back to earlier messages. If you press the Escape key twice, the interface will offer a list of earlier messages that you can return to. This is incredibly helpful if an automated task finishes but you realize the agent took a wrong turn halfway through the process. You can jump back to the point before the error occurred, refine your instructions, and let the agent try again. By treating the agent as a partner that you supervise through retrospective review rather than constant y or n interruptions, you achieve a much higher level of productivity without sacrificing the quality of your code.

Questions people ask

How do I make the agent always start in bypassPermissions mode?

You cannot currently set the startup mode via a flag, but you can define tool-specific permissions in your ~/.claude/settings.json file. By setting tools like Bash, Write, and Edit to allow, you effectively mirror the behavior of the bypass mode for every new session. This ensures that the agent does not stop for y or n prompts even at the very beginning of a task.

Can I skip prompts for some files but not others?

Yes, you can achieve this by placing a CLAUDE.md file in a specific subdirectory of your project. The instructions in a subdirectory CLAUDE.md will apply only to the agent's work within that part of the file tree. You can use this to give the agent full autonomy in a tests folder while keeping more restrictive prompt settings for your core business logic.

What happens if a background task in adhdTerminal fails?

The tile on your wall will change its status to show that it is no longer working and may display a headline indicating an error. You can then click into that tile to read the last few exchanges of the conversation and see exactly where the failure occurred. If you are away from your desk, the iPhone app will reflect this status change so you know a task needs your attention.

Read next

More on when it goes wrong·All posts