Files
bmad-autonomous-development/skills/bad/references/coordinator/pattern-timer.md
stephenleo 494a7390f9 refactor(bad): reorganize references into coordinator/ and subagents/ subdirs
Rename reference files into semantic subdirectories:
- coordinator/: gate-pre-continuation, pattern-monitor, pattern-notify, pattern-timer
- subagents/: phase0-graph, phase0-prompt, phase3-merge

Extract Phase 0 subagent prompt into phase0-prompt.md; SKILL.md now
delegates to it with a single-line read instruction. Update all internal
cross-references to reflect new paths.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-11 13:26:40 +08:00

3.2 KiB

Timer Pattern

Both the retrospective and post-batch wait timers use this pattern. The caller supplies the duration, fire prompt, option labels, and actions.

Behaviour depends on TIMER_SUPPORT:


If TIMER_SUPPORT=true (native platform timers)

Step 1 — compute target cron expression (convert seconds to minutes: SECONDS ÷ 60):

# macOS
date -v +{N}M '+%M %H %d %m *'
# Linux
date -d '+{N} minutes' '+%M %H %d %m *'

Save as CRON_EXPR. Save TIMER_START=$(date +%s).

Step 2 — create the one-shot timer via CronCreate:

  • cron: expression from Step 1
  • recurring: false
  • prompt: the caller-supplied fire prompt

Save the returned job ID as JOB_ID.

Step 3 — print the options menu (always [C], [S], [M]; include [X] only if the caller supplied an [X] label):

Timer running (job: {JOB_ID}). I'll act in {N} minutes.

  • [C] Continue — {C label}
  • [S] Stop — {S label}
  • [X] Exit — {X label} ← omit this line if no [X] label was supplied
  • [M] {N} Modify timer to {N} minutes — shorten or extend the countdown

📣 Notify (see references/coordinator/pattern-notify.md) with the same options so the user can respond from their device:

⏱ Timer set — {N} minutes (job: {JOB_ID})

[C] {C label}
[S] {S label}
[X] {X label}   ← omit if no [X] label supplied
[M] <minutes> — modify countdown

Wait for whichever arrives first — user reply or fired prompt. On any human reply, print elapsed time first:

ELAPSED=$(( $(date +%s) - TIMER_START ))
echo "⏱ Time elapsed: $((ELAPSED / 60))m $((ELAPSED % 60))s"
  • [C]CronDelete(JOB_ID), run the [C] action
  • [S]CronDelete(JOB_ID), run the [S] action
  • [X]CronDelete(JOB_ID), run the [X] action ← only if [X] label was supplied
  • [M] NCronDelete(JOB_ID), recompute cron for N minutes from now, CronCreate again with same fire prompt, update JOB_ID and TIMER_START, print updated countdown, then 📣 Notify:
    ⏱ Timer updated — {N} minutes (job: {JOB_ID})
    
    [C] {C label}
    [S] {S label}
    [X] {X label}   ← omit if no [X] label supplied
    [M] <minutes> — modify countdown
    
  • FIRED (no prior reply) → run the [C] action automatically

If TIMER_SUPPORT=false (prompt-based continuation)

Save TIMER_START=$(date +%s). No native timer is created — print the options menu immediately and wait for user reply:

Waiting {N} minutes before continuing. Reply when ready.

  • [C] Continue — {C label}
  • [S] Stop — {S label}
  • [X] Exit — {X label} ← omit this line if no [X] label was supplied
  • [M] N — remind me after N minutes (reply with [M] <minutes>)

📣 Notify (see references/coordinator/pattern-notify.md) with the same options.

On any human reply, print elapsed time first:

ELAPSED=$(( $(date +%s) - TIMER_START ))
echo "⏱ Time elapsed: $((ELAPSED / 60))m $((ELAPSED % 60))s"
  • [C] → run the [C] action
  • [S] → run the [S] action
  • [X] → run the [X] action ← only if [X] label was supplied
  • [M] N → update TIMER_START, print updated wait message, 📣 Notify, and wait again