agentleFS
roborracleroborracle/agent-workflow-kit/skills/api-client/SKILL.md

api-client

Skill0 starsChanged 3 months agoMITView on GitHub

Integrate with third-party APIs and webhooks. Covers authentication flows (OAuth, API keys, JWT), retry strategies, circuit breakers, rate limiting, webhook verification, and integration testing patterns.

  • Reads credentials

4 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

6 rules. 0 are common, 4 are distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 3 edited versions we read keep these.

  • 4

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Every third-party integration should follow this layered pattern:

    line 12
  2. Very specific:

    Use crypto.timingSafeEqual to compare HMAC-SHA256 digests.

    line 50
  3. Very specific:

    Read x-ratelimit-remaining and x-ratelimit-reset headers.

    line 58
  4. Distinctive:

    Test error paths: timeout, 5xx, rate limit, malformed response

    line 79
  5. Distinctive:

    Test auth token refresh flow

    line 80
  6. Distinctive:

    Verify idempotency key handling

    line 81

“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

API Integration Client

Integration Architecture

Client Structure

Every third-party integration should follow this layered pattern:

Transport Layer    → HTTP client with retry, timeout, circuit breaker
Auth Layer         → Token management, refresh, key rotation
API Layer          → Typed methods per endpoint
Error Mapping      → External errors → internal domain errors

HTTP Client Configuration

const client = {
  baseURL: config.API_BASE_URL,
  timeout: 10_000,              // 10s default, override per endpoint
  retries: 3,                   // Only on 5xx and network errors
  retryDelay: (attempt) =>      // Exponential backoff with jitter
    Math.min(1000 * 2 ** attempt + Math.random() * 1000, 30_000),
  headers: {
    'User-Agent': 'MyApp/1.0',
    'Accept': 'application/json',
  },
};

Authentication Patterns

API Key

// Header-based (preferred)
headers: { 'Authorization': `Bearer ${config.API_KEY}` }
// or
headers: { 'X-API-Key': config.API_KEY }

OAuth 2.0 Client Credentials

Fetch token with client_id/client_secret, cache with buffer before expiry. See reference/integration-patterns.md for full implementation.

HMAC Webhook Signature Verification

Use crypto.timingSafeEqual to compare HMAC-SHA256 digests. See reference/integration-patterns.md.

Resilience Patterns

Circuit Breaker

Three states: CLOSED (normal) → OPEN (reject all) → HALF-OPEN (probe). Open after 5 failures in 60s, cooldown 30s. See reference/integration-patterns.md.

Rate Limit Handling

Read x-ratelimit-remaining and x-ratelimit-reset headers. On 429, respect Retry-After. See reference/integration-patterns.md.

Idempotency Keys

For non-idempotent operations, send an Idempotency-Key header generated once per logical operation (e.g. a UUID stored with the pending operation) and reused unchanged on every retry. A key that includes a timestamp changes between retries and defeats deduplication.

Error Mapping

function mapExternalError(status: number, body: unknown): AppError {
  switch (status) {
    case 400: return new ValidationError('Invalid request to upstream', { upstream: body });
    case 401: return new AuthError('Upstream authentication failed');
    case 404: return new NotFoundError('Upstream resource not found');
    case 429: return new RateLimitError('Upstream rate limit exceeded');
    default:  return new UpstreamError(`Upstream returned ${status}`, { status, body });
  }
}

Integration Testing

  • Record real API responses as fixtures (sanitize secrets)
  • Replay fixtures in tests — never hit live APIs in CI
  • Test error paths: timeout, 5xx, rate limit, malformed response
  • Test auth token refresh flow
  • Verify idempotency key handling

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.