Keep every working tree on the local disk. Send one redacted hunk only after local checks pass. A remote pass stays optional, never the default path.
Pasting a whole repository is the common failure. That habit spends latency and leaks secret lines. A filing cabinet should not travel for one page.
Local inference starts without a network round trip. Remote inference waits on DNS, TLS, and queue time. For a tiny rename, that wait rarely pays.
Measure the path before you trust a feeling. A short timed connect shows whether the route answers. Reachability is not model quality, and it is not a quota.
Secrets ride inside diffs more often than people think. Tokens, private keys, and customer rows do not belong on a free server. Scan the hunk on disk before any upload begins.
Offline work is a normal state, not an error page. Write the request to a local queue and keep editing. Promote that queue only after the link returns.
A free server wins on a narrow class of jobs. The hunk is small, clean, and hard for local models. You still keep tests and secrets on the laptop.
MonkeyCode can serve as the remote hop here. Disclosure: This article was prepared as part of MonkeyCode's product outreach. The operator describes open-source code plus free model access and a free server.
This draft claims no quota, hardware, or permanent tier. Check current project docs before you plan around them. A blog post cannot freeze terms that later change.
Treat the free server like a reading room across town. You carry one page, never the whole cabinet. You leave when the room closes, and the cabinet stays.
Latency has three visible parts, even without a benchmark lab. Name lookup, handshake, and first token are separate waits. A local process skips all three, then spends only compute.
That split matters on flaky links more than on a campus LAN. A laptop on a train loses the path between keystrokes. The edit should not freeze while a socket times out.
Secret risk is not the same problem as slow risk. A fast server can still be the wrong destination. Speed does not wash a key that left the disk.
Offline risk is the third axis, and it is blunt. If the route is down, remote quality is irrelevant. The honest result is a queued file beside the diff.
The decision below uses those three axes and nothing fancier. Payload bytes stand in for the cabinet size. A secret hit or a dead route blocks the trip.
Thresholds in the script are example knobs, not measured optima. Eight thousand bytes is a starting fence, not a law. Change it after you inspect your own diffs.
Classify one hunk
The artifact below is a proposal, not a measured benchmark. It classifies one diff as local, queued, or remote. Run it on a sample file before you trust it.
#!/usr/bin/env python3
"""Proposal only. Routes one diff. Not a benchmark."""
import os
import re
import socket
import sys
from pathlib import Path
# Example fence, not a measured optimum.
MAX_REMOTE_BYTES = 8000
CONNECT_TIMEOUT_S = 1.5
SECRET_RULES = (
re.compile(r"AKIA[0-9A-Z]{16}"),
re.compile(r"-----BEGIN [A-Z ]*PRIVATE KEY-----"),
re.compile(r"(?i)\b(api[_-]?key|secret|token|password)\b\s*[:=]\s*\S+"),
)
def load_diff(path: Path) -> str:
return path.read_text(encoding="utf-8", errors="replace")
def secret_hits(text: str) -> int:
return sum(len(rule.findall(text)) for rule in SECRET_RULES)
def route_open(host: str, port: int) -> bool:
try:
with socket.create_connection((host, port), CONNECT_TIMEOUT_S):
return True
except OSError:
return False
def decide(text: str, host: str, port: int) -> str:
if secret_hits(text) > 0:
return "local"
if len(text.encode("utf-8")) > MAX_REMOTE_BYTES:
return "local"
if not text.strip():
return "local"
if not host:
return "local"
if not route_open(host, port):
return "queued"
return "remote"
def main() -> int:
if len(sys.argv) != 2:
print("usage: route_hunk.py DIFF_FILE", file=sys.stderr)
return 2
text = load_diff(Path(sys.argv[1]))
host = os.environ.get("REMOTE_HOST", "")
port = int(os.environ.get("REMOTE_PORT", "443"))
choice = decide(text, host, port)
print(choice)
if choice == "queued":
queue = Path("queue")
queue.mkdir(exist_ok=True)
target = queue / Path(sys.argv[1]).name
target.write_text(text, encoding="utf-8")
print(f"queued {target}")
return 0
if __name__ == "__main__":
raise SystemExit(main())
Capture a hunk with git, then classify it. Keep the command local until the script prints remote. Do not pipe the diff to a network tool yourself.
git diff --unified=3 -- src/app.py > /tmp/hunk.diff
python3 route_hunk.py /tmp/hunk.diff
An unset host means the script stays local. That empty host is intentional, not a bug. Set a host only when you mean to test the path.
REMOTE_HOST=example.invalid REMOTE_PORT=443 python3 route_hunk.py /tmp/hunk.diff
Use a host you operate or the docs name. This article does not invent a product endpoint. The name example.invalid should land in the queue.
A clean sample looks like a few changed lines. No keys, no dumps, and no giant fixture. That shape is the page you might carry across town.
diff --git a/src/app.py b/src/app.py
--- a/src/app.py
+++ b/src/app.py
@@ -10,3 +10,3 @@
-def timeout_ms():
- return 200
+def timeout_ms():
+ return 350
That hunk is small and has no secret shape. If the route answers, the script may print remote. If the route fails, it prints queued and writes a copy.
A dirty sample should never print the remote word. Plant a fake key in a scratch diff and confirm the local result. Delete the scratch file when the check ends.
printf 'api_key = "not-a-real-secret"\n' > /tmp/dirty.diff
python3 route_hunk.py /tmp/dirty.diff
The expected printed word is local, not remote. The regex is a coarse net, not a full secret scanner. It misses some formats and flags some harmless lines.
False positives belong on the local side of the gate. A missed remote call is cheaper than a leaked row. Widen the rules only after you review real diffs.
False offline signals happen on slow DNS too. A one point five second timeout is an example, not a standard. Raise it if your network is slow but stable.
Do not treat a remote print as permission to upload the tree. Upload the same hunk the script read, or upload nothing. The queue file is still private local state.
When the choice is remote, ask for a bounded review. Name the function, the bug, and the test you already hold. Refuse a request that needs the whole history.
A useful prompt stays smaller than the hunk fence. You can paste the diff into a free-server session by hand. This script does not call an API, and it does not store a token.
That gap is deliberate, because upload would hide the last check. The printout is a gate, and you are the latch. Automatic shipping would train a careless copy habit.
Local remains better for rename sweeps and format noise. Those diffs are wide, dull, and full of names. A remote model adds delay and little new structure.
Remote remains better for a short logic knot. You want a second reading of a clean algorithm. Free model access matters only in that narrow slot.
If the free server is down, the queue still preserves the ask. Replay is a later command, not a background daemon. A daemon that retries blindly can ship a stale hunk.
python3 route_hunk.py queue/hunk.diff
Compare the queued bytes with the current git diff before replay. If the bytes differ, discard the queue file. Stale context produces confident notes that miss the edit.
There is no latency table in this piece, on purpose. No run was executed for publication, so no millisecond claim is honest. Time your own path if a number will guide a team rule.
The same restraint covers cost and capacity claims. Free model access can still meet a fair-use cap you have not read. A blog sentence cannot reserve capacity for your sprint.
Where the route stops
Limitations sit in the regex, the timeout, and the byte fence. Binary diffs may decode as noise and look small. Review binary changes by hand, because the scanner is text-biased.
A successful connect proves a socket, not a healthy model. Auth, region, and capacity can still fail after the port opens. Treat remote as eligible, then confirm with a manual prompt.
The script does not understand licenses or customer contracts. A clean regex is not a legal review. If policy forbids external models, the only result is local.
Do not use this approach for production incident logs. Those files mix tokens, hostnames, and personal data. Keep that material on disk even when the hunk looks short.
Do not use it when the local tree itself is untrusted. A malicious diff can try to confuse a reviewer. Remote reasoning will not purify a poisoned patch.
Do not use it as a silent team default. Each developer should see the printed choice first. Hidden routing trains people to forget where text went.
Skip the free server when you cannot read the current terms. Skip it when the docs disagree with a remembered quota. Memory is a poor source of capacity planning.
If your work is air-gapped, stop at the local branch. Leave the host unset and treat remote as dead code. The queue remains optional even in that setting.
The workflow is a loop you can say in one breath. You diff, scan, classify, and then edit. Cross the wire only for a page that earned the trip.
If you already work this way, the free server is a spare reading room. Read the live MonkeyCode docs, then try one clean hunk. Keep the cabinet at home either way you choose.
Top comments (0)