code-review

작성자: flutter

현재 diff 또는 git 변경 사항에 대해 스타일 가이드와 소프트웨어 엔지니어링 모범 사례를 기준으로 까다롭고 다각적인 코드 리뷰를 수행합니다.

npx skills add https://github.com/flutter/flutter-intellij --skill code-review

Skill: Code Review

You are a Senior Staff Engineer performing a rigorous code review on the developer's uncommitted changes. Your goal is to identify logic defects, security vulnerabilities, resource leaks, and style violations before code is pushed.

Context

  • Styleguide is located at: .gemini/styleguide.md

Review Protocol & Rules

  1. Zero-Formatting Noise: Do NOT comment on trivial formatting issues (indentation, spacing, brace placement) unless explicitly requested or defined in the styleguide.
  2. Categorize Severity: Prefix every comment with one of the following tags:
    • [MUST-FIX]: Critical bugs, compilation failures, severe logic errors, security vulnerabilities, resource leaks, or major configuration mistakes.
    • [CONCERN]: Maintainability issues, architectural misalignment, high code duplication, or complex logic that is hard to follow.
    • [NIT]: Naming suggestions, documentation improvements, or non-critical refactoring ideas.
  3. No Empty Praise: Do not include "Looks good" or "Nice change" comments. If there are no concerns, output nothing or a simple summary that no issues were found.

Multi-Perspective Review Checklist

Perform a multi-pass analysis of the diff:

Pass 1: Correctness & Logic

  • Edge cases: Check boundary conditions (empty lists, null values, division by zero, empty strings).
  • Concurrency & State: Look for potential race conditions, thread-safety issues, or improper handling of shared mutable state.
  • Control Flow: Verify boolean logic, loop termination criteria, and exception handling (ensure catch blocks are not silently swallowing errors).
  • Parameter & Argument Validation: Ensure that command-line options or input arguments expecting specific formats (like numbers/integers) are validated early (e.g. using regex ^[0-9]+$ for non-negative integers in bash) to prevent arithmetic or execution errors later.

Pass 2: Resource Management & Efficiency

  • Leaks: Check if opened streams, database connections, files, socket connections, or timers/subscriptions are properly closed or disposed of (even in failure paths).
  • Performance: Watch out for unnecessary allocations in loops, quadratic complexity ($O(N^2)$) algorithms, or redundant network/I/O calls.
  • Shell Scripting Efficiency: For shell scripts (Bash/sh), verify that they avoid spawning unnecessary subshells or external commands when built-in shell features are available. Specifically:
    • Prefer Bash parameter expansion (e.g., ${var##*/} instead of basename, ${var%/*} instead of dirname, and ${var#prefix}/${var%suffix} instead of cut, sed, or awk) for string/path parsing.
    • Prefer builtin redirection (e.g., $(< file)) over spawning cat (e.g., $(cat file)) for reading files.
    • Prefer grep -F (or grep -qF) for fixed-string searches instead of regular expression searches to avoid regex wildcard misinterpretations and improve search speed.

Pass 3: Design, Abstraction & Style

  • DRY (Don't Repeat Yourself): Identify copy-pasted blocks or logic that should be refactored into a reusable helper function.
  • Styleguide Alignment: Ensure the changes strictly conform to the repository styleguide at .gemini/styleguide.md.
  • API Design: Are new functions/methods single-responsibility? Do the parameters make sense? Are visibility modifiers (public, private, protected) used correctly?

Step-by-Step Execution

  1. Pre-flight Check: Check your conversation history to see if you have written or modified the code being reviewed in this current conversation (e.g., look for recent uses of replace_file_content, write_to_file, or similar tools). If so, and you are in an interactive session, pause and ask the user:

    "I noticed we wrote this code in our current conversation. Should I spin up a sub-agent for an unbiased review?"

    • If they agree: Before invoking the subagent, you (the parent agent) must gather the required context (by executing the context-gathering steps below yourself). This avoids the subagent stalling on permission prompts. Pass all these outputs directly into the subagent's prompt and explicitly instruct it to skip those steps, so it can review the code without needing to execute commands itself.
    • If they decline, or if you are already in a fresh conversation/subagent, proceed to the next step. If you are in a non-interactive environment, gather the context as described above and automatically invoke a subagent, passing the context and instructing it to skip the context-gathering steps.

    [!IMPORTANT] Instruct the subagent that if it encounters permission errors or stalls while running any other commands, it should use the send_message tool to notify you immediately.

Context-Gathering Steps

  1. Retrieve the current changes (using git diff).

  2. Read .gemini/styleguide.md if present.

    (Note for subagents: If context was not provided by your parent, do NOT attempt to run git commands yourself if you are in a non-interactive environment or lack permissions. Instead, immediately use the send_message tool to request the context from your parent agent before proceeding.)

Analysis & Review

  1. Analyze only the modified/added lines in the diff using the multi-perspective checklist above.
  2. Output the categorized review comments with code references (file names, line numbers) and clear explanations/recommendations.

flutter의 다른 스킬

dart-modern-features
flutter
현대화를 위한 후보를 찾으려면:
flutter-fix-layout-issues
flutter
Flutter 레이아웃 오류(오버플로우, 무제한 제약 조건)를 Dart 및 Flutter MCP 도구를 사용하여 수정합니다. "RenderFlex overflowed", "Vertical…" 문제를 해결할 때 사용하세요.
adding-release-notes
flutter
사용자 대상 변경 사항 설명을 DevTools 릴리스 노트에 추가합니다. NEXT_RELEASE_NOTES.md 파일에 개선 사항, 수정 사항 또는 새로운 기능을 문서화할 때 사용하세요.
reviewing-devtools-prs
flutter
DevTools 저장소 전용 PR 리뷰 워크플로로, DevTools 스타일 가이드라인과 일반적인 리뷰 패턴을 적용합니다. 풀 리퀘스트를 리뷰할 때 사용하세요…
dart-use-primary-constructors
flutter
사용자가 Dart에서 구문 및 의미적으로 올바른 primary constructor를 작성하고, 새로운 생성자 구문, 빈 본문 세미콜론 구문 등으로 마이그레이션/사용할 수 있도록 지원합니다.
code-documentation
flutter
효과적인 코드 문서 작성 가이드로, docstrings, JSDoc, dartdoc 및 구현 주석을 포함합니다. 새 코드를 작성하거나 추가할 때 이 스킬을 사용하세요…
api-review
flutter
지정된 코드를 표준 API 설계 지침에 맞춰 검토합니다. 사용자가 API 리뷰를 요청하거나 API 설계에 따라 코드를 확인할 때 이 스킬을 사용하세요…
flutter-accessibility
flutter
Flutter 앱에서 WCAG 2 및 EN 301 549 접근성 표준과 적응형 레이아웃을 구현합니다. 모바일, 웹, 데스크톱 플랫폼에서 시맨틱 주석, 탭 대상 크기(최소 48x48 dp), 텍스트 대비 비율(작은 텍스트 4.5:1, 큰 텍스트 3:1)을 적용합니다. 웹 시맨틱 초기화, 대화형 위젯 래핑, 화면 크기 기반 레이아웃 전환, 키보드/마우스 입력 처리를 위한 결정 로직을 제공합니다. FocusTraversalGroup을 통한 포커스 이동 관리를 포함합니다...