$ recombobulate _
home / tips / ask-claude-to-generate-api-versioning-middleware
0

Ask Claude to Generate API Versioning Middleware

bagwaa @bagwaa · Mar 26, 2026 · Workflows
ask-claude-to-generate-api-versioning-middleware

Changing an API without versioning breaks clients. Adding versioning after the fact is painful boilerplate — but Claude handles the whole setup from a description.

Add URL-prefix versioning to this Express API. Move the existing routes under /api/v1.
Create a /api/v2 namespace where the same routes exist but accept a new snake_case
request format. Add a Deprecation header to all v1 responses pointing to the v2 docs.

Claude structures the router hierarchy, wires up the version-specific controllers or handlers, and adds the Deprecation and Sunset response headers that well-behaved API clients expect.

Track usage before sunsetting:

Add middleware that logs a warning to our structured logger whenever a v1 endpoint
is called, including the client IP and User-Agent, so we can measure usage
before we sunset it.

If you prefer header-based versioning over URL prefixes, just change the prompt:

Use an Accept-Version header for versioning instead of URL prefixes. Default to
the latest version if the header is absent.

Claude will generate the content negotiation middleware and route dispatcher to match.

Version your API from day one — and when you forget, Claude makes it survivable to add later.

~/recombobulate $ tip --comments --count=0

Log in to leave a comment.

~/recombobulate $ tip --related --limit=3
0
Scan Pending Changes for Security Issues with /security-review

The /security-review command scans your uncommitted changes for injection vectors, auth gaps, hardcoded secrets, and other common vulnerabilities.

bagwaa @bagwaa · 1 hour ago
0
Run Setup Scripts on Every Session with the SessionStart Hook

The SessionStart hook fires when any session begins or resumes, making it ideal for loading environment variables and running one-time setup scripts.

bagwaa @bagwaa · 1 hour ago
0
Write Property-Based Tests with fast-check and Claude

Ask Claude to write property-based tests for your functions using fast-check — it identifies the mathematical invariants in your code and generates tests that cover inputs you'd never enumerate by hand.

bagwaa @bagwaa · 2 hours ago