325-networking

325-networking is a cursor rule for coding agents from d-padmanabhan/agent-engineering-handbook. It costs 39 tokens per session (2,634 once invoked), scanned A, original, MIT.

A set of automatic rules for network transport code and Protocol Buffers schemas. Protocol Buffers are a compact format for defining data exchanged between services; the rules cover HTTP and gRPC clients, TCP keepalive, timeouts, and safe field numbering.

In plain words
What is it for?
Use it when editing HTTP or gRPC clients and servers, load-balancer or edge settings, or Protocol Buffers schemas.
Why use it?
It prevents common connection, performance, idle-timeout, and schema-compatibility mistakes when changing network code or message definitions.

Cursor rule

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/d-padmanabhan/agent-engineering-handbook/325-networking
Clone the repo
git clone --depth 1 https://github.com/d-padmanabhan/agent-engineering-handbook

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for 325-networking

README.md
[![agentmods](https://agentmods.dev/badge/rules/d-padmanabhan/agent-engineering-handbook/325-networking.svg)](https://agentmods.dev/rules/d-padmanabhan/agent-engineering-handbook/325-networking)
Your own site
<a href="https://agentmods.dev/rules/d-padmanabhan/agent-engineering-handbook/325-networking"><img src="https://agentmods.dev/badge/rules/d-padmanabhan/agent-engineering-handbook/325-networking.svg" alt="Measured on agentmods" height="20"></a>
Per session 39 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 2,634 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00039 $0.02634
Opus 5 $0.00019 $0.01317
Sonnet 5 $0.00008 $0.00527
Haiku 4.5 $0.00004 $0.00263

Measured 5d ago against content hash 04d56c6d1c3a, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

325-networking scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

- **Python:** module-level `requests.Session()` (or `httpx.Client`) with a mounted `HTTPAdapter`; do not call `requests.get()` ad-hoc in hot paths.
rules/325-networking.mdc · 212 lines

How it starts

The opening of the file, as written. The whole thing — 212 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Networking & Transport Non-Negotiables

Audience: engineers editing protobuf schemas, gRPC client/server code, network configuration (load balancers, edge), or HTTP client wiring.

Scope: the rules that auto-load when you touch those files. The depth and reasoning live in the networking-transport skill (skills/networking-transport/SKILL.md plus references for the gRPC-vs-REST decision matrix and protobuf schema evolution). This rule codifies the non-negotiables so they appear in context without needing to invoke the skill.

[!IMPORTANT] This rule complements 320-api-design.mdc (API surface: verbs, status codes, versioning) and 316-zero-trust.mdc Section 2 (network-tier security on top of the transport). Use this rule for transport-and-wire choices; use those for the API surface and the auth model.


Transport non-negotiables

NN1. HTTP and gRPC clients are reused across requests

A fresh client per request defeats connection pooling, defeats TCP keepalive, and burns 50-150ms / call on TCP+TLS handshake. The single most common production performance bug.

  • Go: package-level http.Client with a tuned Transport; do not construct one per call.
  • Python: module-level requests.Session() (or httpx.Client) with a mounted HTTPAdapter; do not call requests.get() ad-hoc in hot paths.
  • Node: shared https.Agent({ keepAlive: true }) passed via fetch(url, { agent }) (Node 18 and older defaults to keepAlive: false).
  • gRPC: one Channel per (target, credentials) pair, reused for the process lifetime; never new Channel() per call.

NN2. TCP keepalive is set explicitly and tuned below the load balancer idle timeout

Linux defaults (tcp_keepalive_time = 7200s = 2 hours) are wrong for cloud. Load balancers cut idle connections much sooner; the client never notices until the next send fails.

Set keepalive interval less than the proxy's idle timeout:

Proxy Idle timeout Suggested keepalive
AWS Network Load Balancer (NLB) 350s (fixed) 60-120s
AWS Application LB (ALB) 60s default (1-4000s configurable) 30s (or half the configured)
AWS API Gateway REST 29s (fixed) Don't keepalive; reconnect per request
Cloudflare WebSocket ~100s free / ~300s paid Application-level heartbeat every 30-60s
Nginx (proxy_read_timeout) 60s 30s
Envoy (stream_idle_timeout) 1h 30-300s by use case

Read the full file on GitHub · 212 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 5d ago First seen · 212 lines · 39 tokens per session scan A 04d56c6d1c3a

Subscribe to this mod's changes

325-networking is a cursor rule published in the GitHub repository d-padmanabhan/agent-engineering-handbook (16 stars, last pushed 5d ago), licensed MIT. It adds 39 tokens to every session and 2,634 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.