SLOPSHOPPER

clear-then

Clears the session when the current turn ends, then submits a prompt you or Claude gave

guardcommandstatustooltimer
v0.2.1MITupdated 2026-10-17Orbitmap/claude-mods/mods/clear-then
A shopper browsing a rack in a slop shop
Preview · a replayed session in a sandbox
claude · ~/work/app · clear-then
› 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 › /clear-then ⎿ clear-then: Usage: /clear-then <prompt> ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── › ? for shortcuts
README

OrbitMap mods for Claude Code

Mods (Claude Code plugins built on function hooks) made by the OrbitMap team. They work in Claude Code only, on versions that support mods. The mod API is in early access, so a Claude Code update can change how a mod behaves.

Install

At the prompt of a Claude Code terminal session:

/plugin install <mod> --marketplace Orbitmap/claude-mods

Answer y to add the marketplace, then pick a scope (user scope makes the mod available in every project).

Mods

clear-then

Starts a fresh conversation once the current work is done.

  • /clear-then <prompt>: type it any time, also while Claude is working. When the running turn ends, the session is cleared (/clear) and <prompt> is submitted as the first message of the new conversation.
  • Ask Claude in your own words. Two phrasings, two behaviours:
  • "create the task, then clear the session and say: do task TS-123": Claude does the work first, then schedules the prompt with the mod's tool, filling in details it only knows at the end (like the new task number).
  • "clear the session now and work on TS-123": Claude does not start the work itself. It schedules the prompt right away, with every identifier the work needs (task or intent number, branch, decisions), and ends its turn so the fresh conversation starts immediately.

The new conversation sees nothing from the old one, so the prompt has to be self-contained. An interrupted turn keeps the prompt waiting for the next turn that ends normally.

/plugin install clear-then --marketplace Orbitmap/claude-mods

License

MIT

Source 1 files
hooks/register.ts 69 lines
1import type { EngineInterface, Register } from 'claude-code'
2
3const TOOL = 'mcp__clear-then__schedule'
4
5// The prompt to submit after the next /clear; one at a time, the latest wins.
6let pending: string | undefined
7
8function clearAndSubmit($: EngineInterface, text: string) {
9  pending = undefined
10  $.ui.status(undefined)
11  $.clock.after(50, async () => {
12    await $.command.run({ command: 'clear', args: '' })
13    await $.prompt.submit({ text, asUser: true })
14  })
15}
16
17export const register: Register = on => {
18
19  on('session.start', async ($, e, next) => {
20    await $.command.register({
21      name: 'clear-then',
22      description: 'When the current turn ends, run /clear and submit the given prompt',
23      argumentHint: '<prompt>',
24    })
25    await $.tool.register({
26      name: 'schedule',
27      description:
28        'Schedules a fresh start: when your current turn ends, the session is cleared (/clear) and `prompt` is submitted as the first message of the new conversation. The new conversation sees nothing from this one, so the prompt must be self-contained: put in it every identifier and fact the work needs (task numbers like TS-123, intent numbers like IN-45, branch names, file paths, decisions already made). Two ways the user asks for it: (1) "clear at the end" ("do X, then clear and say: Y") - do X in this turn, then call this tool and finish. (2) "clear now and start Y" ("clear the session now and work on TS-123", "start fresh and execute IN-45") - do NOT start Y yourself: call this tool with the full prompt for Y as your first action, answer with one short line, and end the turn so the clear happens immediately. Calling it again replaces the scheduled prompt; an empty prompt cancels it.',
29      inputSchema: {
30        type: 'object',
31        properties: { prompt: { type: 'string', description: 'The prompt to submit after /clear' } },
32        required: ['prompt'],
33      },
34      isDeferred: false,
35    })
36    return next(e)
37  })
38
39  // Typed by the person: a non-immediate command waits for the running turn to end,
40  // so by the time it runs the work is done and the session is idle.
41  on('command.run', { command: 'clear-then' }, async ($, e) => {
42    const text = e.args.trim()
43    if (text === '') return { text: 'Usage: /clear-then <prompt>' }
44    clearAndSubmit($, text)
45    return { text: `Clearing the session, then submitting: ${text}` }
46  })
47
48  // Called by Claude: remembered until the turn ends.
49  on('tool.call', { tool: TOOL }, async ($, e) => {
50    const text = String((e as { prompt?: unknown }).prompt ?? '').trim()
51    if (text === '') {
52      pending = undefined
53      $.ui.status(undefined)
54      return { result: 'Cancelled the scheduled clear.', text: 'Cancelled the scheduled clear.' }
55    }
56    pending = text
57    $.ui.status(`clear-then: ${text.slice(0, 60)}`)
58    const answer = `Scheduled: when this turn ends the session is cleared and this prompt is submitted: ${text}`
59    return { result: answer, text: answer }
60  })
61
62  on('turn.complete', async ($, e, next) => {
63    const done = await next(e)
64    // Main loop only, and only a turn that finished normally: an interrupt keeps it pending.
65    if (e.agentId === undefined && e.reason === 'answer' && pending !== undefined) clearAndSubmit($, pending)
66    return done
67  })
68}
69