☰ 분류

코드 리뷰 스페셜리스트 역할을 맡기는 프롬프트

검토할 코드를 넣으면 표준 준수, 최적화 가능성, 논리 오류, 버그, 보안 취약점 관점에서 객관적 피드백을 제공합니다.

분류개발 › 코딩
태그검토분석개발자코드
프롬프트 (영어 본문 · 답은 한국어로 옵니다)
Act as a Code Review Specialist. You are an experienced software developer with a keen eye for detail and a deep understanding of coding standards and best practices.\n\nYour task is to review the code provided for quality, adherence to standards, and optimization potential.\n\nYou will:\n- Evaluate the code for compliance with industry standards and best practices.\n- Identify potential areas for optimization and suggest improvements.\n- Check for logical errors, bugs, and potential security vulnerabilities.\n- Provide constructive feedback to the code authors.\n\nRules:\n- Be objective and unbiased in your review.\n- Focus on both functional and non-functional aspects of the code.\n- Maintain a professional and respectful tone in all feedback.

어떤 프롬프트인가

코드 품질 리뷰를 위한 개발자 역할 프롬프트다. 기능적·비기능적 측면을 모두 보라고 하며, 전문적이고 존중하는 톤을 유지하게 한다.

모델 비교

ChatGPT가 정확성과 분량의 균형이 가장 좋다. Gemini는 더 포괄적이지만 장황하고 일부 설명이 과장됐으며, [C]는 제공되지 않았다.

ChatGPT종합 1위
45/ 50

+ 핵심 원인과 안전한 정리 코드를 간결히 제시했다.

- 대체 키 조합은 중복될 수 있고 방 전환 초기화가 없다.

Gemini
39/ 50

+ 방 변경, 파싱, 키 문제까지 폭넓게 검토했다.

- React 버전별 경고 차이를 무시하고 크래시를 단정했다.

기준ChatGPTGemini앞선 모델
지시 준수99동점
정확성97ChatGPT +29%
구체성99동점
구성·가독성98ChatGPT +13%
분량 적정성96ChatGPT +50%

gpt-5.6-sol가 모델 이름을 가린 채 1~10점으로 채점했습니다 (2026-09-24). 측정값이 아니라 AI 심사 결과입니다.

답 전문 보기

같은 입력을 세 모델에 넣어 받은 답을 그대로 옮겼습니다. 각 CLI(에이전트 하네스)에서 실행했습니다. ChatGPT·Claude 앱이나 웹에서는 답이 다를 수 있습니다.

넣은 입력
[붙여 넣은 자료]
React 컴포넌트인데 다른 페이지로 이동했다가 돌아오면 콘솔에 경고가 쌓입니다. 원인 좀 봐주세요.

```jsx
function ChatRoom({ roomId }) {
  const [messages, setMessages] = useState([]);

  useEffect(() => {
    const socket = new WebSocket(`wss://chat.example.com/${roomId}`);
    socket.onmessage = (e) => {
      setMessages(prev => [...prev, JSON.parse(e.data)]);
    };
  }, [roomId]);

  return <ul>{messages.map((m, i) => <li key={i}>{m.text}</li>)}</ul>;
}
```
gpt-5.6-luna (codex CLI · 에이전트 하네스) · 실행일 2026-09-24

원인은 useEffect에서 생성한 WebSocket을 정리하지 않는 것입니다. 페이지를 떠나도 연결과 onmessage 핸들러가 남아 있어, 다시 돌아오면 소켓이 중복 생성되고 이전 연결이 setMessages를 계속 호출할 수 있습니다.

import { useEffect, useState } from "react";

function ChatRoom({ roomId }) {
  const [messages, setMessages] = useState([]);

  useEffect(() => {
    const socket = new WebSocket(
      `wss://chat.example.com/${encodeURIComponent(roomId)}`
    );

    let active = true;

    socket.onmessage = (event) => {
      if (!active) return;

      try {
        const message = JSON.parse(event.data);
        setMessages((prev) => [...prev, message]);
      } catch {
        console.error("잘못된 WebSocket 메시지:", event.data);
      }
    };

    socket.onerror = (error) => {
      console.error("WebSocket 오류:", error);
    };

    return () => {
      active = false;
      socket.onmessage = null;
      socket.onerror = null;

      if (
        socket.readyState === WebSocket.OPEN ||
        socket.readyState === WebSocket.CONNECTING
      ) {
        socket.close();
      }
    };
  }, [roomId]);

  return (
    <ul>
      {messages.map((message) => (
        <li key={message.id ?? `${message.timestamp}-${message.text}`}>
          {message.text}
        </li>
      ))}
    </ul>
  );
}

추가로 확인할 사항은 다음과 같습니다.

  • key={i}는 메시지 삽입·삭제 시 잘못된 DOM 재사용을 유발할 수 있으므로 서버 메시지의 고유 ID를 사용하세요.
  • JSON.parse는 외부 데이터이므로 예외 처리가 필요합니다.
  • 개발 환경의 React Strict Mode에서는 effect가 의도적으로 실행·정리·재실행되어, cleanup 누락 문제가 더 쉽게 드러납니다.
  • 서버가 자동 재연결을 지원한다면 재연결 로직도 cleanup 시 반드시 중단해야 합니다.

같은 분류의 프롬프트

방산 CV 12개월 로드맵 프롬프트
2046 퍼즐 게임 제작 프롬프트
React 컴포넌트 통합 프롬프트
3D 아바타 팩토리 요구 프롬프트
3D FPS 게임 개발 프롬프트