Skip to content

lidge-jun/codexclaw / plugins/codexclaw/skills/dev-devops

cxc-dev-devops

Verified

Use for infra, CI/CD, releases, repo policy, worktree cleanup and native desktop apps. Triggers: Dockerfile, K8s, IaC, SRE, Tauri, 스택 PR CI, 배포, 인프라, 쿠버네티스, 브랜치 정리, 브랜치 삭제, 워크트리 정리, 저장소 세팅, 브랜치 보호, 에이전트 PR, PR 정책, 데스크톱 앱, 메뉴 막대.

references/edge-serverless.md

View on GitHub
# Edge & Serverless — Edge Computing Patterns

Last reviewed: 2026-06-16
Applies to: Cloudflare Workers, Vercel Edge Functions, AWS Lambda@Edge
When to read: Edge/serverless deployment tasks
Canonical owner: dev-devops

---

## §1 Edge Request Shaping

### What Belongs at the Edge

| ✅ Edge-appropriate | ❌ Keep at origin |
|--------------------|-------------------|
| Auth token validation (JWT verify) | Auth token issuance (login flow) |
| Rate limiting / throttling | Complex business logic |
| Geo-routing / A-B testing | Database writes |
| Response caching / transformation | Transactions |
| Bot detection / WAF rules | Long-running processes |
| Request header enrichment | ML inference (unless edge-optimized) |
| Static asset serving | Stateful sessions |

### Decision Tree

```
Request arrives at edge →
├── Static asset? → Serve from CDN cache
├── Auth check needed?
│   ├── JWT verify (stateless) → Edge
│   └── Session lookup (stateful) → Origin
├── Rate limit? → Edge (distributed counter)
├── Geo-specific routing? → Edge
└── Business logic → Origin
```

---

## §2 Global API Front Door

### Architecture

```
User → Edge PoP (nearest) → Auth/rate-limit/cache → Origin region
         │
         ├── Cache HIT → respond immediately
         ├── Auth FAIL → 401 at edge (no origin load)
         └── PASS → forward to origin with enriched headers
```

### Request Enrichment Headers

| Header | Source | Purpose |
|--------|--------|---------|
| `X-Country` | Edge geo-IP | Geo-routing, compliance |
| `X-Device-Type` | User-Agent parsing | Responsive content |
| `X-Request-ID` | Edge-generated UUID | Distributed tracing |
| `X-Edge-PoP` | Edge location | Debugging latency |
| `CF-Connecting-IP` | Cloudflare | Real client IP |

---

## §3 Auth at Edge

### JWT Verification Pattern

```typescript
// Cloudflare Workers — JWT verify at edge
export default {
  async fetch(request: Request, env: Env): Promise<Response> {
    const token = request.headers.get("Authorization")?.replace("Bearer ", "");
    if (!token) {
      return new Response("Unauthorized", { status: 401 });
    }

    try {
      const payload = await verifyJWT(token, env.JWT_PUBLIC_KEY);

      // Enrich headers for origin
      const enriched = new Request(request, {
        headers: new Headers({
          ...Object.fromEntries(request.headers),
          "X-User-ID": payload.sub,
          "X-User-Role": payload.role,
        }),
      });

      return fetch(enriched);
    } catch {
      return new Response("Invalid token", { status: 401 });
    }
  },
};
```

### Rules

| Rule | Detail |
|------|--------|
| Stateless only | JWT verify, API key check — no session DB calls |
| Fail closed | Invalid/missing token → 401 at edge |
| Clock skew | Allow 30s tolerance for `exp` / `nbf` claims |
| Key rotation | Support multiple public keys (JWKS) |

---

## §4 Edge AI Triage

### When to Run AI at Edge

| ✅ Edge AI | ❌ Origin AI |
|-----------|-------------|
| Classification (<10ms, small model) | LLM inference (large models) |
| Content moderation (text/image) | Training / fine-tuning |
| Semantic cache lookup | RAG with vector DB |
| Request priority scoring | Complex chain-of-thought |

### Pattern: Semantic Cache at Edge

```
Request → Edge →
  1. Hash prompt → check KV cache
  2. Cache HIT → return cached response (sub-5ms)
  3. Cache MISS → forward to origin LLM → cache response → return
```

---

## §5 Platform Patterns

### Cloudflare Workers

| Feature | Detail |
|---------|--------|
| Runtime | V8 isolates (not Node.js) |
| Limits | 10ms CPU (free), 30s (paid); 128MB memory |
| Storage | KV (global), R2 (objects), D1 (SQLite), Durable Objects (state) |
| Deploy | `wrangler deploy` |

### Vercel Edge Functions

| Feature | Detail |
|---------|--------|
| Runtime | Edge Runtime (Web APIs subset) |
| Framework | Next.js `export const runtime = "edge"` |
| Limits | 30s execution, 4MB response |
| Use case | Middleware, API routes, ISR |

### AWS Lambda@Edge / CloudFront Functions

| Type | Limit | Use Case |
|------|-------|----------|
| CloudFront Functions | 1ms, 10KB | Header manipulation, redirects |
| Lambda@Edge | 30s (origin), 5s (viewer) | Auth, dynamic routing |

---

## §6 Anti-Patterns

| Banned | Symptom | Fix |
|--------|---------|-----|
| Database calls from edge | High latency, connection pool exhaustion | Cache at edge, query at origin |
| Heavy computation at edge | CPU timeout (10ms limit on CF free) | Offload to origin or queue |
| Stateful sessions at edge | Inconsistent state across PoPs | Stateless JWT or edge KV |
| No fallback for edge failures | Users see 500 from edge crash | Fail-open to origin |
| Hardcoded edge config | Can't update without redeploy | Edge KV / feature flags |
writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deploymentStars: 318kUpdated Claude CodeCodexVerifiedInstall
xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved.Stars: 196kUpdated Claude CodeCodexVerifiedInstall
shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy.Stars: 118kUpdated Claude CodeCodexVerifiedInstall
childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release.Stars: 117kUpdated Claude CodeCodexVerifiedInstall