Debugging tools
Rules and matching
How debugging-tool rules pick requests by URL, method and app, the order rules and tools run in, and how to create, export and import rules as JSON.
Every debugging tool except No Caching and DNS Spoofing works with rules. A rule has a name, an on/off checkbox and a matcher that decides which requests it applies to. This page explains matchers, how to limit a rule to certain apps, the order rules and tools run in, and how to create rules from captured traffic and share them as JSON.
The matcher
Section titled “The matcher”Every rule editor starts with a Rule section: a name field and the matcher.
The matcher is the same in every tool: method, URL pattern, mode, subpaths and a live tester.
- Method: ANY or one HTTP method.
- URL pattern.
- Mode: Wildcard or Regex.
- Include subpaths (wildcard mode only).
- Test a URL: shows Matches or No match as you type.
| Field | Options | What it does |
|---|---|---|
| Name | Any text | Shown in the rule list, in the Breakpoint window, in alert notifications and in the script console. |
| Method | ANY, GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS | ANY matches every method. Any other choice matches only that method (case doesn’t matter). |
| URL | A pattern, for example https://api.example.com/v1/* |
The pattern to match. An empty URL matches nothing. |
| Mode | Wildcard (default), Regex | How the URL is read. |
| Include subpaths (/api also matches /api/…) | On (default for new rules) or off | Wildcard mode only. Also matches everything below the URL, at path boundaries: /api matches /api, /api/ and /api/…, not /apiv2. Since 0.6.1 Earlier versions added a trailing *, which also matched /apiv2. |
| Only these apps Since 0.2.0 | App names separated by commas, or empty (default) | Limits the rule to requests from those apps. Empty matches every app. See Limit a rule to apps. |
| Conditions Since 0.4.0 | None (default), or rows added with Add Condition | A header, query parameter, JSON body value, body text or GraphQL operation the request must also have. See Conditions and GraphQL operations. |
Matching is always case-insensitive. The URL a rule sees is the full request URL: scheme, host, a port when it isn’t the default (:443 for HTTPS, :80 for HTTP), path and query string.
Match with wildcards
Section titled “Match with wildcards”In Wildcard mode, the pattern must match the whole URL, and * stands for any run of characters, including / and ?. Every other character, including ? and ., is literal.
- Leave out the scheme to match both
httpandhttps. A pattern likeapi.example.com/v1/*is compared with the URL minus itshttp://orhttps://. - Include subpaths also matches longer paths and any query string, at path boundaries:
/apimatches/api,/api/,/api/…and/api?…, but not/apiv2,/api.jsonor/api-docs. A pattern that already ends in/or*, or has a query, takes anything after it. Since 0.6.1 Before 0.6.1 it added a*, so/apialso matched/apiv2. - Without subpaths, the query string is ignored: the pattern is compared with the URL up to the
?. If your pattern contains a?itself, the query is kept so you can match it.
| Pattern | Subpaths | Matches | Doesn’t match |
|---|---|---|---|
api.example.com/v1/* |
Either | https://api.example.com/v1/users, http://api.example.com/v1/users?page=2 |
https://api.example.com/v2/users |
https://api.example.com/v1/users |
Off | https://api.example.com/v1/users, https://api.example.com/v1/users?page=2 |
https://api.example.com/v1/users/42, http://api.example.com/v1/users |
https://api.example.com/v1/users |
On | https://api.example.com/v1/users/42, https://api.example.com/v1/users?page=2, and also https://api.example.com/v1/users-archive |
https://api.example.com/v1/teams |
https://api.example.com/v1/users/ |
On | https://api.example.com/v1/users/42 |
https://api.example.com/v1/users-archive |
*.example.com/* |
Either | https://cdn.example.com/app.js, https://staging.example.com/ |
https://example.com/ (no subdomain) |
api.example.com/search?q=* |
Off | https://api.example.com/search?q=shoes |
https://api.example.com/search |
localhost:3000/* |
Either | http://localhost:3000/api/users |
http://localhost:8080/api/users |
Match with a regular expression
Section titled “Match with a regular expression”In Regex mode, the pattern is a regular expression searched for anywhere in the full URL, case-insensitive. It isn’t anchored, so example matches any URL containing that word. Add ^ and $ to anchor it. Include subpaths is hidden in this mode.
| Pattern | Matches |
|---|---|
^https://api\.example\.com/v[12]/users |
Users endpoints in v1 and v2 of the API. |
/orders/\d+(\?.*)?$ |
A single order by numeric ID, with or without a query string. |
graphql |
Any URL containing graphql. |
^http:// |
Every plain-HTTP request. |
Escape dots (\.) when you mean a literal dot. A pattern that isn’t a valid regular expression matches nothing.
Test a pattern
Section titled “Test a pattern”Type a URL into the tester under the pattern, or click Captured and pick a captured request: the newest requests the pattern matches come first, then other recent ones. Since 0.5.1 The tester says:
- Matches, URL matches (the rule has conditions, which a typed URL can’t be checked against: pick a captured request to check them), or No match.
- Why not, for the first part that doesn’t fit: the method, the app, the scheme, the host, the path, Include subpaths being off, or the condition that stops a captured request.
- What the tool does with a match: the URL Map Remote sends it to, the file Map Local serves (or that the file isn’t there), the status Block List answers with, what the breakpoint pauses, or how many actions a Rewrite rule runs and the URL it makes.
- A hint for common surprises:
*.example.comdoesn’t coverexample.comitself; a*in the middle of a path also matches across/; a regular expression without^and$matches part of a URL.
A typed URL without a scheme is tested as https://. With a captured request, its method, app, headers and body are tested too, so conditions count. Up to 0.5.0, the tester checked a typed URL only, without the method or the apps.
The tester says why a URL doesn't match.
The test_rule MCP tool and cloakctl rules TOOL test run the same test for AI assistants and scripts.
Since 0.4.0 Above it, Matches N of M captured requests checks the whole rule (URL, method, apps and conditions) against the last 2,000 captured requests as you edit. Click Show Requests to select them in the traffic list.
Limit a rule to apps
Section titled “Limit a rule to apps”A rule normally applies to matching requests from every app. To apply it only to some apps, list them in the Only these apps (comma-separated; empty: every app) field under the URL pattern. Use it when several apps call the same API and you want to change only your own app’s traffic: a breakpoint that doesn’t stop Safari, a slow network for one app, or a Rewrite that adds a debug header only to your app.
-
Find the app’s name in the Apps section of the sidebar. That’s the name to type.
-
Open the rule in the Tools window and type the name into Only these apps, for example
MyApp. Separate several apps with commas:MyApp, Safari. -
Make a request from the app. Requests from other apps that match the URL are now left alone by this rule.
How app names are matched:
| Case | Result |
|---|---|
| The field is empty | The rule matches every app, as before. |
| Names | Compared with the whole app name, ignoring case and the spaces around each name. myapp matches MyApp; My doesn’t. |
| A request whose app Cloak Proxy couldn’t identify | Doesn’t match a rule that lists apps. These requests appear under All Traffic but not under Apps in the sidebar. |
| A device on your network | Its app name is its IP address, so 192.168.1.20 limits a rule to that phone or computer. |
| Repeat, Edit and Repeat and Compose | These requests come from Cloak Proxy (Repeat) or Cloak Proxy (Compose), so a rule limited to MyApp skips them. Add that name to the list to include them. |
The app list works in every tool that has a matcher: Breakpoint, Map Local, Map Remote, Rewrite, Scripting, Block List, Allow List, Network Conditions and Alerts. With the Allow List, a rule limited to MyApp records only that app’s matching requests. DNS Spoofing, Mock Sets and No Caching have no matcher, so they can’t be limited to an app. To narrow a rule further, by a header, a body value or a GraphQL operation, add conditions.
In exported JSON and in the MCP server, the list is the matcher’s apps field, for example "apps" : ["MyApp", "Safari"]. It’s left out when the field is empty.
Manage rules
Section titled “Manage rules”| To | Do this |
|---|---|
| Add a rule | Click + under the rule list, or Add Rule when the list is empty. |
| Delete a rule | Select it and click −, or right-click it and choose Delete. |
| Duplicate a rule | Select it and click the duplicate button, or right-click it and choose Duplicate. The copy gets “ copy” added to its name. |
| Turn one rule off | Clear its checkbox. The tool’s other rules keep working. |
| Turn the whole tool off | Use the On/Off switch in the tool’s header. Rules are kept. |
| Change the order | Drag rules up or down in the list. |
| Put rules in folders Since 0.4.0 | Click the new-folder button under the list, then drag rules in or right-click and choose Move to Folder. See Rule folders and sets. |
| Hide rules that are off Since 0.4.0 | Click the eye under the list. |
New rules start with an empty URL. Since 0.4.0 They take their name from what they match, such as POST api.example.com/v1/orders, and the name follows your edits until you type one of your own.
Rule order inside a tool
Section titled “Rule order inside a tool”Rules are checked from the top of the list to the bottom. Whether one rule or all matching rules apply depends on the tool:
| Tool | Which rules apply |
|---|---|
| Breakpoint | The first enabled rule that matches. Its Pause on settings decide whether the request, the response, or both pause. |
| Map Local | The first matching rule. If it’s a Directory rule with no file for the path, the request carries on as if Map Local hadn’t matched; later Map Local rules aren’t tried. |
| Map Remote | The first matching rule. |
| Rewrite | Every matching rule, top to bottom. Each rule’s actions run in order, and each works on the result of the one before. |
| Scripting | Every matching script, top to bottom. Each script receives the output of the one before it. |
| Block List | The first matching rule. |
| Allow List | Any matching rule. The request is recorded if at least one matches. |
| Network Conditions | The first matching rule. |
| DNS Spoofing | One address per host. If the same host appears twice, the lower row wins. |
| Mock Sets | The first set (top to bottom) that has a recording for the request, or that answers it with an offline 404. |
| Alerts | Every matching rule fires. |
Since 0.4.0 Folders don’t change the order: rules run top to bottom as listed, and a rule in a folder that’s off is skipped.
What happens when several tools match
Section titled “What happens when several tools match”One request can match rules in several tools. Cloak Proxy runs them in this order:
| Step | Tool | Effect on the rest |
|---|---|---|
| 1 | Block List | A match answers with 403 or drops the connection. Nothing after this runs. |
| 2 | Rewrite: request actions | Every matching rule’s request header, query parameter, URL and request body actions, top to bottom. |
| 3 | Failure scenarios Since 0.4.0 | A fault that fires can answer with a status, reset or time out the connection, or serve a kept stale response (nothing after this runs); delay the request; or change how the real response is delivered (truncate, drop mid-body, trickle). See Failure scenarios. |
| 4 | Network Conditions: packet loss | If the request is chosen to be lost, the connection is dropped after the rule’s latency. Nothing after this runs. |
| 5 | Scripting: onRequest |
Every matching script with Run onRequest on, top to bottom. |
| 6 | Breakpoint: request | Pauses for you. Abort ends the request here. |
| 7 | Map Local | A match answers the request locally. Steps 8 to 12 are skipped. |
| 8 | Mock Sets | A recorded response (or an offline 404) answers the request. Steps 9 to 12 are skipped. |
| 9 | Map Remote | Rewrites the URL and, unless you keep it, the Host header. |
| 10 | No Caching: request | Removes conditional headers and adds Cache-Control: no-cache and Pragma: no-cache. |
| 11 | Network Conditions: upload | Waits half the latency plus the upload time for the body. |
| 12 | DNS Spoofing | Connects to the spoofed IP address for the host, and the request goes to the server. |
| 13 | No Caching: response | Removes ETag, Last-Modified and Expires, and sets Cache-Control: no-store, no-cache, must-revalidate. |
| 14 | Rewrite: response actions | Every matching rule’s response header, response body and status actions, top to bottom. |
| 15 | Scripting: onResponse |
Every matching script with Run onResponse on, top to bottom. |
| 16 | Breakpoint: response | Pauses for you. Abort closes the app’s connection. |
| 17 | Network Conditions: download | Waits half the latency plus the download time for the body, then sends the response to the app. |
| 18 | Allow List and Alerts | The request is recorded if the Allow List lets it through, and alert rules check the finished request. |
Steps 13 to 17 run for every response, including those from Map Local and Mock Sets. So you can rewrite, pause or script a mocked response, and it is still slowed by Network Conditions. A Block List 403 skips them.
Which URL each step sees
Section titled “Which URL each step sees”Rewrite, scripts and breakpoints can change a request’s URL. Later steps see the change only where it matters:
| Steps | Match against |
|---|---|
| Block List, Rewrite (request and response actions), Allow List | The request as the app sent it. |
| Network Conditions, request scripts, request breakpoint | The request after Rewrite. |
| Map Local, Mock Sets, Map Remote | The request after Rewrite, request scripts and the request breakpoint. |
| Response scripts, response breakpoint | The request as the app sent it, so editing the URL earlier doesn’t skip them. |
| Alerts | The request as it was finally sent, after Map Remote. |
Create a rule from a request
Section titled “Create a rule from a request”Right-click a captured request in the traffic list, choose Tools, then a tool. The new rule matches that request and opens in the Tools window. With several requests selected, Mock Sets records all of them.
You can also search for New … Rule from Selection or Mock Selected Responses in Search Everything. The Tools submenu isn’t available for encrypted tunnels, and No Caching isn’t in it because it has no rules.
| Menu item | The new rule | Tool switched on |
|---|---|---|
| Breakpoint… | Matches the request’s method and URL without its query string, subpaths off. Pauses request and response. | Yes |
| Map Local… | Same exact match. Status code, body (decoded, JSON pretty-printed) and useful headers are copied from the captured response. See Map Local. | Yes |
| Map Remote… | Matches the URL without its query, any method, subpaths on. Host is prefilled with the current host for you to change. | Yes |
| Rewrite… Since 0.2.0 | Exact match (method and URL without its query, subpaths off), with no actions yet. See Rewrite. | Yes |
| Scripting… | Exact match, with the starter script. | Yes |
| Block List… | Matches the URL without its query, any method, subpaths on. Returns 403. | Yes |
| Allow List… | Matches the whole host (https://api.example.com/), any method, subpaths on. Named after the host. |
No: switch the Allow List on yourself. |
| Network Conditions… | Matches the whole host. Uses the 3G profile. Named after the host. | Yes |
| DNS Spoofing… | A row for the request’s host pointing at 127.0.0.1. |
No change |
| Mock This Response / Mock N Responses | A mock set with the response of each selected request. | Yes |
| Alerts… | Exact match with the request’s method, condition Any error (4xx, 5xx or failure). Named “… fails”. | Yes, and macOS asks for notification permission |
Rules made this way are named after the request, for example GET api.example.com/v1/users. Since 0.4.0 A GraphQL request’s rule is named after its operation, such as mutation CreateOrder, and gets a GraphQL operation is CreateOrder condition, so it doesn’t catch the other operations sent to the same URL.
Export and import rules
Section titled “Export and import rules”Rules are saved on your Mac. To share them with a teammate, keep them in a repository or use them in CI, export them to JSON.
-
Choose Tools › Export Rules….
-
Pick where to save. The suggested name is
Cloak Proxy Rules.json. -
To load rules, choose Tools › Import Rules… and pick a JSON file. Cloak Proxy reports Imported N rules from …. The same command reads Charles settings: see Import Charles settings.
To share one scenario rather than everything, use Export Folder… or Export Set…; see Share folders and sets.
What’s in the file and what import reads:
| Part | Exported | Imported |
|---|---|---|
| Breakpoint, Map Local, Map Remote, Rewrite, Scripting, Block List, Allow List, Network Conditions and DNS Spoofing rules | Yes | Yes. They are added to your current rules; a rule with the same id as an existing one replaces it. |
| Mock Sets, including recorded response bodies, and Alerts | Yes | Yes, the same way. |
| On/off state of each tool, and No Caching | Yes | No. Your current switches stay as they are. |
| New rules are named after the tool (New Breakpoint, New Map Local, New Map Remote, New Rewrite, New Script, New Block Rule, New Allow Rule, New Condition, New Alert) and start with an empty URL. | ||
| Failure scenarios Since 0.4.0 | Yes | Yes, with the switch each had in the file. See Failure scenarios. |
The file is pretty-printed JSON with sorted keys. Each rule has an id, name, isEnabled and matcher, plus the tool’s own fields. An excerpt:
{ "blockList" : [ { "action" : "forbidden", "id" : "6F1C2A3B-0000-4000-8000-00000000AB12", "isEnabled" : true, "matcher" : { "includeSubpaths" : true, "method" : "ANY", "mode" : "wildcard", "url" : "ads.example.com/" }, "name" : "Block ads" } ], "blockListEnabled" : true}The same file works with cloakctl run --tools for headless runs.
Import Charles settings
Section titled “Import Charles settings”If you’re moving from Charles Proxy, you can bring its rules with you. Tools › Import Rules… reads a Charles settings export and turns each Charles tool’s rules into Cloak Proxy rules. You see what will be added, and what can’t be, before anything changes.
-
In Charles, choose Tools › Import/Export Settings, open the Export tab, tick the tools you use and click Export. Charles saves an
.xmlfile.A file from a single tool’s own Export button, such as a Rewrite export, works too. So does Charles’s preferences file,
~/Library/Preferences/com.xk72.charles.config. In the open panel, press ⌘ ⇧ G and paste the path to reach it. -
In Cloak Proxy, choose Tools › Import Rules… and pick the file.
-
Read the Import from Charles sheet. To import lists the number of rules for each tool. Works a little differently lists rules that come in with a change, and Not imported lists what has no equivalent. Each row says why.
-
Click Import, or Cancel to leave everything as it is.
If the file isn’t a Charles export, Cloak Proxy says Couldn’t import with the file name and the reason, and nothing changes.
Imported rules are added after your current ones and never replace them. Importing the same file twice adds its rules twice. Each rule keeps the on/off state it had in Charles, and a rule whose Charles tool was off comes in turned off. A tool that was on in Charles, with at least one rule on, is turned on here too.
What each Charles tool becomes:
| In Charles | In Cloak Proxy | Differences |
|---|---|---|
| Breakpoints | Breakpoint rules | Request, response and method carry over. |
| Map Local | Map Local rules with a File or Directory source | A folder becomes Directory. Windows paths are skipped. A file or folder that isn’t on this Mac is listed so you can copy it over. |
| Map Remote | Map Remote rules | Keep the original Host header carries over. A destination with a wildcard is skipped. When the source matches many paths and the destination sets a path, every request goes to that one path. |
| Rewrite | Rewrite rules: one for each set and location, with an action for each Charles rule | See the next table. A set with no locations matches every request. |
| Block List | Block List rules | Return 403 Forbidden or Drop the connection, as chosen in Charles. |
| Allow List | Allow List rules | Charles blocks requests that aren’t on the list. Cloak Proxy lets them through and doesn’t record them. |
| No Caching | No Caching turned on | Applies to every request, even when Charles limited it to some hosts. |
| Block Cookies | A Rewrite rule named Block Cookies that removes Cookie and Set-Cookie |
|
| DNS Spoofing | DNS Spoofing entries | Host names with a wildcard are skipped. |
| Throttle settings | A Network Conditions rule named Charles throttle | Bandwidth times utilization, latency, and reliability as packet loss. Imported when throttling was on, or for the hosts it was limited to. Custom presets and the unstable connection settings aren’t imported. |
| SSL Proxying locations | Hosts on the SSL Proxying list | Hosts already on the list aren’t added twice. The exclude list isn’t imported: Cloak Proxy decrypts only the hosts on its list. |
| Mirror, Auto Save, Port Forwarding, Reverse Proxies | Not imported | Listed under Not imported when they were on. |
How Charles rewrite rules become Rewrite actions:
| Charles rule | Rewrite action | Not imported when |
|---|---|---|
| Add Header | Request header or Response header, Add | |
| Modify Header | Header Find and replace. A blank match value replaces the whole value of an existing header. | It renames the header. |
| Remove Header | Header Remove | It removes the header only when its value matches, or the name is a regular expression. |
| Host, Path | URL Find and replace with a regular expression that only touches the host or the path | |
| URL | URL Find and replace | |
| Body | Request body or Response body Find and replace | |
| Add Query Param | Query parameter Set | |
| Modify Query Param | Query parameter Find and replace | It renames the parameter. |
| Remove Query Param | Query parameter Remove | It removes the parameter only when its value matches. |
| Response Status | Response status Set | The new value has no status code. When the Charles rule only changed one status, such as 200, the action changes every status; the sheet says so. |
Regex, Match whole value, Replace first and case sensitivity carry over, so some actions use a regular expression where Charles showed a checkbox. Inactive Charles rules become actions that are turned off.
A Charles location (protocol, host, port, path and query) becomes the rule’s matcher:
| Charles location | Matcher |
|---|---|
Host api.example.com |
api.example.com/ with subpaths on: any protocol, path and query. |
Protocol https, host api.example.com, port 443, path /v1/users |
https://api.example.com/v1/users with subpaths off. A path without a wildcard matches exactly, with any query. |
Path /api/*, everything else blank or * |
*/api/* |
Host localhost, port 3000, path /report, query id=* |
localhost:3000/report?id=*. A query in the location must match. |
Host api?.example.com |
A regular expression, since ? stands for one character in Charles. |
Port 443 and 80 are left out of the pattern because they’re the defaults, and they set the protocol when Charles had none. A blank port, or *, matches only the default ports 80 and 443; Charles matched any port. If you used rules on other ports without naming the port, add :port to the pattern after importing.