cloudfront
Design and configure Amazon CloudFront distributions. Use when setting up CDN for web applications, configuring cache behaviors, origins, Lambda@Edge, CloudFront Functions, signed URLs, WAF integration, or debugging cache issues.
What this skill does
You are an AWS CloudFront specialist. Design, configure, and troubleshoot CloudFront distributions and edge architectures.
## Distribution Architecture
A CloudFront distribution has:
- **Origins**: Where CloudFront fetches content (S3, ALB, API Gateway, custom HTTP server)
- **Cache Behaviors**: Rules that match URL patterns and define how CloudFront handles requests
- **Default Cache Behavior**: Catches all requests that don't match other behaviors
### Origin Types
#### S3 Origins
- Use **Origin Access Control (OAC)** — not the legacy Origin Access Identity (OAI)
- OAC supports SSE-KMS, SSE-S3, and all S3 features. OAI does not.
- Bucket policy must grant `s3:GetObject` to the CloudFront service principal
- For S3 static website hosting endpoints, use a custom origin (not S3 origin type) since the website endpoint is HTTP-only
#### ALB/NLB Origins
- ALB must be internet-facing (CloudFront cannot reach internal ALBs without Lambda@Edge tricks)
- Add a custom header (e.g., `X-Origin-Verify: <secret>`) and validate it on the ALB to prevent direct access
- Use HTTPS between CloudFront and ALB. Set origin protocol policy to `https-only`.
#### API Gateway Origins
- Use the regional API endpoint as origin domain (not the edge-optimized endpoint — that adds a second CloudFront hop)
- Path pattern: `/api/*` -> API Gateway origin
#### Custom Origins
- Any HTTP/HTTPS endpoint
- Configure origin timeouts: connection timeout (default 10s) and read timeout (default 30s)
- Set keep-alive timeout to match your origin server
## Cache Behaviors
Cache behaviors are matched by path pattern in order of precedence (most specific first). The default (`*`) is always last.
### Key Settings Per Behavior
- **Viewer Protocol Policy**: Redirect HTTP to HTTPS (always use this for web apps)
- **Allowed HTTP Methods**: GET/HEAD for static, GET/HEAD/OPTIONS/PUT/POST/PATCH/DELETE for APIs
- **Cache Policy**: Controls what's included in the cache key (headers, query strings, cookies)
- **Origin Request Policy**: Controls what's forwarded to the origin (separate from cache key)
- **Response Headers Policy**: Add security headers (HSTS, CSP, X-Frame-Options)
### Cache Policies (use managed policies when possible)
| Policy | Use Case |
|---|---|
| CachingOptimized | Static assets (JS, CSS, images). Ignores query strings and headers. |
| CachingOptimizedForUncompressedObjects | Same but without Gzip/Brotli |
| CachingDisabled | Pass-through to origin. Use for APIs and dynamic content. |
**Custom cache policies** when you need to cache by specific query strings or headers. Include only what you must — every key dimension reduces cache hit ratio.
### Origin Request Policies
| Policy | Use Case |
|---|---|
| AllViewer | Forward all viewer headers to origin |
| AllViewerExceptHostHeader | Forward all except Host (most common for ALB origins) |
| CORS-S3Origin | Forward CORS headers for S3 |
## Lambda@Edge vs CloudFront Functions
| Feature | CloudFront Functions | Lambda@Edge |
|---|---|---|
| Runtime | JavaScript only | Node.js, Python |
| Execution time | < 1ms | Up to 5s (viewer) / 30s (origin) |
| Memory | 2 MB | 128-10240 MB |
| Network access | No | Yes |
| Request body access | No | Yes |
| Trigger points | Viewer request, viewer response | All 4 trigger points |
| Price | ~1/6 of Lambda@Edge | Higher |
| Deploy region | All edge locations | Regional edge caches |
**Use CloudFront Functions for:**
- URL rewrites and redirects
- Header manipulation (add/modify/delete)
- Cache key normalization
- Simple A/B testing via cookie
**Use Lambda@Edge for:**
- Authentication and authorization (calling external APIs)
- Dynamic origin selection
- Modifying request/response bodies
- Generating responses at the edge (SSR)
### Trigger Points
1. **Viewer Request**: After CloudFront receives request from viewer
2. **Origin Request**: Before CloudFront forwards to origin (only on cache miss)
3. **Origin Response**: After CloudFront receives response from origin
4. **Viewer Response**: Before CloudFront returns response to viewer
## Signed URLs and Signed Cookies
Use when you need to restrict access to content:
- **Signed URLs**: One URL = one resource. Best for individual file downloads.
- **Signed Cookies**: One cookie = access to multiple resources. Best for HLS/DASH streaming or restricting entire site sections.
Use a **key group** (not the legacy CloudFront key pair which requires root account). Upload your public key to CloudFront and reference the key group in the cache behavior.
Set expiration times as short as practical. For streaming, 1-2 hours. For downloads, minutes.
## WAF Integration
- Attach AWS WAF WebACL directly to the CloudFront distribution
- WAF runs before cache lookup — it protects even cached content
- Use managed rule groups: AWSManagedRulesCommonRuleSet, AWSManagedRulesKnownBadInputsRuleSet, AWSManagedRulesSQLiRuleSet
- Add rate-limiting rules to prevent abuse
- WAF on CloudFront is in us-east-1 (regardless of where your other resources are)
## Common CLI Commands
```bash
# List distributions
aws cloudfront list-distributions --query 'DistributionList.Items[*].{ID:Id,Domain:DomainName,Status:Status,Aliases:Aliases.Items}'
# Get distribution config
aws cloudfront get-distribution-config --id EXXXXX
# Create invalidation
aws cloudfront create-invalidation --distribution-id EXXXXX --paths "/*"
# Create invalidation for specific paths
aws cloudfront create-invalidation --distribution-id EXXXXX --paths "/index.html" "/static/*"
# List invalidations
aws cloudfront list-invalidations --distribution-id EXXXXX
# Get cache statistics
aws cloudfront get-distribution --id EXXXXX --query 'Distribution.{Status:Status,DomainName:DomainName,Origins:DistributionConfig.Origins.Items[*].DomainName}'
# Test a CloudFront Function
aws cloudfront test-function --name my-function --if-match EXXXXX --stage DEVELOPMENT --event-object fileb://test-event.json
# List CloudFront Functions
aws cloudfront list-functions
# Describe a function
aws cloudfront describe-function --name my-function
```
## Output Format
| Field | Details |
|-------|---------|
| **Distribution type** | Web distribution, streaming, or multi-origin |
| **Origins** | Origin domains, types (S3/ALB/API GW/custom), access control (OAC) |
| **Cache behaviors** | Path patterns, cache policies, and origin request policies per behavior |
| **SSL/TLS** | ACM certificate ARN, minimum protocol version, SNI config |
| **WAF** | WebACL ID, managed rule groups, custom rate-limiting rules |
| **Functions (Edge/CF)** | CloudFront Functions or Lambda@Edge, trigger points, purpose |
| **Headers** | Response headers policy (HSTS, CSP, X-Frame-Options) |
| **Logging** | Standard logging (S3 bucket) or real-time logging (Kinesis) |
## Related Skills
- `s3` — S3 origins, bucket policies, and Origin Access Control
- `api-gateway` — API Gateway origins, regional endpoints, and cache behavior config
- `lambda` — Lambda@Edge functions and CloudFront Function alternatives
- `networking` — ALB origins, VPC connectivity, and DNS with Route53
- `security-review` — WAF rules, signed URLs, and public exposure review
## Anti-Patterns
- **Using OAI instead of OAC**: OAI is legacy and doesn't support SSE-KMS. Always use Origin Access Control.
- **Caching dynamic content without a strategy**: Don't cache API responses unless you explicitly control TTLs and cache keys. Use CachingDisabled policy for APIs.
- **Invalidating as a deployment strategy**: Invalidations take time and cost money after 1,000 paths/month. Instead, use versioned file names (e.g., `app.abc123.js`) for cache busting.
- **Forwarding all headers/cookies/query strings**: This destroys cache hit ratio. Forward only what the origin needs. Use separate cache and origin request policies.
- **Not setting security response headers**: Always add HSTS, X-Content-Type-Options, X-Frame-Options via a response headers policy.
- **Edge-optimized API Gateway behind CloudFroRelated in Design
contribute
IncludedLocal-only OSS contribution command center. Auto-refreshes the user's in-flight PR and issue state on invoke so conversations start with full context — no need to brief Claude on what's in flight. Helps the user find issues to contribute to on GitHub, builds per-repo dossiers of what each upstream expects (CLA, DCO, branch convention, AI policy, draft-first, review bots, issue templates), runs deterministic gates before any external action so AI-assisted contributions don't reach maintainers as slop. State is markdown-only: candidate files at ~/.contribute-system/candidates/, repo dossiers at ~/.contribute-system/research/, append-only event log at ~/.contribute-system/log.jsonl. No database, no cloud calls. Use when the user asks about their PRs / issues / contributions, wants to find new work to take on, claim an issue, build/refresh a repo's dossier, or draft a Design Issue or PR. Trigger with "/contribute", "what's my PR status", "find a contribution", "claim issue X", "draft a Design Issue for Y", "refresh dossier for Z".
architectural-analysis
IncludedUser-triggered deep architectural analysis of a codebase or scoped subtree across eight modes — information architecture, data flow, integration points, UI surfaces, interaction patterns, data model, control flow, and failure modes. This skill should be used when the user asks to "diagram this codebase," "map the architecture," "show the data flow," "give me an ERD," "trace control flow," "find the integration points," "verify the layout pattern," "audit the UX architecture," or any similar request whose primary deliverable is mermaid diagrams plus cited reports under docs/architecture/. Dispatches haiku/sonnet sub-agents in parallel for per-mode exploration, then verifies every citation mechanically before any node lands in a diagram. Not for one-off prose explanations of code (use code-explanation) or for high-level system design from scratch (use system-design).
mcp
IncludedModel Context Protocol (MCP) server development and tool management. Languages: Python, TypeScript. Capabilities: build MCP servers, integrate external APIs, discover/execute MCP tools, manage multi-server configs, design agent-centric tools. Actions: create, build, integrate, discover, execute, configure MCP servers/tools. Keywords: MCP, Model Context Protocol, MCP server, MCP tool, stdio transport, SSE transport, tool discovery, resource provider, prompt template, external API integration, Gemini CLI MCP, Claude MCP, agent tools, tool execution, server config. Use when: building MCP servers, integrating external APIs as MCP tools, discovering available MCP tools, executing MCP capabilities, configuring multi-server setups, designing tools for AI agents.
react-native-skia
IncludedDesign, build, debug, and optimise high-polish animated graphics in React Native or Expo using @shopify/react-native-skia, Reanimated, and Gesture Handler. Use when the user wants canvas-driven UI, shaders, paths, rich text, image filters, sprite fields, Skottie, video frames, snapshots, web CanvasKit setup, or performance tuning for custom motion-heavy elements such as loaders, hero art, cards, charts, progress indicators, particle systems, or gesture-driven surfaces. Also use when the user asks for fluid, glow, glass, blob, parallax, 60fps/120fps, or GPU-friendly animated effects in React Native, even if they do not explicitly say "Skia". Do not use for ordinary form/layout work with standard views.
plaid
IncludedProduct Led AI Development — guides founders from idea to launched product. Six capabilities: Idea (discover a product idea), Validate (pressure-test the idea against fatal flaws, problem reality, competition, and 2-week MVP feasibility), Plan (vision intake + document generation), Design (translate image references into a design.md spec), Launch (go-to-market strategy), and Build (roadmap execution). Use when someone says "PLAID", "plaid idea", "help me find an idea", "product idea", "idea from my business", "idea from my expertise", "plaid validate", "validate my idea", "pressure-test", "is this idea good", "find fatal flaws", "validate the problem", "plan a product", "define my vision", "generate a PRD", "product strategy", "plaid design", "design from image", "translate image to design", "create design.md", "extract design tokens", "plaid launch", "go-to-market", "launch plan", "GTM strategy", "launch playbook", "plaid build", "build the app", "start building", or "execute the roadmap".
nextjs-framer-motion-animations
IncludedAdds production-safe Motion for React or Framer Motion animations to Next.js apps, including reveal, hover and tap micro-interactions, whileInView, stagger, AnimatePresence, layout and layoutId transitions, reorder, scroll-linked UI, and lightweight route-content transitions. Use when the user asks to add, refactor, or debug Motion or Framer Motion in App Router or Pages Router codebases, especially around server/client boundaries, reduced motion, LazyMotion, bundle size, hydration, or route transitions. Avoid for GSAP-style timelines, WebGL or 3D scenes, heavy scroll storytelling, or CSS-only effects unless Motion is explicitly requested.