> ## Documentation Index
> Fetch the complete documentation index at: https://docs.qoder.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Session Management

<div id="overview">
  # Overview
</div>

Every time you run Qoder CLI, it creates a **session** that records the complete history of the conversation—your inputs, Qoder's responses, and tool calls. Sessions can be continued, resumed, named, branched, and cleared, allowing you to flexibly switch between different tasks and pick up where you left off after an interruption.

Sessions are isolated and stored per project. Each session has a unique session ID, and session logs are saved in project-organized directories under the User Configuration Directory (default `~/.qoder/projects/<项目>/<session-id>.jsonl`).

<div id="new-session">
  # New Session
</div>

Running `qodercli` directly in the project root directory starts a new session, and the system automatically generates a session ID:

```shell theme={null}
qodercli
```

In an interactive session, use `/new` to start a brand new session; `/clear` clears the Conversation History and also starts a new session, both achieving similar results.

## Naming Sessions

Use `-n` (`--name`) to set an easily recognizable display name for a session:

```shell theme={null}
qodercli -n "Refactor login"
```

You can also use `/rename` to rename the current session from within the session.

## Specifying a Session ID

Use `--session-id` to specify a session ID, making it easy for scripts or automated workflows to reference a fixed session:

```shell theme={null}
qodercli --session-id 00000000-0000-0000-0000-000000000000
```

<div id="continue-resume">
  # Continue and Resume
</div>

## Continuing the Most Recent Session

Use `-c` (`--continue`) to directly continue the most recent session for the current project:

```shell theme={null}
qodercli -c
```

## Resuming a Specific Session

Use `-r` (`--resume`) to resume a previous session by its ID:

```shell theme={null}
qodercli -r <session-id>
```

Running `qodercli --resume` without an ID opens the Session Browser, allowing you to select the session to resume from a list. In an interactive session, the `/resume` command also opens the Session Browser; `/continue` continues the most recent session.

<div id="fork">
  # Forking Sessions
</div>

Use `--fork-session` to fork a resumed session into a new branch instead of continuing the original session. This allows you to explore different directions from a historical point while keeping the original session intact:

```shell theme={null}
qodercli -r <session-id> --fork-session
```

In an interactive session, you can also use `/branch` to create a branch from the current session.

<div id="export">
  # Exporting Sessions
</div>

Use `/export` to export the current conversation to a file or copy it to the clipboard for sharing, archiving, or further analysis elsewhere:

```shell theme={null}
/export
```

<div id="list-delete">
  # Listing and Deleting
</div>

Use `--list-sessions` to list currently available sessions:

```shell theme={null}
qodercli --list-sessions
```

Use `--delete-session` to delete a session by its list index:

```shell theme={null}
qodercli --delete-session <index>
```

<div id="storage">
  # Session Storage Location
</div>

Session logs are isolated by project and saved under the User Configuration Directory:

```text theme={null}
~/.qoder/projects/<processed-project-path-name>/<session-id>.jsonl
~/.qoder/projects/<processed-project-path-name>/<session-id>/state.json
```

Within this directory, `.jsonl` stores the conversation logs, and `state.json` stores the session state. The User Configuration Directory defaults to `~/.qoder` and can be customized via the `QODER_CONFIG_DIR` Environment Variable.

<div id="command-summary">
  # Commands and Arguments Quick Reference
</div>

| Command / Argument         | Description                                                               |
| :------------------------- | :------------------------------------------------------------------------ |
| `qodercli`                 | Create a new session                                                      |
| `-c, --continue`           | Continue the most recent session                                          |
| `-r, --resume [id]`        | Resume a specific session; opens the Session Browser if no ID is provided |
| `-n, --name <name>`        | Set the session display name                                              |
| `--session-id <id>`        | Use a specified session ID                                                |
| `--fork-session`           | Create a branch from a resumed session                                    |
| `--list-sessions`          | List available sessions                                                   |
| `--delete-session <index>` | Delete a session by index                                                 |
| `/new`                     | Start a new session within a session                                      |
| `/clear`                   | Clear the Conversation History and start a new session                    |
| `/rename`                  | Rename the current session                                                |
| `/branch`                  | Create a branch from the current session                                  |
| `/resume`, `/continue`     | Resume / continue a session                                               |
| `/export`                  | Export the current conversation                                           |
