Tips for Using Claude Code in Non-Interactive Mode
Asked by
~stack8
Hey everyone! I'm exploring ways to utilize Claude Code in non-interactive mode since I'm struggling to fully utilize my MAX plan. I have a couple of questions:
First, can anyone share how they set it up to monitor changes in files within a folder and what actions it can take in response? Additionally, is it possible to have it execute long tasks without needing user confirmations? How would that work? Any advice or use cases you have would be super helpful!
Answers
I was curious about setting up Cron Jobs with Claude Code too. If anyone has experience with that, Iโd love to hear how itโs working out for you!
Reply to this answer
Iโve been using a loop with the claude-yolo setting, no safeties, and itโs been quite a ride. Essentially, I tell it to go through my plan.md and keep running itself until it signals completion. Itโs amazing how effective it can be overnight, but bewareโit can definitely get carried away with scope creep and unexpected refactoring! Canโt wait for the next version to hopefully handle this better!
Reply to this answer
I actually wrote a new provider in Cline that leverages non-interactive mode and uses the --verbose and --output-format json flags. This way, I managed to use Claude Code CLI to make calls more economically with my Max subscription. It works decently well but is a bit slower than using the API. I'm keeping it private for now since I don't want to risk Anthropic taking it down just because Iโm using it differently and might potentially share it on GitHub!
Reply to this answer
You can definitely run Claude Code in non-interactive mode using the --allowed-tools flag. It lets you whitelist tools, but I'm also still figuring out how to manage really long tasks without using the full yolo mode (which requires a Docker container with no internet access). I've been using it for tasks like pull request reviews (by giving it access to GitHub CLI to post comments), shell scripts for MCP server testing, and semantic linting for code checks. Right now, Iโm even experimenting with a webhook to interact with my bot account in GitHub issuesโthough keep in mind, you'd need Bedrock for authentication in that kind of setup.
Reply to this answer
Be sure to program it to conduct tests on the code it generates; that way, you might have a better chance of managing limits. Also, utilizing GitHub for tracking changes can be incredibly useful when automating tasks with Claude.
Reply to this answer
Add your answer
Answers are reviewed before publication.
tsv+header: Just a tip, you could also use "claude --dangerously-skip-permissions" for more flexibility!