claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

[FEATURE] Add /wait Command for Scheduled Execution

Open gianlucamazza opened this issue 5 months ago • 4 comments

Preflight Checklist

  • [x] I have searched existing requests and this feature hasn't been requested yet
  • [x] This is a single feature request (not multiple features)

Problem Statement

Summary

Add a /wait command that pauses execution until a given time. Example:

/wait 16:00 <context to be executed>

This would ensure <context to be executed> only executes once the clock reaches 16:00.

Motivation

  • Useful when session tokens/credits refresh at fixed times.
  • Avoids manual re-running of commands.
  • Keeps automation inside Claude Code without relying on cron or external schedulers.

Proposed Behavior

  • Support both absolute times (HH:MM) and relative delays (+Xm).
  • Queue subsequent commands until the timer completes.

Benefits

  • Improves developer productivity.
  • Enables smoother workflows tied to token/session resets.
  • Lightweight enhancement with clear UX.

Proposed Solution

Proposed Solution

  1. Command Parsing

    • Extend the command parser to recognize the new /wait directive.

    • Syntax:

      • /wait HH:MM → absolute target time.
      • /wait +Xm → relative delay in minutes.
  2. Command Queueing

    • When /wait is invoked, subsequent commands are not executed immediately.
    • Instead, they are stored in an in-memory queue until the timer resolves.
  3. Scheduler / Event Loop

    • A lightweight scheduler monitors the system clock.
    • Once the specified time or delay is reached, the queue is flushed in order.
  4. Edge Case Handling

    • Past time: automatically schedule for the next day.
    • Session ends before timer: queued commands are discarded with a clear message.
    • Cancelation: /cancel aborts any active wait and clears the queue.
  5. User Feedback

    • On invoking /wait continue with our analysis and fixes, show confirmation:

      Waiting until 16:00… queued 2 commands
      
    • On resume:

      Timer complete — resuming queued commands
      
  6. Scope

    • No persistence beyond the current Claude Code session.
    • Future enhancement: allow persistence across restarts if requested by users.

Alternative Solutions

No response

Priority

Low - Nice to have

Feature Category

Interactive mode (TUI)

Use Case Example

No response

Additional Context

Scenario: Token Reset at 16:00

A developer knows that their Claude session tokens will reset at 16:00. They want to queue a script to run immediately after the reset without manual intervention.

# Queue a wait until 16:00
/wait 16:00 continue with our analysis and fixes

# Next command is held until timer completion
/run refresh-tokens.sh

Output:

[Claude Code] Waiting until 16:00… queued 1 command

At 16:00, execution resumes automatically:

[Claude Code] Timer complete — resuming queued commands
→ Running: refresh-tokens.sh

Scenario: Relative Delay for Git Operations

A developer is working on a deployment pipeline and wants to delay a push by 30 minutes (to align with a scheduled maintenance window).

/wait +30m push origin main

Output:

[Claude Code] Waiting 30 minutes… queued 1 command

After 30 minutes:

[Claude Code] Timer complete — resuming queued commands
→ Running: git push origin main

gianlucamazza avatar Sep 06 '25 13:09 gianlucamazza

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/2794
  2. https://github.com/anthropics/claude-code/issues/6147
  3. https://github.com/anthropics/claude-code/issues/2567

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

github-actions[bot] avatar Sep 06 '25 13:09 github-actions[bot]

Hey, this is a really interesting idea! I've definitely had moments where I wanted to pause and resume based on a schedule, especially for long-running automated tasks. I like how it keeps the scheduling logic inside the Claude session itself.

While we wait to see if the team implements something like this, I've found a workaround that uses Claude Code's headless mode combined with a standard Unix utility. It might work for your use case.

The official docs on Common Workflows mention using Claude as a "unix-style utility" with the -p (print/headless) and -c (continue) flags. You can combine this with the at command (which is like cron but for one-off jobs) to achieve scheduled execution.

For your "Token Reset" scenario, you could do this:

# This tells the 'at' scheduler to run the claude command at 4:00 PM today.
# -c continues the most recent conversation.
# -p runs it non-interactively and passes in your prompt.
echo 'claude -c -p "continue with our analysis and fixes"' | at 16:00

And for your "Relative Delay" scenario:

# This schedules the command to run 30 minutes from now.
echo 'claude -c -p "push origin main"' | at now + 30 minutes

Pros of this method:

  • It works today with existing features.
  • It's very reliable since it uses the system scheduler. The command will run even if you close your terminal.

Cons:

  • It's not as nicely integrated as your /wait proposal.
  • The at command might not be installed on all systems by default (though it's common on macOS and Linux).

Your proposal is definitely cleaner because it's all self-contained within the Claude Code session. I especially like the idea of it queuing commands, which would be much more intuitive than scheduling external processes.

Just wanted to share in case it's helpful in the meantime! Great suggestion.

coygeek avatar Sep 06 '25 18:09 coygeek

I've love the ability to queue the next prompt once I hit my token usage limit.

AJ-Acevedo avatar Oct 28 '25 05:10 AJ-Acevedo

This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.

github-actions[bot] avatar Dec 08 '25 10:12 github-actions[bot]

Another use case: coordinating between parallel Claude instances.

When running multiple Claude Code sessions simultaneously, one instance may need to wait for another to complete before starting. For example:

  • Instance A is running a long build/test cycle
  • Instance B needs to work on the same codebase after A finishes

Currently this requires manual intervention or external tooling. A /wait +5m command would let you queue up work in Instance B to start after an estimated completion time for Instance A.

This becomes especially useful with background agents or when orchestrating multi-step workflows across sessions.

PaulRBerg avatar Dec 17 '25 16:12 PaulRBerg