There appears to be no way to non-interactively get a list of chat ids from the CLI. This command:
cursor-agent --print --output-format json ls
Ignores the headless arguments and goes into an interactive list of chats.
Steps to Reproduce
Run
cursor-agent --print --output-format json ls
The result is not headless, its an interactive chat list.
Expected Behavior
Since --print and --output-format are listed as global parameters, I’d expect them to work will all subcommands, including ls.
Operating System
Linux
Version Information
About Cursor CLI
CLI Version 2026.01.28-fd13201
Model Claude 4.5 Opus (Thinking)
OS linux (x64)
Terminal unknown
Shell bash
User Email [email protected]
Hey, thanks for the report. Looks like this is a real gap: the ls subcommand doesn’t support the global --print and --output-format flags right now, even though the docs say they work with any command.
I’ve passed this along to the team.
Unfortunately, there isn’t a workaround at the moment to list chat IDs in a non-interactive way. agent resume and agent --resume <chatId> do work, but you either need to already know the session ID or run them in interactive mode.
If it helps at all, here’s a really stupid hacky shell script to get this from ~/.cursor
#!/bin/bash
echo '{"type": "ls","chats":{'
for DB in `find $HOME/.cursor/chats -name store.db`
do
DIR=`dirname $DB`
ID=`basename $DIR`
PROMPT=`sqlite3 -ascii $DB "select data from blobs limit 1" 2> /dev/null | sed 's/^[0-9]//' | sed 's/..\$.*//'`
PROMPT="${PROMPT#"${PROMPT%%[![:space:]]*}"}"
PROMPT="${PROMPT#"${PROMPT##*[![:space:]]}"}"
if [ ! -z "$PROMPT" ]
then
WORKSPACE=`sqlite3 -ascii $DB "select data from blobs limit 1 offset 1;" | sed 's/\\\\n/\n/g' | grep "^Workspace Path: " | sed 's/^Workspace Path://'`
echo "\"$ID\":{\"workspace\":\"$WORKSPACE\",\"prompt\":\"$PROMPT\"},"
fi
done
echo "}"