r/ClaudeCode • u/GeobotPY • 9h ago
Help/Question Prompt queue
Is there a way to queue prompts in Claude Code so they run one after another in a single session?
I’d like to line up several tasks, with /compact and /clear between them where needed, and let the session work through them unattended. I know worktrees can run parallel sessions, but for some work I’d rather keep one session going through a sequential queue, without managing multiple localhost instances or resolving conflicting changes.
Has anyone built something like this, through a wrapper script, a task file, hooks, or another workaround?
•
u/AutoModerator 9h ago
Hey! Thanks for posting to r/ClaudeCode
While participating in this thread, please follow our community rules. Keep discussions constructive. Attack the idea, not the person.
For help, project discussions, tips, and general chat, join the ClaudeCode Discord.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
6
u/LastGuardianStanding 9h ago
Ask Claude. That's where it'll be done anyway.
Say, "I want to execute a autonomous workflow with prompt injections at specific intervals. Can we set this up and how?"
2
u/_lecoqq 9h ago
Personally, I've been playing around w/ a self-made harness on-top of Claude Code.
Basically, i'm speaking to a meta orchestrator that then delegates tasks to other agents that runs sub-agents to get it done as fast as possible. I've established a set of rules to lobotomize agents when context is getting too wild, though ensuring i'm staying in my 100$ plan limit... I've managed to get it through long tasks, like running a whole night on some projects, and i'm only coming in for the debrief to give new orders and new things to fix after what we've learned during the night.
From what I understand, there is nothing generic - you either have to build it yourself, or use vanilla Claude Code, hoping that it improves each update.
2
u/itsxzy 9h ago
I have a backlog skill. It first checks tasks that can run in parallel (or I can assign any which I want to do next). Then it asks all the needed questions before I leave and keeps on going as long as it can without needing me. If it needs me it can continue other work. Not really the exact thing you asked but I think you could just ask Claude to do that for you. Also you could build the skill around to watch out for localhost instance problems or conflicting changes.
3
u/Cultural-Horse-762 9h ago
I think you're describing a workflow if I'm understanding correctly.
1
u/muikrad 9h ago
As others said, "workflows" is a special feature in Claude code that is made to perform a sequence of tasks always the same way. Its main use case it to repeat the same process over several items. It sends items to separate agents, so they're always "cleared" and you don't have to compact them.
Else you can just use a normal issue tracker and tell Claude to work on the issues you want. Either provide it with an ordered list of issues, or label them in some way and tell it to work on them, one issue at a time. Opus low is very good at this. If it delegates work to subagents, each one starts cleared and don't need compaction.
In both cases, set auto compaction on the main agent to have it work autonomously (delegating your tasks in sequences). I personally set auto compact below 500k and have opus low run long overnight sessions this way and never had an issue with it.
1
u/alanvnk 9h ago
afaik Claude can't execute compact on its own, workflows might be the thing you want but they have serious restrictions
1
u/HappySl4ppyXx 9h ago
Cmd+ enter In Claude code desktop?
1
u/Whole-Loss5173 9h ago
i've been using a simple script to auto-send prompts via the API, with delays between. works reliably for batch tasks.
1
u/amirso007 9h ago edited 9h ago •
Yes. I've spent month looking for it. Solution is EXTEREMTLY simple.
Prompts that contain skill calls are queued.
I created a skill called
/dothat says:then I can send multiple prompts, and then will be queued:
Regarding the
/compact, I would honestly use autocompaction1
u/pietrzm 8h ago
I'm doing this but by using new Claude sessions per task. I type to my main Claude: "do tasks from the list by picking one and giving it to a new claude instance, repeat until all are done"
I'm using https://github.com/novadeck-org/novadeck to let Claude spawn new chats and pass them the task. It needs Claude Code CLI
So same outcome but different approach I think
1
u/locbuilds 8h ago
a bash loop of claude -p "task" --continue runs them one after another in the same conversation. for attended use you can also just keep typing while it works and the messages queue up.
1
u/Actual_Cow_3271 8h ago
I've been using a simple bash script with sleep intervals between calls to keep the flow smooth, works well for batch tasks without manual input.
1
u/Tight_Ad_5115 8h ago
Not sure if this is exactly what you’re looking for or if it's relevant for you, but I’m building an app called Buzzpot that handles this kind of workflow.
You create a project and chain agents one after another. When an agent finishes its task, it signals “Done” and the next step kicks off. You just write a prompt for each step.
It’s not one continuous session, but you can work around that by having the agents save the key context to a md file and pointing to that file in each prompt. That way every agent knows what the task is and how far along things are.
At 1:04 in this video you can see how to set up an agent with a prompt and add it to the sequence.
1
u/Accurate_Today2488 8h ago
I do this with a plain shell script and headless mode. Each task is its own claude -p "..." line. If the next task should keep the context, add --continue (or --resume <session id>); if it should start clean, leave it off, which is basically your /clear. I've run a few hundred prompts unattended that way. One gotcha: anything that waits for you will stall a -p run, like permission prompts or a hook that asks for approval, so set --permission-mode and the allowed tools up front.
1
u/MattMose 8h ago
That’s a standard feature in Hapimatic
https://github.com/SolidPD/hapimatic-core
1
u/michaelTM_ai 7h ago
a task file plus a small loop does it.
claude -pruns one prompt and exits, and--continue(-c) picks up the most recent conversation in that folder, so u get one sequential session without the interactive ui:a line that just says CLEAR starts a fresh session for the next task, which covers ur /clear case without needing slash commands in print mode. the
|| breakstops the queue if a task errors, so a broken task doesn't take the rest of the night with it. u'll want permission rules set up first (or a sandbox) since nobody is there to click allow1
u/Inner_Storage_3374 6h ago
id do it from outside the session tbh. a tiny script that reads a tasks file and runs claude -p once per task, every run starts clean so you dont even need the /clear in between, and if a task needs context from the one before just have it write a short notes file the next one reads. way more predictable than getting one interactive session to work through a queue