.claude/skills/base-client-guardian/SKILL.md
Guardrails for edits to core/base-client.js covering auth injection, retries, circuit breaker behavior, and request/response events. Use when modifying the universal API client or its auth/retry/error handling.
npx skillsauth add thefixer3x/onasis-gateway base-client-guardianInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This skill applies when modifying the Universal API Client (core/base-client.js).
The Base Client provides:
request() - Main entry point for API callsretryRequest() - Handles retry logic with backoffhealthCheck() - Service health verificationgenerateMethods() - Dynamic method generation from endpointsaddAuthentication() - Auth injection into requestsrequest - Emitted before each requestresponse - Emitted on successful responseerror - Emitted on request failurecircuit-breaker-open - Emitted when circuit opensbearer - Bearer token authapikey - API key (header or query)basic - Basic authhmac - HMAC signature authoauth2 - OAuth 2.0 authCLOSED -> OPEN -> HALF_OPEN -> CLOSED// MUST use exponential backoff
const delay = this.config.retryDelay * Math.pow(2, attempt - 1);
// MUST check shouldRetry() before retrying
if (attempt < this.config.retryAttempts && this.shouldRetry(error)) {
await this.sleep(delay);
return this.retryRequest(config, attempt + 1);
}
// MUST emit events after state changes
this.emit('request', { service, method, url, timestamp });
this.emit('response', { service, status, statusText, timestamp });
this.emit('error', { service, type, message, status, timestamp });
// MUST follow state machine
// On success: reset to CLOSED
this.circuitBreaker.failures = 0;
this.circuitBreaker.state = 'CLOSED';
// On failure: increment and potentially open
this.circuitBreaker.failures++;
if (this.circuitBreaker.failures >= 5) {
this.circuitBreaker.state = 'OPEN';
this.emit('circuit-breaker-open', { service, failures });
}
// On timeout: transition to HALF_OPEN
if (timeSinceLastFailure > 60000) {
this.circuitBreaker.state = 'HALF_OPEN';
}
// MUST handle all auth types in switch statement
switch (auth.type) {
case 'bearer':
case 'apikey':
case 'basic':
case 'hmac':
case 'oauth2':
// Implementation here
break;
}
// Add to the switch statement in addAuthentication()
case 'custom_auth_type':
config.headers['X-Custom-Auth'] = auth.config.customValue;
break;
// Extend shouldRetry() - do NOT replace existing conditions
shouldRetry(error) {
return (
error.code === 'ECONNRESET' ||
error.code === 'ETIMEDOUT' ||
error.code === 'ENOTFOUND' ||
error.code === 'YOUR_NEW_CODE' || // ADD here
(error.response && error.response.status >= 500)
);
}
// Add new events - do NOT modify existing event signatures
this.emit('your-new-event', { service, customData, timestamp });
| Component | Integration Method |
|-----------|-------------------|
| Metrics Collector | Listen to request, response, error events |
| Compliance Manager | Intercept in addAuthentication() |
| Version Manager | Pass version in request options |
| Vendor Abstraction | Uses request() method |
Before any changes to this file:
# 1. Run existing tests
npm test -- --grep "BaseClient"
# 2. Verify authentication works for all types
node -e "const BaseClient = require('./core/base-client'); const client = new BaseClient({ name: 'test', baseUrl: 'https://httpbin.org' }); console.log('Client initialized:', client.config.name);"
# 3. Test circuit breaker states
# Verify: CLOSED -> OPEN (after 5 failures) -> HALF_OPEN (after 60s)
# 4. Test retry logic
# Verify exponential backoff: delay * 2^(attempt-1)
If changes cause issues:
Immediate Rollback
git checkout HEAD~1 -- core/base-client.js
Verify Recovery
# Restart the server
bun run dev
# Check health endpoint
curl http://localhost:3001/health
Event Listener Check
// Verify all components can still receive events
client.on('request', () => console.log('Request event works'));
client.on('response', () => console.log('Response event works'));
client.on('error', () => console.log('Error event works'));
tools
# Onasis Gateway — Agent & IDE Skill Guide > **Read this file first.** This guide is the primary reference for AI agents (Claude, Cursor, Copilot, etc.) and developers working with the Onasis Gateway API integration repository. It covers all 16 third-party API integrations, Postman MCP setup, auth patterns, environment variables, and recommended workflows. --- ## Table of Contents 1. [Overview](#overview) 2. [Postman MCP Integration](#postman-mcp-integration) 3. [16 API Integrations](#16-api
data-ai
Guardrails for edits to core/versioning/version-manager.js covering semver validation, deprecation, migrations, and compatibility rules. Use when changing version registration or migration handling.
tools
Guardrails for edits to core/abstraction/vendor-abstraction.js that preserve vendor isolation, mappings, fallback selection, and stable client-facing schemas. Use when adding/removing vendors, operations, or schema fields.
tools
Use this skill when adding new methods, tools, or schema changes to the `@lanonasis/mem-intel-sdk`. Trigger when the user wants to extend the SDK with new capabilities, add a new MCP tool to mcp-core, add a new intelligence endpoint, or migrate the behavior_patterns schema. Also trigger when the user says things like "add a new tool to the SDK", "extend mem-intel-sdk", "add behavior X to the MCP server", or "update the SDK schema." Do NOT use for general behavior pattern recording/recall — use the behavior-memory skill for that.