session-cleanup
Skill0 starsChanged 4 months agoMITView on GitHub
Use at the end of substantial coding work — a long session, several compactions, many commits, interrupted runs, or work done by more than one agent or session — and whenever the user asks for a final cleanup or integrity pass. Reconstructs the complete work delta from the repository against a verified integration baseline, removes in-scope debris, abandoned approaches, speculative compatibility code, and unnecessary complexity, preserves unrelated changes, runs the project's own checks, and reports the final state honestly. Not an audit after every edit, and not authority for destructive cleanup, commits, branch deletion, or worktree removal.
7 other projects use a version of this, 1 of them edited.
Adopted by
Most recently taken up by
- desertcache/agent-ostheir own version, first seen Nov 1, 2026
- edloidas/skillstheir own version, first seen Nov 1, 2026
- apappascs/claude-code-sessionstheir own version, first seen Nov 1, 2026
- FuDesign2008/open-skillstheir own version, first seen Nov 1, 2026
- ArcanEdge-AI/coding-agent-playbook-codexedited, first seen Aug 17, 2026
- Tourbillon-cpu/claude-skillstheir own version, first seen Jul 16, 2026
Other versions7 projects use a version of this.
Word for word · 0
None found.
Edited · 1
- ArcanEdge-AI/coding-agent-playbook-codex★ 314% same
Wrote their own version · 6
- FuDesign2008/open-skills★ 6same name
- apappascs/claude-code-sessions★ 2same name
- edloidas/skills★ 2same name
- ChristopherA/claude_code_tools★ 0same name
- desertcache/agent-os★ 0same name
- Tourbillon-cpu/claude-skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository28 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- aws-local-preflightSkill
- feature-branch-lifecycleSkill
- handoffSkill
- legacy-path-retirementSkill
- local-ci-preflightSkill
- multi-role-repo-reviewSkill
- multi-session-coordinationSkill
- platform-documentationSkill
- production-api-integrationSkill
- production-architecture-reviewSkill
- production-code-qualitySkill
- production-database-integritySkill
- production-devops-releaseSkill
- production-documentation-onboardingSkill
- production-pass-orchestratorSkill
- production-performance-reviewSkill
- production-readiness-reportSkill
- production-reliability-observabilitySkill
- production-security-reviewSkill
- production-testing-qaSkill
- production-ux-accessibilitySkill
- reference-doc-routingSkill
- senior-code-reviewSkill
- subagent-orchestrationSkill
- task-graph-orchestrationSkill
- technical-debt-auditorSkill
- worktree-lifecycleSkill
The file
We split this skill into the rules it gives an agent
7 rules. 0 are common, 5 are distinctive, and 2 are very specific to this project.
0
Common
Most of the 6 edited versions we read keep these.
5
Distinctive
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
- Very specific: line 12
Read references/post-session-cleanup-methodology.md, packaged with this skill, for the checks that apply to the current work delta.
- Distinctive: line 22
If the current branch *is* the baseline, or nothing meaningful has been committed since it diverged, use the verified working-tree changes …
- Distinctive: line 23
If the baseline stays uncertain, say so, continue only with independently verified cleanup, and do not claim a clean completion.
- Distinctive: line 25
Never shrink the surface to what you remember editing.
- Very specific: line 40
Never use a destructive reset, clean, stash, or history rewrite, and make no implicit production or deployment change.
- Distinctive: line 56
Remove or correct clear work-delta debris, defects, abandoned approaches, speculative compatibility code, and unnecessary complexity.
- Distinctive: line 60
Before every additional change, ask: *is this necessary to correctly complete, simplify, stabilize, or clean up the current work delta?* If …
“Common” is measured: kept by at least 6 in 10 of the 6 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Session Cleanup
The final codebase should keep the required implementation, not the history of how you reached it. Long work leaves debris — a debug log, an abandoned helper, a compatibility shim for an interface that never shipped — and a conversation that has been compacted keeps a summary, not a record of all of it.
So the cleanup boundary comes from the repository, never from what this conversation remembers.
Read references/post-session-cleanup-methodology.md, packaged with this skill, for the checks that apply to the current work delta. Its numbered sections are the procedure.
1. Establish the baseline and the work delta
- Resolve the verified integration baseline — the branch this work will integrate into.
- Where the
feature-branch-lifecyclemodel applies, a development branch integrates into its feature integration branch, and a feature integration branch into the long-lived integration branch. - Otherwise use the repository's verified integration branch:
stagingwhere the repository really uses one as its normal integration target, elsemainor the verified primary branch. - Confirm the choice from
CLAUDE.md, release documentation, branch and pull-request conventions, or history. A branch name alone is not evidence.
- Where the
- Find the merge base between the current branch and that baseline.
- The work delta is everything from that merge base through
HEAD, plus staged, unstaged, and untracked changes. - If the current branch is the baseline, or nothing meaningful has been committed since it diverged, use the verified working-tree changes and explicit task evidence as the work delta.
- If the baseline stays uncertain, say so, continue only with independently verified cleanup, and do not claim a clean completion.
Never shrink the surface to what you remember editing. After compaction, across sessions, or when helpers did part of the work, memory is the least reliable source you have.
2. Know what you may touch
| In the working tree | What to do |
| Work-delta changes attributable to this work | Clean up, correct, and simplify within scope |
| Pre-existing baseline behavior | Leave it, unless the work delta broke it |
| Unrelated edits, staging, and files — including another session's changes in a shared checkout | Preserve them exactly, staged state included |
| Files or hunks whose ownership is uncertain | Report them, and continue with the independently verified work |
"Clean" means the work delta holds no unexpected debris, unresolved defect, abandoned implementation, or complexity that should reasonably go now. It does not mean an empty git status.
A cleanup request authorizes reversible, in-scope cleanup. An inspection-only request stays read-only. Existing approval carries forward only within its stated scope.
Never use a destructive reset, clean, stash, or history rewrite, and make no implicit production or deployment change. Do not stage, commit, discard, or deploy on your own initiative. Keep security checks to the touched surfaces, and never print a secret value.
This skill does not delete branches or remove worktrees. A temporary branch that looks finished goes through the feature-branch-lifecycle cleanup gates; a task-created auxiliary checkout goes through worktree-lifecycle.
3. Compatibility needs evidence
- Add no compatibility behavior for hypothetical users, old data, API consumers, deployments, or integrations. New compatibility code needs a real supported dependency: a deployed older version, persisted data in the old representation, an active consumer of the old contract, a documented supported-version requirement, or an active migration window.
- "Someone might use it", "for backwards compatibility", "to be safe", and "future-proofing" are not evidence.
- Code introduced and superseded entirely within an unmerged branch never shipped. Branch history is not production history, so remove it without a compatibility path.
- Compatibility code that predates the work delta is different: it may have consumers you cannot see. Apply the
legacy-path-retirementskill before removing it, and when its necessity cannot be established either way, leave it unchanged and report the uncertainty. - Confirm that a consumer or a data set actually requires continued support before keeping code for it. Obsolete test accounts, fixtures, seed data, and hypothetical users are not support commitments;
legacy-path-retirementseparates that decision from whether their data is preserved or reset under authority. Alpha status justifies neither a compatibility layer nor a rebuild of the flow.
4. Review sequence
- Reconstruct the full work delta before editing: the intended outcome, the changed paths, their ownership, and the classes of change — committed branch changes; staged, unstaged, and untracked work; renames; configuration; dependencies; schemas and migrations; tests; documentation; generated artifacts; tooling.
- Apply every methodology section the delta touches, using the map below. Do not skip one because the visible diff looks small.
- Remove or correct clear work-delta debris, defects, abandoned approaches, speculative compatibility code, and unnecessary complexity. Before each change, verify ownership and usages. Afterwards, re-review the baseline comparison and the status.
- Validate with the project's own commands, narrowest first, then the broader required gates. Classify every failure or unrun check as work-delta-introduced, pre-existing, environmental or tooling, or unknown. A material changed behavior that could not be validated cannot be called complete and clean.
- Report blockers and unresolved ownership or compatibility evidence plainly.
Before every additional change, ask: is this necessary to correctly complete, simplify, stabilize, or clean up the current work delta? If not, leave it and record the unrelated issue separately.
Which methodology sections apply
| Section | Apply when |
| 1. Baseline and work delta | Always |
| 2. Implementation debris | Always |
| 3. Abandoned approaches and speculative compatibility | Always |
| 4. Minimize the implementation surface | Always |
| 5. Code quality | Always |
| 6. Errors and edge cases | Behavior, inputs, network calls, permissions, retries, or state transitions changed |
| 7. Data and state integrity | Persistence, APIs, schemas, migrations, serialization, or state management changed |
| 8. Security boundaries | A touched surface handles secrets, identity, authorization, ownership, input, logs, dynamic execution, or files |
| 9. Dependencies and configuration | Packages, lockfiles, environment variables, build settings, or deployment configuration changed |
| 10. UI and UX | Any user interface changed. Reading the source does not prove UI behavior |
| 11. Tests — E2E coverage of the intended final behavior, meaningful failures, and boundary cases; every created unit test removed once passing E2E coverage carries its still-required assertions | Always |
| 12. Validation pipeline — the smallest meaningful checks, then the required affected gates | Always |
| 13. Documentation against reality | Documentation, setup, configuration, APIs, examples, or user-facing copy is affected |
| 14. Deferred-work markers | Always |
| 15. Repository hygiene and runtime resources | Always. Reconcile task-owned runtime resources; this is not a sweep of unrelated ones |
| 16. Next-developer review | Always |
| 17. Final scope check | Before every additional cleanup change |
5. How this relates to review
senior-code-review reviews the final diff before you hand it over; run it on whatever this pass changes. This skill is the broader editing pass that comes first at the end of substantial work: it reconstructs the whole delta, removes what should not ship, and runs the full validation pipeline.
Required report
Return exactly these five sections, even when one is empty:
## Cleaned Up
[Meaningful cleanup performed.]
## Validation
[Checks actually run, and their outcomes.]
## Problems Found
[Defects, incomplete work, accidental technical debt, abandoned approaches,
speculative compatibility paths, or unnecessary complexity discovered.]
## Remaining Issues
[Work-delta-introduced issues, pre-existing issues, and optional future
improvements, kept separate, each with the reason it was left.]
## Final State
[Exactly one of: complete and clean / complete with documented remaining issues /
not yet safe to consider complete]Use not yet safe to consider complete for a required work-delta defect or material unvalidated behavior. Documented remaining issues allow a complete state only when they do not block a validated requirement. Never claim complete and clean when required validation did not run, or when the baseline, the ownership of material changes, or material changed behavior is unresolved.
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.

