AgentKit
DocsKitsCLI ReferenceDesktop App

CLI Reference

ak logout

Remove the local AgentKit CLI session and renewable API-key credential without deleting the App device session.

Use ak logout before handing off a machine, after rotating a credential, or when you need the next registry operation to require a fresh CLI login.

Usage

ak logout

The documented command has no positional arguments or command-specific flags. The current implementation ignores extra positional tokens; do not rely on that behavior. Shared output flags are covered by CLI conventions.

Before you run

This command removes only the CLI authentication slot. It preserves a paid App device session stored beside it. If your goal is to remove a device activation from the account, ak logout is not that operation.

The command has no prompt, preview, dry-run, or force mode. --yes and --no-interactive do not change its behavior.

Effects

AgentKit atomically takes the CLI slot, including the sign-in kept for secrets sync, from ~/.agentkit/auth/session.json and removes the sibling stored API-key file. AGENTKIT_HOME changes the base directory. A missing CLI session is treated as success, so the command is safe to repeat.

For each removed session that is renewable, meaning an email OTP session or an API-key device session holding a refresh credential, AgentKit attempts remote revocation only after local secrets are removed. Registry failure is best-effort and does not restore the local login.

A plain API-key login and a license-key activation do not use this remote revocation path. The App slot created by license-key activation remains on disk.

Output and streams

Human success output is written to stdout:

[OK] logged out

JSON success is one envelope on stdout:

{"schema_version":1,"kind":"auth.logout","data":{"success":true}}

Local storage errors use stderr; JSON mode emits the shared error envelope. Remote revocation failure is intentionally not reported as command failure. With --json enabled, unknown or invalid flags use the shared JSON stderr error envelope (error_code: validation_failed, exit 2). Human mode, including --json=false, prints Usage.

Exit status

ExitMeaningSafe next step
0The CLI slot is absent after the command, including when it was already absent; remote revocation of a renewable session may still have failed.Run ak whoami to confirm the locally resolved state.
1The auth store could not be read, locked, rewritten, or cleared.Retry once, then inspect permissions with ak doctor; do not delete the whole AgentKit home.
2A flag could not be parsed.Correct the invocation.

If exit 1 occurs after a partial local clear, run ak logout again. The operation does not create a backup and has no rollback; recovery is a fresh ak login.