cleanup-workspace
Skill67 starsChanged 59 days agoMITView on GitHub
Clean up the local workspace after a dev branch has been merged into main. Verifies the current dev branch is fully merged into origin/main, then switches to main, pulls the latest, deletes the local dev branch, and deletes the remote dev branch if it still exists. STOPS and warns the user if the current branch is not yet merged. Triggers: cleanup workspace, cleanup branch, delete merged branch, finish dev branch, post-merge cleanup
- Commits and pushes
In this repository54 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .claude/CLAUDE.mdCLAUDE.md
- convert-finder-skill-to-preprocessor-scriptsSkill
- create-agent-skill-fallbackSkill
- create-cpp-testsSkill
- create-preprocessor-scriptsSkill
- create-prSkill
- dump-vtablesSkill
- find-CBaseEntity_GetChangeAccessorPathInfo_1Skill
- find-CCSBotManager_AddBot_BotNavIgnoreSkill
- find-CCSGameRules__sm_mapGcBanInformationSkill
- find-CCSPlayer_MovementServices_CheckJumpButton_WaterPatchSkill
- find-CCSPlayer_MovementServices_FullWalkMove_SpeedClampSkill
- find-CEntitySystem_Init-decompilesSkill
- find-CEntitySystem_m_entityNamesSkill
- find-CNetworkGameServerBase_CheckTimeouts-decompilesSkill
- find-CNetworkGameServerBase_CreateFakeClientSkill
- find-CNetworkGameServerBase_GetChallengeTypeSkill
- find-CNetworkGameServer_GetFreeClientSkill
- find-CNetworkMessages_dtorSkill
- find-CNetworkMessages_GetIsForServerSkill
- find-CNetworkMessages_GetNetworkSerializationContextDataSkill
- find-CNetworkMessages_vtable-decompilesSkill
- find-CServerSideClientBase_GetUserIDStringSkill
- find-CSource2Server_Shutdown-decompilesSkill
- find-CSteam3ServerS1_InitGameServer-decompilesSkill
- find-INetworkServerService_GetServerSerializersCRCSkill
- find-INetworkServerService_IsActiveInGameSkill
- find-INetworkServerService_IsServerRunningSkill
- find-IVEngineServer2_GetClientSteamIDSkill
- find-OnServerVoiceData_IsPlayingDemo_CalleeSkill
- fix-cppheadersSkill
- generate-reference-yamlSkill
- generate-signature-for-functionSkill
- generate-signature-for-globalvarSkill
- generate-signature-for-patchSkill
- generate-signature-for-structoffsetSkill
- generate-signature-for-vfuncoffsetSkill
- get-func-from-yamlSkill
- get-vtable-addressSkill
- get-vtable-from-yamlSkill
- get-vtable-indexSkill
- init-gamebinSkill
- rename-preprocessor-scriptsSkill
- resolve-pr-conflictSkill
- run-validation-until-no-failureSkill
- run-vcall-finderSkill
- trigger-release-buildSkill
- write-func-as-yamlSkill
- write-globalvar-as-yamlSkill
- write-patch-as-yamlSkill
- write-structoffset-as-yamlSkill
- write-vfunc-as-yamlSkill
- write-vtable-as-yamlSkill
The file
We split this skill into the rules it gives an agent
9 rules. About 0 are common, 4 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 18
After a pull request authored on a dev* branch has been merged into main and the user wants to return the workspace to a clean state on the …
- Very specific: line 22
NEVER: delete a branch that is not fully merged into origin/main.
- Distinctive: line 23
NEVER: run on main itself. If the current branch is main, abort with a clear message.
- Distinctive: line 31
Run these checks in parallel:
- Distinctive: line 62
Do not continue to subsequent steps.
- Very specific: line 71
Use --ff-only so the pull aborts cleanly if something unexpected happened upstream rather than creating a merge commit silently.
- Very specific: line 79
Use lowercase -d (safe delete).
- Distinctive: line 96
If the push fails (permission denied, protected branch, etc.), report the error to the user — do not retry with force.
- Very specific: line 124
If the user wants to clean up a *different* branch than the one currently checked out, they should switch to it first.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 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
Cleanup Workspace
Post-merge housekeeping: verify the active dev branch landed in main, then prune it locally and on origin.
When to Use
After a pull request authored on a dev* branch has been merged into main and the user wants to return the workspace to a clean state on the updated main branch.
Safety Rules
- NEVER delete a branch that is not fully merged into
origin/main. If the merge check fails, STOP immediately and report to the user — do not pass-Dto force delete. - NEVER run on
mainitself. If the current branch ismain, abort with a clear message. - NEVER discard uncommitted changes. If the working tree is dirty, abort and ask the user to commit or stash first.
- The remote name is assumed to be
origin. Iforiginis not present, abort and ask the user which remote to use.
Method
Step 1 — Capture state and validate preconditions
Run these checks in parallel:
git rev-parse --abbrev-ref HEAD # current branch name
git status --porcelain # must be empty (clean working tree)
git remote # must contain 'origin'Abort with a clear message if:
- Current branch is
main(nothing to clean up). git status --porcelainis non-empty (uncommitted changes).originremote does not exist.
Save the current branch name as DEV_BRANCH for later steps.
Step 2 — Fetch latest refs and verify merge status
git fetch origin --pruneThen check whether every commit on DEV_BRANCH is reachable from origin/main:
git merge-base --is-ancestor <DEV_BRANCH> origin/main- Exit code
0→ branch is fully merged. Proceed to Step 3. - Exit code
1→ branch has commits not inorigin/main. STOP and report to the user:- Show the unmerged commits:
git log --oneline origin/main..<DEV_BRANCH> - Tell the user the branch is not merged and the skill will not delete it.
- Do not continue to subsequent steps.
- Show the unmerged commits:
Step 3 — Switch to main and pull
git checkout main
git pull origin main --ff-onlyUse --ff-only so the pull aborts cleanly if something unexpected happened upstream rather than creating a merge commit silently.
Step 4 — Delete the local dev branch
git branch -d <DEV_BRANCH>Use lowercase -d (safe delete). It refuses to delete if not merged — which should not happen since Step 2 already verified the merge, but the double-check is intentional. Do not fall back to -D.
Step 5 — Delete the remote dev branch if it still exists
First check whether the remote branch is still present (the maintainer may have already deleted it after merging the PR):
git ls-remote --heads origin <DEV_BRANCH>- Output empty → remote already deleted. Skip the delete and report "remote branch already removed".
- Output non-empty → delete it:
git push origin --delete <DEV_BRANCH>If the push fails (permission denied, protected branch, etc.), report the error to the user — do not retry with force.
Step 6 — Report final state
Summarize what changed in a short message:
- Current branch (should be
main) and its short SHA. - Whether the local dev branch was deleted.
- Whether the remote dev branch was deleted or was already gone.
Example Walk-through
User finishes work on dev-14156 which has been merged into main via PR:
Step 1: HEAD=dev-14156, working tree clean, origin present. ✓
Step 2: git fetch origin --prune
git merge-base --is-ancestor dev-14156 origin/main → 0 ✓ merged
Step 3: git checkout main
git pull origin main --ff-only → main now at <sha>
Step 4: git branch -d dev-14156 → deleted
Step 5: git ls-remote --heads origin dev-14156 → non-empty
git push origin --delete dev-14156 → deleted
Step 6: Report: on main @ <sha>; local dev-14156 deleted; remote dev-14156 deleted.Notes
- The skill is a pure git workflow — no IDA Pro MCP or codebase analysis is involved.
- If the user wants to clean up a different branch than the one currently checked out, they should switch to it first; this skill only operates on
HEAD. - The skill never force-deletes (
-D) or force-pushes. If a step refuses, that is a signal to stop and surface the situation, not to override.
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.

