# LLM Commands

Manage LLM projects and chat sessions.

## Commands


```bash
tdx llm projects [pattern]          # List projects
tdx llm project list [pattern]      # Same as projects
tdx llm agents [pattern]            # List agents (alias for tdx agent list)
```

Agent Commands
Agent management commands have moved to `tdx agent`. See [Agent Commands](/treasure-code/commands/agent) for:

- `tdx agent list` - List agents
- `tdx agent show` - Show agent details
- `tdx agent create` - Create a new agent
- `tdx agent update` - Update an existing agent
- `tdx agent delete` - Delete an agent


## Project Management

### Set Project Context


```bash
# Set current project context (session-only)
tdx llm use "MyProject"

# Now all agent commands use "MyProject" by default
tdx agent list
tdx agent show "Data Analyst"
```

### Set Default Agent for Chat

Set a default agent for chat operations using `tdx use agent`, so you don't need to specify `--agent` each time:


```bash
# Set default agent (use "Project/Agent" format)
tdx use agent "MyProject/My Agent"

# Now new chats use this agent by default
tdx chat --new "Your question here"
tdx chat "Another question"  # Continues the chat

# Override with --agent for a specific new chat
tdx chat --new "Question" --agent "OtherProject/OtherAgent"
```

The default agent preference is:

- Stored in session context (same as `tdx use database`, etc.)
- Used automatically by `tdx chat --new` when no `--agent` flag is specified
- Overridden by explicit `--agent` flag


### List and Create Projects


```bash
# List available models
tdx llm models

# List all projects
tdx llm projects

# List projects matching pattern
tdx llm projects "data*"
tdx llm projects "*_prod"

# Create a new project
tdx llm project create "MyProject" --description "Data analysis project"

# Delete a project
tdx llm project delete "OldProject"
```

### Backup and Restore Projects (Deprecated)

DEPRECATED
The `backup` and `restore` commands are deprecated. Use the new `tdx agent` commands instead:

- `tdx agent pull` - Export project to Git-friendly YAML/Markdown format
- `tdx agent push` - Import local files to project
- `tdx agent clone` - Clone a project to a new project


See [Agent Commands](/treasure-code/commands/agent) for full documentation.

details
summary
Legacy backup/restore commands (click to expand)
Backup an entire LLM project to a folder, including all agents, knowledge bases, prompts, and integrations:


```bash
# Backup project to default folder ({project_name}.llm)
tdx llm project backup "MyProject"

# Backup to custom folder
tdx llm project backup "MyProject" -o ./backups/myproject

# Preview what would be backed up (dry-run)
tdx llm project backup "MyProject" --dry-run

# Overwrite existing backup without confirmation
tdx llm project backup "MyProject" -y
```

Restore a project from a backup:


```bash
# Restore project with original name
tdx llm project restore ./MyProject.llm

# Restore with a new name
tdx llm project restore ./MyProject.llm --name "MyProject-restored"

# Preview what would be restored (dry-run)
tdx llm project restore ./MyProject.llm --dry-run

# Skip confirmation if project exists
tdx llm project restore ./MyProject.llm -y
```

Backup Contents
The backup folder contains:

- `project.json` - Project metadata and backup info
- `agents.json` - All agents with full configuration
- `knowledgebases.json` - All knowledge bases
- `prompts.json` - All prompts
- `integrations.json` - All integrations


## Agent Management

Agent commands have moved to `tdx agent`. See [Agent Commands](/treasure-code/commands/agent) for full documentation.


```bash
# List agents (alias kept for convenience)
tdx llm agents

# Or use the new commands
tdx agent list
tdx agent show "My Agent"
tdx agent create "New Agent"
tdx agent update "My Agent" --prompt "..."
tdx agent delete "Old Agent"
```

## Chat History


```bash
# List recent chat sessions
tdx llm history

# Show specific chat messages
tdx llm history chat456
```

## Project Resolution

Agent commands resolve projects in this order:

1. `--llm-project` global option (highest priority)
2. `tdx llm use <project>` context (session-only)
3. Default project `tdx_default_<username>` (auto-created)


## Claude Code Integration

See [tdx claude](/treasure-code/commands/claude) for launching Claude Code with TD LLM backend.

## Options Reference

### Backup Options (Deprecated)

| Option | Description | Default |
|  --- | --- | --- |
| `-o, --output <folder>` | Output folder | {project_name}.llm |
| `--dry-run` | Preview without creating files | false |
| `-y, --yes` | Skip confirmation prompt | false |


### Restore Options (Deprecated)

| Option | Description | Default |
|  --- | --- | --- |
| `--name <text>` | New project name | Original name from backup |
| `--dry-run` | Preview without making changes | false |
| `-y, --yes` | Skip confirmation prompt | false |