Skip to main content
Switching between projects can break your workflow, especially when each one has its own codebase and issue history. This recipe shows how to use Persistent Contexts and Session Management to switch between projects instantly and in an organized way.

The Problem

You work on two projects: Project A (a Go API) and Project B (a React frontend). One moment you are debugging a bug in the API; the next, you need to implement a new feature in the frontend. Keeping the conversation history and file context separate for each is a challenge.

Ingredients

  • Two or more project directories on your machine.

The Workflow

The strategy is to create a Context for each project’s codebase and a Session for each task’s conversation history.
1

Create Persistent Contexts for Each Project

First, let’s create “snapshots” of the codebases. We will do this once for each project.Navigate to the Project A folder:
/context create project-a-api ./cmd ./internal --mode smart --description "Main Go API for Project A" --tags go,api
Now, navigate to the Project B folder:
/context create project-b-frontend ./src --mode chunked --description "React frontend for Project B" --tags react,frontend
What did we do? We created two persistent contexts. Now, ChatCLI “knows” the structure of these two projects and we can refer to them by name (project-a-api, project-b-frontend) at any time, from anywhere on your system.
2

Start Working on Project A

Let’s begin debugging the bug in the API.
  1. Load (or create) a conversation session:
    /session load debug-api-project-a
    
    (If the session does not exist, it will be created when you save.)
  2. Attach the project context:
    /context attach project-a-api
    
Now, your prompt will indicate that the session and context are active. You can start asking questions about the API code, and ChatCLI will automatically send the relevant files to the AI.
debug-api-project-a > Where is the JWT validation logic?
3

Switch to Project B

Your lead asks you to pause the debug and work on a new feature in the frontend.
  1. Save the current session: All your debug history will be preserved.
    /session save debug-api-project-a
    
  2. Detach the old context:
    /context detach project-a-api
    
  3. Load the session and context for Project B:
    /session load feature-frontend-project-b
    /context attach project-b-frontend
    
Done! In seconds, you have completely switched environments. Your conversation history is now about the frontend feature, and the AI has all of Project B’s code as context.
feature-frontend-project-b > Create a new React component called 'UserProfile' that displays name and email.
4

Returning to Project A

Frontend task completed? Going back to the API debug is just as simple.
/session save feature-frontend-project-b
/context detach project-b-frontend
/session load debug-api-project-a
/context attach project-a-api
Result: You created a workflow where you can switch between complex projects in seconds, preserving both your conversation history and the complete codebase context, without ever needing to resend a single file manually.