Dev reset workspace

From Nebulavenus/forge-gpu · View interactive version

Dev reset workspace is an AI agent skill from the GitHub repository Nebulavenus/forge-gpu. Clean the workspace of finished-work vestiges so new work can start from a fresh main branch

How to use this skill

Skill file

Reset the workspace to a clean state on main with no leftover branches,

uncommitted files, or background agents from previous work. Run this between

tasks to start fresh.

When to use this skill:

Arguments

files and stale branches without asking. Still preserves files that appear to

contain meaningful uncommitted work.

Workflow

Work through each phase in order. Report findings at each phase before

acting. Unless --force is given, ask the user before destructive actions.


Phase 1 — Stop background agents

Check for running background tasks (agents, shells, builds) from previous work.

  1. List running tasks: Use the TaskList tool (or /tasks output) to find

any in-progress background agents or shells.

  1. For each running task:
  1. Stop safe tasks using TaskStop. Report any tasks you chose not to stop

and why.

  1. If no tasks are running, report "No background tasks found" and proceed.

Phase 2 — Analyze uncommitted changes

Examine the working tree for any modifications or untracked files.

  1. Run diagnostics in parallel:

```bash

git status --short

git diff --stat

git diff --cached --stat

git log --oneline -10

git branch -vv

```

  1. If the working tree is clean (no output from status/diff), skip to

Phase 3.

  1. For each uncommitted or untracked file, classify it:

| Classification | Action | Examples |

|---|---|---|

| Belongs to a merged PR | Should have been committed — warn user | Source files matching recent PR topics |

| Build artifact / generated file | Safe to delete or add to .gitignore | build/, *.o, *.spv, shaders/compiled/ |

| Editor / OS junk | Add to .git/info/exclude (local only) | .DS_Store, *.swp, .vscode/settings.json |

| Meaningful new work | Stash or warn — do NOT delete | New lesson files, library changes |

| Unknown | Ask the user | Anything ambiguous |

  1. To classify files, check recent context:

```bash

# Recent merged PRs

gh pr list --state merged --limit 5

# Recent branches (local and remote)

git branch -a --sort=-committerdate | head -20

# What the current branch was working on

git log --oneline HEAD...origin/main 2>/dev/null

```

  1. Report findings in a table:

```text

Uncommitted files analysis:

──────────────────────────────────────────────

M lessons/gpu/17-normal-maps/main.c → Belongs to merged PR #42 (stale edit)

?? build/CMakeCache.txt → Build artifact (safe to delete)

?? .DS_Store → OS junk (add to local exclude)

A lessons/gpu/30-new-lesson/main.c → New work (stash? ask user)

```

  1. Take action per classification:

have been in the PR. Offer to discard them (git checkout -- <file>) or

stash them.

for those paths only (not a blanket clean).

and then delete.

since these are personal and shouldn't be committed).

Report the stash entry so the user can recover it.

gitignore, local exclude, skip).


Phase 3 — Switch to main and pull latest

  1. If not on main:

```bash

git checkout main

```

If checkout fails due to uncommitted changes, go back to Phase 2 — something

was missed.

  1. Pull latest:

```bash

git pull origin main

```

  1. Verify:

```bash

git status --short

git diff --stat

```

Both should produce no output. If not, investigate and resolve.


Phase 4 — Remove stale local branches

Find and delete local branches whose work has been merged into origin/main.

  1. Fetch latest remote state:

```bash

git fetch --prune origin

```

  1. Find merged branches:

```bash

git branch --merged origin/main \

| sed 's/^[* ]*//' \

| grep -v '^main$'

```

  1. Find branches whose remote tracking branch is gone (PR was merged and

remote branch deleted):

```bash

git branch -vv | grep ': gone]' | awk '{print $1}'

```

  1. Combine both lists (deduplicate). For each branch:

```bash

git branch -d <branch-name>

```

unless the user explicitly confirms or --force was given AND the remote

tracking branch is gone (meaning the PR was merged and the remote branch

was deleted by GitHub).

  1. Report what was removed:

```text

Removed stale branches:

✓ lesson-17-normal-maps (merged, remote deleted)

✓ lesson-18-scene-loading (merged, remote deleted)

⏭ experiment-wip (not merged, kept)

```


Phase 5 — Clean up worktrees

Check for leftover Claude Code worktrees from previous sessions.

git worktree list

If any worktrees exist under .claude/worktrees/:


Phase 6 — Final verification

Run a final check to confirm everything is clean.

git status
git diff
git branch
git log --oneline -3

Expected state:

Report final state:

Workspace Reset Complete
════════════════════════
Branch:          main (up to date with origin/main)
Working tree:    clean
Stale branches:  3 removed, 0 kept
Background tasks: 0 running
Stashed work:    1 entry (use `git stash list` to see)

Ready for new work.

Error handling

resolve manually.

git-only checks.

Safety guarantees

identified paths.

with remote-gone confirmation).

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.