agcel 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/.agent/workflows/api-gen.md +59 -0
  2. package/.agent/workflows/architect.md +44 -0
  3. package/.agent/workflows/brainstorm.md +223 -0
  4. package/.agent/workflows/build.md +38 -0
  5. package/.agent/workflows/changelog.md +51 -0
  6. package/.agent/workflows/checkpoint.md +138 -0
  7. package/.agent/workflows/commit.md +223 -0
  8. package/.agent/workflows/debug.md +57 -0
  9. package/.agent/workflows/deploy.md +76 -0
  10. package/.agent/workflows/doc.md +247 -0
  11. package/.agent/workflows/execute-plan.md +225 -0
  12. package/.agent/workflows/feature.md +255 -0
  13. package/.agent/workflows/fix.md +323 -0
  14. package/.agent/workflows/help.md +63 -0
  15. package/.agent/workflows/index.md +148 -0
  16. package/.agent/workflows/load.md +112 -0
  17. package/.agent/workflows/mode.md +170 -0
  18. package/.agent/workflows/optimize.md +53 -0
  19. package/.agent/workflows/plan.md +337 -0
  20. package/.agent/workflows/pr.md +74 -0
  21. package/.agent/workflows/product-plan.md +36 -0
  22. package/.agent/workflows/production-deploy.md +39 -0
  23. package/.agent/workflows/refactor.md +63 -0
  24. package/.agent/workflows/research.md +116 -0
  25. package/.agent/workflows/review.md +344 -0
  26. package/.agent/workflows/security-scan.md +56 -0
  27. package/.agent/workflows/ship.md +221 -0
  28. package/.agent/workflows/spawn.md +177 -0
  29. package/.agent/workflows/status.md +59 -0
  30. package/.agent/workflows/tdd.md +139 -0
  31. package/.agent/workflows/test.md +340 -0
  32. package/.agent/workflows/verify.md +35 -0
  33. package/LICENSE +21 -0
  34. package/README.md +67 -0
  35. package/dist/commands/init.js +142 -0
  36. package/dist/commands/install.js +98 -0
  37. package/dist/commands/list.js +49 -0
  38. package/dist/commands/restart.js +17 -0
  39. package/dist/commands/start.js +41 -0
  40. package/dist/commands/status.js +24 -0
  41. package/dist/commands/stop.js +29 -0
  42. package/dist/commands/uninstall.js +78 -0
  43. package/dist/index.js +58 -0
  44. package/dist/server/index.js +174 -0
  45. package/dist/utils/index.js +63 -0
  46. package/package.json +54 -0
  47. package/skills/api-security-best-practices/SKILL.md +291 -0
  48. package/skills/api-security-best-practices/references/examples.md +617 -0
  49. package/skills/architecture/SKILL.md +59 -0
  50. package/skills/architecture/context-discovery.md +43 -0
  51. package/skills/architecture/examples.md +94 -0
  52. package/skills/architecture/pattern-selection.md +68 -0
  53. package/skills/architecture/patterns-reference.md +50 -0
  54. package/skills/architecture/trade-off-analysis.md +77 -0
  55. package/skills/aws-serverless/SKILL.md +327 -0
  56. package/skills/brainstorming/SKILL.md +234 -0
  57. package/skills/c4-context/SKILL.md +154 -0
  58. package/skills/ci-cd-engineer/SKILL.md +50 -0
  59. package/skills/code-auditing/SKILL.md +55 -0
  60. package/skills/copywriting/SKILL.md +248 -0
  61. package/skills/database-engineer/SKILL.md +47 -0
  62. package/skills/doc-coauthoring/SKILL.md +379 -0
  63. package/skills/docker-expert/SKILL.md +412 -0
  64. package/skills/langgraph/SKILL.md +291 -0
  65. package/skills/postgresql/SKILL.md +73 -0
  66. package/skills/pricing-strategy/SKILL.md +360 -0
  67. package/skills/product-manager/SKILL.md +57 -0
  68. package/skills/prompt-engineer/README.md +659 -0
  69. package/skills/prompt-engineer/SKILL.md +256 -0
  70. package/skills/python-patterns/SKILL.md +445 -0
  71. package/skills/qa-engineer/SKILL.md +42 -0
  72. package/skills/rag-engineer/SKILL.md +94 -0
  73. package/skills/react-patterns/SKILL.md +202 -0
  74. package/skills/secure-refactoring/SKILL.md +54 -0
  75. package/skills/security-documentation/SKILL.md +53 -0
  76. package/skills/senior-architect/SKILL.md +213 -0
  77. package/skills/senior-architect/references/architecture_patterns.md +103 -0
  78. package/skills/senior-architect/references/system_design_workflows.md +103 -0
  79. package/skills/senior-architect/references/tech_decision_guide.md +103 -0
  80. package/skills/senior-architect/scripts/architecture_diagram_generator.py +114 -0
  81. package/skills/senior-architect/scripts/dependency_analyzer.py +114 -0
  82. package/skills/senior-architect/scripts/project_architect.py +114 -0
  83. package/skills/seo-audit/SKILL.md +491 -0
  84. package/skills/sql-injection-testing/SKILL.md +452 -0
  85. package/skills/test-driven-development/SKILL.md +375 -0
  86. package/skills/test-driven-development/testing-anti-patterns.md +299 -0
  87. package/skills/test-fixing/SKILL.md +123 -0
  88. package/skills/testing-patterns/SKILL.md +263 -0
  89. package/skills/typescript-expert/SKILL.md +202 -0
  90. package/skills/typescript-expert/references/advanced-topics.md +252 -0
  91. package/skills/typescript-expert/references/tsconfig-strict.json +92 -0
  92. package/skills/typescript-expert/references/typescript-cheatsheet.md +383 -0
  93. package/skills/typescript-expert/references/utility-types.ts +335 -0
  94. package/skills/typescript-expert/scripts/ts_diagnostic.py +203 -0
  95. package/skills/ui-ux-designer/SKILL.md +46 -0
  96. package/skills/vercel-deployment/SKILL.md +83 -0
  97. package/skills/vulnerability-scanner/SKILL.md +280 -0
  98. package/skills/vulnerability-scanner/checklists.md +121 -0
  99. package/skills/vulnerability-scanner/scripts/security_scan.py +458 -0
  100. package/skills/writing-plans/SKILL.md +120 -0
@@ -0,0 +1,94 @@
1
+ # Architecture Examples
2
+
3
+ > Real-world architecture decisions by project type.
4
+
5
+ ---
6
+
7
+ ## Example 1: MVP E-commerce (Solo Developer)
8
+
9
+ ```yaml
10
+ Requirements:
11
+ - <1000 users initially
12
+ - Solo developer
13
+ - Fast to market (8 weeks)
14
+ - Budget-conscious
15
+
16
+ Architecture Decisions:
17
+ App Structure: Monolith (simpler for solo)
18
+ Framework: Next.js (full-stack, fast)
19
+ Data Layer: Prisma direct (no over-abstraction)
20
+ Authentication: JWT (simpler than OAuth)
21
+ Payment: Stripe (hosted solution)
22
+ Database: PostgreSQL (ACID for orders)
23
+
24
+ Trade-offs Accepted:
25
+ - Monolith → Can't scale independently (team doesn't justify it)
26
+ - No Repository → Less testable (simple CRUD doesn't need it)
27
+ - JWT → No social login initially (can add later)
28
+
29
+ Future Migration Path:
30
+ - Users > 10K → Extract payment service
31
+ - Team > 3 → Add Repository pattern
32
+ - Social login requested → Add OAuth
33
+ ```
34
+
35
+ ---
36
+
37
+ ## Example 2: SaaS Product (5-10 Developers)
38
+
39
+ ```yaml
40
+ Requirements:
41
+ - 1K-100K users
42
+ - 5-10 developers
43
+ - Long-term (12+ months)
44
+ - Multiple domains (billing, users, core)
45
+
46
+ Architecture Decisions:
47
+ App Structure: Modular Monolith (team size optimal)
48
+ Framework: NestJS (modular by design)
49
+ Data Layer: Repository pattern (testing, flexibility)
50
+ Domain Model: Partial DDD (rich entities)
51
+ Authentication: OAuth + JWT
52
+ Caching: Redis
53
+ Database: PostgreSQL
54
+
55
+ Trade-offs Accepted:
56
+ - Modular Monolith → Some module coupling (microservices not justified)
57
+ - Partial DDD → No full aggregates (no domain experts)
58
+ - RabbitMQ later → Initial synchronous (add when proven needed)
59
+
60
+ Migration Path:
61
+ - Team > 10 → Consider microservices
62
+ - Domains conflict → Extract bounded contexts
63
+ - Read performance issues → Add CQRS
64
+ ```
65
+
66
+ ---
67
+
68
+ ## Example 3: Enterprise (100K+ Users)
69
+
70
+ ```yaml
71
+ Requirements:
72
+ - 100K+ users
73
+ - 10+ developers
74
+ - Multiple business domains
75
+ - Different scaling needs
76
+ - 24/7 availability
77
+
78
+ Architecture Decisions:
79
+ App Structure: Microservices (independent scale)
80
+ API Gateway: Kong/AWS API GW
81
+ Domain Model: Full DDD
82
+ Consistency: Event-driven (eventual OK)
83
+ Message Bus: Kafka
84
+ Authentication: OAuth + SAML (enterprise SSO)
85
+ Database: Polyglot (right tool per job)
86
+ CQRS: Selected services
87
+
88
+ Operational Requirements:
89
+ - Service mesh (Istio/Linkerd)
90
+ - Distributed tracing (Jaeger/Tempo)
91
+ - Centralized logging (ELK/Loki)
92
+ - Circuit breakers (Resilience4j)
93
+ - Kubernetes/Helm
94
+ ```
@@ -0,0 +1,68 @@
1
+ # Pattern Selection Guidelines
2
+
3
+ > Decision trees for choosing architectural patterns.
4
+
5
+ ## Main Decision Tree
6
+
7
+ ```
8
+ START: What's your MAIN concern?
9
+
10
+ ┌─ Data Access Complexity?
11
+ │ ├─ HIGH (complex queries, testing needed)
12
+ │ │ → Repository Pattern + Unit of Work
13
+ │ │ VALIDATE: Will data source change frequently?
14
+ │ │ ├─ YES → Repository worth the indirection
15
+ │ │ └─ NO → Consider simpler ORM direct access
16
+ │ └─ LOW (simple CRUD, single database)
17
+ │ → ORM directly (Prisma, Drizzle)
18
+ │ Simpler = Better, Faster
19
+
20
+ ├─ Business Rules Complexity?
21
+ │ ├─ HIGH (domain logic, rules vary by context)
22
+ │ │ → Domain-Driven Design
23
+ │ │ VALIDATE: Do you have domain experts on team?
24
+ │ │ ├─ YES → Full DDD (Aggregates, Value Objects)
25
+ │ │ └─ NO → Partial DDD (rich entities, clear boundaries)
26
+ │ └─ LOW (mostly CRUD, simple validation)
27
+ │ → Transaction Script pattern
28
+ │ Simpler = Better, Faster
29
+
30
+ ├─ Independent Scaling Needed?
31
+ │ ├─ YES (different components scale differently)
32
+ │ │ → Microservices WORTH the complexity
33
+ │ │ REQUIREMENTS (ALL must be true):
34
+ │ │ - Clear domain boundaries
35
+ │ │ - Team > 10 developers
36
+ │ │ - Different scaling needs per service
37
+ │ │ IF NOT ALL MET → Modular Monolith instead
38
+ │ └─ NO (everything scales together)
39
+ │ → Modular Monolith
40
+ │ Can extract services later when proven needed
41
+
42
+ └─ Real-time Requirements?
43
+ ├─ HIGH (immediate updates, multi-user sync)
44
+ │ → Event-Driven Architecture
45
+ │ → Message Queue (RabbitMQ, Redis, Kafka)
46
+ │ VALIDATE: Can you handle eventual consistency?
47
+ │ ├─ YES → Event-driven valid
48
+ │ └─ NO → Synchronous with polling
49
+ └─ LOW (eventual consistency acceptable)
50
+ → Synchronous (REST/GraphQL)
51
+ Simpler = Better, Faster
52
+ ```
53
+
54
+ ## The 3 Questions (Before ANY Pattern)
55
+
56
+ 1. **Problem Solved**: What SPECIFIC problem does this pattern solve?
57
+ 2. **Simpler Alternative**: Is there a simpler solution?
58
+ 3. **Deferred Complexity**: Can we add this LATER when needed?
59
+
60
+ ## Red Flags (Anti-patterns)
61
+
62
+ | Pattern | Anti-pattern | Simpler Alternative |
63
+ |---------|-------------|-------------------|
64
+ | Microservices | Premature splitting | Start monolith, extract later |
65
+ | Clean/Hexagonal | Over-abstraction | Concrete first, interfaces later |
66
+ | Event Sourcing | Over-engineering | Append-only audit log |
67
+ | CQRS | Unnecessary complexity | Single model |
68
+ | Repository | YAGNI for simple CRUD | ORM direct access |
@@ -0,0 +1,50 @@
1
+ # Architecture Patterns Reference
2
+
3
+ > Quick reference for common patterns with usage guidance.
4
+
5
+ ## Data Access Patterns
6
+
7
+ | Pattern | When to Use | When NOT to Use | Complexity |
8
+ |---------|-------------|-----------------|------------|
9
+ | **Active Record** | Simple CRUD, rapid prototyping | Complex queries, multiple sources | Low |
10
+ | **Repository** | Testing needed, multiple sources | Simple CRUD, single database | Medium |
11
+ | **Unit of Work** | Complex transactions | Simple operations | High |
12
+ | **Data Mapper** | Complex domain, performance | Simple CRUD, rapid dev | High |
13
+
14
+ ## Domain Logic Patterns
15
+
16
+ | Pattern | When to Use | When NOT to Use | Complexity |
17
+ |---------|-------------|-----------------|------------|
18
+ | **Transaction Script** | Simple CRUD, procedural | Complex business rules | Low |
19
+ | **Table Module** | Record-based logic | Rich behavior needed | Low |
20
+ | **Domain Model** | Complex business logic | Simple CRUD | Medium |
21
+ | **DDD (Full)** | Complex domain, domain experts | Simple domain, no experts | High |
22
+
23
+ ## Distributed System Patterns
24
+
25
+ | Pattern | When to Use | When NOT to Use | Complexity |
26
+ |---------|-------------|-----------------|------------|
27
+ | **Modular Monolith** | Small teams, unclear boundaries | Clear contexts, different scales | Medium |
28
+ | **Microservices** | Different scales, large teams | Small teams, simple domain | Very High |
29
+ | **Event-Driven** | Real-time, loose coupling | Simple workflows, strong consistency | High |
30
+ | **CQRS** | Read/write performance diverges | Simple CRUD, same model | High |
31
+ | **Saga** | Distributed transactions | Single database, simple ACID | High |
32
+
33
+ ## API Patterns
34
+
35
+ | Pattern | When to Use | When NOT to Use | Complexity |
36
+ |---------|-------------|-----------------|------------|
37
+ | **REST** | Standard CRUD, resources | Real-time, complex queries | Low |
38
+ | **GraphQL** | Flexible queries, multiple clients | Simple CRUD, caching needs | Medium |
39
+ | **gRPC** | Internal services, performance | Public APIs, browser clients | Medium |
40
+ | **WebSocket** | Real-time updates | Simple request/response | Medium |
41
+
42
+ ---
43
+
44
+ ## Simplicity Principle
45
+
46
+ **"Start simple, add complexity only when proven necessary."**
47
+
48
+ - You can always add patterns later
49
+ - Removing complexity is MUCH harder than adding it
50
+ - When in doubt, choose simpler option
@@ -0,0 +1,77 @@
1
+ # Trade-off Analysis & ADR
2
+
3
+ > Document every architectural decision with trade-offs.
4
+
5
+ ## Decision Framework
6
+
7
+ For EACH architectural component, document:
8
+
9
+ ```markdown
10
+ ## Architecture Decision Record
11
+
12
+ ### Context
13
+ - **Problem**: [What problem are we solving?]
14
+ - **Constraints**: [Team size, scale, timeline, budget]
15
+
16
+ ### Options Considered
17
+
18
+ | Option | Pros | Cons | Complexity | When Valid |
19
+ |--------|------|------|------------|-----------|
20
+ | Option A | Benefit 1 | Cost 1 | Low | [Conditions] |
21
+ | Option B | Benefit 2 | Cost 2 | High | [Conditions] |
22
+
23
+ ### Decision
24
+ **Chosen**: [Option B]
25
+
26
+ ### Rationale
27
+ 1. [Reason 1 - tied to constraints]
28
+ 2. [Reason 2 - tied to requirements]
29
+
30
+ ### Trade-offs Accepted
31
+ - [What we're giving up]
32
+ - [Why this is acceptable]
33
+
34
+ ### Consequences
35
+ - **Positive**: [Benefits we gain]
36
+ - **Negative**: [Costs/risks we accept]
37
+ - **Mitigation**: [How we'll address negatives]
38
+
39
+ ### Revisit Trigger
40
+ - [When to reconsider this decision]
41
+ ```
42
+
43
+ ## ADR Template
44
+
45
+ ```markdown
46
+ # ADR-[XXX]: [Decision Title]
47
+
48
+ ## Status
49
+ Proposed | Accepted | Deprecated | Superseded by [ADR-YYY]
50
+
51
+ ## Context
52
+ [What problem? What constraints?]
53
+
54
+ ## Decision
55
+ [What we chose - be specific]
56
+
57
+ ## Rationale
58
+ [Why - tie to requirements and constraints]
59
+
60
+ ## Trade-offs
61
+ [What we're giving up - be honest]
62
+
63
+ ## Consequences
64
+ - **Positive**: [Benefits]
65
+ - **Negative**: [Costs]
66
+ - **Mitigation**: [How to address]
67
+ ```
68
+
69
+ ## ADR Storage
70
+
71
+ ```
72
+ docs/
73
+ └── architecture/
74
+ ├── adr-001-use-nextjs.md
75
+ ├── adr-002-postgresql-over-mongodb.md
76
+ └── adr-003-adopt-repository-pattern.md
77
+ ```
@@ -0,0 +1,327 @@
1
+ ---
2
+ name: aws-serverless
3
+ description: "Specialized skill for building production-ready serverless applications on AWS. Covers Lambda functions, API Gateway, DynamoDB, SQS/SNS event-driven patterns, SAM/CDK deployment, and cold start optimization."
4
+ source: vibeship-spawner-skills (Apache 2.0)
5
+ ---
6
+
7
+ # AWS Serverless
8
+
9
+ ## Patterns
10
+
11
+ ### Lambda Handler Pattern
12
+
13
+ Proper Lambda function structure with error handling
14
+
15
+ **When to use**: ['Any Lambda function implementation', 'API handlers, event processors, scheduled tasks']
16
+
17
+ ```python
18
+ ```javascript
19
+ // Node.js Lambda Handler
20
+ // handler.js
21
+
22
+ // Initialize outside handler (reused across invocations)
23
+ const { DynamoDBClient } = require('@aws-sdk/client-dynamodb');
24
+ const { DynamoDBDocumentClient, GetCommand } = require('@aws-sdk/lib-dynamodb');
25
+
26
+ const client = new DynamoDBClient({});
27
+ const docClient = DynamoDBDocumentClient.from(client);
28
+
29
+ // Handler function
30
+ exports.handler = async (event, context) => {
31
+ // Optional: Don't wait for event loop to clear (Node.js)
32
+ context.callbackWaitsForEmptyEventLoop = false;
33
+
34
+ try {
35
+ // Parse input based on event source
36
+ const body = typeof event.body === 'string'
37
+ ? JSON.parse(event.body)
38
+ : event.body;
39
+
40
+ // Business logic
41
+ const result = await processRequest(body);
42
+
43
+ // Return API Gateway compatible response
44
+ return {
45
+ statusCode: 200,
46
+ headers: {
47
+ 'Content-Type': 'application/json',
48
+ 'Access-Control-Allow-Origin': '*'
49
+ },
50
+ body: JSON.stringify(result)
51
+ };
52
+ } catch (error) {
53
+ console.error('Error:', JSON.stringify({
54
+ error: error.message,
55
+ stack: error.stack,
56
+ requestId: context.awsRequestId
57
+ }));
58
+
59
+ return {
60
+ statusCode: error.statusCode || 500,
61
+ headers: { 'Content-Type': 'application/json' },
62
+ body: JSON.stringify({
63
+ error: error.message || 'Internal server error'
64
+ })
65
+ };
66
+ }
67
+ };
68
+
69
+ async function processRequest(data) {
70
+ // Your business logic here
71
+ const result = await docClient.send(new GetCommand({
72
+ TableName: process.env.TABLE_NAME,
73
+ Key: { id: data.id }
74
+ }));
75
+ return result.Item;
76
+ }
77
+ ```
78
+
79
+ ```python
80
+ # Python Lambda Handler
81
+ # handler.py
82
+
83
+ import json
84
+ import os
85
+ import logging
86
+ import boto3
87
+ from botocore.exceptions import ClientError
88
+
89
+ # Initialize outside handler (reused across invocations)
90
+ logger = logging.getLogger()
91
+ logger.setLevel(logging.INFO)
92
+
93
+ dynamodb = boto3.resource('dynamodb')
94
+ table = dynamodb.Table(os.environ['TABLE_NAME'])
95
+
96
+ def handler(event, context):
97
+ try:
98
+ # Parse i
99
+ ```
100
+
101
+ ### API Gateway Integration Pattern
102
+
103
+ REST API and HTTP API integration with Lambda
104
+
105
+ **When to use**: ['Building REST APIs backed by Lambda', 'Need HTTP endpoints for functions']
106
+
107
+ ```javascript
108
+ ```yaml
109
+ # template.yaml (SAM)
110
+ AWSTemplateFormatVersion: '2010-09-09'
111
+ Transform: AWS::Serverless-2016-10-31
112
+
113
+ Globals:
114
+ Function:
115
+ Runtime: nodejs20.x
116
+ Timeout: 30
117
+ MemorySize: 256
118
+ Environment:
119
+ Variables:
120
+ TABLE_NAME: !Ref ItemsTable
121
+
122
+ Resources:
123
+ # HTTP API (recommended for simple use cases)
124
+ HttpApi:
125
+ Type: AWS::Serverless::HttpApi
126
+ Properties:
127
+ StageName: prod
128
+ CorsConfiguration:
129
+ AllowOrigins:
130
+ - "*"
131
+ AllowMethods:
132
+ - GET
133
+ - POST
134
+ - DELETE
135
+ AllowHeaders:
136
+ - "*"
137
+
138
+ # Lambda Functions
139
+ GetItemFunction:
140
+ Type: AWS::Serverless::Function
141
+ Properties:
142
+ Handler: src/handlers/get.handler
143
+ Events:
144
+ GetItem:
145
+ Type: HttpApi
146
+ Properties:
147
+ ApiId: !Ref HttpApi
148
+ Path: /items/{id}
149
+ Method: GET
150
+ Policies:
151
+ - DynamoDBReadPolicy:
152
+ TableName: !Ref ItemsTable
153
+
154
+ CreateItemFunction:
155
+ Type: AWS::Serverless::Function
156
+ Properties:
157
+ Handler: src/handlers/create.handler
158
+ Events:
159
+ CreateItem:
160
+ Type: HttpApi
161
+ Properties:
162
+ ApiId: !Ref HttpApi
163
+ Path: /items
164
+ Method: POST
165
+ Policies:
166
+ - DynamoDBCrudPolicy:
167
+ TableName: !Ref ItemsTable
168
+
169
+ # DynamoDB Table
170
+ ItemsTable:
171
+ Type: AWS::DynamoDB::Table
172
+ Properties:
173
+ AttributeDefinitions:
174
+ - AttributeName: id
175
+ AttributeType: S
176
+ KeySchema:
177
+ - AttributeName: id
178
+ KeyType: HASH
179
+ BillingMode: PAY_PER_REQUEST
180
+
181
+ Outputs:
182
+ ApiUrl:
183
+ Value: !Sub "https://${HttpApi}.execute-api.${AWS::Region}.amazonaws.com/prod"
184
+ ```
185
+
186
+ ```javascript
187
+ // src/handlers/get.js
188
+ const { getItem } = require('../lib/dynamodb');
189
+
190
+ exports.handler = async (event) => {
191
+ const id = event.pathParameters?.id;
192
+
193
+ if (!id) {
194
+ return {
195
+ statusCode: 400,
196
+ body: JSON.stringify({ error: 'Missing id parameter' })
197
+ };
198
+ }
199
+
200
+ const item =
201
+ ```
202
+
203
+ ### Event-Driven SQS Pattern
204
+
205
+ Lambda triggered by SQS for reliable async processing
206
+
207
+ **When to use**: ['Decoupled, asynchronous processing', 'Need retry logic and DLQ', 'Processing messages in batches']
208
+
209
+ ```python
210
+ ```yaml
211
+ # template.yaml
212
+ Resources:
213
+ ProcessorFunction:
214
+ Type: AWS::Serverless::Function
215
+ Properties:
216
+ Handler: src/handlers/processor.handler
217
+ Events:
218
+ SQSEvent:
219
+ Type: SQS
220
+ Properties:
221
+ Queue: !GetAtt ProcessingQueue.Arn
222
+ BatchSize: 10
223
+ FunctionResponseTypes:
224
+ - ReportBatchItemFailures # Partial batch failure handling
225
+
226
+ ProcessingQueue:
227
+ Type: AWS::SQS::Queue
228
+ Properties:
229
+ VisibilityTimeout: 180 # 6x Lambda timeout
230
+ RedrivePolicy:
231
+ deadLetterTargetArn: !GetAtt DeadLetterQueue.Arn
232
+ maxReceiveCount: 3
233
+
234
+ DeadLetterQueue:
235
+ Type: AWS::SQS::Queue
236
+ Properties:
237
+ MessageRetentionPeriod: 1209600 # 14 days
238
+ ```
239
+
240
+ ```javascript
241
+ // src/handlers/processor.js
242
+ exports.handler = async (event) => {
243
+ const batchItemFailures = [];
244
+
245
+ for (const record of event.Records) {
246
+ try {
247
+ const body = JSON.parse(record.body);
248
+ await processMessage(body);
249
+ } catch (error) {
250
+ console.error(`Failed to process message ${record.messageId}:`, error);
251
+ // Report this item as failed (will be retried)
252
+ batchItemFailures.push({
253
+ itemIdentifier: record.messageId
254
+ });
255
+ }
256
+ }
257
+
258
+ // Return failed items for retry
259
+ return { batchItemFailures };
260
+ };
261
+
262
+ async function processMessage(message) {
263
+ // Your processing logic
264
+ console.log('Processing:', message);
265
+
266
+ // Simulate work
267
+ await saveToDatabase(message);
268
+ }
269
+ ```
270
+
271
+ ```python
272
+ # Python version
273
+ import json
274
+ import logging
275
+
276
+ logger = logging.getLogger()
277
+
278
+ def handler(event, context):
279
+ batch_item_failures = []
280
+
281
+ for record in event['Records']:
282
+ try:
283
+ body = json.loads(record['body'])
284
+ process_message(body)
285
+ except Exception as e:
286
+ logger.error(f"Failed to process {record['messageId']}: {e}")
287
+ batch_item_failures.append({
288
+ 'itemIdentifier': record['messageId']
289
+ })
290
+
291
+ return {'batchItemFailures': batch_ite
292
+ ```
293
+
294
+ ## Anti-Patterns
295
+
296
+ ### ❌ Monolithic Lambda
297
+
298
+ **Why bad**: Large deployment packages cause slow cold starts.
299
+ Hard to scale individual operations.
300
+ Updates affect entire system.
301
+
302
+ ### ❌ Large Dependencies
303
+
304
+ **Why bad**: Increases deployment package size.
305
+ Slows down cold starts significantly.
306
+ Most of SDK/library may be unused.
307
+
308
+ ### ❌ Synchronous Calls in VPC
309
+
310
+ **Why bad**: VPC-attached Lambdas have ENI setup overhead.
311
+ Blocking DNS lookups or connections worsen cold starts.
312
+
313
+ ## ⚠️ Sharp Edges
314
+
315
+ | Issue | Severity | Solution |
316
+ |-------|----------|----------|
317
+ | Issue | high | ## Measure your INIT phase |
318
+ | Issue | high | ## Set appropriate timeout |
319
+ | Issue | high | ## Increase memory allocation |
320
+ | Issue | medium | ## Verify VPC configuration |
321
+ | Issue | medium | ## Tell Lambda not to wait for event loop |
322
+ | Issue | medium | ## For large file uploads |
323
+ | Issue | high | ## Use different buckets/prefixes |
324
+
325
+
326
+ ## Gap Analysis Rule
327
+ Always identify gaps and suggest next steps to users. In case there is no gaps anymore, then AI should clearly state that there is no gap left.