mcpField
D
delayed-command

delayed-command

github.com/paulrbergDevelopment102135 installsUpdated today
Repository

About delayed-command

delayed-command is a skill for running a Bash command after a specified wait. It supports combined hour, minute, and second durations, running shorter waits synchronously and longer ones in the background.

Key features

  1. 01Parses hour, minute, and second durations
  2. 02Runs commands after the requested delay
  3. 03Uses synchronous execution for waits up to 10 minutes
  4. 04Runs longer waits in the background
  5. 05Reports output, exit status, and elapsed time

Use cases

  1. 01Running a command after a short wait
  2. 02Scheduling a shell task to run later in the background
  3. 03Delaying a deployment or commit command

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/paulrberg/agent-skills --skill delayed-command

After installing, type/delayed-commandin Claude Code to confirm it loaded.

Details

From the project README

Delayed Command Execution

Wait for a specified duration, then execute a Bash command.

Arguments

  • duration: Time to wait before execution (e.g., 30s, 5m, 1h, 1h30m)
  • command: The Bash command to run after the delay

Duration Format

FormatExampleMeaning
Xs30s30 seconds
Xm5m5 minutes
Xh1h1 hour
XhYm1h30m1 hour 30 minutes
XhYmZs1h5m30s1 hour 5 min 30 s

Workflow

1. Parse Duration

Convert the duration argument to seconds:

  • Extract hours (h), minutes (m), and seconds (s) components
  • Calculate total seconds: hours * 3600 + minutes * 60 + seconds

Parsing logic:

duration="$1"
seconds=0

# Extract hours
if [[ $duration =~ ([0-9]+)h ]]; then
  seconds=$((seconds + ${BASH_REMATCH[1]} * 3600))
fi

# Extract minutes
if [[ $duration =~ ([0-9]+)m ]]; then
  seconds=$((seconds + ${BASH_REMATCH[1]} * 60))
fi

# Extract seconds
if [[ $duration =~ ([0-9]+)s ]]; then
  seconds=$((seconds + ${BASH_REMATCH[1]}))
fi
2. Execute with Delay

For durations up to 10 minutes (600 seconds):

Run synchronously using the Bash tool with appropriate timeout:

sleep <seconds> && <command>

Set the Bash tool's timeout parameter to at least (seconds + 60) * 1000 milliseconds.

For durations over 10 minutes:

Run in background using run_in_background: true:

sleep <seconds> && <command>

Inform the user the command is running in background and provide the task ID for checking status.

3. Report Result

After execution completes:

  • Display command output
  • Report exit status
  • Note total elapsed time

Examples

Short Delay (Synchronous)

User: /delayed-command 5m npm test

  1. Parse: 5 minutes = 300 seconds
  2. Execute: sleep 300 && npm test (timeout: 360000ms)
  3. Report test results
Long Delay (Background)

User: /delayed-command 1h git commit -m "auto-commit"

  1. Parse: 1 hour = 3600 seconds
  2. Execute in background: sleep 3600 && git commit -m "auto-commit"
  3. Return task ID for status checking
Combined Duration

User: /delayed-command 1h30m ./deploy.sh

  1. Parse: 1h30m = 5400 seconds
  2. Execute in background (>600s): sleep 5400 && ./deploy.sh
  3. Inform user of background task

Error Handling

ErrorResponse
Invalid duration formatShow supported formats and examples
Missing command argumentPrompt for the command to execute
Command not foundReport error after delay completes
Duration exceeds 24hWarn user and suggest alternative (cron, at)

Comments

Markdown supported