What this is for
The macOS.pkg installs the agent in managed mode: Claude Code’s enterprise
managed-settings.json is pointed at a local tap, so every session on the machine is metered and
policy is applied. Managed settings override user and project settings, which is what makes the
policy enforceable — and it means the wiring outlives the agent.
That matters when removing it. If the tap stops while the settings still point at it, every Claude
Code session on the machine dials a port nothing answers.
Claude Code stopped working — fix it first
If Claude Code hangs or fails to reach the API after an agent change, run this. It un-wires Claude Code and leaves the agent installed:gw-cli itself is gone or won’t run, the standalone uninstaller does the same thing and needs
no Guardway tooling:
These three are the same fix at decreasing levels of tooling. The last one always works, because
it depends on nothing but the file being there.
Full uninstall
sudo. From agent 0.2.217, it also hands the
machine’s console credential back before the data goes, so
Fleet shows the machine as Uninstalled.
Un-wire Claude Code and stop there. The agent stays installed and running. Use this when Claude
Code is broken but you are not trying to remove the product.
Keep scan history, logs, and the data directories. The console credential is kept too: Fleet does
not show the machine as Uninstalled, and a reinstall over the kept data reports again without
enrolling.
Leave org policy controls (skill lockdown, permissions, sandbox) in the harness settings. Note
that this can leave Claude Code restricted to the organisation’s sanctioned skill list after the
agent is gone — the command tells you when it does.
gw-cli uninstall is a thin wrapper — it runs /usr/local/bin/guardway-uninstall, which is
installed by the .pkg. Both accept the same flags and behave identically. The script is
deliberately standalone (plain bash, no Rust, no network) so it still works when the agent is
already broken or removed.Restart open Claude Code sessions
Claude Code reads these settings at launch. Sessions already running when you make the change keep the old configuration, and a stranded session hangs rather than reporting an error — so nothing on screen explains it. The uninstaller lists them for you:--repair the behaviour differs: because the agent is
left running, those sessions keep working for now and fail the next time the tap stops — a
reboot, an upgrade, or a later uninstall. Restart them when convenient rather than urgently.
What the uninstaller guarantees
A failed uninstall must never take Claude Code down. The order is fixed and enforced:1
Un-wire Claude Code — first, before anything is stopped
Removes the base URL, the telemetry export, the policy hooks, and org policy controls from
every tier: managed settings, each user’s
~/.claude, VS Code, and Cursor. Values Guardway did
not write are left alone; a file it empties is deleted.2
Verify from disk
Re-reads the files and confirms nothing remains. If verification fails, the run stops here
and removes nothing else — the tap is left running, Claude Code keeps working, and the
console credential is kept, so the machine keeps reporting. Exit code
2.3
Stop services
Boots out the tap daemon and the menu-bar app, then removes their launchd entries.
4
Remove the app, data, logs and package receipt
Before the data goes, the console credential is handed back (not with
--keep-data). If the
machine cannot reach Guardway, the removal goes ahead and the credential is not handed back.
Timestamped backups of every settings file it edited are kept (the three most recent per file).5
Remove the binaries — last
gw-cli and the uninstaller are the recovery tools right up until the moment they are provably
no longer needed.Recovery notes on the machine
A managed install leaves a plain-text file next to the settings it writes:Linux and Windows
gw-cli uninstall runs the same ordered teardown on Linux and Windows, inside the agent itself.
From agent 0.2.219 the order is: un-wire, verify, stop, hand the console credential back,
remove. Agents 0.2.217 and 0.2.218 hand the credential back before they verify. The flags above
work the same way, and exit code 2 means the same thing. Run it with sudo on Linux (as the user,
without sudo, for an earlier per-user archive install in ~/.local/bin) and from an elevated
PowerShell on Windows.
What Fleet shows after a removal
A removal that hands the console credential back makes Fleet show the machine as Uninstalled under Status, and the machine is not counted as Offline. Its Credential in the machine panel shows Uninstalled too (see Credential status). With agent 0.2.219 and later:
What the status does next depends on whether the agent still runs:
--keep-datastops the agent. Its Credential stays Own device credential, then shows Expired once the refresh window lapses.--repairand a package upgrade leave the agent running and reporting. Its Credential stays Own device credential.msiexec /x … KEEPDATA=1leaves Guardway’s scheduled tasks in place. Where one of them starts the agent, as in the managed mode, the agent starts again at the next boot or sign-in fromC:\ProgramData\Guardway\binand keeps reporting. Its Credential stays Own device credential, while Apps & features no longer lists Guardway. Where only theRunentries start it, its Credential shows Own device credential, then Expired.
- A removal while the machine cannot reach Guardway. The agent is removed anyway. From agent 0.2.219, a removal on Linux or Windows waits at most 20 seconds for an answer.
- A Linux package removal when the agent has not run in the last hour. The removal does not renew an expired access token, so it sends nothing.
- Older agents. Up to 0.2.218, a Linux package removal never hands the credential back; from
0.2.217 a manual
sudo gw-cli uninstalldoes. Agents up to 0.2.216 never hand it back, on any OS. - A machine on Shared org key or Revoked. It has no credential it can hand back, so it keeps that status.
--keep-data or KEEPDATA=1
once its agent no longer runs, keeps showing Online until it has not reported for 7 days, then
shows Offline.
A refused uninstall stops and removes nothing. When the uninstaller cannot verify that Claude
Code is un-wired, it exits with 2 before anything is stopped or removed. It may already have
un-wired some AI tools and given held skills back. The credential is kept and the machine keeps
reporting, except with agents 0.2.217 and 0.2.218 on Linux and Windows, which hand it back before the
check. Fix the file it names and run it again. On Windows the MSI’s own
removal cannot stop there: see
Windows → When the un-wire check fails.
Reinstalling
Which case below applies depends on the install mode. Check it on the machine before you remove the agent, withgw-cli hook --installed-mode (it prints managed, observe or none): a package can
install either mode.
Same record. The machine-wide service of a managed install takes its machine ID from the
hardware. Installed and enrolled again, it comes back on its old Fleet record, with its history, and
its Credential goes from Uninstalled back to Own device credential. No console action
is needed.
Enroll again. A removal that hands the credential back leaves nothing on the machine that can
report. Enroll each agent again, as the first time (Activate),
unless your deployment tool runs the enroll step after the install. On Linux this applies even after
apt remove, which keeps the data: the released credential is taken out of the kept configuration.
Enroll the machine, and have each person who enrolled their own agent enroll it again, as that user.
A new record instead. These reinstalls show up in Fleet as a new machine, and the old record keeps
its status until you remove it:
- An observe install’s agent after a removal that deleted its data. Each user’s agent keeps a random
ID in its data folder, and the removal deletes it. A Linux package removal keeps each user’s
~/.guardway, so those agents come back on their own records. - A machine whose removal did not hand the credential back, when the reinstall does not reuse the
kept data: for example after
apt purge, or after a full removal with no network. - A machine first installed with an agent older than 0.2.217, after its first removal that deleted its data. Its ID was random until then. Later reinstalls keep their record.
--keep-data, KEEPDATA=1), a reinstall over the kept data reports again
on the same record, without enrolling.
History on the old record. When a reinstall with agent 0.2.219 or later comes back on its old
record, the agent does not send again the AI activity the console already holds for it, so that
activity is not counted twice. With agents 0.2.217 and 0.2.218, the new install’s AI activity can
instead be missing from that record for a while.
Related
- CLI Reference — every command and flag
- Overview — install and first run