# How to Uninstall Claude Code, Codex CLI, Gemini CLI and OpenCode on Windows

To uninstall Claude Code, Codex CLI, Gemini CLI or OpenCode on Windows, first find which installation answers to the command, remove it with the tool that installed it (npm, winget, Scoop, Chocolatey or the vendor's own folder), and treat the data folders in your user profile as a separate decision. Removing the program does not remove your sessions and settings, and deleting those folders is what loses chat history, so keep them until you are sure you will not come back to the tool.

## Find out which installation you have

Each of these tools can be installed more than one way, and a second copy is the usual reason a command still works after an uninstall. From PowerShell, list every match for each command name with [Get-Command](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/get-command), and list the global npm packages with [npm ls](https://docs.npmjs.com/cli/v11/commands/npm-ls):

```powershell
Get-Command claude -All
Get-Command codex -All
Get-Command gemini -All
Get-Command opencode -All
npm ls -g --depth=0
```

The path tells you the installer. According to the [npm folders documentation](https://docs.npmjs.com/cli/v11/configuring-npm/folders), a global npm install on Windows puts its commands directly in `%APPDATA%\npm`. Claude Code's [native installer](https://code.claude.com/docs/en/setup#uninstall-a-native-installation) uses `%USERPROFILE%\.local\bin\claude.exe` and `%USERPROFILE%\.local\share\claude`. A path under `WinGet\Packages` points to winget.

## Remove the program

Quit the tool and any editor or terminal session using it first. Use only the row that matches what Get-Command showed.

| Tool | Installed with | Removal |
| --- | --- | --- |
| Claude Code | npm | `npm uninstall -g @anthropic-ai/claude-code` |
| Claude Code | winget | `winget uninstall Anthropic.ClaudeCode` |
| Claude Code | native installer | `Remove-Item -Path "$env:USERPROFILE\.local\bin\claude.exe" -Force`, then `Remove-Item -Path "$env:USERPROFILE\.local\share\claude" -Recurse -Force` |
| Codex CLI | npm | `npm uninstall -g @openai/codex` |
| Codex CLI | winget | `winget uninstall OpenAI.Codex` |
| Gemini CLI | npm | `npm uninstall -g @google/gemini-cli` |
| OpenCode 1 | npm | `npm uninstall -g opencode-ai` |
| OpenCode 1 | Scoop | `scoop uninstall opencode` |
| OpenCode 1 | Chocolatey | `choco uninstall opencode` |

The package names come from each vendor's own page: Claude Code's [uninstall instructions](https://code.claude.com/docs/en/setup#uninstall-claude-code), the [Codex README](https://github.com/openai/codex/blob/main/README.md), the [Gemini CLI uninstall guide](https://www.geminicli.com/docs/resources/uninstall) and the [OpenCode 1 docs](https://opencode.ai/v1/docs/), which list the npm, Scoop and Chocolatey installs. The Codex winget package is not in the README; its [manifest in winget-pkgs](https://github.com/microsoft/winget-pkgs/tree/master/manifests/o/OpenAI/Codex) names OpenAI as publisher and was created by the Codex release workflow. The [winget uninstall](https://learn.microsoft.com/en-us/windows/package-manager/winget/uninstall) command removes a package by its id.

The Claude Code rows delete a program, not your settings, because the native installer and `~/.claude` are separate locations. The two `Remove-Item` lines in the native row are Anthropic's own and skip the Recycle Bin, which is fine for a program you can reinstall.

## Codex's native installer has no uninstall command

OpenAI's [install.ps1](https://github.com/openai/codex/blob/main/scripts/install/install.ps1) puts the runtime under `%USERPROFILE%\.codex\packages\standalone` and a folder of launchers at `%LOCALAPPDATA%\Programs\OpenAI\Codex\bin` that links to it, then adds that folder to your user PATH. `CODEX_INSTALL_DIR` and `CODEX_HOME` can change both. I found no documented uninstall command for this layout, so this is manual removal read from the installer source: after quitting Codex, delete the launcher folder and the `packages\standalone` folder in File Explorer, and remove the launcher folder from your user PATH under Settings › System › About › Advanced system settings › Environment Variables. Leave the rest of `.codex`, which is your data.

## OpenCode 2 is a different install

OpenCode's current docs describe version 2, and they say Windows package managers are not supported for it: you download a standalone binary instead. Its npm package is `@opencode/cli`, not `opencode-ai`. If you run OpenCode 2 you can use the built-in command, which previews first:

```powershell
opencode uninstall --dry-run
opencode uninstall
```

The [OpenCode 2 CLI reference](https://opencode.ai/docs/cli/) says this stops its background services, removes the shared global cache, uses the detected package manager when there is one, and never removes session data, configuration or state. For a standalone binary you extracted yourself, delete that folder and its PATH entry afterwards. OpenCode 1 had `opencode uninstall` with `--keep-config` and `--keep-data` flags; a package-manager copy is safest to remove with its package manager, since a [reported issue](https://github.com/anomalyco/opencode/issues/8573) (January 2026, version 1.1.20) found the command did not handle Scoop or Chocolatey installs on Windows. `opencode upgrade --major` moves OpenCode 1 to 2 and removes 1.

## Gemini CLI also lives in npx

If you only ever ran `npx @google/gemini-cli`, there is no global package to remove. Google's guide says to clear the npx cache instead:

```powershell
Remove-Item -Path (Join-Path $env:LocalAppData "npm-cache\_npx") -Recurse -Force
```

That folder is npx's whole cache, so other tools you ran through npx download again next time. Google's [uninstall page](https://www.geminicli.com/docs/resources/uninstall) also says Gemini CLI was replaced by Antigravity CLI on June 18, 2026 for unpaid-tier and Google One users. If you have Antigravity, its [Windows guide](/windows/tested-apps/antigravity) explains why `%USERPROFILE%\.gemini` is shared with Gemini CLI.

## What stays behind, and what to keep

The commands above leave your data folders alone. These are the locations each vendor documents, with the Windows form of `~`:

| Tool | Where it keeps data on Windows | What deleting it loses |
| --- | --- | --- |
| Claude Code | `%USERPROFILE%\.claude` and `%USERPROFILE%\.claude.json` | Settings, allowed tools, MCP servers, session transcripts and prompt history; the [login file](https://code.claude.com/docs/en/authentication#credential-management) `.credentials.json` is inside `.claude` |
| Codex CLI | `%USERPROFILE%\.codex` (`C:\Users\<name>\.codex`), or `CODEX_HOME` | `sessions` and `archived_sessions` transcripts, config, and `auth.json` when login is stored as a file |
| Gemini CLI | `~/.gemini`, which is `%USERPROFILE%\.gemini`; the docs name `settings.json` | Your user settings; Google's pages do not say where its login is cached |
| OpenCode 1 | `%USERPROFILE%\.local\share\opencode`, `%USERPROFILE%\.config\opencode`, `%USERPROFILE%\.cache\opencode` | The share folder holds `auth.json` (keys and tokens), `opencode.db` (projects, sessions, messages) and `snapshot`; the desktop app also uses `%APPDATA%\ai.opencode.desktop` |

The sources are Claude Code's [`.claude` directory guide](https://code.claude.com/docs/en/claude-directory), the [Codex sandbox page](https://learn.chatgpt.com/docs/windows/windows-sandbox) and [authentication guide](https://learn.chatgpt.com/docs/auth), the [Gemini CLI settings page](https://www.geminicli.com/docs/cli/settings/) and the [OpenCode 1 troubleshooting page](https://opencode.ai/v1/docs/troubleshooting/). OpenCode 2's docs list no Windows paths; `opencode debug paths` prints the data, config, cache and state paths it actually uses. Claude Code's `CLAUDE_CONFIG_DIR` and Codex's `CODEX_HOME` move these folders, so check them before assuming the defaults.

What to keep:

- Sessions and history, if you might want to resume or search an old conversation. They are ordinary local files, so copy the folder somewhere you can read before you delete anything.
- Settings and MCP configuration, which are tedious to rebuild.
- API keys. A key you set yourself lives in your environment variables or a password manager, not in the program folder, and an uninstall does not revoke it. Sign out first if you want the tool's own login cleared: `claude auth logout` for Claude Code, `codex logout` for Codex, which shares its login with the editor extension.
- Project files. `CLAUDE.md`, `AGENTS.md`, `.claude`, `.mcp.json` and `.gemini` inside a repository belong to that project and may be shared with a team. Removing a tool never needs them deleted.

To measure before you decide, this is read-only:

```powershell
Get-ChildItem "$env:USERPROFILE\.claude", "$env:USERPROFILE\.codex" -Recurse -File -ErrorAction SilentlyContinue |
  Measure-Object Length -Sum
```

For a smaller step than deleting everything, Claude Code has `claude purge <path> --dry-run` to preview deleting the state for one project. If you do reset the data, quit every client that shares it (the VS Code extension, the JetBrains plugin and the desktop app also write to `~/.claude`) and delete the folders in File Explorer, so the Recycle Bin still holds them. PowerShell's `Remove-Item -Recurse` skips it.

## Check the result

Open a new terminal, since a terminal reads PATH when it starts, and run these read-only commands:

```powershell
Get-Command claude, codex, gemini, opencode -All -ErrorAction SilentlyContinue
npm ls -g --depth=0
winget list --id Anthropic.ClaudeCode
Test-Path "$env:USERPROFILE\.claude"
Test-Path "$env:USERPROFILE\.codex"
```

- A path from Get-Command is another installation or an alias, so go back to the table above for that path.
- No output only means this shell cannot resolve the name, not that every folder is gone.
- `Test-Path` returning `True` for `.claude` or `.codex` is expected if you kept your data.

## What Mole for Windows does here

Mole does not remove npm or native-installer command-line tools, and it has no npm integration. Two things do touch this area.

The Clean tab has a section called AI Tools that lists caches only, selected by default, and for these tools the rows are Claude Code Cache (`%USERPROFILE%\.claude\cache`), Codex CLI Cache (`.codex\cache`, which keeps `session_index.jsonl` and `codex_app_directory`), Codex Temp (folders in `.codex\.tmp` that sat unused for a week, keeping `marketplaces`) and OpenCode Cache (`.cache\opencode`). Codex CLI Cache and OpenCode Cache are held while `codex` or `opencode` is running, and Claude Code Cache and Codex Temp are judged by the files that are open. There is no Gemini CLI row. Mole's guard refuses Claude Code's `projects`, `file-history` and `history.jsonl` and Codex's `sessions`, `archived_sessions` and `history.jsonl` outright, so cleaning caches cannot reach your transcripts, and Mole has no leftover rule for `.claude`, `.codex` or `.gemini` after an uninstall.

In Mole's test of the winget package, Codex showed up under Apps and its program folder was removed. That run never signed in, so no `.codex` data existed to check. For the desktop app, [Claude Desktop](/windows/tested-apps/claude) has its own guide.

## FAQ

### How do I uninstall Claude Code on Windows?

Match the installation first. For npm, run `npm uninstall -g @anthropic-ai/claude-code`; for winget, `winget uninstall Anthropic.ClaudeCode`; for the native installer, delete `%USERPROFILE%\.local\bin\claude.exe` and `%USERPROFILE%\.local\share\claude`. Your settings and history in `%USERPROFILE%\.claude` stay until you delete them.

### Why does claude, codex or gemini still run after I uninstalled it?

A second installation answers to the same name, such as an npm copy next to a winget copy. Run `Get-Command <name> -All` in a new terminal and remove the one that path belongs to.

### Does uninstalling delete my chat history?

No. These uninstall commands remove the program only. History is in `.claude`, `.codex` and the OpenCode data folder, and it is lost only when you delete those folders, so copy them first if you want to keep it.

### How do I uninstall OpenCode on Windows?

For OpenCode 1 installed with Scoop, Chocolatey or npm, use that package manager's uninstall. OpenCode 2 has `opencode uninstall --dry-run` to preview and `opencode uninstall` to remove, and neither removes your sessions or configuration.


Canonical: https://mole.fit/windows/blog/uninstall-claude-code-codex-windows
