lminspect authoring skill

lminspect is a statically linked pure-Go HTTP/HTTPS proxy, dynamic SSL-Bump TLS interceptor, JSONL flow recorder and replayer, and LMScript host. It executes bytecode-compiled _lmcode_ traffic addons at wire speed while enforcing mandatory credential sanitization across every output channel.

Purpose

Use lminspect to intercept, inspect, rewrite, mock, record, and replay HTTP and HTTPS traffic in forward, reverse, or transparent proxy modes; author deterministic mitmproxy-style request and response hooks in LMScript; generate sanitized JSONL flow captures compatible with lmmock; and expose standard lmcode_std_v3 REST and CLI interfaces.

When to use it

Choose lminspect when an automated test, microservice integration, or API reverse-engineering workflow needs an inline HTTP/HTTPS proxy that can tamper with headers, query strings, URLs, or payloads, serve synthetic responses, or record credential-scrubbed traffic fixtures. Use lmcurl when issuing client requests directly from a script, lmmock when hosting standalone contract mock servers from recorded fixtures, or lmdebug when capturing raw L2–L4 packets with libpcap.

Install

Install the lmctl toolchain with npm install -g @lmctl-ai/lmctl@latest. Prebuilt static binaries (CGO_ENABLED=0) are published for Linux and macOS on x64 and arm64, and can also be built from source with Go 1.25 or newer. When an LMScript program specifies cli="lminspect" and install="github:lmctl-ai/lminspect@latest", lmscript resolves lminspect on PATH or downloads the release binary automatically.

lmscript --version
lminspect --version
lminspect --lmcode-schema
lminspect --lmcode-signatures

Commands

lminspect supports Root CA certificate generation, forward and reverse proxy execution with live DSL addons or declarative rules, JSONL client/server flow replay, and standalone _lmcode_ bytecode execution.

# Host schema, signatures, and standalone bytecode execution
lminspect --version
lminspect --lmcode-schema --json
lminspect --lmcode-signatures
lminspect --lmcode build/addon.dslb
lminspect --lmcode build/addon.dslb --save build/saved-addon.dslb

# Generate a local Root CA for dynamic SSL-Bump MITM
lminspect certgen --cert ca.crt --key ca.key

# Forward proxy with SSL-Bump, live stderr tap, JSONL recording, and DSL addon
lminspect run --listen 127.0.0.1:8080 --ssl-bump --ca-cert ca.crt --ca-key ca.key --tap --record flows.jsonl --script build/addon.dslb

# Reverse proxy in front of an upstream service with declarative rules
lminspect run --listen 127.0.0.1:9090 --mode reverse:http://127.0.0.1:8000 --header "/api/*=X-Env:staging" --mock "/health=200:OK"

# Serve recorded responses directly or replay recorded requests against a target
lminspect run --listen 127.0.0.1:8080 --replay-server flows.jsonl
lminspect replay --client flows.jsonl --target 127.0.0.1:9000

Inputs and outputs

In _lmcode_ mode, lminspect provides context inspect: Inspector and context flow: Flow, three hook interfaces (RequestHook, ResponseHook, FlowHook), object types Request and Response, functions println(string) and assert(bool, string), and the 226 standard lmcode_std_v3 signatures. Recorded JSONL files (--record) contain one JSON object per line with request (method, host, port, path, headers, base64 content) and response (status_code, headers, base64 content) fields after mandatory credential redaction.

Safety rules

Adhere to lminspect credential sanitization and TLS interception rules when capturing or mutating traffic:

Worked examples

The first example defines RequestHook and ResponseHook handlers that rewrite request headers, short-circuit a synthetic mock endpoint with Flow.respond, and test the flow logic offline via inspect.new_flow:

p = _lmcode_ cli="lminspect" install="github:lmctl-ai/lminspect@latest";
@request
fn on_request(f: Flow) -> void implements RequestHook {
  f.request().set_header("X-Proxy-By", "lminspect");
  if (f.request().path() == "/mock") {
    f.respond(200, "{\"mocked\":true}", "application/json");
  }
}

@response
fn on_response(f: Flow) -> void implements ResponseHook {
  f.response().set_header("X-Inspected", "true");
}

let sim = inspect.new_flow("GET", "https://api.example.com/mock");
on_request(sim);
on_response(sim);
assert(sim.has_response(), "expected synthetic response");
assert(sim.response().status_code() == 200, "expected 200");
assert(sim.response().header("X-Inspected") == "true", "expected response header");
end _lmcode_
res = run_lmcode(p);
require(res.ok, json_stringify(res));

The second example combines Inspector flow construction with the standard lmcode_std_v3 CliOption, CliCommand, and RestGet interfaces and dispatches them in-process with rest_cli:

p = _lmcode_ cli="lminspect" install="github:lmctl-ai/lminspect@latest";
@"--host"
fn opt_host(x: RestExchange) -> void implements CliOption {
  x.set("host", x.query("host"));
}

@"flow"
fn cmd_flow(x: RestExchange) -> void implements CliCommand {
  let f = inspect.new_flow("GET", "https://" + x.get("host") + "/v1/ping");
  x.send(f.request().method() + ":" + f.request().host() + f.request().path());
}

@"/flow/:seg"
fn get_flow(x: RestExchange) -> void implements RestGet {
  let f = inspect.new_flow("POST", "https://api.internal/" + x.param("seg"));
  f.respond(201, "{\"seg\":\"" + x.param("seg") + "\"}", "application/json");
  x.json("{\"status\":" + str(f.response().status_code()) + ",\"path\":\"" + f.request().path() + "\"}");
}

rest_config("session", "global");
let cli_out = rest_cli(str_split("--host=gateway.internal flow", " "));
let rest_out = rest_cli(str_split("/flow/orders", " "));
assert(cli_out == "GET:gateway.internal/v1/ping", "cli mismatch");
assert(rest_out == "{\"status\":201,\"path\":\"/orders\"}", "rest mismatch");
end _lmcode_

Errors and exit codes

lminspect returns deterministic exit codes across proxy, replay, certgen, and _lmcode_ host modes:

How to verify

Verify the lminspect binary by inspecting its version, embedded schema JSON, canonical signature table, and running the repository test suite:

lminspect --version
lminspect --lmcode-schema --json > /tmp/lminspect-schema.json
lminspect --lmcode-signatures > /tmp/lminspect-sigs.txt
lmscript --lmcode-signatures /tmp/lminspect-schema.json > /tmp/lminspect-compiler-sigs.txt
diff -u /tmp/lminspect-compiler-sigs.txt /tmp/lminspect-sigs.txt

In a source checkout, run go test ./... and ./test.sh to execute Go unit tests, example addon compilations, HTTP and HTTPS SSL-Bump proxy tests, JSONL recording and replay checks, and python scripts/test-sanitize-mutation.py for credential sanitization verification.