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.
In this repository16 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- anti-ai-writingSkill
- installSkill
- knowledge-base-governanceSkill
- librarianSkill
- project-creationSkill
- services-catalogSkill
- session-teardownSkill
- anti-ai-writingSkill
- installSkill
- knowledge-base-governanceSkill
- librarianSkill
- project-creationSkill
- services-catalogSkill
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
- Distinctive: line 8
Use this only after work has ended or the user has asked to stop it.
- Distinctive: line 12
Before closing anything, identify every branch, worktree, terminal, and agent session created for the work.
- Distinctive: line 20
Do not delete a branch or worktree merely because a task or terminal has finished.
- Distinctive: line 22
If the work is only local, stop teardown.
- Distinctive: line 26
Run checks appropriate to the repository and report what they cover:
- Distinctive: line 41
Remove temporary local worktrees.
- Very specific: line 43
Remove a remote branch only after its commits are verified on origin/main or the user explicitly wants it retained.
- Very specific: line 45
Before removing a deployed or shared resource, including a remote branch, follow .agents/working-agreements.md: restate the exact target …
≈ “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.
Files
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
- Preserve and verify commits.
- Close the agent and terminal sessions.
- Remove temporary local worktrees.
- Remove local branches.
- Remove a remote branch only after its commits are verified on
origin/mainor 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.
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
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.

