HTTP
Use HTTP correctly with proper methods, status codes, headers, and caching.
by clawic★ 23 GitHub stars
Install HTTP in Claude Code & Claude Desktop
Sign up to install this skill
Create a free account to reveal the install command and save the skill to your library.
- Reveal the one-line install command
- Save skills to your synced library
- Get notified when skills update
About this skill
Redirects (Often Confused)
- 307 vs 308: both preserve method; 307 temporary, 308 permanent—use these for POST/PUT redirects
- 301/302 may change POST to GET (browser behavior)—don't use for API redirects with body
- Include
Locationheader with absolute URL—relative may fail in older clients - Redirect loops: limit to 5-10 follows; infinite loops crash clients
Caching Combinations
Cache-Control: no-storefor sensitive data—never written to diskno-cachestill caches but revalidates every time—not "don't cache"private, max-age=0, must-revalidatefor user-specific, always-fresh contentpublic, max-age=31536000, immutablefor versioned static assetsVary: Accept-Encoding, Authorizationwhen response depends on these headers—forgetting Vary breaks caching
Conditional Requests
ETag+If-None-Match: prefer for APIs—content hash based- Strong vs weak ETags:
"abc"vsW/"abc"—weak allows semantically equivalent responses If-Matchfor optimistic locking: fail update if resource changed since read- 412 Precondition Failed when
If-Matchfails—not 409 Conflict
CORS Preflight Triggers
- Custom headers (anything not Accept, Accept-Language, Content-Language, Content-Type simple values)
- Content-Type other than: application/x-www-form-urlencoded, multipart/form-data, text/plain
- PUT, DELETE, PATCH methods—even to same origin if other conditions met
- ReadableStream body—triggers preflight
- Preflight cached per
Access-Control-Max-Age—set to 86400 to reduce OPTIONS spam
Security Headers (Always Set)
Strict-Transport-Security: max-age=31536000; includeSubDomains—HSTS, once set can't easily undoX-Content-Type-Options: nosniff—prevents MIME sniffing attacksX-Frame-Options: DENYorSAMEORIGIN—prevents clickjackingContent-Security-Policy—complex but essential; start with report-only mode
Range Requests
Accept-Ranges: bytessignals support—clients can request partial contentRange: bytes=0-1023requests first 1024 bytes;bytes=-500requests last 500- Return 206 Partial Content with
Content-Range: bytes 0-1023/5000 - 416 Range Not Satisfiable if range invalid—include
Content-Range: bytes */5000
Error Response Best Practices
- Structured JSON errors:
{"error": {"code": "VALIDATION_FAILED", "message": "...", "details": [...]}} - Include request ID in error response—enables log correlation
- Don't leak stack traces in production—log server-side, return generic message
- 409 Conflict for business rule violations (duplicate email, insufficient funds)—not just 400
Retry Patterns
- Retry only idempotent methods by default—GET, PUT, DELETE, HEAD
- POST retry needs idempotency key—
Idempotency-Key: <client-generated-uuid> - Exponential backoff: 1s, 2s, 4s, 8s... with jitter—prevents thundering herd
- Respect
Retry-Afterheader—can be seconds or HTTP date - Set reasonable timeout (30s typical)—don't wait forever
Headers Often Forgotten
Vary: must include headers that affect response—CORS withoutVary: OriginbreaksContent-Disposition: attachment; filename="report.pdf"for downloadsX-Request-ID: generate if not present, propagate to downstream servicesAccept-Languagefor localized responses—respect with graceful fallback
Connection Behavior
- HTTP/1.1 without
Content-Lengthor chunked = connection close after response Transfer-Encoding: chunkedfor streaming—can't set Content-Length- HTTP/2 is binary, multiplexed—no head-of-line blocking at HTTP level
- WebSocket upgrade: GET with
Connection: Upgrade,Upgrade: websocket
Allowed tools
Tools this skill is permitted to call.
No restriction — this skill can use any tool.
Bundled files
- _meta.json
FAQ
What does the HTTP skill do?
Use HTTP correctly with proper methods, status codes, headers, and caching.
How do I install the HTTP skill?
Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.
Does the HTTP skill run scripts?
No, this skill is instructions only (SKILL.md) with no executable scripts.
Related skills
theme-factory
AnthropicToolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
access
AnthropicManage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
configure
AnthropicSet up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
access
AnthropicManage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…