Workspace Hygiene for Permanent Workspaces
This is a global workflow skill for workspaces that persist between tasks.
Treat the workspace as user data: preserve uncommitted work, dependencies,
caches, local configuration, and stashes unless the user or repository policy
explicitly authorizes changing or removing them.
Before starting a task
Discover the workspace scope. Identify every Git repository involved in the
task, including repositories in a multi-repository workspace. Do not assume
a project name, directory layout, operating system, remote name, or default
branch. Avoid operating on nested repositories twice.
Read applicable AGENTS.md, CLAUDE.md, CONTRIBUTING.md, and repository
documentation. Repository-specific instructions control the required base
branch, validation, and cleanup policy.
Inspect each repository before changing Git state:
git -C <repo> status --short --branch
git -C <repo> branch --show-current
git -C <repo> remote -v
git -C <repo> stash list
Determine the intended base branch and remote from repository instructions
or the remote's default branch. If no base branch is specified, use the
repository's configured default rather than assuming main.
Establish a clean starting point without destroying local state. If the
repository has changes, untracked files, or stashes, preserve them and
account for them before starting. Do not silently reset, clean, switch away
from a working branch, or overwrite files.
If the repository policy requires synchronization to its base branch, use a
fast-forward-only update when the working tree is already safe to switch:
git -C <repo> fetch <remote> --prune
git -C <repo> switch <base-branch>
git -C <repo> pull --ff-only <remote> <base-branch>
git -C <repo> status --short --branch
If switching or updating would discard work, stop and ask for direction.
Use reset --hard only when the user or an explicit repository policy has
authorized that exact destructive operation.
During the task
Keep changes isolated to the repositories and files in scope.
Do not use git clean -fdx in a permanent workspace as routine hygiene. It
removes ignored dependencies, virtual environments, caches, build output,
and local tooling.
If cleanup is required, inspect first:
git -C <repo> status --porcelain
git -C <repo> clean -nxd
Remove only the approved paths. Use git clean -fd for approved untracked
files while preserving ignored files; use git clean -fdx only when the
policy explicitly requires ignored files to be removed too.
Never run git stash clear in a permanent workspace. Preserve pre-existing
stashes and remove only a stash created by the current task, after confirming
it is no longer needed.
Do not delete local branches merely to make the workspace look tidy. A PR
branch may be needed for review updates.
After creating a pull request
When a PR is created, return affected repositories to the documented base
branch only if doing so is safe:
Confirm the task's changes are committed or otherwise accounted for.
Switch to the base branch without overwriting changes.
Remove only session-created temporary artifacts that are known to be safe to
remove. Leave dependencies, caches, ignored tooling, pre-existing stashes,
and local branches intact unless explicit instructions say otherwise.
Verify and report the final state:
git -C <repo> status --short --branch
git -C <repo> diff --stat
If the workspace cannot safely return to the base branch, do not force it. Tell
the user which repository, branch, changes, or artifacts remain and why.
Completion criteria
Before reporting completion, verify that:
- every repository in scope was identified;
- applicable repository instructions were followed;
- no user changes, stashes, dependencies, caches, or branches were removed
without authorization; and
- the final Git state and any intentional deviations are clearly reported.
1---2name: workspace-hygene3description: Use in permanent or long-lived Git workspaces to prepare repositories, preserve local state, and leave workspaces predictable across sessions and pull requests.4---56# Workspace Hygiene for Permanent Workspaces78This is a global workflow skill for workspaces that persist between tasks.9Treat the workspace as user data: preserve uncommitted work, dependencies,10caches, local configuration, and stashes unless the user or repository policy11explicitly authorizes changing or removing them.1213## Before starting a task14151. Discover the workspace scope. Identify every Git repository involved in the16 task, including repositories in a multi-repository workspace. Do not assume17 a project name, directory layout, operating system, remote name, or default18 branch. Avoid operating on nested repositories twice.192. Read applicable `AGENTS.md`, `CLAUDE.md`, `CONTRIBUTING.md`, and repository20 documentation. Repository-specific instructions control the required base21 branch, validation, and cleanup policy.223. Inspect each repository before changing Git state:2324 ```bash25 git -C <repo> status --short --branch26 git -C <repo> branch --show-current27 git -C <repo> remote -v28 git -C <repo> stash list29 ```30314. Determine the intended base branch and remote from repository instructions32 or the remote's default branch. If no base branch is specified, use the33 repository's configured default rather than assuming `main`.345. Establish a clean starting point without destroying local state. If the35 repository has changes, untracked files, or stashes, preserve them and36 account for them before starting. Do not silently reset, clean, switch away37 from a working branch, or overwrite files.386. If the repository policy requires synchronization to its base branch, use a39 fast-forward-only update when the working tree is already safe to switch:4041 ```bash42 git -C <repo> fetch <remote> --prune43 git -C <repo> switch <base-branch>44 git -C <repo> pull --ff-only <remote> <base-branch>45 git -C <repo> status --short --branch46 ```4748 If switching or updating would discard work, stop and ask for direction.49 Use `reset --hard` only when the user or an explicit repository policy has50 authorized that exact destructive operation.5152## During the task5354- Keep changes isolated to the repositories and files in scope.55- Do not use `git clean -fdx` in a permanent workspace as routine hygiene. It56 removes ignored dependencies, virtual environments, caches, build output,57 and local tooling.58- If cleanup is required, inspect first:5960 ```bash61 git -C <repo> status --porcelain62 git -C <repo> clean -nxd63 ```6465 Remove only the approved paths. Use `git clean -fd` for approved untracked66 files while preserving ignored files; use `git clean -fdx` only when the67 policy explicitly requires ignored files to be removed too.68- Never run `git stash clear` in a permanent workspace. Preserve pre-existing69 stashes and remove only a stash created by the current task, after confirming70 it is no longer needed.71- Do not delete local branches merely to make the workspace look tidy. A PR72 branch may be needed for review updates.7374## After creating a pull request7576When a PR is created, return affected repositories to the documented base77branch only if doing so is safe:78791. Confirm the task's changes are committed or otherwise accounted for.802. Switch to the base branch without overwriting changes.813. Remove only session-created temporary artifacts that are known to be safe to82 remove. Leave dependencies, caches, ignored tooling, pre-existing stashes,83 and local branches intact unless explicit instructions say otherwise.844. Verify and report the final state:8586 ```bash87 git -C <repo> status --short --branch88 git -C <repo> diff --stat89 ```9091If the workspace cannot safely return to the base branch, do not force it. Tell92the user which repository, branch, changes, or artifacts remain and why.9394## Completion criteria9596Before reporting completion, verify that:9798- every repository in scope was identified;99- applicable repository instructions were followed;100- no user changes, stashes, dependencies, caches, or branches were removed101 without authorization; and102- the final Git state and any intentional deviations are clearly reported.