backend-bff-pattern
Use when the user asks about Backend for Frontend (BFF), a mobile vs web API layer, API aggregation or composition for one client, or a frontend-specific…
от j4flmao★ 47 звёзд на GitHub
Установить backend-bff-pattern в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Backend BFF Pattern
Purpose
Design specialized Backend for Frontend (BFF) services that compose and transform backend APIs for each client type (web, mobile, IoT, third-party), reducing over-fetching and client complexity.
Agent Protocol
Trigger
Exact user phrases: "BFF", "Backend for Frontend", "API gateway", "gateway specialization", "frontend API", "mobile API", "web API", "API composition", "aggregation service", "frontend gateway", "BFF pattern".
Input Context
- Client types consuming the API (web, iOS, Android, third-party).
- Backend microservices architecture.
- Latency and data shape requirements per client.
Output Artifact
BFF architecture design or implementation snippet. No file unless requested.
Response Format
BFF: {client type}
Backing Services: [{service list}]
Composition: {aggregation|transformation|caching}
Security: {auth pattern}
Completion Criteria
- BFF per distinct client type defined.
- API composition logic documented.
- Auth model appropriate for each BFF.
- Caching and error handling configured.
- No business logic in BFF — only orchestration.
Max Response Length
4 lines per BFF. 20 lines for full design.
Workflow
Step 1: Identify Client Types
Web BFF -> SPA (React, Vue)
Mobile BFF -> iOS + Android apps
Partners BFF -> Third-party integrations
Admin BFF -> Internal admin panel
Step 2: Design BFF API per Client
Each BFF exposes APIs shaped for its client:
// Web BFF: returns a page-shaped response
GET /api/web/checkout/{cartId}
{
"items": [
{"id": "prod-1", "name": "Widget", "quantity": 2, "price": 19.99, "image": "https://..."}
],
"subtotal": 39.98,
"shipping": 5.99,
"tax": 3.20,
"total": 49.17,
"shippingOptions": [
{"id": "standard", "name": "Standard", "price": 5.99, "estimate": "5-7 days"},
{"id": "express", "name": "Express", "price": 12.99, "estimate": "2-3 days"}
],
"paymentMethods": [
{"id": "card", "name": "Credit Card", "last4": "4242", "expiry": "04/27"}
]
}
// Mobile BFF: returns a compact response with mobile-specific fields
GET /api/mobile/checkout/{cartId}
{
"total": 49.17,
"shippingOptions": ["standard", "express"],
"defaultPayment": "card_4242"
}
// Partner BFF: returns normalized data with partner-specific metadata
GET /api/partners/checkout/{cartId}?partner=acme
{
"orderReference": "ext-123",
"items": [...],
"commission": 2.46,
"total": 49.17
}
Step 3: Implement Composition
// Web BFF composition logic
class WebCheckoutComposer {
constructor(
private cartService: CartServiceClient,
private pricingService: PricingServiceClient,
private shippingService: ShippingServiceClient,
private paymentService: PaymentServiceClient,
private cache: CacheService,
) {}
async getCheckout(cartId: string, userId: string): Promise<CheckoutResponse> {
const cacheKey = `checkout:web:${cartId}`;
const cached = await this.cache.get(cacheKey);
if (cached) return JSON.parse(cached);
try {
const [cart, pricing, shipping, payment] = await Promise.all([
this.cartService.getCart(cartId),
this.pricingService.calculateTotal(cartId),
this.shippingService.getOptions(cartId, { zipCode: cart.zipCode }),
this.paymentService.getMethods({ userId }),
]);
const response = {
items: cart.items.map(item => ({
id: item.productId,
name: item.name,
quantity: item.quantity,
price: item.unitPrice,
image: item.imageUrl,
})),
subtotal: pricing.subtotal,
shipping: pricing.shipping,
tax: pricing.tax,
total: pricing.total,
shippingOptions: shipping.options.map(opt => ({
id: opt.id,
name: opt.displayName,
price: opt.price,
estimate: opt.deliveryEstimate,
})),
paymentMethods: payment.methods.map(m => ({
id: m.id,
name: m.displayName,
last4: m.lastFourDigits,
expiry: m.expiryDate,
})),
};
await this.cache.set(cacheKey, JSON.stringify(response), { ttl: 30 });
return response;
} catch (error) {
throw new BffError('Failed to compose checkout', {
cartId,
cause: error,
partial: await this.buildPartialResponse(cartId),
});
}
}
private async buildPartialResponse(cartId: string): Promise<Partial<CheckoutResponse>> {
try {
const cart = await this.cartService.getCart(cartId);
return { items: cart.items, subtotal: cart.totalAmount };
} catch {
return {};
}
}
}
Step 4: Handle Auth per BFF
| BFF Type | Auth Mechanism | Token Storage | CSRF |
|---|---|---|---|
| Web BFF | Session cookie | httpOnly cookie | SameSite=Strict + CSRF token |
| Mobile BFF | Bearer JWT | Device keystore | Not needed |
| Partner BFF | API Key + HMAC | Server-side |
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
- references/bff-advanced.md
- references/bff-architecture.md
- references/bff-auth-session.md
- references/bff-fundamentals.md
- references/bff-implementation-strategies.md
- references/bff-orchestration.md
- references/bff-performance.md
- references/bff-rate-limiting.md
- references/bff-security.md
- references/bff-testing.md
FAQ
Что делает скилл backend-bff-pattern?
Use when the user asks about Backend for Frontend (BFF), a mobile vs web API layer, API aggregation or composition for one client, or a frontend-specific gateway. Produces a BFF design with aggregation, partial failure and caching. Not for federated GraphQL (use api-graphql-federation) or general API design (use backend-api-design).
Как установить скилл backend-bff-pattern?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл backend-bff-pattern запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
AnthropicGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
claude-api
AnthropicReference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
algorithmic-art
AnthropicCreating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
mcp-integration
AnthropicThis skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…