SLOPSHOPPER

idle-compact

Compact the conversation after 50 minutes without user input

newtoastprompttimer
★ 1v0.1.0no licenseupdated 2026-10-08Tsukina-7mochi/dotfiles/config/agents/skills/idle-compact
A shopper browsing a rack in a slop shop
Source 1 files
hooks/register.ts 34 lines
1import type { Register, Timer } from 'claude-code'
2
3const IDLE_MS = 50 * 60 * 1000
4
5export const register: Register = on => {
6  let timer: Timer | undefined
7
8  const cancel = () => {
9    timer?.cancel()
10    timer = undefined
11  }
12
13  on('prompt.submit', ($, e, next) => {
14    cancel()
15    return next(e)
16  }).catch(($, e, next) => next(e))
17
18  on('turn.complete', async ($, e, next) => {
19    const result = await next(e)
20    if (e.agentId !== undefined) return result
21
22    cancel()
23    timer = $.clock.after(IDLE_MS, () => {
24      timer = undefined
25      $.session
26        .compact()
27        .then(() => $.ui.toast('idle-compact: compacted after 50 minutes idle'))
28        .catch(() => undefined)
29    })
30
31    return result
32  })
33}
34