/algo-trading-skills:sandbox-vs-production-endpoint-driftfrom algo-trading-skills
Compares captured API responses from sandbox and production environments to detect schema drift, nullability changes, rate-limit header differences, and missing endpoints before promoting broker integrations.
Ships in algo-trading-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Invoke this before promoting a broker integration from a sandbox, testnet or paper environment into live trading, and again whenever either environment's API version changes. Sandbox environments drift from production silently: brokers deploy upcoming features to a testnet first, alter production payloads without updating paper-trading documentation, and expose only part of the production endpoint surface. Schema drift — a nested field that changed from a JSON number to a string, a field production stopped returning, a null where the sandbox always had a value, a rate-limit header the sandbox never emits — surfaces as a parser crash or an unhandled throttle on the first live order.
The tool is a promotion gate, and its failure modes are asymmetric: a false positive costs a developer a few minutes, a false negative promotes an integration that was rehearsed against a contract production does not honour. Its severity model is biased accordingly.
demo-account-realism-gap-assessment.broker-api-changelog-diffing-tool.str fields with different contents are not drift here;
only shapes, presence, nullability and headers are compared.sandbox_json, prod_json. Not raw text — parsing is the caller's job.sandbox_headers, prod_headers,
sandbox_status, prod_status.compare_endpoint_inventory.Capture like for like, then gate on the combined report. Call audit_endpoint,
not compare_schemas alone: the schema report's passed flag knows nothing about
header or status-code drift, so gating on it is the easiest way to get a green light
for an endpoint that has plainly drifted. report.exit_code is 0 when no CRITICAL
finding was raised and 1 otherwise; report.format_report() renders findings
severity-first.
Let the detector reject unusable input. DriftAuditError is raised when a payload
is not a mapping, when both payloads are empty, or when a status code is not an
integer in 100–599. This is deliberate: a failed capture yields an empty dict, and a
comparator that shrugs and reports parity turns the gate green at exactly the moment
it matters. For an endpoint that genuinely returns no body, pass no payloads and audit
headers and status codes instead.
Compare payloads recursively, not key-by-key at the top level. Broker responses
nest — an order inside an envelope, legs and fills inside the order. Findings carry the
dotted path (order.legs[0].price) where the drift was found.
Treat absence and null as drift in both directions. A field present only in
production is a surface the sandbox never exercised; a field present only in the
sandbox raises KeyError the first time the code runs live. Both are CRITICAL. A null
on one side and a value on the other is CRITICAL too — the code will meet a type it was
never tested against. An array populated in production but empty in sandbox is CRITICAL
(its element schema was never rehearsed); an array empty in the production sample is a
WARNING, because those elements were not compared at all.
Distinguish numeric widening from a type change. int versus float is a WARNING;
float versus str is CRITICAL. bool is a subclass of int in Python, but JSON
true is not JSON 1, so a bool/number pair is CRITICAL rather than a widening.
Audit headers for presence, quota value, and content type. Field names are matched
case-insensitively (RFC 9110 §5.1). A rate-limit field present in production but absent
from the sandbox is a WARNING — throttling handling is unrehearsed. A sandbox
advertising a more permissive quota than production is CRITICAL: pacing calibrated
against it will breach the production limit and have live orders rejected. A
content-type media type that differs (application/json versus text/html) is
CRITICAL, since the decoder will not match live; a differing charset parameter is not
drift.
Grade status codes by class, not by numeric distance. A sandbox 200 against a production 429 or 500 is a different outcome class (RFC 9110 §15) and blocks promotion; 400 versus 404 is a same-class difference worth reviewing. Numeric distance conflates the two — 404 and 500 differ by 96, 200 and 299 by 99.
Compare the endpoint inventory when a whole family may be missing. Binance's Spot
Test Network exposes only /api endpoints, not /sapi, so an integration can pass
every payload-level check and still call a path that does not exist in the environment
it was rehearsed against.
Full procedure: see
references/workflows.md. Severity contract and classification rationale: seereferences/standards.md. Printable pre-flight checklist: seeassets/checklist.md.
"filled_at": null never exercised the timestamp parse path that production will hand
the code on the first fill.python -m unittest discover -s skills/sandbox-vs-production-endpoint-drift/scriptsfield_name is the dotted path. A comparator that passes every
flat-payload test can still fail this one, which is the case that matters.DriftAuditError rather than reporting parity, and
that a non-mapping payload raises rather than raising AttributeError deep in the walk.audit_endpoint with clean payloads but a 200/400 status pair reports
passed=False and exit_code == 1.x-ratelimit-limit higher than production's is CRITICAL, and that
Content-Type differing only by charset is not a finding.sandbox-credential-leakage-preventionbroker-api-changelog-diffing-tooldemo-account-realism-gap-assessmentpaper-to-live-promotion-checklistenvironment-parity-dev-staging-productionWhat SKILL.md sets; muted values are Claude Code's defaults
36 skills in this plugin
/alpaca-paper-live-key-separationUse when a bot connects to the Alpaca Trading API and must never cross paper keys with the live endpoint; pins the base URL per environment, checks the key prefix, probes /v2/account and requires an explicit ALLOW_LIVE_TRADING flag./api-key-least-privilege-audit-toolUse before deploying a live bot, to audit existing broker API keys for scopes they do not need. Flags withdrawal, transfer and admin rights that turn a leaked execution key into theft./broker-account-margin-call-handlingUse when a bot trades a Reg T, portfolio or futures margin account and must act before the broker liquidates: tiered maintenance-margin warnings cross-checked against broker excess liquidity, initial-margin order gating and liquidity-aware de-leveraging.npx claudepluginhub himanshuj16/algo-trading-skills --plugin algo-trading-broker-integrationOther plugins' skills for the same job