go-http-client-resilience
Design, implement, test, and review resilient Go HTTP client boundaries with context propagation, layered timeouts, transport reuse, request construction, authentication, status classification, bounded bodies, retry safety, backoff, rate limits, pagination, observability, and deterministic fakes. Use when a Go CLI or service calls remote APIs or when HTTP behavior is slow, flaky, unsafe, or hard to test.
- License 许可
- MIT
- 最近更新
- 2026-11-14
- Stars
- ★ 1.6k
- Forks
- 491
01 前言 Front Matter
- name
- go-http-client-resilience
- license
- MIT
- metadata
- { "tags": "go,golang,http,client,resilience,retries,api", "version": "0.3.0", "category": "Go", "displayName": "Go HTTP Client Resilience" }
- description
- Design, implement, test, and review resilient Go HTTP client boundaries with context propagation, layered timeouts, transport reuse, request construction, authentication, status classification, bounded bodies, retry safety, backoff, rate limits, pagination, observability, and deterministic fakes. Use when a Go CLI or service calls remote APIs or when HTTP behavior is slow, flaky, unsafe, or hard to test.
- compatibility
- Codex, Claude Code, and other Agent Skills-compatible clients.
02 资源文件 6
- 参考文档agents/openai.yaml235 B
- 参考文档guidelines.md1.5 KB
- 参考文档references/http-client-resilience/examples.md2.2 KB
- 参考文档references/http-client-resilience/knowledge.md2.5 KB
- 参考文档references/http-client-resilience/rules.md2.4 KB
- 参考文档workflows/build-http-client.md1.9 KB
03 SKILL.md 正文
Go HTTP Client Resilience
Treat HTTP as a failure-prone boundary with a finite time and resource budget. Retry only when both the failure and the operation are safe.
Core Workflow
- Define operation semantics, total deadline, idempotency, and response limits.
- Reuse a configured client and transport; propagate context into every request.
- Construct URLs, headers, authentication, and bodies without secret leakage.
- Classify transport, timeout, status, protocol, and decode failures.
- Add bounded retries with jitter only for safe transient cases.
- Drain or close bodies correctly and bound all reads.
- Test with a function-backed transport and focused integration server.
Read Next
| Task | Load |
|---|---|
| Build or overhaul an HTTP client | guidelines.md, workflows/build-http-client.md |
| Configure deadlines, retries, or pagination | references/http-client-resilience/rules.md |
| Review Go patterns | references/http-client-resilience/examples.md |
| Understand failure and budget models | references/http-client-resilience/knowledge.md |
Guardrails
- Never use an unbounded body read or an unbounded retry loop.
- Do not retry unsafe operations without an idempotency mechanism.
- Do not create a new transport per request.
- Do not log authorization headers, cookies, tokens, or unreviewed bodies.
- Close every non-nil response body, including non-2xx responses.
Source Notes
Guidance is transformed and paraphrased from Marian Montagnino, Building Modern CLI Applications in Go (Packt, 2023), especially Chapter 6, and Ricardo Gerardi, Powerful Command-Line Applications in Go (2021).
Streaming, transport-pool, and HTTP test guidance also incorporates transformed material from Inanc Gumus, Go by Example: Programmer's Guide to Idiomatic and Testable Programs (Manning, 2025), Chapter 7.
Body ownership and client-timeout guidance also incorporates transformed material from Teiva Harsanyi, 100 Go Mistakes and How to Avoid Them (Manning, 2022), Chapter 10.
Verify behavior against https://pkg.go.dev/net/http and current API-specific rate-limit, pagination, and idempotency documentation.
04 同仓库更多 Skills
worktable-review-with-annotations
Create, inspect, reply to, update, or resolve situated Worktable annotations. Use when feedback belongs to a Doc section, block, text range, or HTML Doc, or when the user asks to address existing review feedback and coordinate a requested artifact edit.
worktable-find-and-synthesize-context
Find, assess, and synthesize context from Worktable Docs and Records. Use when the user asks what a workspace contains, wants workspace-backed research, needs current facts reconciled across artifacts, or requests a cited synthesis without changing workspace state.
worktable-create-or-update-docs
Create, edit, rename, or maintain narrative Worktable Docs. Use for plans, decisions, briefs, notes, research syntheses, and other durable prose when the user requests a new artifact or a safe update to an existing one.
worktable-create-or-manage-records
Organize repeated structured information as durable Worktable Records. Use for research datasets, inventories, directories, pipelines, trackers, and other collections whose items need identity, fields, filtering, links, validation, or individual updates.
worktable-create-or-manage-interactive-html
Create or improve durable visual and interactive artifacts in Worktable. Use for dashboards, trackers, calculators, mini apps, slide presentations, and other requests that benefit from a polished HTML Doc.
worktable-collaborate-threads
Read, answer, and hand off messages through durable Worktable threads with users or other authenticated participants. Use when the user asks to check addressed messages, reply to a participant, continue a thread, request another agent's help, wait briefly for a response, or watch for comments and messages sent to the agent.