Documentation and dx

From oborchers/fractional-cto · View interactive version

Documentation and dx is an AI agent skill from the GitHub repository oborchers/fractional-cto. This skill should be used when the user is writing API documentation, designing developer onboarding, building interactive API explorers, generating SDKs, creating code examples, setting up sandbox environments, implementing API changelogs, or optimizing time-to-first-API-call. Covers three-panel do

How to use this skill

Skill file

Your Docs Are Your Best Salesperson

Documentation is the #1 factor in API adoption. SmartBear surveys consistently show that "accurate and detailed documentation" is the top requirement developers cite when evaluating an API. Stripe and Twilio did not win because they had better infrastructure -- they won because their docs made developers productive in minutes, not days. Every hour you invest in documentation returns tenfold in reduced support tickets, faster integration times, and higher conversion from free-tier to paid.

Three-Panel Layout

Adopt the Stripe three-panel pattern: navigation on the left, conceptual content in the center, runnable code on the right. This layout lets developers read context and copy code simultaneously without scrolling or switching tabs.

Navigation panel rules:

Content panel rules:

Code panel rules:

Time to First API Call Under 5 Minutes

"Time to first API call" (TTFAC) is the single most important developer experience metric. Stripe achieves approximately 3 minutes. AWS takes 30+ minutes. The difference is not complexity -- it is onboarding design.

The ideal onboarding flow:

  1. Sign up with email and password -- no credit card required
  2. Dashboard immediately shows API keys with no email verification required for sandbox access
  3. A "Get Started" page presents a cURL command pre-filled with the developer's actual test key
  4. The developer pastes the command, sees a real response, and feels accomplishment
  5. "Next steps" links lead to SDK quickstarts in their chosen language

Pre-fill everything. When a developer is logged into your docs site, render their real test API key directly into every code example. Never show YOUR_API_KEY as a placeholder. Copy-paste friction kills onboarding.

Code Examples in 3+ Languages

Provide code examples in at minimum cURL, Python, and JavaScript/Node.js. High-value additions are Ruby, PHP, Java, and Go. Every example must be complete and runnable -- no // ... your code here ... placeholders, no truncated response bodies.

Quality rules:

Structure the docs hierarchy clearly:

Interactive "Try It" Explorers

Embed interactive API explorers directly in the documentation so developers can make real or simulated calls without leaving the page. Swagger UI and Redoc both support "Try It" panels that can be pre-populated with sandbox credentials.

Best practices:

Tier your explorers: embedded Try-It in docs is the minimum, a standalone Postman workspace or custom console is better, and a guided interactive tutorial that walks through multi-step flows is best.

Sandbox Environments

Every API that handles real data or real money must provide a sandbox. Use the "separate keys" pattern -- test keys (sk_test_...) hit the same API but a separate test database. This is lowest-friction because developers do not need to change base URLs or configure separate environments.

Sandbox rules:

Onboarding Checklist

Design the onboarding path so a developer can go from signup to receiving their first webhook in under 10 minutes:

  1. Sign up -- email and password only, no credit card
  2. Get API key -- visible on the dashboard immediately, no email verification for sandbox
  3. Make first call -- copy-paste a pre-filled cURL command from docs
  4. Install SDK -- one-line install command for their language
  5. Create a resource -- guided example that creates something real in the sandbox
  6. Receive a webhook -- set up a local listener (provide a CLI tool or ngrok instructions), trigger a test event, see the payload arrive

Track TTFAC as a product metric. Measure it in user testing. Optimize it quarterly. Every friction point you remove from onboarding directly increases adoption.

Error Messages as Documentation

Every error response is an opportunity to teach. Include a doc_url field in every error that links directly to a help page explaining the error, its common causes, and resolution steps.

The anatomy of a great API error:

Rules for error messages:

SDK Generation Strategy

Choose between auto-generated SDKs, hand-crafted SDKs, or the recommended hybrid approach.

Auto-generated (openapi-generator, Stainless, Fern, Speakeasy) is fast and consistent but produces unidiomatic, hard-to-use code. Hand-crafted (Stripe, Twilio) feels native to each language but costs an entire team per language. Hybrid is the sweet spot: generate a base client from the OpenAPI spec, then layer hand-crafted ergonomic wrappers on top.

The hybrid workflow:

  1. Generate a base client from the OpenAPI spec
  2. Add ergonomic wrappers: custom method names, builder patterns, convenience methods
  3. Generate tests from the spec to validate the hand-crafted layer
  4. Hand-write quickstart and conceptual documentation, auto-generate reference docs

The difference matters: client.apis.default_api.create_payment_intent_api_v1_payment_intents_post(...) versus stripe.PaymentIntent.create(amount=2000, currency="usd"). Developers judge your entire platform by how your SDK feels.

Changelog and Breaking Change Communication

Maintain a date-stamped changelog with categorization: Added, Changed, Deprecated, Removed, Fixed. Note the API version on every entry. Provide an RSS/Atom feed so developers can subscribe. Show dashboard banners when a developer's pinned API version approaches end-of-life.

Migration guide formula:

  1. What changed (one sentence)
  2. Why it changed (context reduces frustration)
  3. What to do (step-by-step code diff showing old versus new)
  4. Deadline (when the old behavior is removed)
  5. Testing instructions (how to verify the migration worked)

Deprecation lifecycle: Announce with Sunset header and docs notice, then soft-deprecate for 6 months with SDK warnings and monthly emails, then hard-deprecate with aggressive rate limits and dashboard countdowns, then remove after 12+ months by returning 410 Gone with migration instructions in the response body.

API Design Review Process

Adopt design-first for public APIs: write the OpenAPI specification before writing any code. The spec is the contract. Frontend and backend teams can work in parallel (frontend builds against a Prism mock server), and the design review catches naming issues, missing fields, and inconsistencies before any code is written.

The design-first workflow:

  1. Product requirements
  2. Write OpenAPI spec
  3. Lint the spec with Spectral (enforce snake_case, required descriptions, required examples)
  4. Design review by 1-2 API-experienced engineers
  5. Generate mock server with Prism for frontend development
  6. Backend implements against the spec
  7. Contract tests verify implementation matches spec
  8. Deploy

Establish a formal review checklist: resources are nouns, collections are plural, all fields use snake_case, boolean fields use is_ or has_ prefix, timestamps use _at suffix, every list endpoint supports pagination, every error scenario is documented.

Contract Testing

Contract tests verify that the running API matches the OpenAPI specification. Run them in CI on every pull request.

Schemathesis generates test cases from the spec and throws them at the API -- it checks that response schemas match, status codes are correct, and edge cases (empty strings, huge numbers, special characters) do not crash the server. Dredd tests every endpoint in the spec against a running server and reports which responses violate the contract.

Integrate both into CI:

  1. Lint the OpenAPI spec with Redocly CLI
  2. Check for breaking changes with Optic (compare spec against the main branch)
  3. Start the API server
  4. Run Schemathesis with --checks all for fuzz testing
  5. Run Dredd for strict compliance testing

Contract tests should verify: response schemas match the spec, required fields are always present, status codes match the spec, error responses conform to the error schema, pagination has_more is accurate, and Content-Type headers are correct.

Review Checklist

When building or reviewing API documentation and developer experience:

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.