- Home
- Skills
- Testing & Debugging
- Offline Test Rewriter: hermetic tests, no network
Works with the AI Agents you already use
Offline Test Rewriter: hermetic tests, no network
Sandboxed validators such as AgentHarness run every test command with **no network**, so these tests fail every time there.
$12
Offline Test Rewriter: hermetic tests, no network
Example session with this skill installed
Our gate runs tests without network and tests/test_weather.py plus src/geo.test.ts fail there. Make them pass offline without losing coverage.
- Read your context and instructions
- Compiled the offline test rewriter
Example session (illustrative).
1. Detect.
pytest --disable-socket --allow-unix-socket raised SocketBlockedError in 6 tests:
- 4 in
test_weather.pycallapi.weather.examplethroughrequests. - 2 in
test_reports.pywere a surprise: boto3 probes the EC2 metadata endpoint for credentials.
With nock.disableNetConnect() in jest.setup.ts, 3 tests in src/geo.test.ts failed with NetConnectNotAllowedError for nominatim.openstreetmap.org.
2. Make it injectable.
WeatherClient hardcoded its base URL. It now takes base_url with the old value as default. geocode() now takes a baseUrl option.
3. Rewrite.
Weather: 3 tests now use @responses.activate with explicit 200, 429 and malformed-JSON cases. The 429 case was previously untested. The forecast test, which needs a 40 KB payload, uses a pytest-recording cassette with filter_headers=["authorization"] and --record-mode=none in CI.
Reports: set AWS_EC2_METADATA_DISABLED=true and fake credentials in a fixture, and wrapped the tests in moto's @mock_aws.
- Geo: msw
setupServerwithonUnhandledRequest: "error"and saved JSON fixtures for the 3 cases.
4. Secrets check.
The grep over tests/cassettes turned up an appid= query param in an old cassette. Added filter_query_parameters=["appid"] and re-recorded. Flagged the key for rotation, because it is in git history.
5. Opt-in live test.
Kept one real call, test_live_forecast_schema, behind RUN_INTEGRATION=1.
6. Verify.
unshare -r -n sh -c 'ip link set lo up && pytest && npx jest' passed: 0 network calls, 9 tests rewritten, 1 gated. Coverage unchanged, plus the new 429 path.
Connects securely to your tools. The creator never sees your data.
About this skill
The problem. Tests that call real APIs fail in sandboxes, in hermetic CI and offline. They also break on rate limits and vendor outages, and often need real credentials checked in somewhere. Sandboxed validators such as AgentHarness run every test command with no network, so these tests fail every time there. Coding agents usually respond by loosening the sandbox or adding retries. Both are wrong.
What the agent does with this skill.
- Detects network use. Runs the suite with the network actually cut (
unshare -non Linux,docker --network none) and adds call-site guards:pytest-socket --disable-socket, pytest-recording--block-network,nock.disableNetConnect(), mswonUnhandledRequest: "error". It also hunts hidden calls: cloud SDK metadata probes, runtime model downloads, telemetry, token refresh. - Picks the right double for each test. Request mocks for exact assertions and error paths (responses, pytest-httpx, respx, moto, msw, nock, Go
httptest, Rust wiremock/mockito). Recorded cassettes for large payloads (VCR.py, pytest-recording, Polly.js, go-vcr), replay-only in CI. Local fakes for stateful services. Testcontainers for real databases, noting that it needs Docker and image pulls. - Makes the code injectable. If the base URL or client is hardcoded, it makes it injectable first, because that hardcoding is the real defect.
- Keeps secrets out of fixtures. Filters headers and query parameters at record time, redacts token bodies, then greps and runs gitleaks before commit. It flags any leaked secret for rotation.
- Handles contract drift on purpose. Recordings are refreshed deliberately and reviewed like code. A small set of live checks moves behind
RUN_INTEGRATION,go test -tags integrationor#[ignore].
Who it's for. Teams adopting sandboxed or hermetic CI, AgentHarness users whose gate blocks on network-dependent tests, and anyone tired of tests that fail when a vendor has a bad day.
Requirements. Any agent that supports SKILL.md (Claude Code, Cursor, Codex CLI, and others) with shell access to run tests. The agent proposes the mocking library that fits your HTTP client and asks before adding dependencies. Testcontainers needs a running Docker daemon. unshare needs Linux with unprivileged user namespaces.
Library-specific version constraints apply, such as Nock 15+ ESM requirements. Testcontainers require Docker access. Some cloud SDKs require specific env vars to disable metadata probes.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before any payment.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 17 days ago
Requires
Permissions
Allowed Hosts