Config

Stoobly Config CLI - Questions & Answers

The config CLI manages Stoobly configuration including proxy settings, scenarios, rewrite rules, match rules, firewall rules, and project settings. It allows runtime configuration of the agent without editing files directly.


Understanding Configuration

Q: What is Stoobly configuration?

A: Configuration controls how Stoobly intercepts, modifies, and routes HTTP requests. It includes rewrite rules for transforming requests, match rules for identifying requests, and firewall rules for filtering traffic.

Example:

# View current configuration
stoobly-agent config dump

# View configuration directory
stoobly-agent config dump --dir

Q: Where is configuration stored?

A: Configuration is stored in the .stoobly directory, typically in ~/.stoobly/settings.yml or your project's .stoobly/settings.yml.

Example:

# View config directory location
stoobly-agent config dump --dir
# Output: /home/user/.stoobly

# View full configuration
stoobly-agent config dump

Viewing and Managing Configuration

Q: How do I view the current configuration?

A: Use config dump to display all configuration settings.

Example:

Q: How do I save configuration to a file?

A: Use the --save-to-file flag to export configuration.

Example:

Q: How do I reset configuration to defaults?

A: Use config reset to restore default settings.

Example:

Q: How do I validate my configuration?

A: Use config validate to check for configuration errors.

Example:


Managing Active Scenario

Q: How do I set the active scenario?

A: Use config scenario set with the scenario key to make it active for intercept operations.

Example:

Q: How do I view the currently active scenario?

A: Use config scenario show to display active scenario details.

Example:

Q: How do I clear the active scenario?

A: Use config scenario clear to remove the active scenario setting.

Example:

Q: Why would I set an active scenario?

A: Setting an active scenario directs all intercepted requests to that scenario automatically, useful for organizing recorded requests during development.

Example:


Rewrite Rules

Q: What are rewrite rules?

A: Rewrite rules transform HTTP requests in flight, allowing you to modify URLs, headers, query parameters, or body parameters before they're sent or matched.

Example:

Q: How do I create a rewrite rule to change the hostname?

A: Use config rewrite set with --hostname option.

Example:

Q: How do I create a rewrite rule to change the URL path?

A: Use the --path option to specify the new path.

Example:

Q: How do I create a rewrite rule to change the scheme?

A: Use the --scheme option to switch between http and https.

Example:

Q: How do I create a rewrite rule to change the port?

A: Use the --port option to specify a different port.

Example:

Q: How do I rewrite request headers?

A: Use --type header with --name and --value options.

Example:

Q: How do I rewrite query parameters?

A: Use --type query_param with parameter name and value.

Example:

Q: How do I rewrite body parameters?

A: Use --type body_param for POST/PUT request body parameters.

Example:

Q: How do I rewrite response headers?

A: Use --type response_header to modify response headers.

Example:

Q: How do I rewrite response parameters?

A: Use --type response_param to modify response body parameters.

Example:

Q: How do I apply rewrite rules to specific modes?

A: Use multiple --mode options to specify which intercept modes the rule applies to.

Example:

Q: How do I create rewrite rules for specific HTTP methods?

A: Use multiple --method options to target specific methods.

Example:


Match Rules

Q: What are match rules?

A: Match rules determine which request components (headers, query params, body params) are used to match requests to recorded responses during mocking or testing.

Example:

Q: How do I create a match rule to ignore certain components?

A: Specify only the components you want to match; unspecified components are ignored.

Example:

Q: How do I match by query parameters?

A: Use --component query_param to include query parameters in matching.

Example:

Q: How do I match by headers?

A: Use --component header to include headers in matching.

Example:

Q: How do I match by body parameters?

A: Use --component body_param for POST/PUT request body matching.

Example:

Q: How do I match by multiple components?

A: Use multiple --component options to combine matching criteria.

Example:


Firewall Rules

Q: What are firewall rules?

A: Firewall rules filter which requests are intercepted, allowing you to include or exclude specific URLs, methods, or patterns.

Example:

Q: How do I exclude requests from interception?

A: Use --action exclude with a pattern to filter out requests.

Example:

Q: How do I include only specific requests?

A: Use --action include with a pattern to whitelist requests.

Example:

Q: How do I filter by HTTP method?

A: Use multiple --method options to target specific methods.

Example:

Q: How do I apply firewall rules to specific modes?

A: Use multiple --mode options to control which intercept modes are affected.

Example:


Project Management (Remote Features)

Q: How do I set the active project?

A: Use config project set with the project key (requires remote features).

Example:

Q: How do I view the current project?

A: Use config project show to display active project details.

Example:

Q: How do I switch to local project mode?

A: Use config project local to use local storage instead of remote.

Example:

Q: How do I set my API key for remote features?

A: Use config api-key set with your API key.

Example:


Configuration Workflows

Q: How do I set up environment-specific rewrite rules?

A: Create rewrite rules that redirect production URLs to local or staging environments.

Example:

Q: How do I configure request filtering for testing?

A: Combine firewall and match rules to control which requests are tested.

Example:

Q: How do I mock with modified authentication?

A: Use rewrite rules to replace authentication tokens in mock mode.

Example:


Advanced Configuration

Q: How do I create rules for specific projects?

A: Use the --project-key option to scope rules to a specific project.

Example:

Q: How do I configure rules for microservices?

A: Create separate rules for each service endpoint.

Example:


Troubleshooting

Q: How do I debug configuration issues?

A: Dump configuration and validate it.

Example:

Q: How do I reset a specific configuration section?

A: Currently, you can only reset all configuration. To reset specific sections, edit the config file manually or use reset and reconfigure.

Example:

Q: How do I check if my rewrite rules are working?

A: Use increased logging and flow detail to see rule application.

Example:


Quick Reference

Q: What are the most common config commands?

A: Here's a quick reference of frequently used commands:

Example:


Best Practices

Q: How should I organize my configuration?

A: Use specific patterns for different services and environments.

Example:

Q: When should I use firewall rules vs match rules?

A: Use firewall rules to filter what gets intercepted, match rules to control how requests are matched to responses.

Example:

Last updated

Was this helpful?