# Debugging tools

> What Cloak Proxy's debugging tools do, how to open the Tools window, turn each tool on or off, and see which tools are active and which requests they changed.

Source: https://docs.subcloak.com/cloak-proxy/tools/overview/

Debugging tools change traffic while it passes through Cloak Proxy. You can pause a request and edit it, answer it from a local file, send it to another server, change its headers and bodies without code or with JavaScript, slow it down, block it, or replay recorded responses offline. Use them to test how your app handles errors, edge cases and bad networks without changing the app or the server.

## The tools

Cloak Proxy has twelve tools. Each one has its own rules and its own on/off switch.

| Tool | What it does | Default |
|---|---|---|
| [Breakpoint](https://docs.subcloak.com/cloak-proxy/tools/breakpoint/) | Pauses matching requests or responses so you can edit them before they continue. | On |
| [Map Local](https://docs.subcloak.com/cloak-proxy/tools/map-local/) | Answers matching requests with a local file, folder, or a response you write. The server is never contacted. | On |
| [Map Remote](https://docs.subcloak.com/cloak-proxy/tools/map-remote/) | Sends matching requests to a different scheme, host, port, path or query, such as staging instead of production, or `/v1/*` to a local server keeping the rest of the path ([Swap the prefix](https://docs.subcloak.com/cloak-proxy/tools/map-remote/#swap-the-prefix)). | On |
| [Rewrite](https://docs.subcloak.com/cloak-proxy/tools/rewrite/) (added in Cloak Proxy 0.2.0) | Changes headers, query parameters, the URL, body text or the status of matching requests and responses, without writing a script. | On |
| [Scripting](https://docs.subcloak.com/cloak-proxy/tools/scripting/) | Changes requests and responses with JavaScript: `onRequest` and `onResponse`. | On |
| [Block List](https://docs.subcloak.com/cloak-proxy/tools/block-list/) | Blocks matching requests with a 403 or by dropping the connection. | On |
| [Allow List](https://docs.subcloak.com/cloak-proxy/tools/allow-list/) | Only records matching requests. Everything else still works but isn't shown. | Off |
| [Network Conditions](https://docs.subcloak.com/cloak-proxy/tools/network-conditions/) | Slows matching requests down to test 3G, high latency or packet loss. | Off |
| [DNS Spoofing](https://docs.subcloak.com/cloak-proxy/tools/dns-spoofing/) | Connects a host name to a different IP address while keeping the URL and Host header. | On |
| [No Caching](https://docs.subcloak.com/cloak-proxy/tools/no-caching/) | Strips caching headers so every request reaches the server with fresh data. | Off |
| [Mock Sets](https://docs.subcloak.com/cloak-proxy/tools/mock-sets/) | Replays recorded responses without the network, so you can demo, test or debug an app offline. | On |
| [Alerts](https://docs.subcloak.com/cloak-proxy/tools/alerts/) | Posts a macOS notification when matching traffic fails, slows down or returns something specific. | On |

A tool only does something when it's on **and** has at least one enabled rule. No Caching has no rules: turning it on applies it to every request.

(added in Cloak Proxy 0.4.0) **Failure scenarios** (**Tools › Failure Scenarios…**, <kbd>⌥</kbd> <kbd>⌘</kbd> <kbd>F</kbd>) have their own window: named groups of faults, such as a timeout or a reset connection, switched on and off together, with a log of what each did. See [Failure scenarios](https://docs.subcloak.com/cloak-proxy/tools/failure-scenarios/).

> **Which traffic tools can change:**
> Tools work on HTTP requests that Cloak Proxy can read: plain HTTP, and HTTPS to hosts or apps with [SSL Proxying](https://docs.subcloak.com/cloak-proxy/capture/ssl-proxying/) on. Encrypted tunnels Cloak Proxy doesn't decrypt, and WebSocket messages, pass through untouched. DNS Spoofing is the exception: it applies to every connection Cloak Proxy makes, including tunnels and WebSockets.

## Open the Tools window

All rules live in the **Debugging Tools** window.

1. Choose **Tools › Debugging Tools…** or press <kbd>⌥</kbd> <kbd>⌘</kbd> <kbd>0</kbd>.

   You can also click **Tools** (the wrench) in the main window's toolbar and choose **Debugging Tools…**.

2. Pick a tool in the sidebar on the left.

3. Add a rule with the **+** button at the bottom of the rule list, or with **Add Rule** when the list is empty.

4. Fill in the rule on the right. Changes apply right away; there's no Save button.

Seven tools also have their own shortcut in the **Tools** menu, which opens the window on that tool:

| Menu item | Shortcut |
|---|---|
| **Edit Breakpoint Rules…** | <kbd>⌥</kbd> <kbd>⌘</kbd> <kbd>B</kbd> |
| **Edit Map Local Rules…** | <kbd>⌥</kbd> <kbd>⌘</kbd> <kbd>L</kbd> |
| **Edit Map Remote Rules…** | <kbd>⌥</kbd> <kbd>⌘</kbd> <kbd>M</kbd> |
| **Edit Rewrite Rules…** (added in Cloak Proxy 0.2.0) | <kbd>⌥</kbd> <kbd>⌘</kbd> <kbd>R</kbd> |
| **Edit Scripting Rules…** | <kbd>⌥</kbd> <kbd>⌘</kbd> <kbd>S</kbd> |
| **Edit Block List Rules…** | <kbd>⌥</kbd> <kbd>⌘</kbd> <kbd>K</kbd> |
| **Edit Network Conditions Rules…** | <kbd>⌥</kbd> <kbd>⌘</kbd> <kbd>T</kbd> |

The other tools have **Edit … Rules…** items in the same menu without a shortcut.

> **On Linux:**
> The Tools window opens from the toolbar's wrench, or <kbd>Ctrl</kbd> <kbd>Alt</kbd> <kbd>0</kbd>. The seven tools with shortcuts use digits, because <kbd>Ctrl</kbd> <kbd>Alt</kbd> <kbd>T</kbd> and <kbd>Ctrl</kbd> <kbd>Alt</kbd> <kbd>L</kbd> belong to the desktop: Breakpoint <kbd>1</kbd>, Map Local <kbd>2</kbd>, Map Remote <kbd>3</kbd>, Rewrite <kbd>4</kbd>, Scripting <kbd>5</kbd>, Block List <kbd>6</kbd>, Network Conditions <kbd>7</kbd>, each with <kbd>Ctrl</kbd> <kbd>Alt</kbd>.

*[Screenshot: The Debugging Tools window with the Breakpoint tool selected, one rule for GET api.example.com/v1/users, and the rule editor on the right. The Debugging Tools window: tools on the left, rules in the middle, the selected rule's editor on the right.]*

### Window layout

| Area | What it shows |
|---|---|
| Sidebar (**Debugging Tools**) | Every tool with its icon, the number of rules it has, and a green (on) or gray (off) dot. Below the tools, **Rule Sets** (added in Cloak Proxy 0.4.0) lists your [rule sets](https://docs.subcloak.com/cloak-proxy/tools/folders-and-sets/#rule-sets). |
| Header | The tool's name, a one-line summary of what it does, and the **On**/**Off** switch. |
| Rule list | Each rule's checkbox, name (or **Untitled**) and, under it, the method and URL it matches (or **No URL yet**). Right-click a rule for **Duplicate** and **Delete**. |
| Rule list buttons | **+** adds a rule, **−** deletes the selected rule, and the third button duplicates it. (added in Cloak Proxy 0.4.0) The fourth adds a [folder](https://docs.subcloak.com/cloak-proxy/tools/folders-and-sets/), and the eye at the right hides rules that are off. Rules run top to bottom; drag to reorder. |
| Editor | The selected rule's settings. Every rule starts with a **Rule** section: a name and a [matcher](https://docs.subcloak.com/cloak-proxy/tools/rules-and-matching/). |

DNS Spoofing uses a table instead of a rule list, No Caching has only its switch, and Mock Sets lists recorded sets instead of rules. Their pages explain the differences.

(added in Cloak Proxy 0.4.0) Rules can be grouped in [folders](https://docs.subcloak.com/cloak-proxy/tools/folders-and-sets/), and the sidebar's **Rule Sets** switch groups of folders across tools. The bottom bar's tools popover has a **Rule set** picker. Any rule can also have [conditions](https://docs.subcloak.com/cloak-proxy/tools/conditions-and-graphql/) on headers, body values or GraphQL operations.

> **Tip:**
> A new rule has an empty URL and matches nothing until you fill it in. That makes it safe to add rules while traffic is flowing.

## Turn tools on and off

Each tool has one switch that turns all its rules on or off at once. Its rules stay saved while it's off. You can flip the switch in several places:

- The **On**/**Off** switch in the tool's header in the Tools window.
- **Tools** menu: a checkmark item for every tool.
- The **Tools** toolbar button in the main window: the same list of toggles.
- The **N tools on** button in the main window's bottom bar: a popover with a switch for every tool. (added in Cloak Proxy 0.2.2)
- [Search Everything](https://docs.subcloak.com/cloak-proxy/inspect/search-and-command-palette/) (<kbd>⇧</kbd> <kbd>⌘</kbd> <kbd>A</kbd>): type the tool's name and choose **Turn On …** or **Turn Off …**.

To pause a single rule, clear its checkbox in the rule list. A disabled rule is dimmed.

Rules and switches are saved and come back the next time you open Cloak Proxy.

> **Turn tools off when you're done:**
> Rules keep working after you close the Tools window, and after you restart the app. A forgotten Map Local, Block List or Network Conditions rule can make a real app behave strangely later. Check the **N tools on** button in the bottom bar before you move on.

## See which tools are on

(added in Cloak Proxy 0.2.2)

The bottom bar of the main window has one button for every debugging tool: **N tools on** counts the tools whose switch is on, in your accent color, or reads **No tools on** in gray.

- Hover it to see the tools that are on and have at least one enabled rule (and **No Caching** while it's on).
- Click it for the **Debugging tools** popover: every tool with its icon, its name and an on/off switch. Click a tool's name to open its rules in the Tools window, or **Edit Rules…** to open the Tools window.

While a request or response is paused at a breakpoint, the bottom bar also shows an orange **N paused at breakpoint** button that opens the Breakpoint window.

## See which tools changed a request

When a tool touches a request, the [traffic list](https://docs.subcloak.com/cloak-proxy/inspect/traffic-list/) shows a colored badge before its path, with the tools separated by dots, for example `Script · Map Remote`. The labels are:

| Badge | Added when |
|---|---|
| `Block List` | A Block List rule answered or dropped the request. |
| `Rewrite` (added in Cloak Proxy 0.2.0) | A Rewrite rule changed the request or its response. |
| `Network Conditions` | A Network Conditions rule slowed or dropped it. |
| `Script` | At least one script ran on the request or response. |
| `Breakpoint` | The request or response paused at a breakpoint. |
| `Map Local` | Map Local answered the request. |
| `Mock` | A mock set answered it (with a recording or an offline 404). |
| `Map Remote` | Map Remote rewrote the URL. |
| `No Caching` | No Caching changed its headers. |
| `DNS Spoofing` | The host was connected to a spoofed address. |

The traffic list records the request as it was finally sent, after every change.

## Create rules from captured traffic

The quickest way to make a rule is from a request you already captured. Right-click a request in the traffic list and choose **Tools**, then a tool. Cloak Proxy creates a rule that matches that request, turns the tool on in most cases, and opens it in the Tools window. [Rules and matching](https://docs.subcloak.com/cloak-proxy/tools/rules-and-matching/#create-a-rule-from-a-request) lists what each tool's rule is prefilled with.

## Share rules and use them elsewhere

- **Tools › Export Rules…** saves your rules to a JSON file, and **Tools › Import Rules…** adds rules from one. See [Export and import rules](https://docs.subcloak.com/cloak-proxy/tools/rules-and-matching/#export-and-import-rules).
- [`cloakctl run --tools RULES.json`](https://docs.subcloak.com/cloak-proxy/automation/headless-and-ci/) loads an exported file for headless and CI runs.
- The [MCP server](https://docs.subcloak.com/cloak-proxy/automation/mcp-server/) lets an AI assistant read and change rules with tools such as `list_rules`, `upsert_rule`, `delete_rule`, `set_tool_enabled`, `rule_from_request`, `rule_folders`, `rule_sets` and `failure_scenarios`, and resolve breakpoints with `list_paused` and `resolve_paused`. See the [MCP tools reference](https://docs.subcloak.com/cloak-proxy/automation/mcp-tools-reference/).

## How tools work together

When several tools match one request, they run in a fixed order: Block List first, then Rewrite's request actions, then failure scenarios, then scripts and breakpoints, then Map Local, Mock Sets and Map Remote, then the server, then Rewrite's response actions, then response scripts and breakpoints. The full order, and what each step can skip, is in [Rule order and multiple tools](https://docs.subcloak.com/cloak-proxy/tools/rules-and-matching/#what-happens-when-several-tools-match).

## Related

  - [Rules and matching](https://docs.subcloak.com/cloak-proxy/tools/rules-and-matching/): Wildcards, regex, methods, subpaths, the URL tester and rule order.
  - [Breakpoint](https://docs.subcloak.com/cloak-proxy/tools/breakpoint/): Pause and edit requests and responses.
  - [Map Local](https://docs.subcloak.com/cloak-proxy/tools/map-local/): Answer requests from local files or inline responses.
  - [Mock a backend](https://docs.subcloak.com/cloak-proxy/guides/mock-a-backend/): A guide that combines Map Local, Scripting and Mock Sets.
