# Recording from the CLI

## Recording Requests

The basic method for recording requests uses the intercept commands directly:

### Command

```bash
stoobly-agent intercept set --mode record
stoobly-agent intercept enable
```

### Options

To see more options for the command:

```sh
$ stoobly-agent intercept set -h

```

```
Usage: stoobly-agent intercept set [OPTIONS]

  Configure intercept

Options:
  --mode [mock|record|replay]
  --policy [all|found]
  -h, --help                   Show this message and exit.
```

## Recording with Scaffold Workflows

When using Stoobly scaffold for E2E testing or multi-service setups, you can record requests using scaffold workflows. The approach differs based on your runtime:

### Docker Runtime

For Docker runtime, use Makefile commands to run the record workflow:

```bash
# Start the record workflow
make -f .stoobly/services/Makefile record

# Enable intercept to start recording
make -f .stoobly/services/Makefile intercept/enable

# Stop the workflow
make -f .stoobly/services/Makefile record/down
```

**Note:** With Docker runtime and E2E testing, your tests typically run automatically in the entrypoint container, and all HTTP requests are recorded.

### Local Runtime

For local runtime, use CLI commands directly:

```bash
# Start the record workflow
stoobly-agent scaffold workflow up record

# Enable intercept to start recording
stoobly-agent intercept enable

# In another terminal, configure your application to use the proxy
export HTTP_PROXY=http://localhost:8080
export HTTPS_PROXY=http://localhost:8080

# Run your application or tests
# Requests will be intercepted and recorded

# View recorded requests
stoobly-agent request list

# Stop the workflow
stoobly-agent scaffold workflow down record
```

**Note:** Make commands (e.g., `make -f .stoobly/services/Makefile record`) are Docker-specific only. Local runtime uses `stoobly-agent scaffold workflow up/down` commands directly.

### Additional Recording Options

You can configure recording behavior using intercept options:

```bash
# Record all requests (default)
stoobly-agent intercept set --mode record --policy all

# Record only new requests (skip already recorded ones)
stoobly-agent intercept set --mode record --policy not_found

# Record with full strategy (complete request/response data)
stoobly-agent intercept set --mode record --strategy full

# Overwrite existing recordings
stoobly-agent intercept set --mode record --order overwrite
```

For more details on scaffold workflows, see:

{% content-ref url="../how-to-integrate-e2e-testing/how-to-run-a-workflow" %}
[how-to-run-a-workflow](https://docs.stoobly.com/guides/how-to-integrate-e2e-testing/how-to-run-a-workflow)
{% endcontent-ref %}
