agentleFS
mrdaioffmrdaioff/baby-brain/.claude/skills/session-teardown/SKILL.md

session-teardown

Skill0 starsChanged 2 months agoMITView on GitHub

Close coding-agent sessions, terminals, worktrees, and branches without losing unfinished work. Use when asked to close a session, clean up a worktree, or remove a branch after implementation.

The file

We split this skill into the rules it gives an agent

8 rules. About 0 are common, 6 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈6

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use this only after work has ended or the user has asked to stop it.

    line 8
  2. Distinctive:

    Before closing anything, identify every branch, worktree, terminal, and agent session created for the work.

    line 12
  3. Distinctive:

    Do not delete a branch or worktree merely because a task or terminal has finished.

    line 20
  4. Distinctive:

    If the work is only local, stop teardown.

    line 22
  5. Distinctive:

    Run checks appropriate to the repository and report what they cover:

    line 26
  6. Distinctive:

    Remove temporary local worktrees.

    line 41
  7. Very specific:

    Remove a remote branch only after its commits are verified on origin/main or the user explicitly wants it retained.

    line 43
  8. Very specific:

    Before removing a deployed or shared resource, including a remote branch, follow .agents/working-agreements.md: restate the exact target …

    line 45

≈ “Common” is an estimate: at least 1 in 5 of the 372,429 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Session teardown

Use this only after work has ended or the user has asked to stop it. It does not authorize deleting code, remote branches, deployments, or other shared resources.

Preserve work first

Before closing anything, identify every branch, worktree, terminal, and agent session created for the work.

For each branch with work, verify one of these states against the remote:

  • Its intended commits are reachable from origin/main.
  • Its intended commits are in an open pull request with a recorded URL.
  • The user has explicitly chosen to keep the work unmerged, and its commit SHA and remote branch have been reported.

Do not delete a branch or worktree merely because a task or terminal has finished. A clean worktree does not prove that its commits are preserved elsewhere.

If the work is only local, stop teardown. Commit and push it, open a pull request, or ask the user whether to discard it. Do not infer permission to discard unmerged work from a request to "close the session."

Verify before removal

Run checks appropriate to the repository and report what they cover:

git status --short
git log --oneline <base>..<branch>
git merge-base --is-ancestor <commit> origin/main
git ls-remote --heads origin <branch>

For a branch intended to merge, resolve conflicts and get it merged before branch cleanup. If the main checkout is dirty, use an isolated worktree or a pull request. Do not merge into or reset that checkout.

Close in safe order

  1. Preserve and verify commits.
  2. Close the agent and terminal sessions.
  3. Remove temporary local worktrees.
  4. Remove local branches.
  5. Remove a remote branch only after its commits are verified on origin/main or the user explicitly wants it retained.

Before removing a deployed or shared resource, including a remote branch, follow .agents/working-agreements.md: restate the exact target and get confirmation in that moment. A prior instruction to clean up does not replace that confirmation.

Handoff

State the commit or pull request that preserves the work, every resource closed, and anything intentionally left open. If the work cannot be preserved or needs a choice, leave the branch and worktree intact and ask for direction.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.