Command reference ยท Cursor CLI
agent logout
Signs the CLI out of your Cursor account and clears locally stored credentials.
agent logout is a top-level command from the CLI reference and signs the current CLI installation out of the Cursor account ("Sign out and clear stored authentication"). Afterward, the locally stored credentials are removed, and another agent login is required for the next use. The official docs don't specify in detail how the credentials are technically stored โ the authentication reference only states that credentials are "securely stored locally" after login, without naming a keychain or a specific storage variable. For scripts and CI environments, authentication can alternatively be provided entirely without an interactive login via the CURSOR_API_KEY environment variable or the --api-key <key> flag, which usually makes a logout unnecessary there.
โ WHEN TO USE IT?
Switching accounts on a shared machine
Run agent logout, then start agent login with the other account
Clean wrap-up before this machine's credentials are no longer used
Run agent logout on a machine that will no longer be used for this Cursor account
โ WHEN NOT TO?
Just briefly checking auth status, not logging out
agent logout immediately deletes the stored credentials for this installation.
Better: Use agent status or agent whoami to just see the status
Automated scripts/CI should run without an interactive login state
A logout removes the interactive session entirely, which is unnecessary for one-off, non-interactive calls.
Better: Set CURSOR_API_KEY or pass --api-key <key> per call, instead of logging in/out interactively
SOURCES
- Cursor Docs โ CLI Reference: Parameters โ cursor.com