ModsCode / Claude Code Mods / Ranking / graceful-stop
graceful-stop
Winds agents down cleanly as the session's credit runs out and has the orchestrator write a resume memo.
What it does
- Draws a band above the prompt, toasts
- Watches tool calls and can refuse them
- Hooks agent.spawn, config.describe, session.measure, session.start and 3 more
- Keeps its own state between turns
- Calls the network
Good points
- Starts no processes
- Written in TypeScript
- Has a desktop-specific branch
- Handles errors
Code to start from
A starter ModsCode writes from the drawing it read, and the mod's own lines that draw, where there are any.
Starter (register.tsx)
import type { Register } from 'claude-code'
// Drawn like graceful-stop by Renaud Couttet (band, toast), as ModsCode read it from the mod's code:
// https://modscode.com/claude-mods/mods/rctt27-graceful-stop/
// Written by ModsCode from that reading, not copied from the mod: use it as you like.
// Each value below stands for one the mod works out at run time; put in your own.
export const register: Register = on => {
// the band above the prompt; what else goes there is drawn under it
on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
const { Box, Text, Button } = $.ui.resolve(e)
const badgeText = '…'
const phaseDetail = '…'
const notice = '…'
const name = '…'
const text = '…'
const text2 = '…'
const text3 = '…'
const percent = '…'
const tail = '…'
const name2 = '…'
const text4 = '…'
const text5 = '…'
const text6 = '…'
const percent2 = '…'
const tail2 = '…'
const name3 = '…'
const text7 = '…'
const text8 = '…'
const text9 = '…'
const percent3 = '…'
const tail3 = '…'
const memoPath = '…'
return (
<Box flexDirection="column" borderStyle="round" borderColor="#71717a" paddingX={1}>
<Box flexDirection="row" justifyContent="space-between" gap={2}>
<Box flexDirection="row" flexShrink={1}>
<Box width={3} flexShrink={0}>
<Text color="yellow" bold>
⏹
</Text>
</Box>
<Box flexShrink={0}>
<Text color="yellow" bold>
graceful-stop
</Text>
</Box>
<Text bold>
{badgeText}
</Text>
<Text dimColor wrap="truncate">
{` ${phaseDetail}`}
</Text>
</Box>
<Box flexDirection="row" flexShrink={0} gap={1}>
<Button hotkey="o">
On
</Button>
<Button hotkey="r" variant="primary">
Resume
</Button>
</Box>
</Box>
<Text wrap="wrap">
{`› ${notice}`}
</Text>
<Box height={1} />
<Box flexDirection="row">
<Box width={3} flexShrink={0} />
<Box flexShrink={0} justifyContent="flex-end">
<Text bold>
{name}
</Text>
</Box>
<Box flexShrink={0} />
<Text>
{text}
</Text>
<Text>
{text2}
</Text>
<Text>
{text3}
</Text>
<Text bold>
{percent}
</Text>
<Text dimColor wrap="truncate">
{tail}
</Text>
</Box>
<Box flexDirection="row">
<Box width={3} flexShrink={0} />
<Box flexShrink={0} justifyContent="flex-end">
<Text bold>
{name2}
</Text>
</Box>
<Box flexShrink={0} />
<Text>
{text4}
</Text>
<Text>
{text5}
</Text>
<Text>
{text6}
</Text>
<Text bold>
{percent2}
</Text>
<Text dimColor wrap="truncate">
{tail2}
</Text>
</Box>
<Box flexDirection="row">
<Box width={3} flexShrink={0} />
<Box flexShrink={0} justifyContent="flex-end">
<Text bold>
{name3}
</Text>
</Box>
<Box flexShrink={0} />
<Text>
{text7}
</Text>
<Text>
{text8}
</Text>
<Text>
{text9}
</Text>
<Text bold>
{percent3}
</Text>
<Text dimColor wrap="truncate">
{tail3}
</Text>
</Box>
<Text dimColor wrap="truncate">
No credit reading yet: it comes with the first answer.
</Text>
<Text dimColor wrap="truncate">
Last reading from an earlier session: it refreshes with the first answer.
</Text>
<Text dimColor wrap="truncate">
{`Memo ${memoPath}`}
</Text>
{await next(e)}
</Box>
)
})
on('session.start', async ($, e, next) => {
const drop = '…'
const trigger = '…'
const resumeHint = '…'
await $.ui.toast(`graceful-stop: the resume prompt did not go through (${drop}).`)
await $.ui.toast(`graceful-stop: ${trigger}, nothing running. No more requests will leave. ${resumeHint}`)
return next(e)
})
}
The mod's own code
Shown under the mod's licence (MIT); its text is below. Keep the notice if you copy these lines.
hooks/register.tsx lines 1236–1240 · Band
on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
if (e.props.hasSurvey) return next(e)
return drawPanel($, cfg, e, { columns: e.props.bodyColumns, isWorking: e.props.isWorking, notice: null })
})hooks/register.tsx lines 929–1010 · Band
async function drawPanel($: Engine, cfg: Config, e: ResolveInput, o: PanelOptions) {
const s = await read($, status)
await read($, minute)
const { reading, isKept } = await readCredit($)
const now = await $.clock.now()
const back = backOf(cfg, reading?.windows ?? [], now)
const canResume = !isWatching(s) && !o.isWorking && back === null
const gauges = gaugesOf(cfg, reading?.windows ?? [], o.columns, now)
const badge = BADGES[s.phase]
const ui = $.ui.resolve(e)
const { Box, Button, Text } = ui
// Raster paints each cell's colors: the terminal's alone (another surface's
// table may hold it as a fragment that draws nothing).
const Raster = e.surface === 'terminal' && 'Raster' in ui ? ui.Raster : null
return (
<Box flexDirection="column" borderStyle="round" borderColor={CARD_BORDER} paddingX={1}>
<Box flexDirection="row" justifyContent="space-between" gap={2}>
<Box flexDirection="row" flexShrink={1}>
<Box width={ICON_CELLS} flexShrink={0}>
<Text color={MOD_COLOR} bold>⏹</Text>
</Box>
<Box width={LEFT_CELLS - ICON_CELLS} flexShrink={0}>
<Text color={MOD_COLOR} bold>{NAME}</Text>
</Box>
<Text color={badge.fg} backgroundColor={badge.bg} bold>{badgeText(s.phase)}</Text>
<Text dimColor wrap="truncate">{` ${phaseDetail(cfg, s, isHalted(s) ? back : null)}`}</Text>
</Box>
<Box flexDirection="row" flexShrink={0} gap={1}>
<Button key="toggle" hotkey="o" onPress={() => toggle($)}>
{s.phase === 'off' ? 'On' : 'Off'}
</Button>
<Button
key="resume"
hotkey="r"
variant={canResume ? 'primary' : 'secondary'}
dimColor={!canResume}
onPress={() => pressResume($, cfg, o.isWorking)}
>
Resume
</Button>
</Box>
</Box>
{o.notice !== null && (
<Text key="notice" wrap="wrap">{`› ${o.notice}`}</Text>
)}
<Box height={1} />
{gauges.map(g => (
<Box key={`gauge-${g.name.trim()}`} flexDirection="row">
<Box width={ICON_CELLS} flexShrink={0} />
<Box width={NAME_CELLS} flexShrink={0} justifyContent="flex-end">
<Text bold>{g.name}</Text>
</Box>
<Box width={LEFT_CELLS - ICON_CELLS - NAME_CELLS} flexShrink={0} />
{Raster !== null ? (
<Raster key={`bar-${g.name.trim()}`} columns={g.cells.length} rows={1} cells={rasterCells(g.cells)} />
) : (
textRuns(g.cells).map((r, i) => (
<Text key={`run-${i}`} color={hex(r.fg)} backgroundColor={r.bg === DEFAULT_BG ? undefined : hex(r.bg)}>
{r.text}
</Text>
))
)}
<Text color={g.color} bold>{g.percent}</Text>
<Text dimColor wrap="truncate">{g.tail}</Text>
</Box>
))}
{reading === null && (
<Text dimColor wrap="truncate">No credit reading yet: it comes with the first answer.</Text>
)}
{isKept && reading !== null && (
<Text dimColor wrap="truncate">
{`Last reading ${Number.isNaN(reading.at) ? 'from an earlier session' : `at ${clockOf(reading.at, now)}`}: it refreshes with the first answer.`}
</Text>
)}
{s.memoPath !== null && s.phase !== 'armed' && s.phase !== 'off' && (
<Text dimColor wrap="truncate">{`Memo ${s.memoPath}`}</Text>
)}
</Box>
)
}Licence text (MIT)
MIT License Copyright (c) 2026 Renaud Couttet Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
How to build this: Band above the prompt, Deny a tool call
What its code calls
networkwrites filesdrives Claudetool callsremembers
What its code shows
Read from the source at commit 2957efa7178c on 2026-10-11. The first group decides whether a mod is listed; the rest is for you to weigh. A later commit is not read until the next crawl.
| Decides the listing: code you can check | |
|---|---|
| Entry read | Every module hooks/hooks.json names was read.hooks/register.tsx |
| Parses | Every file parses as TypeScript or JavaScript.1 files parsed |
| All its code is in the mod | Every import is a file of the mod or the engine's own module; no packages, no require.all its code is in the mod |
| Readable | No minified lines, no eval or new Function, no import of a computed path, no encoded blobs.no minified code, no eval, no encoded blobs |
| Calls in the open | Network and programs are reached as $.http.fetch and $.process.run in place, never passed around.every call outside goes through $ in the open |
| For you to weigh before installing | |
| Where it draws | The terminal, the desktop app, both, or nothing (hooks only: a guard or a prompt rewriter), as its code says. Shown, never a reason to leave a mod out.draws in the terminal and the desktop app, the same in both |
| Install line | Whether its repository's own .claude-plugin/marketplace.json lists it, so it installs from that marketplace with the lines on its page.listed in its repository's .claude-plugin/marketplace.json: installs from there |
| Programs on Windows | Whether every program it starts through $.process exists on Windows (tail, date, open, osascript, /usr/… do not).runs no program a Windows PC lacks |
| Network | Whether every fetch names its https host in the code.no network |
| Programs | Whether every program it starts is named in the code and is not a shell, an interpreter or a network tool.starts no programs |
| Reads and sends | Whether it both reads something of yours (files, environment variables, the transcript, settings) and reaches outside (the network, an MCP server, another session, telemetry).reads files and reaches another session |
| Keys in the source | Whether the source holds what looks like an API key or a private key.no keys in the source |
| Licence | An open licence (MIT, Apache-2.0, BSD, ISC, Unlicense, 0BSD, CC0) with its text lets ModsCode show its code; otherwise the code is linked.MIT |
| Settings hooks | Hooks declared in hooks/hooks.json or plugin.json beside the module: a command (a shell when it has no args), an HTTP request, an MCP tool or a model prompt at an event. They run outside $.no settings hooks: its function hooks alone |
| Servers it ships | MCP servers (a program, or a URL; a headersHelper is a shell command; a .mcpb bundle is unpacked at run time), LSP servers, monitors (a shell command for the whole session) and bin/ (on the PATH of the Bash tool).ships no MCP or LSP server, no monitor, no bin/ |
| Skills, commands, agents | What its Markdown declares beyond text: allowed-tools granted for the turn, hooks added when a skill is invoked, a command run before Claude reads the skill.no skills, commands, agents or workflows |
| Tools and MCP | Whether every tool it calls through $.tool.call and $.mcp.call is named in the code, and none is a shell (Bash through the tool runs a shell without $.process).calls no tool, MCP server or command |
| Asks of the model | Completions it runs ($.model.complete, fork, classify), subagents it spawns, prompts it submits as you, and the tools, commands and agents it adds.prompt.submit (as the person), adds command ? |
| Events it hooks | By what a hook there can do: gates (refuse a tool call, a prompt, a setting, another plugin), shapes (what the model reads: the system prompt, tool descriptions, each request), reads (your input, the events of the settings hooks, every event with *), and the rest.gates: tool.call, command.run · shapes: turn.step · also: session.start, config.describe, session.measure, turn.start (+3) · timers: clock.after, clock.every |
| Reads, by name | The environment variables and files it names, and whether it reads the transcript, settings.json, the prompt box or the mouse selection.files: a path computed at run time |
| Writes, by name | The files and environment variables it names, and whether it changes settings, the prompt box, the clipboard, the conversation (a row the model reads) or another session.files: a path computed at run time; the conversation (a row the model reads); another session |
This is a reading of the code text, not a security review: it does not run the mod, and it cannot see what a program the mod starts does. The check before installing is yours. How mods are chosen
Install it
Check it yourself before you install it. Mods run unsandboxed, with your permissions, and ModsCode does not vouch for what this code does. Read its code (or run claude plugin validate . in its folder), weigh what it reaches, and install the commit you read.
From its marketplace
Its repository is its marketplace. Add that marketplace (in the terminal with these commands, or in the desktop app's plugin settings) and install the mod from it:
/plugin marketplace add Rctt27/clean-end-of-session/plugin install graceful-stop@graceful-stop/reload-pluginsThis installs the marketplace's latest commit, which may not be the one read here (2957efa7178c). Compare them before you install. /reload-plugins loads it into a session that is already open.
Try the commit ModsCode read
No marketplace needed. In a terminal, clone the repository, check out the commit read, validate the mod, and load it for one session:
git clone https://github.com/Rctt27/clean-end-of-sessiongit -C clean-end-of-session checkout 2957efa7178ccd108a06cd540891d8785700f433claude plugin validate clean-end-of-sessionclaude --plugin-dir clean-end-of-sessionThe validate line lists the events the mod hooks and what it asks Claude Code to do, without running it. The last line loads the mod for this session only and writes nothing to your settings. If the author has rewritten history, the commit may no longer exist.
Ask Claude about it
With the ModsCode connector added, Claude can read this mod's code and what it reaches, and build on them. Ask it like this:
Read the ModsCode mod "rctt27-graceful-stop" with its code and make me one like itSearch them from Claude: the MCP connector
Similar mods
- code-modernizationAnthropic★ 37,653
- next-stepsThariq Shihipar★ 4,505
- token-optimizerAlex Greenshpun★ 2,534
- reflect-modBayram Annakov★ 1,703
- crit-tuiTomasz Tomczyk★ 1,196
- ai-maestro-secrets23blocks-OS★ 817
Badge for your README
If this is your mod, paste this into your README. It links to this page.
[](https://modscode.com/claude-mods/mods/rctt27-graceful-stop/)