| name | adapter-scaffold |
| description | Scaffold new POS or payment adapter implementations. Use when adding support for Square, Toast, Clover, Stripe, or other integrations. |
| disable-model-invocation | false |
| allowed-tools | Read, Write, Bash(cd packages/*) |
Adapter Scaffold Generator
This skill generates new POS or payment adapter implementations following the adapter pattern.
Workflow
-
Gather Requirements
Ask user:
- Adapter Type: POS or Payment?
- Vendor Name: Square, Toast, Clover, Stripe, PayPal, etc.
Example:
Creating new adapter. Please provide:
1. Adapter type (POS or Payment):
2. Vendor name (e.g., Square, Toast, Stripe):
-
Read Adapter Interface
For POS Adapters:
cat packages/pos-adapters/src/types.ts
Interface includes:
testConnection(config) - Verify credentials and API access
pullMenu(config) - Fetch menu from POS system
pushOrder(config, order) - Send order to POS
parseWebhook(body, headers) - Parse webhook events
parseStockUpdate(webhookData) - Parse inventory updates
For Payment Adapters:
cat packages/payment-adapters/src/types.ts
Interface includes:
createPayment(config, amount, metadata) - Create payment intent
parseWebhook(body, headers) - Parse webhook events
refund(config, paymentId, amount) - Process refunds
-
Read Example Implementation
For POS:
cat packages/pos-adapters/src/square.ts
For Payment:
cat packages/payment-adapters/src/stripe.ts
-
Generate Adapter File
Create new file at:
- POS:
packages/pos-adapters/src/{vendor}.ts
- Payment:
packages/payment-adapters/src/{vendor}.ts
Template Structure:
import { IPosAdapter, PosConfig, PosMenu, PosOrder, PosWebhookEvent } from './types';
export class {Vendor}Adapter implements IPosAdapter {
async testConnection(config: PosConfig): Promise<boolean> {
();
}
(: ): <> {
();
}
(: , : ): <> {
();
}
(: , : <, >): | {
();
}
(: ): { : ; : } | {
();
}
}
-
Update Package Exports
Add to packages/{pos|payment}-adapters/src/index.ts:
export * from './{vendor}';
-
Generate Test Stub
Create packages/{pos|payment}-adapters/src/{vendor}.test.ts:
import { describe, it, expect } from 'vitest';
import { {Vendor}Adapter } from './{vendor}';
describe('{Vendor}Adapter', () => {
const adapter = new {Vendor}Adapter();
describe('testConnection', () => {
it('should validate API credentials', async () => {
});
});
describe('pullMenu', () => {
it('should fetch and transform menu data', async () => {
});
});
describe('pushOrder', () => {
it('should create order in {Vendor} system', async () => {
});
});
(, {
(, {
});
(, {
});
});
});
-
Provide Implementation Guidance
Critical Security Requirements:
-
Webhook Signature Verification:
const signature = headers['x-{vendor}-signature'];
const expectedSignature = crypto
.createHmac('sha256', config.webhookSecret)
.update(JSON.stringify(body))
.digest('hex');
if (signature !== expectedSignature) {
return null;
}
-
Encrypted Config Storage:
interface {Vendor}Config extends PosConfig {
apiKey: string;
apiSecret: string;
locationId: string;
}
-
Error Handling:
try {
const response = await fetch('{vendor-api-url}', {
headers: { Authorization: `Bearer ${config.apiKey}` }
});
(!response.) {
();
}
response.();
} (error) {
.(, error);
();
}
-
Remind About Next Steps
After scaffolding:
- Read vendor API documentation
- Set up test account with vendor
- Implement each method incrementally
- Add integration tests with real API (use test mode)
- Update
apps/api/src/services/pos-service.ts to register new adapter
- Add vendor to dashboard settings UI
- Document required config fields in
docs/
Common Pitfalls
1. Forgetting AGPL Header
Every new file must include the license header.
2. Incomplete Interface Implementation
All methods must be implemented, even if just throwing "Not implemented" initially.
3. Hardcoding Credentials
Never put API keys in code - always use config parameter.
4. Skipping Webhook Verification
Unverified webhooks are a security risk - always validate signatures.
5. Not Handling Pagination
Many POS APIs paginate menu/order data - implement pagination handling.
6. Ignoring Rate Limits
Implement exponential backoff for API calls to respect rate limits.
Testing Checklist
Before marking adapter complete: