Switch Directories Mid-Session Using /cd Command
Switch project folders mid-session without losing your AI context.
Use the /cd command to change your working directory within a single AI session to maintain context while moving between different parts of a project.
The Scenario
While debugging a full-stack app, you finish working on the backend and need to immediately apply similar logic to the frontend directory without starting a new chat.
Before & after
You would have to exit the AI CLI, navigate folders in your terminal, and restart a new AI session from scratch, losing your current conversation context. This takes 2-3 minutes.
Type /cd followed by the path to switch instantly; the AI will auto-migrate session files and refresh the directory context in seconds. This takes about 5 seconds.
The Prompt
/cd [NEW_DIRECTORY_PATH] Now that we've switched, can you apply the same logic from the previous file to the main.py in this folder?
This command is particularly useful in multi-module projects where you need to move between frontend and backend directories without breaking the 'thought' flow of the AI.
Source
Qwen Code Blog: AI Coding Updates and Guides | Qwen Code Docs"/cd switches the current session’s working directory without exiting the CLI, session files auto-migrate to the new workspace."
