Skip to content
#

Qwen Code

Save Qwen Code sessions with the SpecStory CLI.

#

Before you start

Install Qwen Code and the SpecStory CLI. Qwen Code needs SpecStory CLI 2.12.0 or later, and sessions created with Qwen Code 0.23.4 or later. Sessions from earlier Qwen Code versions may work but are not officially supported. Open your project folder in a terminal and run specstory check qwen.

#

Run with SpecStory

specstory run qwen

Use Qwen Code as usual. SpecStory saves the conversation in .specstory/history/. Cloud sync can run when you are logged in; add --no-cloud-sync to keep the session local.

#

Export existing sessions

specstory list qwen
specstory sync qwen

# Export a single session
specstory sync qwen -s <session-id>

SpecStory reads Qwen Code's session history from ~/.qwen/projects/<sanitized-cwd>/chats/<session-id>.jsonl. You can export conversations even if you did not start them through SpecStory. Qwen Code derives the project directory name from your working directory, replacing non-alphanumeric characters with hyphens. SpecStory also checks the workspace recorded inside each session, so run these commands from the project where you used Qwen Code. Sessions in Qwen's .qwen/worktrees/ layout belong to their parent project.

If you set QWEN_RUNTIME_DIR or QWEN_HOME, set the same variables for SpecStory so it reads the same sessions. QWEN_RUNTIME_DIR takes precedence over QWEN_HOME; SpecStory looks under projects/ within the selected directory.

Exports preserve the recorded conversation in chronological order, including turns recorded before a rewind or compaction. They do not represent only Qwen's active branch. Archived sessions and sessions containing only system records or slash commands are not exported.

#

Capture in the background

specstory watch qwen

Leave this running while using Qwen Code directly. Stop watching with Ctrl+C.

#

Find and resume a session

Run specstory search to find saved work or specstory resume to choose a previous session. Qwen Code continues one of its own sessions in place with qwen --resume <session-id>, and can receive a session from another agent as reconstructed conversation text. Use specstory resume qwen to choose Qwen Code as the target, or select another supported agent to continue a Qwen session there. See search and resume for the picker and supported handoffs.

#

Troubleshooting

If Qwen Code is not detected, check that qwen is on your PATH and that qwen --version succeeds. If your CLI does not list Qwen in specstory run --help, update SpecStory. To launch Qwen Code from another location, set qwen_cmd in your config or pass specstory run qwen -c "/absolute/path/to/qwen"; use an absolute path, because the command setting does not expand a quoted ~.

If no sessions appear, run the commands from the project where you used Qwen Code, use the same QWEN_RUNTIME_DIR or QWEN_HOME values, and confirm that its local history still exists. Start a conversation with a user prompt: opening Qwen Code or running only slash commands does not create an exportable conversation.

See the CLI reference for custom commands, configuration, and debug logging.