Skip to content
Back to skills

Clean Stop

ASecurity

Clean stop before the machine goes away: sweep every repo and worktree touched for uncommitted, unpushed or PR-less work, push it, and give a free-and-clear verdict. Use when: 'clean stop', 'safe to shut down', or stopping for the day. Gates destructive cleanup.

  • 34 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 2, 2026
ai-agentsgogitapidocumentation

Works with

  • terminal
  • api

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned December 3, 2026

npx -y skills add melodic-software/claude-code-plugins --skill clean-stop --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Clean Stop?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Clean Stop
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/melodic-software-clean-stop/badge)](https://www.skillsdirectory.com/skills/melodic-software-clean-stop)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
description: "Clean stop before the machine goes away: sweep every repo and worktree touched for uncommitted, unpushed or PR-less work, push it, and give a free-and-clear verdict. Use when: 'clean stop', 'safe to shut down', or stopping for the day. Gates destructive cleanup."
argument-hint: "[--unattended]"
user-invocable: true
disable-model-invocation: false
metadata:
  workflow-stage: session
  summary: Make everything durable before the machine goes away
---

# Clean stop

## Purpose

Before a machine may disappear (end of day, a reclaimed spot instance, a torn-down
container, walking away), sweep everything touched this session to a durable,
linked resting state and report whether it is genuinely safe to shut down.

`/session-flow:keep-going` recovers a session after an interruption; clean-stop
makes the interruption safe beforehand. It supersedes a local
`/session-flow:handoff` when the machine itself may go away: a handoff file dies
with the disk, so clean-stop leaves the resumable state in the PR and issue
bodies on the remote.

## Arguments

`--unattended` is the only argument: the caller declares that nobody is present. It only gates the
`/export` step (dropped: an unattended run neither suggests nor runs a user-only built-in); remote artifacts are always created
without prompting, as step 3 states. Take it out wherever it appears; other text is context for the
sweep. The bare word `unattended` is not this flag: stop and name `--unattended`.

## Steps

1. **Inspect first, never assume.** Enumerate every repository and worktree
   this session touched and read its real state: uncommitted changes,
   stashes, unpushed commits, branches without a PR, which PRs/issues already
   carry the resumable context, and any ignored, machine-local state that is
   not reproducible, a generated handoff, local config, hand-made
   credentials, which `git status` hides but which dies with the disk just
   the same. Act only on the gaps. Running
   clean-stop when a branch is already pushed and its PR already describes the
   work must not re-push, open a duplicate PR, or re-file issues. The sweep
   converges on what is missing, not on redoing what is done.
2. **Durability sweep.** Make the gaps durable. Push unpushed commits; for
   coherently committable work, including a clean, coherent stash, commit
   it with a real message and push. What is not coherently committable,
   ambiguous work-in-progress, a half-edit, a stash that will not cleanly
   apply, is not force-committed and not silently dropped: surface it in the
   verdict as an explicit "not durable, do X before shutdown" item. A bad
   commit and a lost stash are both worse than a named dangling item. Ignored,
   machine-local state that must not go to the remote, secrets, credentials,
   deliberately-ignored files, is never pushed; when it is not reproducible,
   surface it as a "preserve off the machine before shutdown" item so it is
   not silently lost with the disk.
   The conversation itself is another machine-local, non-durable item:
   transcripts live only in this machine's `~/.claude` tree and are
   retention-swept besides (pointer:
   [All settings § cleanupPeriodDays](https://code.claude.com/docs/en/settings-reference#cleanupperioddays)).
   When the session is worth keeping:
   **Native suggestions** are on unless `native_suggestions` resolves `off`: the team `docs/conventions/session-flow.yaml` value wins over the per-user value `${user_config.native_suggestions}` (a literal unexpanded token means unset); with none set they are on. A value other than `on` or `off` is named and that layer dropped: a valid higher layer still wins, otherwise `on`, never a lower layer's value. When off, skip the sentence below and write nothing in its place, not even a note that it was skipped or why.
   If /export is available in your session (gate basis: **Verification record: `/export`** below) and native suggestions are on (`native_suggestions`, [Configuration](../../README.md#configuration)), suggest that the person run it for a durable conversation copy at `<memory_dir>/exports/<YYYYMMDDTHHMMSSZ>-<topic>.txt` after verifying the memory root's self-ignore guard (a `.gitignore` containing `*`; create it and announce it when absent). This skill never invokes `/export` itself. **`--unattended`:** make no suggestion and write `Withheld suggestion (unattended): /export` in the output.
   That destination is machine-local, so when the machine may go away, also
   surface copying the export off the machine as a "preserve off the machine" item.
3. **Linkage + breadcrumbs (redact before any remote write).** Before a PR
   or issue body is created or updated, sweep everything outbound: remaining
   tasks, dependencies, resume context, any pasted terminal output or diffs,
   for secrets, API keys, tokens, credentials, connection strings, and PII,
   and replace each hit with a shape marker (`<REDACTED: API key>`), never the
   value. This scrub is a hard gate: the breadcrumbs land on a remote shared
   with others and pass no human review first, so nothing outbound is written
   before it runs. Then link the work: every pushed *non-default* branch gets
   a PR. A branch that is the repo's default (`main` / `master` / `trunk`, or
   whatever `git symbolic-ref refs/remotes/origin/HEAD` resolves to) carries
   no PR and needs none once pushed. Every follow-up gets filed as an issue
   linked to that PR; dependencies, remaining tasks, and the context needed to
   continue live in the PR and issue bodies, never only in a local file. The
   acceptance bar is a cold agent: someone who finds the PR or issue with no
   memory of this session should have everything needed to offer to continue.
   Every remote artifact is created unattended, so the issue-linkage decision
   is made up front, never left for an interactive prompt: use the closing
   keyword when the branch or context names an issue, otherwise an explicit
   no-linkage reason. For an orphan branch, a hotfix, refactor, or drift
   sweep with no issue in its name, open the PR with the forge's own tooling,
   passing that no-linkage reason, the title, and the body non-interactively:
   the guaranteed non-interactive path. Route through
   `/source-control:pull-request create` (if enabled) or a
   work-item capability only when it can run unattended with that decision
   passed in; if it would stop to ask, use `git` and the forge's own tooling
   carrying the same decision instead.
4. **Local hygiene.** Prune only what is provably safe: branches whose work is
   fully merged, worktrees with no uncommitted or stashed state and no
   irreplaceable ignored files, background work that has genuinely finished.
   Before removing a worktree, inspect its ignored content explicitly
   (`git status --ignored`) and preserve or surface anything not
   reproducible: a local `.env`, credentials, generated handoff data, or files
   a bootstrap copied in. When checking what plain `git status` lists and
   what `git worktree remove` refuses or deletes, read
   [git-status `--ignored`](https://git-scm.com/docs/git-status#Documentation/git-status.txt---ignoredmode)
   and [git-worktree `remove`](https://git-scm.com/docs/git-worktree#Documentation/git-worktree.txt-remove)
   live. A worktree `git worktree list --porcelain` reports `locked` is
   another session's claim unless the lock reason names this session; leave
   it alone. Anything still holding unmerged commits, dirty state,
   irreplaceable ignored files, a running job, or another session's lock is
   not pruned. It becomes a
   named item in the verdict.
5. **Free-and-clear verdict.** Lead the report with one of two honest
   outcomes: "clean to shut down, everything durable and linked", or a named
   list of the dangling items that still need a hand, each with the one
   action that would clear it; what was pushed, opened, and filed follows.
   Never report clean while step 2 or 4 left something surfaced.

## Autonomy policy. Make durable freely, gate destructive cleanup

- **Make durable without asking.** Pushing a commit, opening a PR for a
  pushed branch, and filing a linked follow-up issue are loss-prevention with
  low blast radius and are the whole point of the invocation: do them once
  the step 3 redaction gate has scrubbed anything outbound. Idempotency comes
  from step 1: act on gaps, never re-fire what already landed.
- **Gate destructive hygiene.** Deleting a branch, removing a worktree, or any
  force operation is irreversible. Do it only when step 1 proved it safe
  (fully merged, no uncommitted or stashed state, and, for a worktree, no
  irreplaceable ignored files a plain status hides). When safety cannot be
  proven, do not prune; name the item in the verdict instead. Losing unmerged
  work, or the only copy of an ignored `.env`, to a tidy-up is the exact
  failure this skill exists to prevent.

## Nothing-dirty case

If the sweep finds everything already durable and linked, nothing
uncommitted, nothing unpushed, every non-default branch that carries session
work has a PR (work committed straight to the default branch is durable once
pushed and needs none), nothing strandable left only on local disk, including
non-reproducible ignored state a plain status hides, say so and give the
free-and-clear verdict directly. A clean session is a valid, common outcome;
do not manufacture work to look thorough.

## Verification record: `/export`

- **Our decision.** This skill suggests `/export` to the person and never runs it: we treat it as an interactive built-in the Skill tool cannot invoke and a headless run cannot reach, and a command that is not available to the person is left out of the menu.
- **Probe record**: the `export` → `session-flow:clean-stop` entry of `docs/native-surfaces.md` in this plugin's marketplace repository holds the headless refusal, the invocation mode, and the trigger that reopens this decision.
- **Pointer**: when deciding whether `/export` can run headless or take a format or redaction flag, fetch the `/export` row of [Commands § All commands](https://code.claude.com/docs/en/commands#all-commands) live.

## What this skill does not do

- **Does not duplicate capability mechanics.** It routes PR, issue, and
  worktree work to whatever capabilities are installed and falls back to
  `git` and the forge's or tracker's own tooling; it does not reimplement them.

## Related

- Local save-point when machine stays available: /session-flow:handoff.
- Resume after an interruption: /session-flow:keep-going.
- Prune stale .work memory items: /session-flow:tidy-work.

## Gotchas

- "Pushed" is not "linked". A branch can be safely on the remote and still
  strand its context if no PR or issue carries the why and the next step. The
  durability sweep and the breadcrumb bar are two separate checks; passing the
  first does not pass the second.
- A stash is invisible to a casual glance and cannot be pushed. Inspect for
  stashes explicitly; each one is either converted to a durable commit or
  named in the verdict, never left to die with the machine.

Files in this skill

  • SKILL.md9.8 KB
  • evals/evals.json6.4 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.