workers-code-review

작성자: cloudflare

Workers 및 Cloudflare Developer Platform 코드를 타입 정확성, API 사용, 설정 유효성 측면에서 검토합니다. TypeScript/JavaScript를 검토할 때 로드합니다…

npx skills add https://github.com/cloudflare/cloudflare-docs --skill workers-code-review

Your knowledge of Cloudflare Workers APIs, types, and wrangler configuration may be outdated. Prefer retrieval over pre-training for any Workers code review task.

Reference Sources

Use the repo's local copies — do not run npm pack or install packages to fetch types.

SourceWhere to find itUse for
Wrangler config schemanode_modules/wrangler/config-schema.jsonConfig fields, binding shapes, allowed values
Workers typesnode_modules/@cloudflare/workers-types/index.d.tsAPI usage, handler signatures, binding types
Cloudflare docs searchUse the cloudflare-docs search tool or read files in this repoAPI reference, compatibility dates/flags, binding docs

Read these files directly when you need to verify a type, config field, or API signature. The guides in this folder describe what to validate — not how to fetch packages.

Review Process

1. Build Context

Read full files, not just diffs or isolated snippets. Code that looks wrong in isolation may be correct given surrounding logic.

  • Identify the purpose of the code: is it a complete Worker, a snippet, a configuration example?
  • Check git history for context: git log --oneline -5 -- <file>
  • Understand which bindings, types, and patterns the code depends on

2. Categorize the Code

Every code block falls into one of three categories. Review in the context of its category.

CategoryDefinitionExpectations
IllustrativeDemonstrates a concept; uses comments for most logicCorrect API names, realistic signatures
DemonstrativeFunctional but incomplete; would work if placed in the right contextSyntactically valid, correct APIs and binding access
ExecutableStandalone and complete; runs without modificationCompiles, runs, includes imports and config

3. Validate with Tools

Run type-checking and linting. Tool output is evidence, not opinion.

npx tsc --noEmit                    # TypeScript errors
npx eslint <files>                  # Lint issues

For config files, validate against the latest wrangler config schema (see wrangler-config.md for retrieval) and check that all fields, binding types, and values conform.

4. Check Against Rules

See workers-types.md for type system rules, wrangler-config.md for config validation, and common-patterns.md for correct API patterns.

Quick-reference rules:

RuleDetail
Binding accessenv.X in module export handlers; this.env.X in classes extending platform base classes. See common-patterns.md.
No anyNever use any for binding types, handler params, or API responses. Use proper generics.
No type-system cheatsFlag as unknown as T, unjustified @ts-ignore, unsafe assertions. See workers-types.md.
Config-code consistencyBinding names in wrangler config must match env.X usage in code. See wrangler-config.md.
Required config fieldsVerify against the wrangler config schema — do not assume which fields are required.
Concise examplesExamples should focus on core logic. Minimize boilerplate that distracts from what the code teaches.
Floating promisesEvery Promise must be awaited, returned, voided, or passed to ctx.waitUntil(). See common-patterns.md.
SerializationData crossing Queue, Workflow step, or DO storage boundaries must be structured-clone serializable. See common-patterns.md.
StreamingLarge/unknown payloads must stream, not buffer. Flag await response.text() on unbounded data.
Error handlingMinimal but present — null checks on nullable returns, basic fetch error handling. Do not distract with verbose try/catch.

5. Assess Risk

RiskTriggers
HIGHAuth, crypto, external calls, value transfer, validation removal, access control, binding misconfiguration
MEDIUMBusiness logic, state changes, new public APIs, error handling, config changes
LOWComments, logging, formatting, minor style

Focus deeper analysis on HIGH risk. For critical paths, check blast radius: how many other files reference this code?

Security logic escalation: for crypto, auth, and timing-sensitive code, do not stop at verifying API calls are correct. Examine the surrounding logic for flaws that undermine the security property (e.g., correct timingSafeEqual call but early return on length mismatch). See common-patterns.md Security section.

Anti-patterns to Flag

Anti-patternWhy it matters
any on Env or handler paramsDefeats type safety for every binding access downstream
as unknown as T double-castHides real type incompatibilities — fix the underlying design
@ts-ignore / @ts-expect-error without explanationMasks errors silently; require a comment justifying each suppression
Buffering unbounded data (await res.text(), await res.json() on streams)Memory exhaustion on large payloads; use streaming
Hardcoded secrets or API keysUse env bindings and wrangler secret
blockConcurrencyWhile on every requestOnly for initialization; blocks all concurrent requests
Single global Durable ObjectCreates a bottleneck; shard by coordination atom
In-memory-only state in DOsLost on eviction; persist to SQLite storage
Missing DO migrations in configNew DO classes require migration entries or deployment fails
Floating promises (step.do(), fetch() without await)Silent bugs — drops results, breaks Workflow durability, ignores errors
Non-serializable values across boundaries (Response, Error in step/queue)Compiles but fails at runtime; extract plain data before crossing boundary
implements instead of extends on platform base classesLegacy pattern — loses this.ctx, this.env access from base class

What NOT to Flag

  • Style not enforced by linters
  • "Could be cleaner" when code is correct and clear
  • Theoretical performance concerns without evidence
  • Missing features not in scope of the example
  • Pre-existing issues in unchanged code

Output Format

**[SEVERITY]** Brief description
`file.ts:42` — explanation with evidence (tool output, type error, config mismatch)
Suggested fix: `code` (if applicable)

Severity: CRITICAL (security, data loss, crash) | HIGH (type error, wrong API, broken config) | MEDIUM (missing validation, edge case, outdated pattern) | LOW (style, minor improvement)

End with a summary count by severity. If no issues found, say so directly.

Principles

  • Be certain. Investigate before flagging. If you cannot confirm an API, binding pattern, or config field, retrieve the docs or schema first.
  • Provide evidence. Reference line numbers, tool output, schema fields, or type definitions.
  • Correctness over completeness. A concise example that works is better than a comprehensive one with errors.
  • Respect existing patterns. Do not flag conventions already established in the codebase unless actively harmful.
  • Focus on what developers will copy. Code in documentation gets pasted into production. Treat it accordingly.

cloudflare의 다른 스킬

dependabot-review
cloudflare
Dependabot PR을 분석하여 각 업데이트된 패키지에서 실제로 변경된 사항과 해당 변경 사항이 이 저장소에 영향을 미치는지 확인합니다. 변경된 API/메서드 등을 보고합니다.
module-registry
cloudflare
workerd에서 모듈 레지스트리를 작업할 때 로드 — 모듈 해석, 컴파일, 평가, 등록을 읽기, 수정, 디버깅, 검토하는 경우…
reproduce
cloudflare
cloudflare/agents GitHub 이슈를 재현하기 위해 최소한의 Agents/Worker 프로젝트를 스캐폴딩하고 임시 Cloudflare 계정에 배포한 후 보고합니다…
local-explorer
cloudflare
로컬 탐색기 또는 로컬 API에 제품/리소스를 추가하는 방법. 새로운 로컬 API나 UI 라우트를 구현할 때 사용합니다.
open-pr
cloudflare
클라우드플레어/에이전트 GitHub 이슈와 재현 결과를 바탕으로 수정 PR을 한 번에 생성합니다 — 브랜치 생성, 변경, 테스트, 푸시, 그리고 이슈에 연결된 PR 열기까지 수행합니다.
write-endpoints
cloudflare
chanfana를 사용한 OpenAPI 엔드포인트 구축을 위한 종합 가이드 - 스키마 정의, 요청 검증, CRUD 작업, D1 데이터베이스 통합 등
agents-sdk
cloudflare
Cloudflare Workers에서 Agents SDK를 사용하여 AI 에이전트를 구축하세요. 상태 저장 에이전트, 지속 가능한 워크플로우, 실시간 WebSocket 앱, 예약된 작업 등을 생성할 때 로드하세요.
changelog
cloudflare
Cloudflare 문서 사이트의 제품 변경 로그 항목을 생성, 업데이트 및 검토합니다. 변경 로그 MDX 파일을 생성하거나 기존 파일을 편집할 때 로드합니다.