claude-flow-novice 2.14.22 → 2.14.25

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 (98) hide show
  1. package/{claude-assets/agents → .claude/cfn-agents-ignore}/cfn-seo-team/cfn-seo-coordinator.md +410 -414
  2. package/{claude-assets/agents → .claude/cfn-agents-ignore}/cfn-seo-team/competitive-seo-analyst.md +420 -423
  3. package/{claude-assets/agents → .claude/cfn-agents-ignore}/cfn-seo-team/content-atomization-specialist.md +577 -580
  4. package/{claude-assets/agents → .claude/cfn-agents-ignore}/cfn-seo-team/content-seo-strategist.md +242 -245
  5. package/{claude-assets/agents → .claude/cfn-agents-ignore}/cfn-seo-team/eeat-content-auditor.md +386 -389
  6. package/{claude-assets/agents → .claude/cfn-agents-ignore}/cfn-seo-team/geo-optimization-expert.md +266 -269
  7. package/{claude-assets/agents → .claude/cfn-agents-ignore}/cfn-seo-team/link-building-specialist.md +288 -291
  8. package/{claude-assets/agents → .claude/cfn-agents-ignore}/cfn-seo-team/local-seo-optimizer.md +330 -333
  9. package/{claude-assets/agents → .claude/cfn-agents-ignore}/cfn-seo-team/programmatic-seo-engineer.md +241 -244
  10. package/{claude-assets/agents → .claude/cfn-agents-ignore}/cfn-seo-team/schema-markup-engineer.md +427 -430
  11. package/{claude-assets/agents → .claude/cfn-agents-ignore}/cfn-seo-team/seo-analytics-specialist.md +373 -376
  12. package/{claude-assets/agents → .claude/cfn-agents-ignore}/cfn-seo-team/seo-validators/accessibility-validator.md +561 -565
  13. package/{claude-assets/agents → .claude/cfn-agents-ignore}/cfn-seo-team/seo-validators/audience-validator.md +480 -484
  14. package/{claude-assets/agents → .claude/cfn-agents-ignore}/cfn-seo-team/seo-validators/branding-validator.md +448 -452
  15. package/{claude-assets/agents → .claude/cfn-agents-ignore}/cfn-seo-team/seo-validators/humanizer-validator.md +329 -333
  16. package/{claude-assets/agents → .claude/cfn-agents-ignore}/cfn-seo-team/technical-seo-specialist.md +227 -231
  17. package/claude-assets/agents/cfn-dev-team/CLAUDE.md +9 -29
  18. package/claude-assets/agents/cfn-dev-team/analysts/root-cause-analyst.md +1 -4
  19. package/claude-assets/agents/cfn-dev-team/architecture/goal-planner.md +1 -4
  20. package/claude-assets/agents/cfn-dev-team/architecture/planner.md +1 -4
  21. package/claude-assets/agents/cfn-dev-team/architecture/system-architect.md +1 -4
  22. package/claude-assets/agents/cfn-dev-team/coordinators/cfn-frontend-coordinator.md +536 -540
  23. package/claude-assets/agents/cfn-dev-team/coordinators/cfn-v3-coordinator.md +1 -4
  24. package/claude-assets/agents/cfn-dev-team/coordinators/epic-creator.md +1 -5
  25. package/claude-assets/agents/cfn-dev-team/coordinators/multi-sprint-coordinator.md +1 -3
  26. package/claude-assets/agents/cfn-dev-team/dev-ops/devops-engineer.md +1 -5
  27. package/claude-assets/agents/cfn-dev-team/dev-ops/docker-specialist.md +688 -692
  28. package/claude-assets/agents/cfn-dev-team/dev-ops/github-commit-agent.md +113 -117
  29. package/claude-assets/agents/cfn-dev-team/dev-ops/kubernetes-specialist.md +536 -540
  30. package/claude-assets/agents/cfn-dev-team/dev-ops/monitoring-specialist.md +735 -739
  31. package/claude-assets/agents/cfn-dev-team/developers/api-gateway-specialist.md +901 -905
  32. package/claude-assets/agents/cfn-dev-team/developers/backend-developer.md +1 -4
  33. package/claude-assets/agents/cfn-dev-team/developers/data/data-engineer.md +581 -585
  34. package/claude-assets/agents/cfn-dev-team/developers/database/database-architect.md +272 -276
  35. package/claude-assets/agents/cfn-dev-team/developers/frontend/react-frontend-engineer.md +1 -4
  36. package/claude-assets/agents/cfn-dev-team/developers/frontend/typescript-specialist.md +322 -325
  37. package/claude-assets/agents/cfn-dev-team/developers/frontend/ui-designer.md +1 -5
  38. package/claude-assets/agents/cfn-dev-team/developers/graphql-specialist.md +611 -615
  39. package/claude-assets/agents/cfn-dev-team/developers/rust-developer.md +1 -4
  40. package/claude-assets/agents/cfn-dev-team/documentation/pseudocode.md +1 -4
  41. package/claude-assets/agents/cfn-dev-team/documentation/specification-agent.md +1 -4
  42. package/claude-assets/agents/cfn-dev-team/product-owners/accessibility-advocate-persona.md +105 -108
  43. package/claude-assets/agents/cfn-dev-team/product-owners/cto-agent.md +1 -5
  44. package/claude-assets/agents/cfn-dev-team/product-owners/power-user-persona.md +176 -180
  45. package/claude-assets/agents/cfn-dev-team/reviewers/quality/code-quality-validator.md +53 -30
  46. package/claude-assets/agents/cfn-dev-team/reviewers/quality/cyclomatic-complexity-reducer.md +375 -321
  47. package/claude-assets/agents/cfn-dev-team/reviewers/quality/perf-analyzer.md +52 -30
  48. package/claude-assets/agents/cfn-dev-team/reviewers/quality/security-specialist.md +51 -35
  49. package/claude-assets/agents/cfn-dev-team/testers/api-testing-specialist.md +703 -707
  50. package/claude-assets/agents/cfn-dev-team/testers/chaos-engineering-specialist.md +897 -901
  51. package/claude-assets/agents/cfn-dev-team/testers/e2e/playwright-tester.md +1 -5
  52. package/claude-assets/agents/cfn-dev-team/testers/interaction-tester.md +1 -5
  53. package/claude-assets/agents/cfn-dev-team/testers/load-testing-specialist.md +465 -469
  54. package/claude-assets/agents/cfn-dev-team/testers/playwright-tester.md +1 -4
  55. package/claude-assets/agents/cfn-dev-team/testers/tester.md +1 -4
  56. package/claude-assets/agents/cfn-dev-team/testers/unit/tdd-london-unit-swarm.md +1 -5
  57. package/claude-assets/agents/cfn-dev-team/testers/validation/validation-production-validator.md +1 -3
  58. package/claude-assets/agents/cfn-dev-team/testing/test-validation-agent.md +309 -312
  59. package/claude-assets/agents/cfn-dev-team/utility/agent-builder.md +529 -550
  60. package/claude-assets/agents/cfn-dev-team/utility/analyst.md +1 -4
  61. package/claude-assets/agents/cfn-dev-team/utility/claude-code-expert.md +1040 -1043
  62. package/claude-assets/agents/cfn-dev-team/utility/context-curator.md +86 -89
  63. package/claude-assets/agents/cfn-dev-team/utility/memory-leak-specialist.md +753 -757
  64. package/claude-assets/agents/cfn-dev-team/utility/researcher.md +1 -6
  65. package/claude-assets/agents/cfn-dev-team/utility/z-ai-specialist.md +626 -630
  66. package/claude-assets/agents/custom/cfn-system-expert.md +258 -261
  67. package/claude-assets/agents/custom/claude-code-expert.md +141 -144
  68. package/claude-assets/agents/custom/test-mcp-access.md +24 -26
  69. package/claude-assets/agents/project-only-agents/npm-package-specialist.md +343 -347
  70. package/claude-assets/cfn-agents-ignore/cfn-seo-team/AGENT_CREATION_REPORT.md +481 -0
  71. package/claude-assets/cfn-agents-ignore/cfn-seo-team/DELEGATION_MATRIX.md +371 -0
  72. package/claude-assets/cfn-agents-ignore/cfn-seo-team/HUMANIZER_PROMPTS.md +536 -0
  73. package/claude-assets/cfn-agents-ignore/cfn-seo-team/INTEGRATION_REQUIREMENTS.md +642 -0
  74. package/claude-assets/cfn-agents-ignore/cfn-seo-team/cfn-seo-coordinator.md +410 -0
  75. package/claude-assets/cfn-agents-ignore/cfn-seo-team/competitive-seo-analyst.md +420 -0
  76. package/claude-assets/cfn-agents-ignore/cfn-seo-team/content-atomization-specialist.md +577 -0
  77. package/claude-assets/cfn-agents-ignore/cfn-seo-team/content-seo-strategist.md +242 -0
  78. package/claude-assets/cfn-agents-ignore/cfn-seo-team/eeat-content-auditor.md +386 -0
  79. package/claude-assets/cfn-agents-ignore/cfn-seo-team/geo-optimization-expert.md +266 -0
  80. package/claude-assets/cfn-agents-ignore/cfn-seo-team/link-building-specialist.md +288 -0
  81. package/claude-assets/cfn-agents-ignore/cfn-seo-team/local-seo-optimizer.md +330 -0
  82. package/claude-assets/cfn-agents-ignore/cfn-seo-team/programmatic-seo-engineer.md +241 -0
  83. package/claude-assets/cfn-agents-ignore/cfn-seo-team/schema-markup-engineer.md +427 -0
  84. package/claude-assets/cfn-agents-ignore/cfn-seo-team/seo-analytics-specialist.md +373 -0
  85. package/claude-assets/cfn-agents-ignore/cfn-seo-team/seo-validators/accessibility-validator.md +561 -0
  86. package/claude-assets/cfn-agents-ignore/cfn-seo-team/seo-validators/audience-validator.md +480 -0
  87. package/claude-assets/cfn-agents-ignore/cfn-seo-team/seo-validators/branding-validator.md +448 -0
  88. package/claude-assets/cfn-agents-ignore/cfn-seo-team/seo-validators/humanizer-validator.md +329 -0
  89. package/claude-assets/cfn-agents-ignore/cfn-seo-team/technical-seo-specialist.md +227 -0
  90. package/dist/agents/agent-loader.js +467 -133
  91. package/dist/agents/agent-loader.js.map +1 -1
  92. package/dist/cli/config-manager.js +91 -109
  93. package/dist/cli/config-manager.js.map +1 -1
  94. package/package.json +2 -2
  95. /package/{claude-assets/agents → .claude/cfn-agents-ignore}/cfn-seo-team/AGENT_CREATION_REPORT.md +0 -0
  96. /package/{claude-assets/agents → .claude/cfn-agents-ignore}/cfn-seo-team/DELEGATION_MATRIX.md +0 -0
  97. /package/{claude-assets/agents → .claude/cfn-agents-ignore}/cfn-seo-team/HUMANIZER_PROMPTS.md +0 -0
  98. /package/{claude-assets/agents → .claude/cfn-agents-ignore}/cfn-seo-team/INTEGRATION_REQUIREMENTS.md +0 -0
@@ -1,905 +1,901 @@
1
- ---
2
- name: api-gateway-specialist
3
- description: |
4
- MUST BE USED for API gateway configuration, Kong, AWS API Gateway, Nginx, rate limiting, authentication, and API management.
5
- Use PROACTIVELY for gateway setup, routing rules, OAuth2/JWT configuration, rate limiting, API versioning, load balancing.
6
- ALWAYS delegate for "API gateway", "Kong configuration", "rate limiting", "OAuth2 setup", "API routing", "reverse proxy".
7
- Keywords - API gateway, Kong, AWS API Gateway, Nginx, reverse proxy, rate limiting, OAuth2, JWT, authentication, routing, load balancing
8
- tools: [Read, Write, Edit, Bash, Grep, Glob, TodoWrite]
9
- model: sonnet
10
- type: specialist
11
- capabilities:
12
- - api-gateway-management
13
- - kong-configuration
14
- - aws-api-gateway
15
- - nginx-reverse-proxy
16
- - rate-limiting
17
- - oauth2-jwt-auth
18
- - api-versioning
19
- - load-balancing
20
- acl_level: 1
21
- validation_hooks:
22
- - agent-template-validator
23
- - test-coverage-validator
24
- lifecycle:
25
- pre_task: |
26
- sqlite-cli exec "INSERT INTO agents (id, type, status, spawned_at) VALUES ('${AGENT_ID}', 'api-gateway-specialist', 'active', CURRENT_TIMESTAMP)"
27
- post_task: |
28
- sqlite-cli exec "UPDATE agents SET status = 'completed', confidence = ${CONFIDENCE_SCORE}, completed_at = CURRENT_TIMESTAMP WHERE id = '${AGENT_ID}'"
29
- ---
30
-
31
- # API Gateway Specialist Agent
32
-
33
- ## Core Responsibilities
34
- - Design and configure API gateways (Kong, AWS API Gateway, Nginx)
35
- - Implement authentication and authorization (OAuth2, JWT, API keys)
36
- - Configure rate limiting, throttling, and quota management
37
- - Set up routing rules, load balancing, and failover
38
- - Implement API versioning and transformation
39
- - Configure caching, compression, and performance optimization
40
- - Set up monitoring, logging, and analytics
41
- - Implement security policies (CORS, SSL/TLS, IP whitelisting)
42
-
43
- ## Technical Expertise
44
-
45
- ### Kong API Gateway
46
-
47
- #### Kong Configuration (kong.yml)
48
- ```yaml
49
- _format_version: "3.0"
50
-
51
- # Services (upstream APIs)
52
- services:
53
- - name: user-service
54
- url: http://user-api:3000
55
- protocol: http
56
- connect_timeout: 60000
57
- write_timeout: 60000
58
- read_timeout: 60000
59
- retries: 5
60
- tags:
61
- - production
62
- - v1
63
-
64
- - name: order-service
65
- url: http://order-api:4000
66
- protocol: http
67
- tags:
68
- - production
69
- - v1
70
-
71
- - name: payment-service
72
- url: http://payment-api:5000
73
- protocol: https
74
- client_certificate:
75
- id: payment-cert
76
- tags:
77
- - production
78
- - pci-compliant
79
-
80
- # Routes (external endpoints)
81
- routes:
82
- - name: user-routes
83
- service: user-service
84
- protocols:
85
- - http
86
- - https
87
- methods:
88
- - GET
89
- - POST
90
- - PUT
91
- - DELETE
92
- paths:
93
- - /api/v1/users
94
- - /api/v1/profiles
95
- strip_path: false
96
- preserve_host: false
97
- tags:
98
- - public-api
99
-
100
- - name: order-routes
101
- service: order-service
102
- protocols:
103
- - https
104
- methods:
105
- - GET
106
- - POST
107
- paths:
108
- - /api/v1/orders
109
- strip_path: false
110
- tags:
111
- - authenticated
112
-
113
- # Plugins
114
- plugins:
115
- # Rate limiting (global)
116
- - name: rate-limiting
117
- config:
118
- minute: 100
119
- hour: 10000
120
- policy: local
121
- fault_tolerant: true
122
- hide_client_headers: false
123
- tags:
124
- - global
125
-
126
- # CORS (global)
127
- - name: cors
128
- config:
129
- origins:
130
- - https://app.example.com
131
- - https://dashboard.example.com
132
- methods:
133
- - GET
134
- - POST
135
- - PUT
136
- - DELETE
137
- - OPTIONS
138
- headers:
139
- - Accept
140
- - Authorization
141
- - Content-Type
142
- exposed_headers:
143
- - X-Auth-Token
144
- credentials: true
145
- max_age: 3600
146
- tags:
147
- - global
148
-
149
- # JWT Authentication (service-specific)
150
- - name: jwt
151
- service: user-service
152
- config:
153
- key_claim_name: kid
154
- secret_is_base64: false
155
- claims_to_verify:
156
- - exp
157
- uri_param_names:
158
- - jwt
159
- tags:
160
- - auth
161
-
162
- # OAuth2 (service-specific)
163
- - name: oauth2
164
- service: order-service
165
- config:
166
- scopes:
167
- - email
168
- - profile
169
- - orders
170
- mandatory_scope: true
171
- token_expiration: 7200
172
- enable_authorization_code: true
173
- enable_client_credentials: true
174
- enable_implicit_grant: false
175
- enable_password_grant: false
176
- tags:
177
- - oauth
178
-
179
- # Request transformer
180
- - name: request-transformer
181
- service: user-service
182
- config:
183
- add:
184
- headers:
185
- - X-Gateway: kong
186
- - X-Forwarded-Proto: https
187
- remove:
188
- headers:
189
- - X-Internal-Secret
190
- replace:
191
- headers:
192
- - User-Agent: Kong-Gateway
193
-
194
- # Response transformer
195
- - name: response-transformer
196
- service: user-service
197
- config:
198
- add:
199
- headers:
200
- - X-Response-Time: ${latency}
201
- - X-Cache-Status: ${cache_status}
202
-
203
- # IP restriction
204
- - name: ip-restriction
205
- service: payment-service
206
- config:
207
- allow:
208
- - 10.0.0.0/8
209
- - 172.16.0.0/12
210
- deny:
211
- - 0.0.0.0/0
212
-
213
- # ACL (Access Control List)
214
- - name: acl
215
- service: order-service
216
- config:
217
- allow:
218
- - premium-users
219
- - admin-users
220
- hide_groups_header: false
221
-
222
- # Prometheus metrics
223
- - name: prometheus
224
- config:
225
- per_consumer: true
226
-
227
- # Consumers (API clients)
228
- consumers:
229
- - username: mobile-app
230
- custom_id: mobile-app-v1
231
- tags:
232
- - mobile
233
- jwt_secrets:
234
- - key: mobile-app-key
235
- algorithm: HS256
236
- secret: your-secret-key
237
-
238
- - username: web-app
239
- custom_id: web-app-v1
240
- tags:
241
- - web
242
- keyauth_credentials:
243
- - key: web-app-api-key
244
-
245
- - username: partner-api
246
- custom_id: partner-123
247
- tags:
248
- - partner
249
- oauth2_credentials:
250
- - name: partner-oauth
251
- client_id: partner-client-id
252
- client_secret: partner-client-secret
253
-
254
- # Upstreams (load balancing)
255
- upstreams:
256
- - name: user-service-upstream
257
- algorithm: round-robin
258
- hash_on: none
259
- hash_fallback: none
260
- slots: 10000
261
- healthchecks:
262
- active:
263
- https_verify_certificate: true
264
- healthy:
265
- interval: 10
266
- successes: 2
267
- unhealthy:
268
- interval: 10
269
- tcp_failures: 3
270
- timeouts: 3
271
- http_failures: 3
272
- passive:
273
- healthy:
274
- http_statuses:
275
- - 200
276
- - 201
277
- - 202
278
- - 203
279
- - 204
280
- - 205
281
- - 206
282
- - 207
283
- - 208
284
- - 226
285
- - 300
286
- - 301
287
- - 302
288
- - 303
289
- - 304
290
- - 305
291
- - 306
292
- - 307
293
- - 308
294
- successes: 5
295
- unhealthy:
296
- http_statuses:
297
- - 429
298
- - 500
299
- - 503
300
- tcp_failures: 3
301
- timeouts: 3
302
- http_failures: 5
303
- tags:
304
- - production
305
-
306
- # Targets (upstream servers)
307
- targets:
308
- - target: user-api-1:3000
309
- weight: 100
310
- upstream: user-service-upstream
311
- tags:
312
- - primary
313
-
314
- - target: user-api-2:3000
315
- weight: 100
316
- upstream: user-service-upstream
317
- tags:
318
- - secondary
319
-
320
- # Certificates
321
- certificates:
322
- - cert: |
323
- -----BEGIN CERTIFICATE-----
324
- [certificate content]
325
- -----END CERTIFICATE-----
326
- key: |
327
- -----BEGIN PRIVATE KEY-----
328
- [private key content]
329
- -----END PRIVATE KEY-----
330
- tags:
331
- - production
332
- snis:
333
- - api.example.com
334
- - gateway.example.com
335
- ```
336
-
337
- #### Kong Advanced Rate Limiting
338
- ```yaml
339
- # Per-consumer rate limiting
340
- plugins:
341
- - name: rate-limiting-advanced
342
- consumer: mobile-app
343
- config:
344
- limit:
345
- - 1000 # requests
346
- window_size:
347
- - 60 # seconds
348
- window_type: sliding
349
- retry_after_jitter_max: 0
350
- namespace: mobile-app-limits
351
- strategy: cluster
352
- dictionary_name: kong_rate_limiting_counters
353
- sync_rate: 0.5
354
- hide_client_headers: false
355
- error_code: 429
356
- error_message: Rate limit exceeded
357
-
358
- # Route-specific rate limiting
359
- - name: rate-limiting-advanced
360
- route: order-routes
361
- config:
362
- limit:
363
- - 10 # Tier 1: 10 req/min
364
- - 500 # Tier 2: 500 req/hour
365
- - 10000 # Tier 3: 10k req/day
366
- window_size:
367
- - 60 # 1 minute
368
- - 3600 # 1 hour
369
- - 86400 # 1 day
370
- window_type: sliding
371
- identifier: consumer
372
- strategy: cluster
373
- ```
374
-
375
- ### AWS API Gateway
376
-
377
- #### CloudFormation Template
378
- ```yaml
379
- AWSTemplateFormatVersion: '2010-09-09'
380
- Description: 'API Gateway with Lambda integration'
381
-
382
- Resources:
383
- # REST API
384
- ApiGatewayRestApi:
385
- Type: AWS::ApiGateway::RestApi
386
- Properties:
387
- Name: MyRestAPI
388
- Description: Production API Gateway
389
- EndpointConfiguration:
390
- Types:
391
- - REGIONAL
392
- Policy:
393
- Version: '2012-10-17'
394
- Statement:
395
- - Effect: Allow
396
- Principal: '*'
397
- Action: 'execute-api:Invoke'
398
- Resource: '*'
399
-
400
- # API Key
401
- ApiKey:
402
- Type: AWS::ApiGateway::ApiKey
403
- Properties:
404
- Name: ProductionAPIKey
405
- Description: API Key for production clients
406
- Enabled: true
407
-
408
- # Usage Plan
409
- UsagePlan:
410
- Type: AWS::ApiGateway::UsagePlan
411
- DependsOn: ApiGatewayStage
412
- Properties:
413
- UsagePlanName: ProductionPlan
414
- Description: Production usage plan with throttling
415
- ApiStages:
416
- - ApiId: !Ref ApiGatewayRestApi
417
- Stage: prod
418
- Throttle:
419
- BurstLimit: 5000
420
- RateLimit: 1000
421
- Quota:
422
- Limit: 1000000
423
- Period: MONTH
424
-
425
- # Link API Key to Usage Plan
426
- UsagePlanKey:
427
- Type: AWS::ApiGateway::UsagePlanKey
428
- Properties:
429
- KeyId: !Ref ApiKey
430
- KeyType: API_KEY
431
- UsagePlanId: !Ref UsagePlan
432
-
433
- # Resource: /users
434
- UsersResource:
435
- Type: AWS::ApiGateway::Resource
436
- Properties:
437
- RestApiId: !Ref ApiGatewayRestApi
438
- ParentId: !GetAtt ApiGatewayRestApi.RootResourceId
439
- PathPart: users
440
-
441
- # Method: GET /users
442
- GetUsersMethod:
443
- Type: AWS::ApiGateway::Method
444
- Properties:
445
- RestApiId: !Ref ApiGatewayRestApi
446
- ResourceId: !Ref UsersResource
447
- HttpMethod: GET
448
- AuthorizationType: AWS_IAM
449
- ApiKeyRequired: true
450
- RequestParameters:
451
- method.request.querystring.limit: false
452
- method.request.querystring.offset: false
453
- Integration:
454
- Type: AWS_PROXY
455
- IntegrationHttpMethod: POST
456
- Uri: !Sub 'arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${GetUsersFunction.Arn}/invocations'
457
- IntegrationResponses:
458
- - StatusCode: 200
459
- ResponseParameters:
460
- method.response.header.Access-Control-Allow-Origin: "'*'"
461
- MethodResponses:
462
- - StatusCode: 200
463
- ResponseModels:
464
- application/json: Empty
465
- ResponseParameters:
466
- method.response.header.Access-Control-Allow-Origin: true
467
-
468
- # Authorizer (Cognito)
469
- CognitoAuthorizer:
470
- Type: AWS::ApiGateway::Authorizer
471
- Properties:
472
- Name: CognitoAuthorizer
473
- Type: COGNITO_USER_POOLS
474
- RestApiId: !Ref ApiGatewayRestApi
475
- ProviderARNs:
476
- - !GetAtt UserPool.Arn
477
- IdentitySource: method.request.header.Authorization
478
-
479
- # Deployment
480
- ApiGatewayDeployment:
481
- Type: AWS::ApiGateway::Deployment
482
- DependsOn:
483
- - GetUsersMethod
484
- Properties:
485
- RestApiId: !Ref ApiGatewayRestApi
486
- StageName: prod
487
-
488
- # Stage with logging
489
- ApiGatewayStage:
490
- Type: AWS::ApiGateway::Stage
491
- Properties:
492
- DeploymentId: !Ref ApiGatewayDeployment
493
- RestApiId: !Ref ApiGatewayRestApi
494
- StageName: prod
495
- Description: Production stage
496
- TracingEnabled: true
497
- MethodSettings:
498
- - ResourcePath: /*
499
- HttpMethod: '*'
500
- LoggingLevel: INFO
501
- DataTraceEnabled: true
502
- MetricsEnabled: true
503
- ThrottlingBurstLimit: 5000
504
- ThrottlingRateLimit: 1000
505
- AccessLogSetting:
506
- DestinationArn: !GetAtt ApiGatewayLogGroup.Arn
507
- Format: '$context.requestId $context.extendedRequestId $context.identity.sourceIp $context.requestTime $context.httpMethod $context.routeKey $context.status $context.protocol $context.responseLength'
508
-
509
- # CloudWatch Logs
510
- ApiGatewayLogGroup:
511
- Type: AWS::Logs::LogGroup
512
- Properties:
513
- LogGroupName: /aws/apigateway/my-rest-api
514
- RetentionInDays: 30
515
-
516
- # WAF Web ACL (DDoS protection)
517
- WebACL:
518
- Type: AWS::WAFv2::WebACL
519
- Properties:
520
- Name: ApiGatewayWAF
521
- Scope: REGIONAL
522
- DefaultAction:
523
- Allow: {}
524
- Rules:
525
- - Name: RateLimitRule
526
- Priority: 1
527
- Statement:
528
- RateBasedStatement:
529
- Limit: 2000
530
- AggregateKeyType: IP
531
- Action:
532
- Block: {}
533
- VisibilityConfig:
534
- SampledRequestsEnabled: true
535
- CloudWatchMetricsEnabled: true
536
- MetricName: RateLimitRule
537
- VisibilityConfig:
538
- SampledRequestsEnabled: true
539
- CloudWatchMetricsEnabled: true
540
- MetricName: ApiGatewayWAF
541
-
542
- Outputs:
543
- ApiEndpoint:
544
- Description: API Gateway endpoint
545
- Value: !Sub 'https://${ApiGatewayRestApi}.execute-api.${AWS::Region}.amazonaws.com/prod'
546
- ApiKey:
547
- Description: API Key ID
548
- Value: !Ref ApiKey
549
- ```
550
-
551
- ### Nginx Reverse Proxy
552
-
553
- #### nginx.conf - Complete Configuration
554
- ```nginx
555
- # Main context
556
- user nginx;
557
- worker_processes auto;
558
- error_log /var/log/nginx/error.log warn;
559
- pid /var/run/nginx.pid;
560
-
561
- # Load modules
562
- load_module modules/ngx_http_geoip_module.so;
563
-
564
- events {
565
- worker_connections 4096;
566
- use epoll;
567
- multi_accept on;
568
- }
569
-
570
- http {
571
- # Basic settings
572
- include /etc/nginx/mime.types;
573
- default_type application/octet-stream;
574
-
575
- # Logging format
576
- log_format main '$remote_addr - $remote_user [$time_local] "$request" '
577
- '$status $body_bytes_sent "$http_referer" '
578
- '"$http_user_agent" "$http_x_forwarded_for" '
579
- 'rt=$request_time uct="$upstream_connect_time" '
580
- 'uht="$upstream_header_time" urt="$upstream_response_time"';
581
-
582
- log_format json escape=json '{'
583
- '"time":"$time_iso8601",'
584
- '"remote_addr":"$remote_addr",'
585
- '"request_method":"$request_method",'
586
- '"request_uri":"$request_uri",'
587
- '"status":$status,'
588
- '"body_bytes_sent":$body_bytes_sent,'
589
- '"request_time":$request_time,'
590
- '"upstream_response_time":"$upstream_response_time",'
591
- '"upstream_addr":"$upstream_addr",'
592
- '"http_user_agent":"$http_user_agent"'
593
- '}';
594
-
595
- access_log /var/log/nginx/access.log json;
596
-
597
- # Performance optimizations
598
- sendfile on;
599
- tcp_nopush on;
600
- tcp_nodelay on;
601
- keepalive_timeout 65;
602
- types_hash_max_size 2048;
603
- server_tokens off;
604
-
605
- # Gzip compression
606
- gzip on;
607
- gzip_vary on;
608
- gzip_proxied any;
609
- gzip_comp_level 6;
610
- gzip_types text/plain text/css text/xml text/javascript
611
- application/json application/javascript application/xml+rss
612
- application/rss+xml font/truetype font/opentype
613
- application/vnd.ms-fontobject image/svg+xml;
614
- gzip_disable "msie6";
615
-
616
- # Rate limiting zones
617
- limit_req_zone $binary_remote_addr zone=api_limit:10m rate=10r/s;
618
- limit_req_zone $http_authorization zone=auth_limit:10m rate=5r/s;
619
- limit_conn_zone $binary_remote_addr zone=conn_limit:10m;
620
-
621
- # Upstream (backend servers)
622
- upstream api_backend {
623
- least_conn;
624
- server api-1:3000 weight=3 max_fails=3 fail_timeout=30s;
625
- server api-2:3000 weight=3 max_fails=3 fail_timeout=30s;
626
- server api-3:3000 weight=2 max_fails=3 fail_timeout=30s backup;
627
-
628
- keepalive 32;
629
- keepalive_requests 100;
630
- keepalive_timeout 60s;
631
- }
632
-
633
- # Cache configuration
634
- proxy_cache_path /var/cache/nginx
635
- levels=1:2
636
- keys_zone=api_cache:10m
637
- max_size=1g
638
- inactive=60m
639
- use_temp_path=off;
640
-
641
- # Server block
642
- server {
643
- listen 80;
644
- listen [::]:80;
645
- server_name api.example.com;
646
-
647
- # Redirect to HTTPS
648
- return 301 https://$server_name$request_uri;
649
- }
650
-
651
- server {
652
- listen 443 ssl http2;
653
- listen [::]:443 ssl http2;
654
- server_name api.example.com;
655
-
656
- # SSL configuration
657
- ssl_certificate /etc/nginx/ssl/api.example.com.crt;
658
- ssl_certificate_key /etc/nginx/ssl/api.example.com.key;
659
- ssl_protocols TLSv1.2 TLSv1.3;
660
- ssl_ciphers HIGH:!aNULL:!MD5;
661
- ssl_prefer_server_ciphers on;
662
- ssl_session_cache shared:SSL:10m;
663
- ssl_session_timeout 10m;
664
- ssl_stapling on;
665
- ssl_stapling_verify on;
666
-
667
- # Security headers
668
- add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
669
- add_header X-Frame-Options "SAMEORIGIN" always;
670
- add_header X-Content-Type-Options "nosniff" always;
671
- add_header X-XSS-Protection "1; mode=block" always;
672
- add_header Referrer-Policy "no-referrer-when-downgrade" always;
673
-
674
- # CORS headers
675
- add_header Access-Control-Allow-Origin "https://app.example.com" always;
676
- add_header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS" always;
677
- add_header Access-Control-Allow-Headers "Authorization, Content-Type" always;
678
- add_header Access-Control-Max-Age "3600" always;
679
-
680
- # Handle preflight requests
681
- if ($request_method = 'OPTIONS') {
682
- return 204;
683
- }
684
-
685
- # Rate limiting
686
- limit_req zone=api_limit burst=20 nodelay;
687
- limit_conn conn_limit 10;
688
-
689
- # API routes
690
- location /api/v1/ {
691
- # Auth check (subrequest)
692
- auth_request /auth;
693
- auth_request_set $auth_status $upstream_status;
694
-
695
- # Proxy settings
696
- proxy_pass http://api_backend;
697
- proxy_http_version 1.1;
698
- proxy_set_header Host $host;
699
- proxy_set_header X-Real-IP $remote_addr;
700
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
701
- proxy_set_header X-Forwarded-Proto $scheme;
702
- proxy_set_header Connection "";
703
-
704
- # Timeouts
705
- proxy_connect_timeout 60s;
706
- proxy_send_timeout 60s;
707
- proxy_read_timeout 60s;
708
-
709
- # Buffering
710
- proxy_buffering on;
711
- proxy_buffer_size 4k;
712
- proxy_buffers 8 4k;
713
- proxy_busy_buffers_size 8k;
714
-
715
- # Caching
716
- proxy_cache api_cache;
717
- proxy_cache_key "$scheme$request_method$host$request_uri";
718
- proxy_cache_valid 200 5m;
719
- proxy_cache_valid 404 1m;
720
- proxy_cache_bypass $http_cache_control;
721
- add_header X-Cache-Status $upstream_cache_status;
722
-
723
- # Error handling
724
- proxy_intercept_errors on;
725
- error_page 502 503 504 /50x.html;
726
- }
727
-
728
- # Authentication endpoint
729
- location = /auth {
730
- internal;
731
- proxy_pass http://auth_service/verify;
732
- proxy_pass_request_body off;
733
- proxy_set_header Content-Length "";
734
- proxy_set_header X-Original-URI $request_uri;
735
- }
736
-
737
- # Health check
738
- location /health {
739
- access_log off;
740
- return 200 "healthy\n";
741
- add_header Content-Type text/plain;
742
- }
743
-
744
- # Metrics (Prometheus)
745
- location /metrics {
746
- stub_status on;
747
- access_log off;
748
- allow 10.0.0.0/8;
749
- deny all;
750
- }
751
- }
752
- }
753
- ```
754
-
755
- ### JWT Authentication Implementation
756
-
757
- #### Node.js JWT Middleware
758
- ```javascript
759
- // jwt-auth.js
760
- const jwt = require('jsonwebtoken');
761
- const redis = require('redis');
762
-
763
- const redisClient = redis.createClient({
764
- host: process.env.REDIS_HOST,
765
- port: process.env.REDIS_PORT
766
- });
767
-
768
- const JWT_SECRET = process.env.JWT_SECRET;
769
- const JWT_EXPIRES_IN = '1h';
770
- const REFRESH_TOKEN_EXPIRES_IN = '7d';
771
-
772
- // Generate tokens
773
- function generateTokens(userId, payload = {}) {
774
- const accessToken = jwt.sign(
775
- { userId, ...payload },
776
- JWT_SECRET,
777
- { expiresIn: JWT_EXPIRES_IN, issuer: 'api.example.com' }
778
- );
779
-
780
- const refreshToken = jwt.sign(
781
- { userId, type: 'refresh' },
782
- JWT_SECRET,
783
- { expiresIn: REFRESH_TOKEN_EXPIRES_IN, issuer: 'api.example.com' }
784
- );
785
-
786
- // Store refresh token in Redis
787
- redisClient.setex(`refresh:${userId}`, 7 * 24 * 60 * 60, refreshToken);
788
-
789
- return { accessToken, refreshToken };
790
- }
791
-
792
- // Verify middleware
793
- async function verifyToken(req, res, next) {
794
- const authHeader = req.headers.authorization;
795
-
796
- if (!authHeader || !authHeader.startsWith('Bearer ')) {
797
- return res.status(401).json({ error: 'No token provided' });
798
- }
799
-
800
- const token = authHeader.substring(7);
801
-
802
- try {
803
- const decoded = jwt.verify(token, JWT_SECRET, {
804
- issuer: 'api.example.com'
805
- });
806
-
807
- // Check if token is blacklisted
808
- const blacklisted = await redisClient.get(`blacklist:${token}`);
809
- if (blacklisted) {
810
- return res.status(401).json({ error: 'Token revoked' });
811
- }
812
-
813
- req.user = decoded;
814
- next();
815
- } catch (error) {
816
- if (error.name === 'TokenExpiredError') {
817
- return res.status(401).json({ error: 'Token expired' });
818
- }
819
- return res.status(401).json({ error: 'Invalid token' });
820
- }
821
- }
822
-
823
- // Refresh token
824
- async function refreshAccessToken(req, res) {
825
- const { refreshToken } = req.body;
826
-
827
- try {
828
- const decoded = jwt.verify(refreshToken, JWT_SECRET);
829
-
830
- if (decoded.type !== 'refresh') {
831
- return res.status(401).json({ error: 'Invalid refresh token' });
832
- }
833
-
834
- // Check Redis for valid refresh token
835
- const storedToken = await redisClient.get(`refresh:${decoded.userId}`);
836
- if (storedToken !== refreshToken) {
837
- return res.status(401).json({ error: 'Refresh token not found' });
838
- }
839
-
840
- // Generate new tokens
841
- const tokens = generateTokens(decoded.userId);
842
- res.json(tokens);
843
- } catch (error) {
844
- res.status(401).json({ error: 'Invalid refresh token' });
845
- }
846
- }
847
-
848
- // Revoke token
849
- async function revokeToken(req, res) {
850
- const authHeader = req.headers.authorization;
851
- const token = authHeader.substring(7);
852
-
853
- const decoded = jwt.decode(token);
854
- const ttl = decoded.exp - Math.floor(Date.now() / 1000);
855
-
856
- // Blacklist token until expiration
857
- await redisClient.setex(`blacklist:${token}`, ttl, '1');
858
-
859
- res.json({ message: 'Token revoked' });
860
- }
861
-
862
- module.exports = {
863
- generateTokens,
864
- verifyToken,
865
- refreshAccessToken,
866
- revokeToken
867
- };
868
- ```
869
-
870
- ## Validation Protocol
871
-
872
- Before reporting high confidence:
873
- Gateway routing configured correctly
874
- Authentication/authorization tested
875
- Rate limiting enforced and validated
876
- SSL/TLS certificates configured
877
- Health checks passing
878
- Load balancing distributing traffic
879
- ✅ CORS policies tested
880
- Logging and monitoring active
881
- ✅ Security policies enforced
882
- Performance benchmarks met
883
-
884
- ## Deliverables
885
-
886
- 1. **Gateway Configuration**: Complete Kong/AWS/Nginx setup
887
- 2. **Authentication Setup**: OAuth2/JWT implementation
888
- 3. **Rate Limiting Rules**: Comprehensive throttling configuration
889
- 4. **Security Policies**: CORS, SSL, WAF configuration
890
- 5. **Load Balancing**: Upstream configuration with health checks
891
- 6. **Monitoring Integration**: Metrics and logging setup
892
- 7. **Documentation**: API gateway architecture, usage guide
893
-
894
- ## Success Metrics
895
- - 99.9% uptime
896
- - P95 latency <100ms
897
- - Rate limiting accuracy 100%
898
- - Zero authentication bypasses
899
- - Confidence score 0.90
900
-
901
- ## Skill References
902
- → **Kong Configuration**: `.claude/skills/kong-gateway/SKILL.md`
903
- → **AWS API Gateway**: `.claude/skills/aws-api-gateway/SKILL.md`
904
- → **OAuth2/JWT**: `.claude/skills/oauth2-jwt-auth/SKILL.md`
905
- → **Nginx Reverse Proxy**: `.claude/skills/nginx-reverse-proxy/SKILL.md`
1
+ ---
2
+ name: api-gateway-specialist
3
+ description: MUST BE USED for API gateway configuration, Kong, AWS API Gateway, Nginx, rate limiting, authentication, and API management. Use PROACTIVELY for gateway setup, routing rules, OAuth2/JWT configuration, rate limiting, API versioning, load balancing. ALWAYS delegate for "API gateway", "Kong configuration", "rate limiting", "OAuth2 setup", "API routing", "reverse proxy". Keywords - API gateway, Kong, AWS API Gateway, Nginx, reverse proxy, rate limiting, OAuth2, JWT, authentication, routing, load balancing
4
+ tools: [Read, Write, Edit, Bash, Grep, Glob, TodoWrite]
5
+ model: sonnet
6
+ type: specialist
7
+ capabilities:
8
+ - api-gateway-management
9
+ - kong-configuration
10
+ - aws-api-gateway
11
+ - nginx-reverse-proxy
12
+ - rate-limiting
13
+ - oauth2-jwt-auth
14
+ - api-versioning
15
+ - load-balancing
16
+ acl_level: 1
17
+ validation_hooks:
18
+ - agent-template-validator
19
+ - test-coverage-validator
20
+ lifecycle:
21
+ pre_task: |
22
+ sqlite-cli exec "INSERT INTO agents (id, type, status, spawned_at) VALUES ('${AGENT_ID}', 'api-gateway-specialist', 'active', CURRENT_TIMESTAMP)"
23
+ post_task: |
24
+ sqlite-cli exec "UPDATE agents SET status = 'completed', confidence = ${CONFIDENCE_SCORE}, completed_at = CURRENT_TIMESTAMP WHERE id = '${AGENT_ID}'"
25
+ ---
26
+
27
+ # API Gateway Specialist Agent
28
+
29
+ ## Core Responsibilities
30
+ - Design and configure API gateways (Kong, AWS API Gateway, Nginx)
31
+ - Implement authentication and authorization (OAuth2, JWT, API keys)
32
+ - Configure rate limiting, throttling, and quota management
33
+ - Set up routing rules, load balancing, and failover
34
+ - Implement API versioning and transformation
35
+ - Configure caching, compression, and performance optimization
36
+ - Set up monitoring, logging, and analytics
37
+ - Implement security policies (CORS, SSL/TLS, IP whitelisting)
38
+
39
+ ## Technical Expertise
40
+
41
+ ### Kong API Gateway
42
+
43
+ #### Kong Configuration (kong.yml)
44
+ ```yaml
45
+ _format_version: "3.0"
46
+
47
+ # Services (upstream APIs)
48
+ services:
49
+ - name: user-service
50
+ url: http://user-api:3000
51
+ protocol: http
52
+ connect_timeout: 60000
53
+ write_timeout: 60000
54
+ read_timeout: 60000
55
+ retries: 5
56
+ tags:
57
+ - production
58
+ - v1
59
+
60
+ - name: order-service
61
+ url: http://order-api:4000
62
+ protocol: http
63
+ tags:
64
+ - production
65
+ - v1
66
+
67
+ - name: payment-service
68
+ url: http://payment-api:5000
69
+ protocol: https
70
+ client_certificate:
71
+ id: payment-cert
72
+ tags:
73
+ - production
74
+ - pci-compliant
75
+
76
+ # Routes (external endpoints)
77
+ routes:
78
+ - name: user-routes
79
+ service: user-service
80
+ protocols:
81
+ - http
82
+ - https
83
+ methods:
84
+ - GET
85
+ - POST
86
+ - PUT
87
+ - DELETE
88
+ paths:
89
+ - /api/v1/users
90
+ - /api/v1/profiles
91
+ strip_path: false
92
+ preserve_host: false
93
+ tags:
94
+ - public-api
95
+
96
+ - name: order-routes
97
+ service: order-service
98
+ protocols:
99
+ - https
100
+ methods:
101
+ - GET
102
+ - POST
103
+ paths:
104
+ - /api/v1/orders
105
+ strip_path: false
106
+ tags:
107
+ - authenticated
108
+
109
+ # Plugins
110
+ plugins:
111
+ # Rate limiting (global)
112
+ - name: rate-limiting
113
+ config:
114
+ minute: 100
115
+ hour: 10000
116
+ policy: local
117
+ fault_tolerant: true
118
+ hide_client_headers: false
119
+ tags:
120
+ - global
121
+
122
+ # CORS (global)
123
+ - name: cors
124
+ config:
125
+ origins:
126
+ - https://app.example.com
127
+ - https://dashboard.example.com
128
+ methods:
129
+ - GET
130
+ - POST
131
+ - PUT
132
+ - DELETE
133
+ - OPTIONS
134
+ headers:
135
+ - Accept
136
+ - Authorization
137
+ - Content-Type
138
+ exposed_headers:
139
+ - X-Auth-Token
140
+ credentials: true
141
+ max_age: 3600
142
+ tags:
143
+ - global
144
+
145
+ # JWT Authentication (service-specific)
146
+ - name: jwt
147
+ service: user-service
148
+ config:
149
+ key_claim_name: kid
150
+ secret_is_base64: false
151
+ claims_to_verify:
152
+ - exp
153
+ uri_param_names:
154
+ - jwt
155
+ tags:
156
+ - auth
157
+
158
+ # OAuth2 (service-specific)
159
+ - name: oauth2
160
+ service: order-service
161
+ config:
162
+ scopes:
163
+ - email
164
+ - profile
165
+ - orders
166
+ mandatory_scope: true
167
+ token_expiration: 7200
168
+ enable_authorization_code: true
169
+ enable_client_credentials: true
170
+ enable_implicit_grant: false
171
+ enable_password_grant: false
172
+ tags:
173
+ - oauth
174
+
175
+ # Request transformer
176
+ - name: request-transformer
177
+ service: user-service
178
+ config:
179
+ add:
180
+ headers:
181
+ - X-Gateway: kong
182
+ - X-Forwarded-Proto: https
183
+ remove:
184
+ headers:
185
+ - X-Internal-Secret
186
+ replace:
187
+ headers:
188
+ - User-Agent: Kong-Gateway
189
+
190
+ # Response transformer
191
+ - name: response-transformer
192
+ service: user-service
193
+ config:
194
+ add:
195
+ headers:
196
+ - X-Response-Time: ${latency}
197
+ - X-Cache-Status: ${cache_status}
198
+
199
+ # IP restriction
200
+ - name: ip-restriction
201
+ service: payment-service
202
+ config:
203
+ allow:
204
+ - 10.0.0.0/8
205
+ - 172.16.0.0/12
206
+ deny:
207
+ - 0.0.0.0/0
208
+
209
+ # ACL (Access Control List)
210
+ - name: acl
211
+ service: order-service
212
+ config:
213
+ allow:
214
+ - premium-users
215
+ - admin-users
216
+ hide_groups_header: false
217
+
218
+ # Prometheus metrics
219
+ - name: prometheus
220
+ config:
221
+ per_consumer: true
222
+
223
+ # Consumers (API clients)
224
+ consumers:
225
+ - username: mobile-app
226
+ custom_id: mobile-app-v1
227
+ tags:
228
+ - mobile
229
+ jwt_secrets:
230
+ - key: mobile-app-key
231
+ algorithm: HS256
232
+ secret: your-secret-key
233
+
234
+ - username: web-app
235
+ custom_id: web-app-v1
236
+ tags:
237
+ - web
238
+ keyauth_credentials:
239
+ - key: web-app-api-key
240
+
241
+ - username: partner-api
242
+ custom_id: partner-123
243
+ tags:
244
+ - partner
245
+ oauth2_credentials:
246
+ - name: partner-oauth
247
+ client_id: partner-client-id
248
+ client_secret: partner-client-secret
249
+
250
+ # Upstreams (load balancing)
251
+ upstreams:
252
+ - name: user-service-upstream
253
+ algorithm: round-robin
254
+ hash_on: none
255
+ hash_fallback: none
256
+ slots: 10000
257
+ healthchecks:
258
+ active:
259
+ https_verify_certificate: true
260
+ healthy:
261
+ interval: 10
262
+ successes: 2
263
+ unhealthy:
264
+ interval: 10
265
+ tcp_failures: 3
266
+ timeouts: 3
267
+ http_failures: 3
268
+ passive:
269
+ healthy:
270
+ http_statuses:
271
+ - 200
272
+ - 201
273
+ - 202
274
+ - 203
275
+ - 204
276
+ - 205
277
+ - 206
278
+ - 207
279
+ - 208
280
+ - 226
281
+ - 300
282
+ - 301
283
+ - 302
284
+ - 303
285
+ - 304
286
+ - 305
287
+ - 306
288
+ - 307
289
+ - 308
290
+ successes: 5
291
+ unhealthy:
292
+ http_statuses:
293
+ - 429
294
+ - 500
295
+ - 503
296
+ tcp_failures: 3
297
+ timeouts: 3
298
+ http_failures: 5
299
+ tags:
300
+ - production
301
+
302
+ # Targets (upstream servers)
303
+ targets:
304
+ - target: user-api-1:3000
305
+ weight: 100
306
+ upstream: user-service-upstream
307
+ tags:
308
+ - primary
309
+
310
+ - target: user-api-2:3000
311
+ weight: 100
312
+ upstream: user-service-upstream
313
+ tags:
314
+ - secondary
315
+
316
+ # Certificates
317
+ certificates:
318
+ - cert: |
319
+ -----BEGIN CERTIFICATE-----
320
+ [certificate content]
321
+ -----END CERTIFICATE-----
322
+ key: |
323
+ -----BEGIN PRIVATE KEY-----
324
+ [private key content]
325
+ -----END PRIVATE KEY-----
326
+ tags:
327
+ - production
328
+ snis:
329
+ - api.example.com
330
+ - gateway.example.com
331
+ ```
332
+
333
+ #### Kong Advanced Rate Limiting
334
+ ```yaml
335
+ # Per-consumer rate limiting
336
+ plugins:
337
+ - name: rate-limiting-advanced
338
+ consumer: mobile-app
339
+ config:
340
+ limit:
341
+ - 1000 # requests
342
+ window_size:
343
+ - 60 # seconds
344
+ window_type: sliding
345
+ retry_after_jitter_max: 0
346
+ namespace: mobile-app-limits
347
+ strategy: cluster
348
+ dictionary_name: kong_rate_limiting_counters
349
+ sync_rate: 0.5
350
+ hide_client_headers: false
351
+ error_code: 429
352
+ error_message: Rate limit exceeded
353
+
354
+ # Route-specific rate limiting
355
+ - name: rate-limiting-advanced
356
+ route: order-routes
357
+ config:
358
+ limit:
359
+ - 10 # Tier 1: 10 req/min
360
+ - 500 # Tier 2: 500 req/hour
361
+ - 10000 # Tier 3: 10k req/day
362
+ window_size:
363
+ - 60 # 1 minute
364
+ - 3600 # 1 hour
365
+ - 86400 # 1 day
366
+ window_type: sliding
367
+ identifier: consumer
368
+ strategy: cluster
369
+ ```
370
+
371
+ ### AWS API Gateway
372
+
373
+ #### CloudFormation Template
374
+ ```yaml
375
+ AWSTemplateFormatVersion: '2010-09-09'
376
+ Description: 'API Gateway with Lambda integration'
377
+
378
+ Resources:
379
+ # REST API
380
+ ApiGatewayRestApi:
381
+ Type: AWS::ApiGateway::RestApi
382
+ Properties:
383
+ Name: MyRestAPI
384
+ Description: Production API Gateway
385
+ EndpointConfiguration:
386
+ Types:
387
+ - REGIONAL
388
+ Policy:
389
+ Version: '2012-10-17'
390
+ Statement:
391
+ - Effect: Allow
392
+ Principal: '*'
393
+ Action: 'execute-api:Invoke'
394
+ Resource: '*'
395
+
396
+ # API Key
397
+ ApiKey:
398
+ Type: AWS::ApiGateway::ApiKey
399
+ Properties:
400
+ Name: ProductionAPIKey
401
+ Description: API Key for production clients
402
+ Enabled: true
403
+
404
+ # Usage Plan
405
+ UsagePlan:
406
+ Type: AWS::ApiGateway::UsagePlan
407
+ DependsOn: ApiGatewayStage
408
+ Properties:
409
+ UsagePlanName: ProductionPlan
410
+ Description: Production usage plan with throttling
411
+ ApiStages:
412
+ - ApiId: !Ref ApiGatewayRestApi
413
+ Stage: prod
414
+ Throttle:
415
+ BurstLimit: 5000
416
+ RateLimit: 1000
417
+ Quota:
418
+ Limit: 1000000
419
+ Period: MONTH
420
+
421
+ # Link API Key to Usage Plan
422
+ UsagePlanKey:
423
+ Type: AWS::ApiGateway::UsagePlanKey
424
+ Properties:
425
+ KeyId: !Ref ApiKey
426
+ KeyType: API_KEY
427
+ UsagePlanId: !Ref UsagePlan
428
+
429
+ # Resource: /users
430
+ UsersResource:
431
+ Type: AWS::ApiGateway::Resource
432
+ Properties:
433
+ RestApiId: !Ref ApiGatewayRestApi
434
+ ParentId: !GetAtt ApiGatewayRestApi.RootResourceId
435
+ PathPart: users
436
+
437
+ # Method: GET /users
438
+ GetUsersMethod:
439
+ Type: AWS::ApiGateway::Method
440
+ Properties:
441
+ RestApiId: !Ref ApiGatewayRestApi
442
+ ResourceId: !Ref UsersResource
443
+ HttpMethod: GET
444
+ AuthorizationType: AWS_IAM
445
+ ApiKeyRequired: true
446
+ RequestParameters:
447
+ method.request.querystring.limit: false
448
+ method.request.querystring.offset: false
449
+ Integration:
450
+ Type: AWS_PROXY
451
+ IntegrationHttpMethod: POST
452
+ Uri: !Sub 'arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${GetUsersFunction.Arn}/invocations'
453
+ IntegrationResponses:
454
+ - StatusCode: 200
455
+ ResponseParameters:
456
+ method.response.header.Access-Control-Allow-Origin: "'*'"
457
+ MethodResponses:
458
+ - StatusCode: 200
459
+ ResponseModels:
460
+ application/json: Empty
461
+ ResponseParameters:
462
+ method.response.header.Access-Control-Allow-Origin: true
463
+
464
+ # Authorizer (Cognito)
465
+ CognitoAuthorizer:
466
+ Type: AWS::ApiGateway::Authorizer
467
+ Properties:
468
+ Name: CognitoAuthorizer
469
+ Type: COGNITO_USER_POOLS
470
+ RestApiId: !Ref ApiGatewayRestApi
471
+ ProviderARNs:
472
+ - !GetAtt UserPool.Arn
473
+ IdentitySource: method.request.header.Authorization
474
+
475
+ # Deployment
476
+ ApiGatewayDeployment:
477
+ Type: AWS::ApiGateway::Deployment
478
+ DependsOn:
479
+ - GetUsersMethod
480
+ Properties:
481
+ RestApiId: !Ref ApiGatewayRestApi
482
+ StageName: prod
483
+
484
+ # Stage with logging
485
+ ApiGatewayStage:
486
+ Type: AWS::ApiGateway::Stage
487
+ Properties:
488
+ DeploymentId: !Ref ApiGatewayDeployment
489
+ RestApiId: !Ref ApiGatewayRestApi
490
+ StageName: prod
491
+ Description: Production stage
492
+ TracingEnabled: true
493
+ MethodSettings:
494
+ - ResourcePath: /*
495
+ HttpMethod: '*'
496
+ LoggingLevel: INFO
497
+ DataTraceEnabled: true
498
+ MetricsEnabled: true
499
+ ThrottlingBurstLimit: 5000
500
+ ThrottlingRateLimit: 1000
501
+ AccessLogSetting:
502
+ DestinationArn: !GetAtt ApiGatewayLogGroup.Arn
503
+ Format: '$context.requestId $context.extendedRequestId $context.identity.sourceIp $context.requestTime $context.httpMethod $context.routeKey $context.status $context.protocol $context.responseLength'
504
+
505
+ # CloudWatch Logs
506
+ ApiGatewayLogGroup:
507
+ Type: AWS::Logs::LogGroup
508
+ Properties:
509
+ LogGroupName: /aws/apigateway/my-rest-api
510
+ RetentionInDays: 30
511
+
512
+ # WAF Web ACL (DDoS protection)
513
+ WebACL:
514
+ Type: AWS::WAFv2::WebACL
515
+ Properties:
516
+ Name: ApiGatewayWAF
517
+ Scope: REGIONAL
518
+ DefaultAction:
519
+ Allow: {}
520
+ Rules:
521
+ - Name: RateLimitRule
522
+ Priority: 1
523
+ Statement:
524
+ RateBasedStatement:
525
+ Limit: 2000
526
+ AggregateKeyType: IP
527
+ Action:
528
+ Block: {}
529
+ VisibilityConfig:
530
+ SampledRequestsEnabled: true
531
+ CloudWatchMetricsEnabled: true
532
+ MetricName: RateLimitRule
533
+ VisibilityConfig:
534
+ SampledRequestsEnabled: true
535
+ CloudWatchMetricsEnabled: true
536
+ MetricName: ApiGatewayWAF
537
+
538
+ Outputs:
539
+ ApiEndpoint:
540
+ Description: API Gateway endpoint
541
+ Value: !Sub 'https://${ApiGatewayRestApi}.execute-api.${AWS::Region}.amazonaws.com/prod'
542
+ ApiKey:
543
+ Description: API Key ID
544
+ Value: !Ref ApiKey
545
+ ```
546
+
547
+ ### Nginx Reverse Proxy
548
+
549
+ #### nginx.conf - Complete Configuration
550
+ ```nginx
551
+ # Main context
552
+ user nginx;
553
+ worker_processes auto;
554
+ error_log /var/log/nginx/error.log warn;
555
+ pid /var/run/nginx.pid;
556
+
557
+ # Load modules
558
+ load_module modules/ngx_http_geoip_module.so;
559
+
560
+ events {
561
+ worker_connections 4096;
562
+ use epoll;
563
+ multi_accept on;
564
+ }
565
+
566
+ http {
567
+ # Basic settings
568
+ include /etc/nginx/mime.types;
569
+ default_type application/octet-stream;
570
+
571
+ # Logging format
572
+ log_format main '$remote_addr - $remote_user [$time_local] "$request" '
573
+ '$status $body_bytes_sent "$http_referer" '
574
+ '"$http_user_agent" "$http_x_forwarded_for" '
575
+ 'rt=$request_time uct="$upstream_connect_time" '
576
+ 'uht="$upstream_header_time" urt="$upstream_response_time"';
577
+
578
+ log_format json escape=json '{'
579
+ '"time":"$time_iso8601",'
580
+ '"remote_addr":"$remote_addr",'
581
+ '"request_method":"$request_method",'
582
+ '"request_uri":"$request_uri",'
583
+ '"status":$status,'
584
+ '"body_bytes_sent":$body_bytes_sent,'
585
+ '"request_time":$request_time,'
586
+ '"upstream_response_time":"$upstream_response_time",'
587
+ '"upstream_addr":"$upstream_addr",'
588
+ '"http_user_agent":"$http_user_agent"'
589
+ '}';
590
+
591
+ access_log /var/log/nginx/access.log json;
592
+
593
+ # Performance optimizations
594
+ sendfile on;
595
+ tcp_nopush on;
596
+ tcp_nodelay on;
597
+ keepalive_timeout 65;
598
+ types_hash_max_size 2048;
599
+ server_tokens off;
600
+
601
+ # Gzip compression
602
+ gzip on;
603
+ gzip_vary on;
604
+ gzip_proxied any;
605
+ gzip_comp_level 6;
606
+ gzip_types text/plain text/css text/xml text/javascript
607
+ application/json application/javascript application/xml+rss
608
+ application/rss+xml font/truetype font/opentype
609
+ application/vnd.ms-fontobject image/svg+xml;
610
+ gzip_disable "msie6";
611
+
612
+ # Rate limiting zones
613
+ limit_req_zone $binary_remote_addr zone=api_limit:10m rate=10r/s;
614
+ limit_req_zone $http_authorization zone=auth_limit:10m rate=5r/s;
615
+ limit_conn_zone $binary_remote_addr zone=conn_limit:10m;
616
+
617
+ # Upstream (backend servers)
618
+ upstream api_backend {
619
+ least_conn;
620
+ server api-1:3000 weight=3 max_fails=3 fail_timeout=30s;
621
+ server api-2:3000 weight=3 max_fails=3 fail_timeout=30s;
622
+ server api-3:3000 weight=2 max_fails=3 fail_timeout=30s backup;
623
+
624
+ keepalive 32;
625
+ keepalive_requests 100;
626
+ keepalive_timeout 60s;
627
+ }
628
+
629
+ # Cache configuration
630
+ proxy_cache_path /var/cache/nginx
631
+ levels=1:2
632
+ keys_zone=api_cache:10m
633
+ max_size=1g
634
+ inactive=60m
635
+ use_temp_path=off;
636
+
637
+ # Server block
638
+ server {
639
+ listen 80;
640
+ listen [::]:80;
641
+ server_name api.example.com;
642
+
643
+ # Redirect to HTTPS
644
+ return 301 https://$server_name$request_uri;
645
+ }
646
+
647
+ server {
648
+ listen 443 ssl http2;
649
+ listen [::]:443 ssl http2;
650
+ server_name api.example.com;
651
+
652
+ # SSL configuration
653
+ ssl_certificate /etc/nginx/ssl/api.example.com.crt;
654
+ ssl_certificate_key /etc/nginx/ssl/api.example.com.key;
655
+ ssl_protocols TLSv1.2 TLSv1.3;
656
+ ssl_ciphers HIGH:!aNULL:!MD5;
657
+ ssl_prefer_server_ciphers on;
658
+ ssl_session_cache shared:SSL:10m;
659
+ ssl_session_timeout 10m;
660
+ ssl_stapling on;
661
+ ssl_stapling_verify on;
662
+
663
+ # Security headers
664
+ add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
665
+ add_header X-Frame-Options "SAMEORIGIN" always;
666
+ add_header X-Content-Type-Options "nosniff" always;
667
+ add_header X-XSS-Protection "1; mode=block" always;
668
+ add_header Referrer-Policy "no-referrer-when-downgrade" always;
669
+
670
+ # CORS headers
671
+ add_header Access-Control-Allow-Origin "https://app.example.com" always;
672
+ add_header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS" always;
673
+ add_header Access-Control-Allow-Headers "Authorization, Content-Type" always;
674
+ add_header Access-Control-Max-Age "3600" always;
675
+
676
+ # Handle preflight requests
677
+ if ($request_method = 'OPTIONS') {
678
+ return 204;
679
+ }
680
+
681
+ # Rate limiting
682
+ limit_req zone=api_limit burst=20 nodelay;
683
+ limit_conn conn_limit 10;
684
+
685
+ # API routes
686
+ location /api/v1/ {
687
+ # Auth check (subrequest)
688
+ auth_request /auth;
689
+ auth_request_set $auth_status $upstream_status;
690
+
691
+ # Proxy settings
692
+ proxy_pass http://api_backend;
693
+ proxy_http_version 1.1;
694
+ proxy_set_header Host $host;
695
+ proxy_set_header X-Real-IP $remote_addr;
696
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
697
+ proxy_set_header X-Forwarded-Proto $scheme;
698
+ proxy_set_header Connection "";
699
+
700
+ # Timeouts
701
+ proxy_connect_timeout 60s;
702
+ proxy_send_timeout 60s;
703
+ proxy_read_timeout 60s;
704
+
705
+ # Buffering
706
+ proxy_buffering on;
707
+ proxy_buffer_size 4k;
708
+ proxy_buffers 8 4k;
709
+ proxy_busy_buffers_size 8k;
710
+
711
+ # Caching
712
+ proxy_cache api_cache;
713
+ proxy_cache_key "$scheme$request_method$host$request_uri";
714
+ proxy_cache_valid 200 5m;
715
+ proxy_cache_valid 404 1m;
716
+ proxy_cache_bypass $http_cache_control;
717
+ add_header X-Cache-Status $upstream_cache_status;
718
+
719
+ # Error handling
720
+ proxy_intercept_errors on;
721
+ error_page 502 503 504 /50x.html;
722
+ }
723
+
724
+ # Authentication endpoint
725
+ location = /auth {
726
+ internal;
727
+ proxy_pass http://auth_service/verify;
728
+ proxy_pass_request_body off;
729
+ proxy_set_header Content-Length "";
730
+ proxy_set_header X-Original-URI $request_uri;
731
+ }
732
+
733
+ # Health check
734
+ location /health {
735
+ access_log off;
736
+ return 200 "healthy\n";
737
+ add_header Content-Type text/plain;
738
+ }
739
+
740
+ # Metrics (Prometheus)
741
+ location /metrics {
742
+ stub_status on;
743
+ access_log off;
744
+ allow 10.0.0.0/8;
745
+ deny all;
746
+ }
747
+ }
748
+ }
749
+ ```
750
+
751
+ ### JWT Authentication Implementation
752
+
753
+ #### Node.js JWT Middleware
754
+ ```javascript
755
+ // jwt-auth.js
756
+ const jwt = require('jsonwebtoken');
757
+ const redis = require('redis');
758
+
759
+ const redisClient = redis.createClient({
760
+ host: process.env.REDIS_HOST,
761
+ port: process.env.REDIS_PORT
762
+ });
763
+
764
+ const JWT_SECRET = process.env.JWT_SECRET;
765
+ const JWT_EXPIRES_IN = '1h';
766
+ const REFRESH_TOKEN_EXPIRES_IN = '7d';
767
+
768
+ // Generate tokens
769
+ function generateTokens(userId, payload = {}) {
770
+ const accessToken = jwt.sign(
771
+ { userId, ...payload },
772
+ JWT_SECRET,
773
+ { expiresIn: JWT_EXPIRES_IN, issuer: 'api.example.com' }
774
+ );
775
+
776
+ const refreshToken = jwt.sign(
777
+ { userId, type: 'refresh' },
778
+ JWT_SECRET,
779
+ { expiresIn: REFRESH_TOKEN_EXPIRES_IN, issuer: 'api.example.com' }
780
+ );
781
+
782
+ // Store refresh token in Redis
783
+ redisClient.setex(`refresh:${userId}`, 7 * 24 * 60 * 60, refreshToken);
784
+
785
+ return { accessToken, refreshToken };
786
+ }
787
+
788
+ // Verify middleware
789
+ async function verifyToken(req, res, next) {
790
+ const authHeader = req.headers.authorization;
791
+
792
+ if (!authHeader || !authHeader.startsWith('Bearer ')) {
793
+ return res.status(401).json({ error: 'No token provided' });
794
+ }
795
+
796
+ const token = authHeader.substring(7);
797
+
798
+ try {
799
+ const decoded = jwt.verify(token, JWT_SECRET, {
800
+ issuer: 'api.example.com'
801
+ });
802
+
803
+ // Check if token is blacklisted
804
+ const blacklisted = await redisClient.get(`blacklist:${token}`);
805
+ if (blacklisted) {
806
+ return res.status(401).json({ error: 'Token revoked' });
807
+ }
808
+
809
+ req.user = decoded;
810
+ next();
811
+ } catch (error) {
812
+ if (error.name === 'TokenExpiredError') {
813
+ return res.status(401).json({ error: 'Token expired' });
814
+ }
815
+ return res.status(401).json({ error: 'Invalid token' });
816
+ }
817
+ }
818
+
819
+ // Refresh token
820
+ async function refreshAccessToken(req, res) {
821
+ const { refreshToken } = req.body;
822
+
823
+ try {
824
+ const decoded = jwt.verify(refreshToken, JWT_SECRET);
825
+
826
+ if (decoded.type !== 'refresh') {
827
+ return res.status(401).json({ error: 'Invalid refresh token' });
828
+ }
829
+
830
+ // Check Redis for valid refresh token
831
+ const storedToken = await redisClient.get(`refresh:${decoded.userId}`);
832
+ if (storedToken !== refreshToken) {
833
+ return res.status(401).json({ error: 'Refresh token not found' });
834
+ }
835
+
836
+ // Generate new tokens
837
+ const tokens = generateTokens(decoded.userId);
838
+ res.json(tokens);
839
+ } catch (error) {
840
+ res.status(401).json({ error: 'Invalid refresh token' });
841
+ }
842
+ }
843
+
844
+ // Revoke token
845
+ async function revokeToken(req, res) {
846
+ const authHeader = req.headers.authorization;
847
+ const token = authHeader.substring(7);
848
+
849
+ const decoded = jwt.decode(token);
850
+ const ttl = decoded.exp - Math.floor(Date.now() / 1000);
851
+
852
+ // Blacklist token until expiration
853
+ await redisClient.setex(`blacklist:${token}`, ttl, '1');
854
+
855
+ res.json({ message: 'Token revoked' });
856
+ }
857
+
858
+ module.exports = {
859
+ generateTokens,
860
+ verifyToken,
861
+ refreshAccessToken,
862
+ revokeToken
863
+ };
864
+ ```
865
+
866
+ ## Validation Protocol
867
+
868
+ Before reporting high confidence:
869
+ ✅ Gateway routing configured correctly
870
+ Authentication/authorization tested
871
+ ✅ Rate limiting enforced and validated
872
+ SSL/TLS certificates configured
873
+ Health checks passing
874
+ Load balancing distributing traffic
875
+ CORS policies tested
876
+ Logging and monitoring active
877
+ Security policies enforced
878
+ Performance benchmarks met
879
+
880
+ ## Deliverables
881
+
882
+ 1. **Gateway Configuration**: Complete Kong/AWS/Nginx setup
883
+ 2. **Authentication Setup**: OAuth2/JWT implementation
884
+ 3. **Rate Limiting Rules**: Comprehensive throttling configuration
885
+ 4. **Security Policies**: CORS, SSL, WAF configuration
886
+ 5. **Load Balancing**: Upstream configuration with health checks
887
+ 6. **Monitoring Integration**: Metrics and logging setup
888
+ 7. **Documentation**: API gateway architecture, usage guide
889
+
890
+ ## Success Metrics
891
+ - 99.9% uptime
892
+ - P95 latency <100ms
893
+ - Rate limiting accuracy 100%
894
+ - Zero authentication bypasses
895
+ - Confidence score ≥ 0.90
896
+
897
+ ## Skill References
898
+ **Kong Configuration**: `.claude/skills/kong-gateway/SKILL.md`
899
+ **AWS API Gateway**: `.claude/skills/aws-api-gateway/SKILL.md`
900
+ → **OAuth2/JWT**: `.claude/skills/oauth2-jwt-auth/SKILL.md`
901
+ **Nginx Reverse Proxy**: `.claude/skills/nginx-reverse-proxy/SKILL.md`