← スキル一覧に戻る

serverless
by jsmithdenverdev
OpenCode configuration
⭐ 0🍴 0📅 2026年1月21日
SKILL.md
name: serverless description: Serverless architecture pattern for event-driven, function-based applications license: MIT compatibility: opencode metadata: category: architecture pattern: serverless deployment: faas
What I do
I provide guidance on building serverless applications using Functions-as-a-Service (FaaS) and managed services.
When to use me
Load this skill when:
- Event-driven workloads
- Variable/unpredictable traffic patterns
- Want to minimize operational overhead
- Pay-per-use cost model preferred
- Rapid iteration and deployment
- Don't need long-running processes
Core Principles
1. Stateless Functions
Functions don't maintain state between invocations.
2. Event-Driven
Functions triggered by events (HTTP, queue, schedule, etc.).
3. Managed Infrastructure
No server management - cloud provider handles scaling.
4. Pay Per Execution
Only pay for actual function execution time.
Function Structure
// AWS Lambda handler
export const handler = async (event: APIGatewayEvent) => {
const userId = event.pathParameters?.id;
const user = await dynamodb.get({
TableName: 'Users',
Key: { id: userId },
});
return {
statusCode: 200,
body: JSON.stringify(user),
};
};
Event Sources
HTTP (API Gateway)
// GET /users/{id}
export const getUser = async (event: APIGatewayEvent) => {
// Handle GET request
};
// POST /users
export const createUser = async (event: APIGatewayEvent) => {
// Handle POST request
};
Queue (SQS, EventBridge)
export const processOrder = async (event: SQSEvent) => {
for (const record of event.Records) {
const order = JSON.parse(record.body);
await processOrderLogic(order);
}
};
Schedule (Cron)
// Run every hour
export const cleanupOldRecords = async () => {
const cutoffDate = new Date();
cutoffDate.setHours(cutoffDate.getHours() - 24);
await dynamodb.delete({
TableName: 'TempRecords',
Key: { createdAt: { $lt: cutoffDate } },
});
};
Advantages
- No Server Management: Focus on code, not infrastructure
- Auto-Scaling: Automatic scaling to demand
- Cost Efficient: Pay only for execution time
- Fast Deployment: Deploy functions independently
- Built-in HA: High availability by default
Challenges
- Cold Starts: Initial invocation latency
- Execution Limits: Timeout constraints (15 min AWS Lambda)
- Vendor Lock-in: Platform-specific code
- Debugging: Harder to debug distributed functions
- State Management: No local state between invocations
Best Practices
- Keep functions small: Single responsibility
- Minimize cold starts: Keep dependencies minimal
- Use managed services: DynamoDB, S3, SQS instead of self-hosted
- Handle errors gracefully: Implement retries and dead letter queues
- Monitor everything: CloudWatch, distributed tracing
- Optimize bundle size: Tree-shake dependencies
Example Stack (AWS)
API Gateway → Lambda → DynamoDB
→ S3
→ SQS → Lambda → External API
Infrastructure as Code
# serverless.yml
service: user-service
provider:
name: aws
runtime: nodejs18.x
functions:
getUser:
handler: src/handlers/getUser.handler
events:
- http:
path: users/{id}
method: get
createUser:
handler: src/handlers/createUser.handler
events:
- http:
path: users
method: post
resources:
Resources:
UsersTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: Users
BillingMode: PAY_PER_REQUEST
References
- AWS Lambda documentation
- Serverless Framework
- AWS SAM (Serverless Application Model)
スコア
総合スコア
50/100
リポジトリの品質指標に基づく評価
✓SKILL.md
SKILL.mdファイルが含まれている
+20
○LICENSE
ライセンスが設定されている
0/10
○説明文
100文字以上の説明がある
0/10
○人気
GitHub Stars 100以上
0/15
○最近の活動
3ヶ月以内に更新がある
0/10
○フォーク
10回以上フォークされている
0/5
✓Issue管理
オープンIssueが50未満
+5
✓言語
プログラミング言語が設定されている
+5
○タグ
1つ以上のタグが設定されている
0/5
レビュー
💬
レビュー機能は近日公開予定です