Skip to content

Capture Proxy, Shadow & Watch

This page covers three long-running local commands:

  • recon proxy sits between a client and an upstream API and records every exchange in the Flight Recorder.
  • recon shadow sends each request to a primary backend, returns the primary’s answer, and compares it in the background with a candidate backend’s answer.
  • recon watch watches the workspace and reruns the .http requests affected by a file change.

All three bind to 127.0.0.1 only.

Point a client at the proxy instead of the real API. The proxy forwards each request to --target and records the request and response.

Terminal window
recon proxy --target http://127.0.0.1:4500 --port 4502 --export-http collections/captured.http
http://127.0.0.1:4502
Capture Reverse Proxy listening on http://127.0.0.1:4502 (Ctrl-C to stop)…

Send traffic through it:

Terminal window
curl -si -H 'Authorization: Bearer abc123' 'http://127.0.0.1:4502/_sandbox/local/v1/students?x=1'
curl -s -X POST -H 'Content-Type: application/json' \
-d '{"student_id":"001001","course":"CS-401"}' \
http://127.0.0.1:4502/_sandbox/local/v1/enrollments
curl -si http://127.0.0.1:4502/_sandbox/local/v1/students-paged
HTTP/1.1 200 OK
content-type: application/json
date: Mon, 30 Nov 2026 15:45:55 GMT
x-recon-captured: true
content-length: 669
...

Press Ctrl-C. The proxy prints its counters and writes the .http export:

Captured 3 request(s) (0 upstream errors).
### GET /_sandbox/local/v1/students-paged
# @name GET /_sandbox/local/v1/students-paged
# @folder Captured Proxy
GET {{base_url}}/_sandbox/local/v1/students-paged
user-agent: curl/8.5.0
accept: */*
### GET /_sandbox/local/v1/students
# @name GET /_sandbox/local/v1/students
# @folder Captured Proxy
GET {{base_url}}/_sandbox/local/v1/students?x=1
user-agent: curl/8.5.0
accept: */*
### POST /_sandbox/local/v1/enrollments
# @name POST /_sandbox/local/v1/enrollments
# @folder Captured Proxy
POST {{base_url}}/_sandbox/local/v1/enrollments
user-agent: curl/8.5.0
accept: */*
content-type: application/json
{"student_id":"001001","course":"CS-401"}

The Authorization header is missing from the export because it was redacted when recorded (see below).

  1. Reads the full request body, up to 32 MiB.
  2. Copies the request headers, except Host and these hop-by-hop or framing headers: connection, keep-alive, proxy-authenticate, proxy-authorization, te, trailers, transfer-encoding, upgrade, content-length, content-encoding. Header values that are not valid visible ASCII are dropped.
  3. Builds the target URL as --target (trailing / removed) followed by the incoming path and query string.
  4. Runs the request through the Outbound Secret Firewall. The proxy passes no secret taints, so in practice this step only rejects a URL that does not parse.
  5. Sends the request with a 15 second timeout. Redirects are not followed.
  6. Runs the response through the PII Airlock to produce an Airlock receipt, and records the exchange in the Flight Recorder.
  7. Returns the upstream status, headers (minus the hop-by-hop and framing headers above) and body to the client, with X-Recon-Captured: true added.
Field Value
Actor label proxy
Environment --env (default capture)
Request ID proxy-<method>-<path>, for example proxy-get-_sandbox-local-v1-students
Request name <METHOD> <normalized path>, for example GET /_sandbox/local/v1/students
Request headers As forwarded, with authorization, proxy-authorization, cookie, set-cookie and x-api-key values replaced by [REDACTED:PROXY_HEADER]
Request body As text (lossy UTF-8)
Response Status, headers, body, timing waterfall, TLS info, byte counts, Airlock receipt

The captured_requests counter only counts exchanges that were written to the Flight Recorder successfully.

Status Cause Body
502 Request body could not be read (for example, over 32 MiB) {"error":"failed reading incoming body: ..."}
403 Firewall rejected the request {"error":"..."}
502 Upstream connection or timeout failure {"error":"..."}

These responses carry X-Recon-Captured: error and count as upstream_errors. Nothing is recorded for them.

With --export-http <FILE>, Recon writes a .http file after you press Ctrl-C. Parent directories are created. The export:

  • reads the 200 most recent Flight Recorder runs whose environment equals --env, so it can include runs from earlier proxy sessions with the same label;
  • keeps one request per method and path-plus-query, ordered by method and then path;
  • puts every request in the folder Captured Proxy and rewrites the URL to {{base_url}} followed by the path and query;
  • drops headers whose recorded value starts with [REDACTED;
  • writes a body that starts with { or [ as JSON and any other non-empty body as text.
Flag Default Description
--target <URL> required Upstream origin or base URL. Must be http or https.
--port <PORT> 9090 Port on 127.0.0.1. 0 picks a free port.
--env <NAME> capture Environment label stored on each captured run.
--export-http <FILE> none Write captured requests as a .http file on shutdown.

On shutdown, --format json prints {"captured_requests": N, "upstream_errors": N} to stdout. Human format prints the Captured ... line to stderr. Exit code is 0. Startup errors (invalid --target, port in use) exit 2 with E_CLI_RUNTIME.

Use shadow mode to compare a new backend against the current one with real traffic. The client always gets the primary’s response. The candidate is called afterwards, off the request path.

Terminal window
recon shadow \
--primary http://127.0.0.1:4500/_sandbox/local \
--candidate http://127.0.0.1:4500/_sandbox/staging \
--port 4503 --format json
Terminal window
curl -si http://127.0.0.1:4503/v1/students
HTTP/1.1 200 OK
content-type: application/json
date: Mon, 30 Nov 2026 15:46:14 GMT
x-recon-shadow: primary
content-length: 669
...

After Ctrl-C, JSON format prints the counters and every recorded finding:

{
"findings": [
{
"candidate_ms": 0.384713,
"candidate_status": 200,
"diff": {
"body_changes": [
{
"kind": "changed",
"left": "\"local\"",
"path": "$.environment",
"pattern": "$.environment",
"right": "\"staging\""
},
{
"kind": "type_changed",
"left": "3.92",
"path": "$.students[0].gpa",
"pattern": "$.students[*].gpa",
"right": "\"3.92\""
},
...
],
"header_changes": [
{
"kind": "changed",
"left": "669",
"path": "header:content-length",
"pattern": "header:content-length",
"right": "673"
}
],
"identical": false,
"ignored_count": 1,
"latency_delta_ms": -2.135155,
"status_changed": false,
"status_left": 200,
"status_right": 200
},
"method": "GET",
"path": "/v1/students",
"primary_ms": 2.519868,
"primary_status": 200,
"timestamp": "2026-11-30T15:46:14.657885680+00:00"
}
],
"stats": {
"candidate_errors": 0,
"dropped_count": 0,
"mirrored_count": 1,
"regressions_count": 1,
"total_proxied": 2
}
}

In this run a POST was also sent through the proxy. It counts in total_proxied but was not mirrored, because mutating methods are not mirrored by default.

Human format prints one line to stderr instead and does not print findings:

Shadow summary: proxied=2, mirrored=1, regressions=1, dropped=0
  1. The request is read (body up to 16 MiB) and its headers are filtered the same way as in the capture proxy.
  2. The request goes to --primary plus the incoming path and query, through the Outbound Secret Firewall (no taints), with a 15 second timeout and no redirect following.
  3. The primary’s response goes back to the client with X-Recon-Shadow: primary.
  4. If the method is GET, HEAD or OPTIONS, or --mirror-mutations is set, a mirror task is put on a queue with room for 256 tasks. If the queue is full, the task is dropped and dropped_count goes up. The client never waits for the queue.
  5. One background worker takes tasks in order, sends the same method, path, headers and body to --candidate, and computes a semantic diff of the primary and candidate responses. The workspace volatile_paths from .recon.toml are excluded from the diff. The diff format is described in Twin-Run & Diff.
  6. If the diff is not identical, a finding is stored. Only the 200 newest findings are kept, newest first.

Nothing from shadow mode is written to the Flight Recorder.

Field Meaning
total_proxied Requests that got a primary response.
mirrored_count Candidate comparisons completed.
regressions_count Comparisons where the diff was not identical.
dropped_count Mirror tasks dropped because the queue was full.
candidate_errors Candidate requests that failed the firewall or the network call.
Field Meaning
timestamp RFC 3339 time the comparison finished.
method HTTP method.
path Path and query string as received.
primary_status, candidate_status Status codes.
primary_ms, candidate_ms Total latency of each call in milliseconds.
diff Semantic diff (identical, status_changed, status_left, status_right, header_changes, body_changes, ignored_count, latency_delta_ms).
Status Cause
502 Request body could not be read, or the primary call failed.
403 Firewall rejected the primary request.

These responses carry X-Recon-Shadow: error and a JSON body {"error":"..."}. They do not count in total_proxied and are not mirrored.

Flag Default Description
--primary <URL> required Authoritative upstream. Its responses go to the client. Must be http or https.
--candidate <URL> required Upstream compared in the background. Must be http or https.
--port <PORT> 9091 Port on 127.0.0.1. 0 picks a free port.
--mirror-mutations off Also mirror methods other than GET, HEAD and OPTIONS.

As with the capture proxy, the global transport flags are not applied. Exit code is 0 after Ctrl-C and 2 for startup errors.

recon watch watches a directory recursively. When files change, it works out which saved requests are affected and runs them.

Terminal window
recon watch --once
Watch executed 3 impacted request(s) [FAIL]
✓ List Students (200)
✓ Create Enrollment (201)
✗ Stripe Prod Key Leak Check (0)

--once runs every request in the workspace one time and exits. The exit code is 0 if all passed and 1 otherwise. This is the mode to use in scripts and CI. In this example the third request is a firewall drill that is meant to be blocked.

Without --once, Recon prints Recon watching <path> for handler & .http changes (Ctrl-C to stop)… to stderr and keeps running.

Events are collected for 150 ms after the first one (the debounce window), then handled as one batch. Paths are ignored if they contain one of the directories .git/, .recon/, target/, node_modules/ or dist/, or end in ~, .swp or .tmp.

For each batch, Recon reloads the workspace, scans the repository with Code Scanning, and selects requests:

  • If .recon.toml or any file under the environments directory changed, every request runs.
  • Otherwise a request runs if any of these is true:
    • its own .http file changed;
    • its # @handler location points at a changed file;
    • a scanned route defined in a changed file has the same method and a matching path;
    • a scanned route uses a request or response DTO that is defined in a changed file, and has the same method and a matching path.

Selected requests run one after another through the Outbound Secret Firewall and your transport settings. A request passes if all its assertions pass, or, when it has no assertions, if the status is below 400. Each run is recorded in the Flight Recorder with the actor label watch, without the request headers or body.

With --drift, Recon also computes the Three-Way Drift report from the 30 most recent runs after each batch. Any breaking drift marks the batch as failed. The drift report appears only in JSON output, under drift.

JSON format prints one object per batch. This is recon watch --once --format json:

{
"changed_files": [],
"drift": null,
"executed": 3,
"full_suite": true,
"passed": false,
"results": [
{
"ms": 0.615596,
"passed": true,
"request": "List Students",
"status": 200
},
{
"ms": 0.274017,
"passed": true,
"request": "Create Enrollment",
"status": 201
},
{
"error": "outbound secret firewall blocked 1 violation(s)",
"passed": false,
"request": "Stripe Prod Key Leak Check"
}
]
}

changed_files holds workspace-relative paths. It is empty for --once.

Flag Default Description
[PATH] --workspace Directory to watch. It is also used as the workspace root for loading .recon.toml, requests and environments, and for the code scan.
--env <NAME> workspace default_env Environment to run requests against.
--drift off Compute Three-Way Drift after each batch.
--once off Run every request once and exit with 0 (all passed) or 1.

The global transport flags apply to watch runs. Errors before a --once batch starts (for example a missing workspace) exit 2 with E_CLI_RUNTIME.

  • Web Studio: the Studio button in the top bar opens the “Freeze-to-Mock & Shadow Studio” dialog. Its Shadow Mirror tab takes a primary and candidate URL (prefilled with the offline sandbox local and staging URLs), a “Mirror POST/PUT/PATCH/DELETE mutations” checkbox, and shows the shadow endpoint, proxied and regressions counts, and the 10 newest findings. It binds an ephemeral port. See Web Studio.
  • HTTP API: POST /api/v1/shadow/start (body {primary_url, candidate_url, port?, mirror_mutations?}), GET /api/v1/shadow/findings, POST /api/v1/shadow/stop. Starting a new shadow stops the previous one. See HTTP API.
  • The capture proxy and watch mode have no HTTP route or MCP tool.