Communitygithub.com

YepAPI/skills

업로드 처리, 이미지 리사이즈/압축, CDN 전송, 블러 플레이스홀더 및 next/image 패턴을 제공합니다.

skills란 무엇인가요?

이 스킬은 Next.js 애플리케이션에서 이미지 최적화를 위한 완벽한 워크플로우를 제공합니다. 업로드 시 서버 측에서 sharp를 사용하여 리사이즈 및 압축을 수행하고, WebP/AVIF 같은 현대적인 포맷으로 변환합니다. next/image를 자동으로 활용하여 lazy loading, 반응형 srcset, 블러 플레이스홀더를 지원하며, 원격 이미지의 경우 next.config.js의 remotePatterns로 CDN 도메인을 허용 목록에 추가합니다. 주요 기능으로는 presigned URL을 통한 안전한 업로드, 객체 스토리지(S3/R2) 저장, CDN(CloudFront/Cloudflare) 전송, 클라이언트 및 서버 측 파일 크기 검증을 포함합니다. Claude Code, Cursor, Cline, Copilot 등 다양한 AI 에이전트 플랫폼과 호환되며, Next.js 13+에서 Image 컴포넌트를 사용하는 모든 프로젝트에 적용 가능합니다.

지원 대상~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/YepAPI/skills/tree/HEAD/skills/image-optimization

즐겨 사용하는 AI에게 물어보기

이 에이전트 스킬이 미리 로드된 새 채팅을 엽니다.

문서

이미지 최적화

규칙

  • Next.js의 모든 이미지에 next/image 사용 — 자동 최적화, 지연 로딩, 반응형 srcset
  • 항상 width와 height를 설정하거나 크기가 지정된 컨테이너와 함께 fill 사용 — 레이아웃 이동(CLS) 방지
  • 블러 플레이스홀더: 빌드/업로드 시 plaiceholder로 blurDataURL을 생성하거나 정적 가져오기에 placeholder="blur" 사용
  • 원격 이미지: next.config.js에서 remotePatterns 설정 — CDN 도메인 허용 목록 등록
  • 업로드 흐름: 클라이언트 → 사전 서명된 URL (S3/R2/Supabase Storage) → 직접 업로드 → 데이터베이스에 URL 저장
  • 업로드 시 리사이즈: 서버 측에서 sharp를 사용하여 여러 크기(썸네일, 중간, 원본) 생성 — 원본을 제공하지 않음
  • 포맷: next/image 자동 포맷으로 WebP/AVIF 제공 — 호환성을 위해 JPEG 폴백
  • CDN 전송: 객체 스토리지(S3, R2)에 원본 저장, 캐시 헤더와 함께 CDN(CloudFront, Cloudflare)을 통해 제공
  • 최대 파일 크기 검증: 클라이언트(업로드 전) 및 서버(처리 전)에서 확인 — 일반적으로 5-10MB 제한

패턴

// 블러 플레이스홀더가 있는 next/image
import Image from "next/image";

<Image
  src="/hero.jpg"
  alt="히어로 이미지"
  width={1200}
  height={630}
  placeholder="blur"
  blurDataURL="data:image/jpeg;base64,/9j/4AAQ..."
  priority // 접힌 부분 위
/>

// 동적 컨테이너를 위한 채우기 모드
<div className="relative aspect-video">
  <Image src={url} alt={alt} fill className="object-cover" sizes="(max-width: 768px) 100vw, 50vw" />
</div>
// sharp를 사용한 서버 측 리사이즈
import sharp from "sharp";

async function processUpload(buffer: Buffer) {
  const thumbnail = await sharp(buffer).resize(200, 200, { fit: "cover" }).webp({ quality: 80 }).toBuffer();
  const medium = await sharp(buffer).resize(800).webp({ quality: 85 }).toBuffer();
  const full = await sharp(buffer).resize(1920).webp({ quality: 90 }).toBuffer();
  return { thumbnail, medium, full };
}

피해야 할 것

  • Next.js에서 <img> 태그 사용 — 자동 최적화, 지연 로딩, 포맷 변환 상실
  • 반응형 이미지에 sizes 속성 누락 — 브라우저가 올바른 srcset 크기를 선택할 수 없음
  • 리사이즈되지 않은 원본 제공 — 400px로 표시되는 5MB 사진은 낭비
  • 파일 형식 검증 생략 — 파일 확장자뿐만 아니라 서버 측에서 MIME 타입 확인

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

YepAPI/skills

WCAG 2.1 AA — semantic HTML, keyboard navigation, screen readers.

YepAPI/skills

Experiment setup, variant splitting, statistical significance, and feature flag integration.

YepAPI/skills

CRUD generators, data tables, user management, role-based access, and bulk operations.

YepAPI/skills

Monitor what ChatGPT and Gemini say about your brand using YepAPI.

YepAPI/skills

Queue workers with BullMQ/Inngest/Trigger.dev, job retries, dead letter queues, concurrency.

YepAPI/skills

Commander.js, interactive prompts with Clack, spinners, colors, config files, exit codes, and npm publishing.

YepAPI/skills

cmdk integration, Cmd+K trigger, fuzzy search, grouped actions, keyboard navigation, and dynamic action registration.

YepAPI/skills

Content planning with trend and sentiment data from YepAPI.

YepAPI/skills

Content calendar, keyword-driven planning, and content briefs.

YepAPI/skills

Theme switching with CSS variables, system preference detection, next-themes, and persistence.

YepAPI/skills

Threaded comments, @mentions, reactions, moderation queue, optimistic UI, and cursor pagination.

YepAPI/skills

Competitive analysis between domains using YepAPI.

YepAPI/skills

Layout grids, KPI cards, data tables with sorting/filtering, sidebar navigation, and responsive breakpoints.

YepAPI/skills

Data encryption — TLS everywhere, AES-256-GCM for PII, bcrypt passwords, encrypted backups.

YepAPI/skills

Chart patterns with Recharts/Nivo/D3, responsive containers, color scales, and accessibility.

YepAPI/skills

Drizzle schema definition, push vs migrate, type-safe queries, relations, transactions, and prepared statements.

YepAPI/skills

Local business and Google Maps research using YepAPI.

YepAPI/skills

Cursor-based pagination, IntersectionObserver, virtualized lists with @tanstack/react-virtual, and scroll position restoration.

YepAPI/skills

Tenant isolation (row-level vs schema), subdomain routing, per-tenant config, and data partitioning.

YepAPI/skills

Chat UI components, streaming responses with AI SDK, context window management, and RAG patterns.

관련 스킬