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

# When to Use the CLI

> Command line for automation and scripting

# When to Use the CLI

The command line interface is ideal for automation and reproducible workflows.

## Best For

* **Automation** - Script repetitive tasks
* **CI/CD pipelines** - Integrate with deployment
* **Remote servers** - SSH into cloud instances
* **Batch processing** - Train multiple models
* **Reproducibility** - Save and share exact commands

## What It Looks Like

Type commands in your terminal:

```bash theme={null}
aitraining text-classification \
  --model bert-base-uncased \
  --data train.csv \
  --epochs 5
```

## Workflow Example

```bash theme={null}
# Prepare data
python prepare_data.py

# Train model
aitraining train \
  --task text-classification \
  --data data/train.csv \
  --output models/v1

# Evaluate
aitraining evaluate \
  --model models/v1 \
  --test data/test.csv

# Deploy
aitraining serve --model models/v1
```

## Advantages

* **Scriptable** - Automate everything
* **Reproducible** - Save exact commands
* **Version control** - Track in git
* **Remote friendly** - Works over SSH
* **Parallel execution** - Run multiple trainings

## Limitations

* **Learning curve** - Must know command syntax
* **No visual feedback** - Text output only
* **Error prone** - Typos in commands
* **Less discoverable** - Must know options exist

## When to Switch

Move to UI when you:

* Need visual feedback
* Want to explore options
* Teaching non-technical users
* Doing quick experiments

Move to API when you:

* Need custom logic
* Building applications
* Complex preprocessing
* Dynamic configuration

## Common Use Cases

### Hyperparameter Search

```bash theme={null}
for lr in 1e-5 2e-5 5e-5; do
  aitraining train \
    --learning-rate $lr \
    --output models/lr_$lr
done
```

### Nightly Training

```bash theme={null}
# In cron or scheduler
0 2 * * * /path/to/retrain.sh
```

### Remote Training

```bash theme={null}
ssh gpu-server
screen -S training
aitraining train --data s3://bucket/data.csv
# Detach with Ctrl-A D
```

### CI/CD Integration

```yaml theme={null}
# .github/workflows/train.yml
- name: Train model
  run: aitraining train --config config.yaml
```

## Tips for CLI Users

1. **Save commands** - Keep a `commands.txt` file
2. **Use configs** - YAML files over long commands
3. **Log output** - Redirect to files
4. **Use screen/tmux** - For long-running jobs
5. **Write scripts** - Combine multiple steps

## CLI-Exclusive Features

Things the CLI does best:

* Pipe data from other commands
* Integrate with shell scripts
* Run on headless servers
* Batch process files
* Scheduled execution

## Essential Commands

```bash theme={null}
# See all options
aitraining --help

# List available models
aitraining models list

# Check training status
aitraining status

# Resume interrupted training
aitraining train --resume

# Convert model formats
aitraining convert --from pytorch --to onnx
```

## Environment Variables

```bash theme={null}
# Set defaults
export AITRAINING_MODEL=bert-base
export AITRAINING_EPOCHS=5

# Now simpler commands
aitraining train --data train.csv
```

## Next Steps

<CardGroup cols={2}>
  <Card title="CLI Reference" href="/cli/command-structure">
    Full command documentation
  </Card>

  <Card title="API Alternative" href="/foundations/api-when-to-use">
    When to use Python instead
  </Card>
</CardGroup>
