# 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="/pages/7J10qWFxe9zweKA3YQtH" %}
[How to Run a Workflow](/guides/how-to-integrate-e2e-testing/how-to-run-a-workflow.md)
{% endcontent-ref %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.stoobly.com/guides/how-to-record-requests/recording-from-the-cli.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
