Run

Stoobly Main CLI Commands - Questions & Answers

The main CLI provides core commands for running the Stoobly agent, initializing contexts, and performing quick record/mock operations without starting the full proxy server.


Getting Started

Q: How do I check the Stoobly agent version?

A: Use the --version flag to display the installed version.

Example:

stoobly-agent --version

Q: How do I get help for any command?

A: Use --help or -h after any command to see detailed usage information.

Example:

# Main help
stoobly-agent --help

# Command-specific help
stoobly-agent run --help
stoobly-agent record --help
stoobly-agent mock --help

Initializing Stoobly

Q: How do I initialize a new Stoobly context?

A: Use the init command to create a new .stoobly directory with necessary configuration files.

Example:

Q: What does init create?

A: The init command creates the .stoobly directory structure including database, configuration files, and necessary subdirectories.

Example:

Q: When should I run init?

A: Run init when setting up Stoobly in a new project directory or when you want to create a fresh Stoobly context.

Example:


Running the Agent

Q: How do I start Stoobly with both proxy and UI?

A: Use the run command without any flags to start both the proxy server and web UI.

Example:

Q: How do I run Stoobly in headless mode (proxy only)?

A: Use the --headless flag to disable the UI and run only the proxy.

Example:

Q: How do I run Stoobly without the proxy (UI only)?

A: Use the --proxyless flag to run only the web UI.

Example:

Q: How do I run Stoobly on custom ports?

A: Use --proxy-port and --ui-port to specify custom ports.

Example:

Q: How do I run Stoobly on a specific host/interface?

A: Use --proxy-host and --ui-host to bind to specific network interfaces.

Example:

Q: How do I run Stoobly in detached/background mode?

A: Use the --detached flag with a file path to redirect output and run in the background.

Example:

Q: How do I enable intercept mode on startup?

A: Use the --intercept flag to activate interception immediately.

Example:

Q: How do I set the intercept mode on startup?

A: Use the --intercept-mode option with one of: mock, record, replay, test.

Example:


Logging and Debugging

Q: How do I increase logging verbosity?

A: Use the --log-level option to control log output detail.

Example:

Q: How do I control proxy flow detail output?

A: Use the --flow-detail option with levels 0-4.

Example:

Q: How do I enable request logging?

A: Use the --request-log-enable flag to log all intercepted requests.

Example:

Q: How do I view the intercepted requests log?

A: Use the request log list command while the agent is running or after.

Example:


SSL/TLS Configuration

Q: How do I specify a custom CA certificates directory?

A: Use the --ca-certs-dir-path option to set the CA certificate location.

Example:

Q: How do I use custom SSL certificates?

A: Use the --certs option to provide custom certificate files.

Example:

Q: How do I provide a passphrase for encrypted certificates?

A: Use the --cert-passphrase option (note: visible in process list, prefer config file).

Example:

Q: How do I disable SSL certificate verification?

A: Use the --ssl-insecure flag to skip upstream SSL verification (use with caution).

Example:


Proxy Modes

Q: What proxy modes are available?

A: Stoobly supports regular, transparent, socks5, reverse, and upstream proxy modes.

Example:

Q: How do I set up a reverse proxy?

A: Use the reverse proxy mode with the target host specification.

Example:

Q: How do I use an upstream proxy?

A: Use the upstream proxy mode to chain through another proxy.

Example:


Lifecycle Hooks

Q: How do I use lifecycle hooks with the agent?

A: Use the --lifecycle-hooks-path option to specify a Python script with custom hooks.

Example:


Mocking and Response Fixtures

Q: How do I use response fixtures for mocking?

A: Use the --response-fixtures-path option to provide YAML files with mock responses.

Example:

Q: How do I serve static files for mocking?

A: Use the --public-directory-path option to serve files from a directory.

Example:

Q: How do I specify origin for fixtures and public directories?

A: Use the format <PATH>:<ORIGIN> to match specific origins.

Example:


Header Modification

Q: How do I modify request headers?

A: Use the --modify-headers option with header modification patterns.

Example:


Quick Record Command

Q: How do I quickly record a single request without starting the agent?

A: Use the record command to make a request and store it.

Example:

Q: How do I record a request to a scenario?

A: Use the --scenario-key option to add the recorded request to a scenario.

Example:

Q: How do I save recorded response to a file?

A: Use the -o or --output option to write the response.

Example:

Q: How do I format the recorded response output?

A: Use the --format option to control output format.

Example:

Q: How do I record requests with lifecycle hooks?

A: Use the --lifecycle-hooks-path option with the record command.

Example:


Quick Mock Command

Q: How do I quickly mock a request without starting the agent?

A: Use the mock command to replay a previously recorded request.

Example:

Q: How do I mock with custom headers?

A: Use the -H flag to add custom headers to the mock request.

Example:

Q: How do I mock a POST request?

A: Use -X POST and -d for the request body.

Example:

Q: How do I mock with response fixtures?

A: Use the --response-fixtures-path option to provide mock data.

Example:

Q: How do I mock with public directory files?

A: Use the --public-directory-path option to serve static files.

Example:

Q: How do I save mocked response to a file?

A: Use the -o option to write the response to a file.

Example:


Connection Strategy

Q: What connection strategies are available?

A: Stoobly supports eager and lazy connection strategies for handling upstream connections.

Example:


Complete Examples

Q: How do I set up a complete development environment?

A: Initialize, install CA cert, start agent with intercept mode.

Example:

Q: How do I run Stoobly for API mocking in tests?

A: Start in headless mode with mock mode and fixtures.

Example:

Q: How do I run Stoobly in CI/CD?

A: Use headless, detached mode with specific configuration.

Example:


Environment Variables

Q: How do I enable latency simulation for mocked responses?

A: Set the AGENT_SIMULATE_LATENCY environment variable to enable latency simulation. When enabled, Stoobly will simulate the expected response latency based on the X-Stoobly-Response-Latency header value in milliseconds.

Example:

How it works:

  • The latency simulation calculates wait time as: expected_latency - estimated_rtt_network_latency - api_latency

  • expected_latency comes from the X-Stoobly-Response-Latency response header (in milliseconds)

  • estimated_rtt_network_latency is fixed at 15ms

  • api_latency is the time elapsed since the request started

  • If the calculated wait time is positive, Stoobly will sleep for that duration before returning the response

Use cases:

  • Testing how your application handles slow API responses

  • Simulating real-world network conditions during development

  • Validating timeout and retry logic

Note: This feature only works in mock mode and requires the X-Stoobly-Response-Latency header to be present in the mocked response.


Troubleshooting

Q: How do I debug connection issues?

A: Increase log level and flow detail for verbose output.

Example:

Q: How do I verify the agent is running?

A: Check the proxy and UI ports.

Example:

Q: What do I do if ports are already in use?

A: Use custom ports to avoid conflicts.

Example:


Quick Reference

Q: What are the essential commands?

A: Here's a quick reference of the most common commands:

Example:

Last updated

Was this helpful?