Skip to main content

Overview

The --session-id option allows you to specify a custom identifier for your Qwen Code session. This makes it easier to organize, track, and resume specific conversations, especially for long-running projects or specific features.

Syntax

Basic Usage

Create Named Session

This creates a session with ID feature-authentication instead of a random UUID.

Resume Named Session

Much easier than remembering a1b2c3d4-e5f6-7890-abcd-ef1234567890!

Benefits

Easy Identification

Organized Workflows

Team Collaboration

CI/CD Integration

Naming Conventions

By Feature

By Bug Number

By Task

By Date

By Project Phase

Use Cases

Feature Development

Bug Fixing

Code Reviews

Learning Sessions

Session Validation

Valid Session IDs

✅ Alphanumeric characters: feature-auth
✅ Hyphens: fix-bug-123
✅ Underscores: feature_oauth
✅ UUIDs: a1b2c3d4-e5f6-7890-abcd-ef1234567890

Invalid Session IDs

❌ Spaces: feature auth (use feature-auth)
❌ Special chars: feature@auth (use feature-auth)
❌ Empty string: "" (must provide ID)

Validation Rules

Combining with Other Options

With Prompts

With YOLO Mode

With Models

With Output Format

Session Persistence

Sessions with custom IDs are stored in:

List Your Sessions

Session Metadata

Automation Examples

CI/CD Build Session

Daily Standup

Feature Tracking

Test Session

Best Practices

Make session IDs self-explanatory:
Be consistent across your team:
Balance brevity with clarity:
Add relevant context to IDs:

Session ID vs Resume

Use —session-id When:

Creating a new session with a specific name
You know the name you want to use
Organizing work by feature or task
CI/CD and automation

Use —resume When:

Continuing existing session
Don’t remember the exact ID
Want to browse available sessions

Example Workflow

Troubleshooting

Session ID Already Exists

If you use an existing session ID:
To start fresh:

Invalid Session ID Format

Solution:

Can’t Find Custom Session

If you can’t find your named session:

Advanced Usage

Dynamic Session IDs

Session Templates

Session Namespaces

See Also

--resume Option

Resume previous sessions

--continue Option

Continue most recent session

Session Management

Complete guide to sessions

Workflow Organization

Organizing your AI workflow