external-api-adapters
Use when designing, writing, or reviewing adapters for external APIs, ERP systems, payment providers, storage providers, or third-party services. Covers boundary contracts, typed clients, retries, timeouts, pagination, error normalization, observability, and tests. Do not use for pure internal domain logic with no external service boundary.
- License 许可
- MIT
- 最近更新
- 2026-11-14
- Stars
- ★ 0
- Forks
- 2
01 前言 Front Matter
- name
- external-api-adapters
- metadata
- { "tags": [ "backend", "api", "integration", "adapters" ], "author": "Marcio Altoé", "source": "https://github.com/marcioaltoe/skills", "version": "0.1.0", "category": "backend" }
- description
- Use when designing, writing, or reviewing adapters for external APIs, ERP systems, payment providers, storage providers, or third-party services. Covers boundary contracts, typed clients, retries, timeouts, pagination, error normalization, observability, and tests. Do not use for pure internal domain logic with no external service boundary.
03 SKILL.md 正文
External API Adapters
Use this skill when code crosses a process or vendor boundary.
Core Rules
- Keep external APIs behind adapters. Domain and use case code should depend on ports, not SDKs or HTTP client details.
- Convert external DTOs into internal domain/application types at the boundary.
- Normalize external errors into a small set of application errors.
- Set explicit timeouts for every network call.
- Make retry behavior deliberate, bounded, and safe for the operation.
- Capture correlation IDs, request IDs, vendor IDs, and pagination cursors as structured evidence.
- Keep credentials and raw sensitive payloads out of logs, snapshots, and thrown messages.
Adapter Shape
export interface ErpCustomerGateway {
fetchCustomer(id: CustomerId): Promise<ExternalCustomerResult>;
}
export class HttpErpCustomerAdapter implements ErpCustomerGateway {
async fetchCustomer(id: CustomerId): Promise<ExternalCustomerResult> {
// HTTP or SDK details stay here.
}
}
Prefer one adapter per external capability or bounded integration. Avoid large "vendor client" classes that mix unrelated operations.
Boundary Checklist
- Input is validated before leaving the application.
- Output is parsed and validated before entering the application.
- Timeouts are configured and tested.
- Retry policy is documented by operation.
- Non-idempotent calls have idempotency keys or no automatic retry.
- Pagination and cursors have deterministic stop conditions.
- Rate limit responses are handled explicitly.
- Logs include operation, external system, request ID, and safe identifiers.
- The adapter has tests for success, validation failure, timeout, retryable failure, non-retryable failure, and malformed response.
Retry Guidance
Retry only when the operation is idempotent or has an idempotency key. Do not retry validation failures, authentication failures, authorization failures, or permanent business-rule responses.
Use small bounded retries with jitter for transient network failures and 5xx responses. Surface repeated failure as a typed application error.
Error Normalization
Map vendor-specific details to application errors:
type ExternalServiceError =
| { kind: "unavailable"; retryAfterMs?: number; requestId?: string }
| { kind: "unauthorized"; requestId?: string }
| { kind: "not-found"; requestId?: string }
| { kind: "invalid-response"; requestId?: string; reason: string };
The rest of the application should not branch on SDK exception names or raw HTTP status codes unless the adapter contract explicitly exposes them.
Testing Guidance
- Unit test mapping and error normalization with focused fixtures.
- Use contract tests for real or recorded external response shapes.
- Keep fake clients behavior-based, not assertion-only mocks.
- Include negative fixtures for malformed, partial, and unexpected responses.
- Verify observability fields for failure paths when operations teams need them.
Common Mistakes
- Passing external DTOs through the application unchanged.
- Retrying non-idempotent operations.
- Hiding partial failure behind empty arrays or
undefined. - Treating all 4xx or all 5xx responses the same.
- Adding SDK imports throughout use case or domain code.
04 同仓库更多 Skills
startup-validator
Comprehensive startup idea validation and market analysis tool. Use when users need to evaluate a startup idea, assess market fit, analyze competition, validate problem-solution fit, or determine market positioning. Triggers include requests to "validate my startup idea", "analyze market opportunity", "check if there's demand for", "research competition for", "evaluate business idea", or "see if my idea is viable". Provides data-driven analysis using web search, market frameworks, competitive research, and positioning recommendations.
positioning-icp
When the user wants to define their ideal customer profile, position an AI product, build messaging architecture, or validate product-market fit. Also use when the user mentions 'ICP,' 'ideal customer profile,' 'positioning,' 'PMF,' 'product-market fit,' 'messaging,' 'buyer persona,' 'enrichment signals,' 'market positioning,' or 'competitive positioning.' This skill covers market positioning, ICP definition, messaging architecture, and PMF validation for AI-native products. Do NOT use for technical implementation, code review, or software architecture.
copywriting
When the user wants to write or rewrite page copy (homepage, landing, pricing, feature), or asks which headline, promise, or message to lead with. Diagnoses the input first (blank brief, real voice, or point edit) and changes only what it calls for. Claims must be supportable; a declined claim names the evidence that would unlock it. No AI tells like 'it's not X, it's Y' or 'no X, no Y, no Z'. For editing, see copy-editing. For emails, see emails. For the offer, see offers.
business-storyteller
Transforms technical work into persuasive business-language documents for non-technical stakeholders, including internal announcements, approval proposals, incident explainers, technical-debt cases, product explainers, and investor or partner memos. Use when the user asks to present technical work to the company, explain software to business teams, write a business case, make an approval document, or convert a technical artifact into stakeholder communication in the requested language. Do not use for READMEs, specs, ADRs, external marketing pages, or customer-facing sales copy.
brand-storytelling
Help users craft compelling brand narratives. Use when someone is defining brand strategy, writing company positioning, creating pitch narratives, developing messaging frameworks, or trying to make their company story more memorable.
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.