$ recombobulate _
home / tips / ask-claude-to-create-api-mocks-from-your-actual-integration-code
124

Ask Claude to Create API Mocks from Your Actual Integration Code

recombobulate @recombobulate · Mar 29, 2026 · Workflows
ask-claude-to-create-api-mocks-from-your-actual-integration-code

Developing against external APIs is painful — rate limits, authentication requirements, and services going down all block your workflow. Claude reads your actual API integration code and generates mock responses that match the real data shape.

Read how we call the Stripe API in src/billing/. Generate mock responses 
for each endpoint we use — payment intents, customers, subscriptions — 
with realistic data that covers the happy path and common error states.

Claude reads your API client code, checks what fields you actually access in the response, and generates mocks that match:

{
  "id": "pi_mock_1234567890",
  "object": "payment_intent",
  "amount": 2999,
  "currency": "usd",
  "status": "succeeded",
  "customer": "cus_mock_abc123"
}

Target different mocking needs:

# Generate a complete mock server
Read all external API calls in src/services/. Create a mock server 
that returns realistic responses for each endpoint. Include error 
responses for testing error handling.

# Create test fixtures
Generate JSON fixtures for every external API response our tests need. 
Base the shape on the actual response types we've defined in types/api.ts.

# Mock with edge cases
Create mock responses that test edge cases — pagination with empty pages, 
webhooks with duplicate event IDs, API responses with optional fields 
missing, and rate limit responses.

# Environment-based mocking
Set up a mock mode that activates when an env variable is set, so the 
app uses mock responses in development but real APIs in staging and production.

Ask Claude to keep the mocks maintainable:

Generate a mock factory for each external service. Each factory should 
accept overrides so tests can customise specific fields without rebuilding 
the entire response. Follow the factory pattern used in our existing test helpers.

External APIs are someone else's uptime — mock them locally so your development never blocks on a third-party service.

via Claude Code

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

Log in to leave a comment.

~/recombobulate $ tip --related --limit=3
0
Run Claude Code in GitHub Actions to Automatically Review Every Pull Request

Set up Claude Code as an automated reviewer in your CI pipeline — on every pull request, it reads the diff, checks for bugs, security issues, missing tests, and convention violations, then posts its findings as a PR comment. Your human reviewers get a head start because the obvious issues are already flagged before they look.

recombobulate @recombobulate · 1 day ago
0
Ask Claude to Build a Deployment Checklist from Your Actual Infrastructure

Before deploying, tell Claude to read your project — migrations, environment variables, queue workers, scheduled tasks, caching, third-party integrations — and generate a deployment checklist that's specific to your app. Not a generic "did you run migrations?" list, but one that knows YOUR infrastructure and catches the things YOUR deploy can break.

recombobulate @recombobulate · 1 day ago
0
Ask Claude to Generate a README from Your Actual Codebase — Not a Template

Instead of writing a README from memory or copying a template, tell Claude to read your project and generate one that's actually accurate — real setup instructions from your config, real architecture from your directory structure, real API examples from your routes, and real prerequisites from your dependency files.

recombobulate @recombobulate · 1 day ago