SLOPSHOPPER

auto-continue

When the 5-hour usage limit is hit, wait for the reset and send "continue" automatically.

bandcommandtoastprompttimer
v0.1.0MITupdated 2026-10-11icedevil2001/auto-continue
A shopper browsing a rack in a slop shop
Preview · a replayed session in a sandbox
claude · ~/work/app · auto-continue
› fix the failing auth test and add an audit log call ⏺ Read(src/auth.ts) ⎿ Read 6 lines ⏺ Update(src/auth.ts) ⎿ Added 2 lines, removed 1 line ⏺ Bash(bun test) ⎿ 3 pass, 1 fail ● Done. refresh now rejects expired claims and logs an audit event. ✻ Worked for 42s · done 4:20 PM › /auto-continue ⎿ auto-continue: Auto-continue ON. [ Auto-continue: ON ] ███░░░░░░░ ⟨Claude Code's own drawing⟩ ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── › ? for shortcuts

Draws

Band
[ Auto-continue: ON ] ███░░░░░░░ ⟨Claude Code's own drawing⟩
README

auto-continue

A Claude Code mod. Part of my wider collection, claude-mods.

Hit the 5-hour limit and walk away: this mod waits for the window to reset (plus a margin) and submits "continue" so the session carries on without you.

Install

claude plugin marketplace add icedevil2001/auto-continue
claude plugin install auto-continue@auto-continue --scope user

Needs a Claude Code build with mods (tested on 2.1.286). Footprint: reads the engine's rate-limit usage, sets one timer, submits one prompt; no network, files or processes.

Use

  • A button Auto-continue: ON/OFF appears above the prompt once the 5-hour window is 25% used (or while armed), next to a bar of the window used and the time it resets.
  • Or use the slash command: /auto-continue (toggle), /auto-continue on|off|status.
  • When a turn fails on the limit while armed, a toast shows the resume time; typing your own prompt cancels the pending resume.

Options (config menu)

OptionDefault
threshold25% of the 5-hour window at which the button appears
graceMinutes5wait after the reset time before sending
messagecontinuethe prompt sent on resume

Limits

  • Only the 5-hour window is handled; the 7-day limit is ignored.
  • A limit hit is detected as an API-error turn while the 5-hour window reads >= 95% with a future reset time. If the limit error leaves the usage reading stale, the resume will not arm; see the ponytail: note in hooks/register.tsx.
  • Armed state and the pending timer live in the session; quitting Claude Code drops them.
Source 2 files
hooks/register.tsx 139 lines
1import { atom, read, update } from 'claude-code'
2import type { Register } from 'claude-code'
3
4const percent = atom({ plugin: 'auto-continue', key: 'percent' } as const, null)
5const isArmed = atom({ plugin: 'auto-continue', key: 'isArmed' } as const, false)
6const resumeAt = atom({ plugin: 'auto-continue', key: 'resumeAt' } as const, null)
7const resetsAt = atom({ plugin: 'auto-continue', key: 'resetsAt' } as const, null)
8
9const clock = (ms: number) =>
10  new Date(ms).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })
11
12const BAR = 10
13const bar = (pct: number) => {
14  const filled = Math.min(BAR, Math.max(0, Math.round((pct / 100) * BAR)))
15  return '█'.repeat(filled) + '░'.repeat(BAR - filled)
16}
17
18export const register: Register = (on, options) => {
19  const threshold = Number(options.threshold)
20  const graceMs = Number(options.graceMinutes) * 60_000
21  const message = String(options.message)
22  let timer: { cancel: () => void } | undefined
23
24  const stopTimer = () => {
25    timer?.cancel()
26    timer = undefined
27  }
28
29  on('session.start', async ($, e, next) => {
30    await $.command.register({
31      name: 'auto-continue',
32      description: 'Resume automatically after the 5-hour limit resets',
33      argumentHint: '[on|off|status]',
34      immediate: true,
35    })
36
37    return next(e)
38  })
39
40  on('command.run', { command: 'auto-continue' }, async ($, e) => {
41    const arg = e.args.trim()
42    const was = await read($, isArmed)
43    const now = arg === 'on' ? true : arg === 'off' ? false : arg === '' ? !was : was
44    if (!now) {
45      stopTimer()
46      await update($, resumeAt, () => null)
47    }
48    await update($, isArmed, () => now)
49    const at = await read($, resumeAt)
50    const wait = at ? `, resuming ~${clock(at)}` : ''
51
52    return { text: `Auto-continue ${now ? 'ON' : 'OFF'}${wait}.` }
53  })
54
55  on('session.measure', async ($, e, next) => {
56    const w = e.rateLimits.find(l => l.kind === 'five_hour')
57    await update($, percent, () => w?.percentUsed ?? null)
58    await update($, resetsAt, () => (w?.resetsAt ? Date.parse(w.resetsAt) : null))
59
60    return next(e)
61  })
62
63  on('turn.complete', async ($, e, next) => {
64    const done = await next(e)
65    if (e.reason !== 'error' || e.isAborted || !(await read($, isArmed))) {
66      return done
67    }
68
69    const { rateLimits } = await $.session.usage()
70    const w = rateLimits.find(l => l.kind === 'five_hour')
71    const reset = w?.resetsAt ? Date.parse(w.resetsAt) : NaN
72    const now = await $.clock.now()
73    // ponytail: an API error with the window >= 95% counts as the limit hit;
74    // if the error response leaves the usage stale, parse the reset time from the message instead
75    if (!w || w.percentUsed < 95 || !(reset > now)) {
76      return done
77    }
78
79    stopTimer()
80    const at = reset + graceMs
81    await update($, resumeAt, () => at)
82    $.ui.toast(`Limit reached. Resuming at ${clock(at)}.`)
83    timer = $.clock.after(at - now, () => {
84      timer = undefined
85      void update($, resumeAt, () => null)
86      void $.prompt.submit({ text: message })
87    })
88
89    return done
90  })
91
92  // the person typing takes over from a pending resume
93  on('prompt.submit', async ($, e, next) => {
94    if (timer && e.origin.kind !== 'plugin') {
95      stopTimer()
96      await update($, resumeAt, () => null)
97    }
98
99    return next(e)
100  })
101
102  on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
103    const pct = await read($, percent)
104    const armed = await read($, isArmed)
105    const at = await read($, resumeAt)
106    const reset = await read($, resetsAt)
107    const isQuiet = e.props.hasSurvey || (!armed && (pct === null || pct < threshold))
108    if (isQuiet) {
109      return next(e)
110    }
111
112    const { Box, Button, Text } = $.ui.resolve(e)
113    const below = await next(e)
114
115    return (
116      <Box flexDirection="column">
117        <Box>
118          <Button
119            key="toggle"
120            label={`Auto-continue: ${armed ? 'ON' : 'OFF'}`}
121            onPress={async () => {
122              if (armed) {
123                stopTimer()
124                await update($, resumeAt, () => null)
125              }
126              await update($, isArmed, () => !armed)
127            }}
128          />
129          <Text dimColor>
130            {` ${bar(pct ?? 0)}`}
131            {at ? ` resumes ~${clock(at)}` : reset ? ` resets ${clock(reset)}` : ''}
132          </Text>
133        </Box>
134        {below}
135      </Box>
136    )
137  })
138}
139
types/index.d.ts 13 lines
1export type Timestamp = number | null
2
3declare module 'claude-code' {
4  interface PluginState {
5    'auto-continue': {
6      percent: number | null
7      isArmed: boolean
8      resumeAt: Timestamp
9      resetsAt: Timestamp
10    }
11  }
12}
13