home / skills / velcrafting / codex-skills / integration-adapter
This skill helps you implement a robust external API adapter with timeouts, bounded retries, idempotency, and error mapping for reliable integrations.
npx playbooks add skill velcrafting/codex-skills --skill integration-adapterReview the files below or copy the command above to add this skill to your agents.
---
name: integration-adapter
description: Build an external API adapter with timeouts, retries, idempotency, and error mapping.
metadata:
short-description: External adapter + reliability policy
layer: backend
mode: write
idempotent: false
---
# Skill: backend/integration-adapter
## Purpose
Integrate with an external service via a dedicated adapter that enforces:
- timeouts
- retry policy
- idempotency where applicable
- error mapping into shared taxonomy
- observability (logs/metrics/traces) consistent with repo standards
This skill prevents “HTTP calls sprinkled everywhere.”
---
## Inputs
- External API/service name + base URL (or SDK)
- Required operations (list)
- Auth mechanism (token, key, oauth) WITHOUT secrets
- Expected failure cases (timeouts, rate limits, invalid responses)
- Repo profile (preferred): `<repo>/REPO_PROFILE.json`
---
## Outputs
- Adapter module with a narrow interface
- Retry/timeout configuration
- Error mapping to shared taxonomy
- Contract tests or mocks (preferred)
- Minimal observability instrumentation
---
## Non-goals
- Implementing domain rules (use `backend/domain-logic-module`)
- Building orchestration/jobs (use `backend/job-worker-orchestration`)
- Storing secrets in code
---
## Workflow
1) Create adapter boundary:
- `ExternalServiceClient` or module functions
2) Implement calls with:
- explicit timeouts
- bounded retries (with backoff) where safe
- idempotency keys when supported/needed
3) Normalize errors:
- map external errors to internal taxonomy
4) Add contract tests/mocks:
- validate request construction
- validate response parsing and error handling
5) Add basic observability:
- correlation id propagation if present
6) Run validations per profile.
---
## Checks
- Adapter is the only place external calls exist for this integration
- Timeouts are explicit
- Retry policy is bounded and safe (no infinite loops)
- If retries, backoff, rate limiting, or multi-step external workflows are introduced,
- recommend `system/state-machine-mapper` to model external interaction states explicitly.
- Errors map to internal taxonomy
- Tests cover:
- success
- timeout or retry scenario
- bad response parsing
---
## Failure modes
- Retry safety unclear → default to no retry and document why.
- Rate limits encountered → add backoff and respect headers if available.
- External contract unstable → increase mocking/contract tests and tighten parsing.
- Retry/backoff logic added without explicit state modeling →
require `system/state-machine-mapper` before shipping.
---
## Telemetry
Log:
- skill: `backend/integration-adapter`
- service: `<name>`
- retries: `none | bounded`
- timeout
This skill helps build a focused external API adapter that centralizes all outbound calls and enforces timeouts, retries, idempotency, and error mapping into a shared taxonomy. It produces a narrow client interface, config for retry/timeouts, basic observability, and contract tests or mocks. The goal is deterministic, testable integration code and to avoid HTTP calls scattered across the codebase.
You define the external service, operations, and auth (without embedding secrets). The adapter implements calls with explicit timeouts, bounded retries and backoff when safe, and idempotency keys where appropriate. It normalizes external errors into the internal taxonomy and emits minimal logs/metrics/traces with correlation propagation. Contract tests or mocks validate request shape, parsing, and error handling.
Should I always enable retries?
No. Default to no retry when safety is unclear. Enable bounded retries only for operations that are idempotent or safe to repeat and document the rationale.
Where should secrets live?
Do not store secrets in code. Use your platform's secret store or environment configuration and pass non-secret auth metadata into the adapter.