AgentKit
DocsKitsCLI ReferenceDesktop App

ak kit

ak kit uninstall

Preview or remove one kit's owned runtime output while preserving user and sibling state.

Use ak kit uninstall to plan or apply removal of one installed Kit. The command classifies installed paths from lifecycle evidence, removes clean AgentKit-owned state, and preserves user-modified, unknown, and sibling-owned content.

Syntax

ak kit uninstall <kit-name>

<kit-name> is required and must be an installable Kit ID.

Before you run

Uninstall is local and does not contact the registry or require authentication or entitlement. It reads install manifests, ownership indexes, runtime settings, and provider state for the selected route. This includes lifecycle evidence for Grok routes; cleanup removes recorded local output and does not validate the current registry package or provider login state.

The command is a preview unless --yes is present. It does not open an interactive confirmation prompt.

--json, --no-interactive, and a TTY do not authorize deletion. Only --yes applies the plan. --dry-run always keeps the command in preview mode.

Arguments

<kit-name> is the single installed Kit ID whose selected route will be planned or removed. It is required; the command does not prompt for a Kit.

The command has no alias.

Options

OptionDefaultEffect
--dry-runfalseShow the removal plan without changing installed files.
-g, --globalfalseSelect user/global native lifecycle roots.
--kits-dir <dir>EmptySupply a local source for legacy fallback classification when recorded manifests are unavailable.
--plugin-modefalseSelect Claude Code plugin delivery instead of native routes.
--project-dir <dir>EmptySelect a project-native route, or a project plugin when combined with --plugin-mode.

Shared flags are documented in CLI conventions.

Select the exact scope and mode

SelectorRoute
No scope or mode flagsThe project-native lifecycle roots of the working directory when that project holds a native install of the Kit, the same scope ak kit install used. Otherwise broad user-scope cleanup: the recognized user plugin/legacy roots and registered global native lifecycle roots for the Kit.
--globalRegistered user/global native lifecycle roots.
--global --plugin-modeOnly the Claude Code user plugin.
--project-dir <dir>Project-native lifecycle roots for the selected project.
--plugin-modeClaude Code project plugin in the current directory.
--plugin-mode --project-dir <dir>Claude Code project plugin in the specified project.

With no scope flag, a working directory whose project route is the user-level install, such as your home directory, keeps the user scope. After a removal from the detected project, a warning names any install of the Kit that remains in the user scope and the command that removes it.

--global cannot be combined with --project-dir. Project and user state are independent; a project-plugin uninstall does not authorize user-plugin or native cleanup.

A project route is refused with exit 6 when it resolves to the user-level install, for example --project-dir set to your home directory, or a project .claude that is your user Claude Code home. Native project uninstall checks every project runtime, and project plugin mode checks Claude Code. The check runs before any plan, lock, snapshot, or removal, so --dry-run is refused too. Use --global to remove the user-level install.

uninstall has no --target flag. A recorded Grok native route is selected through the same project or user lifecycle roots: use --project-dir <dir> for a project route or --global for registered user/global native roots.

Examples

# Preview the default plan: this project's native install when it holds one,
# otherwise the broad user-scope plan.
ak kit uninstall engineer --dry-run

# Apply the reviewed default plan.
ak kit uninstall engineer --yes

# Remove only the Claude user plugin.
ak kit uninstall engineer --global --plugin-mode --yes

# Preview one project-native route as JSON.
ak kit uninstall engineer --project-dir ./app --json

# Remove recorded project-native output, including a local Grok route.
ak kit uninstall engineer --project-dir . --yes

# Remove one project plugin.
ak kit uninstall engineer --plugin-mode --project-dir ./app --yes

Preview, apply, and decline semantics

If --yes is absent, the command computes and renders the full plan, changes no owned surface, then exits 3. --dry-run does the same even when --yes is also present. This exit is a completed preview, not a failed classification.

When the selected scope holds no file, config entry, or plugin registration of the Kit, the result says not installed in the <scope> scope instead of reporting a removal. A warning names each other scope that holds the Kit and the exact ak kit uninstall ... --yes command for it. A preview then exits 3 with nothing to remove in the <scope> scope.

An applied uninstall holds the Kit lifecycle lock from planning through mutation. A dry-run is lock-free because it does not change owned surfaces.

Output and streams

Human output goes to stdout. It reports dry-run or uninstalled, counts for delete, preserve, and skip, warnings, and every actionable recovery snapshot.

With --json, stdout contains a versioned envelope with kind=kit.uninstall. Its data includes:

kit, dryRun, scope, scopeDetected, nothingToRemove, installedElsewhere
pluginDir, pluginDirs
snapshotId, snapshotIds, recovery
removedPaths, removedDiagnosticPaths, preservedPaths, skippedPaths, configPaths
deactivationSteps, warnings, manifestResult
deleted, preserved, skipped, success

scope is the scope the run planned: project, project-plugin, global, or global-plugin. scopeDetected is true when the project scope was chosen because the working directory holds the Kit and no scope flag was set. nothingToRemove is true when the plan found nothing of the Kit in that scope. installedElsewhere lists other scopes that hold the Kit, each with scope, path, and command.

A successful preview has data.success=true and data.dryRun=true, then the process exits 3. Mutation failures in JSON mode write an error envelope to stderr with optional recovery.snapshots. Flag-parse errors (exit 2) also get the envelope.

Exit status

ExitMeaning
0The reviewed uninstall plan was applied successfully.
1Invalid Kit or route, unreadable or unsafe ownership state, snapshot failure, provider/config failure, mutation failure, or refused automatic rollback.
2Cobra rejected flags or arguments.
3Preview completed because --yes was absent or --dry-run was set.
4Another Kit lifecycle mutation holds the lock.
6The project route resolves to the user-level install; use --global.

Effects and ownership safety

Depending on the selected route, an applied uninstall can remove clean owned runtime files and lifecycle metadata, deactivate a Claude plugin, update shared runtime settings, remove Kit-owned Codex registrations, and clean recorded manifest state.

Classification is anchored on install-time paths and hashes, not on a rebuilt current Kit source:

  • A recorded path whose bytes still match can be removed.
  • A recorded path changed by the user is preserved.
  • Unknown files are preserved.
  • The Kit's own Hook diagnostic logs (hooks/.logs/hook-log.jsonl and its lock file inside the Kit's plugin or extension directory) are removed after the snapshot, because the Kit's Hooks wrote them at runtime. They are listed in removedDiagnosticPaths, not removedPaths.
  • Shared files and entries owned by another Kit or the user are preserved.
  • Unsafe symlinks, changed mutation boundaries, corrupt ownership evidence, and ambiguous shared state fail closed.
  • A project uninstall keeps paths outside the project that no declared root covers, paths reached through a link, and files of a nested project install, and reports them as preserved.
  • If another Kit is committed to the project's Claude Code files but has not been initialized on this machine, the shared .claude files stay, with a warning that names ak kit init <kit> --yes.
  • If the project was moved or copied, the preview says that ownership records still name the old location and keeps those files; a confirmed run first re-keys the records onto this project, snapshotting the original indexes.
  • A Kit rules section in a shared AGENTS.md (the dsh $DSH_HOME/AGENTS.md block, or the OpenCode or project omp AGENTS.md section) that you edited, or that is malformed or unfinished, stays with the Kit's ownership index. After you restore or remove your edit, run the same uninstall again: it strips only that section, returns the rest of the file to its pre-install bytes, and removes the index.

After removing tracked native files, uninstall also tries to remove their empty parent directories within the selected cleanup roots. Directories that still contain files or subdirectories stay, and cleanup skips links.

For global Codex Hooks, ownership evidence created by installation participates in rollback. Last-owner cleanup can remove AgentKit-emptied groups, events, and the outer hooks wrapper instead of leaving empty owned structures. Pre-existing empty structures, foreign fields, user Hooks, and sibling-owned entries remain preserved; this does not authorize deleting arbitrary shared Hook content.

Kit Hooks write diagnostics to hooks/.logs/hook-log.jsonl and hook-log.lock beside the Hook logger they run from. In a native install that Hooks directory is shared, for example .claude/hooks or .codex/hooks, so the logs stay while any other Kit still owns the shared logger there. The uninstall that removes the last logger lists the two log files in removedPaths, snapshots them, removes them, and prunes the emptied .logs directory. Other files in .logs and linked log paths are preserved.

A flagless plan that stays on the user scope can span several user-scope providers. Always inspect removedPaths, configPaths, and preservedPaths before adding --yes.

Recovery and limitations

Before applied writes, AgentKit creates snapshots for affected roots and exact shared provider files. Output supplies ak backups verify, a bounded restore command, or a manual recovery path for snapshots outside normal restore scope.

ak backups verify <id>
ak backups show <id>

Rollback guards concurrent changes and may refuse a destructive automatic restore when it cannot prove the live postimage. Keep reported recovery data and inspect state manually in that case. Snapshots are not full-machine backups, and multi-file operations are not guaranteed to be transactional across process termination.