{"slug":"code-review-5","title":"code-review","summary":"Use when asked to review a PR, MR, branch, or diff, audit changed files, or check code quality.","platform":"Claude","tags":[],"authorName":"LLM Mart","authorSlug":"llm-mart","score":0,"source":"github","price":null,"verified":false,"createdAt":"2026-08-30T09:57:15.849533Z","repo":{"url":"https://github.com/evanca/flutter-ai-rules","stars":644,"forks":67,"license":"MIT","updatedAt":"2026-09-14T07:51:38Z"},"bodyHtml":"<hr>\n<h2>name: code-review\ndescription: \"Use when asked to review a PR, MR, branch, or diff, audit changed files, or check code quality.\"\nhooks:\nPreToolUse:\n- matcher: \"Bash\"\nhooks:\n- type: command\ncommand: \"./scripts/protect-token.sh\"\nlicense: MIT</h2>\n<h1>Code Review Skill</h1>\n<p>Perform structured, objective code reviews for Flutter/Dart projects following a repeatable checklist.</p>\n<h2>When to Use</h2>\n<p>Use this skill when:</p>\n<ul>\n<li>Asked to review a pull request, merge request, or branch.</li>\n<li>Evaluating changed, added, or deleted files for correctness and quality.</li>\n<li>Auditing a diff before merging.</li>\n<li>Checking whether new code meets project standards.</li>\n</ul>\n<hr>\n<h2>Review Workflow</h2>\n<h3>Step 1 — Validate branch and merge target</h3>\n<ol>\n<li>Confirm the current branch is a <strong>feature, bugfix, or PR/MR branch</strong> — not the project's primary branch (e.g. <code>main</code>, <code>master</code>, <code>develop</code>).</li>\n<li>Verify the branch is <strong>up-to-date</strong> with the target branch (no unresolved conflicts).</li>\n<li>Identify the <strong>target branch</strong> for the merge.</li>\n</ol>\n<p><strong>Checkpoint:</strong> If the branch is behind the target, flag it before proceeding.</p>\n<h3>Step 2 — Discover changes</h3>\n<ol>\n<li>List all <strong>changed, added, and deleted files</strong>.</li>\n<li>For each change, look up the <strong>commit title</strong> and review how connected components are implemented.</li>\n<li><strong>Analyze the change</strong>: is it clear <em>why</em> the change was made? If not, dig into the connected methods and files until it is. When you report, name <strong>which connected files/methods you analyzed and why</strong> — this shows the change was understood, not assumed.</li>\n<li><strong>Never assume</strong> a change is correct without investigating the implementation.</li>\n<li>If a change remains unclear after investigation, <strong>note this explicitly</strong> in the report.</li>\n</ol>\n<h3>Step 3 — Review each file</h3>\n<p>Iterate through each changed file. For every file, verify the following:</p>\n<table>\n<thead>\n<tr>\n<th>Area</th>\n<th>What to verify</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><strong>Understand the change</strong></td>\n<td>Why was it made? Review connected methods/files; note which ones you analyzed and why</td>\n</tr>\n<tr>\n<td><strong>Location</strong></td>\n<td>File is in the correct directory</td>\n</tr>\n<tr>\n<td><strong>Naming</strong></td>\n<td>File name follows project naming conventions</td>\n</tr>\n<tr>\n<td><strong>Responsibility</strong></td>\n<td>The file's responsibility is clear; reason for change is understandable</td>\n</tr>\n<tr>\n<td><strong>Readability</strong></td>\n<td>Variable, function, and class names are descriptive and consistent</td>\n</tr>\n<tr>\n<td><strong>Logic &amp; correctness</strong></td>\n<td>No logic errors or missing edge cases</td>\n</tr>\n<tr>\n<td><strong>Code smells</strong></td>\n<td>Scan for the smells in <a href=\"#code-smells-reference\">Code Smells Reference</a> below</td>\n</tr>\n<tr>\n<td><strong>Maintainability</strong></td>\n<td>Code is modular; no unnecessary duplication</td>\n</tr>\n<tr>\n<td><strong>Error handling</strong></td>\n<td>Errors and exceptions are handled appropriately</td>\n</tr>\n<tr>\n<td><strong>Security</strong></td>\n<td>No input validation gaps; no secrets committed to code</td>\n</tr>\n<tr>\n<td><strong>Performance</strong></td>\n<td>No obvious inefficiencies (e.g., unnecessary rebuilds, O(n^2) loops on large lists)</td>\n</tr>\n<tr>\n<td><strong>SOLID principles</strong></td>\n<td>Adherence assessed without forcing unnecessary boilerplate or over-abstraction</td>\n</tr>\n<tr>\n<td><strong>Flutter/Dart/</strong></td>\n<td>Match against the project's loaded guidelines and conventions</td>\n</tr>\n<tr>\n<td><strong>Documentation</strong></td>\n<td>Public APIs, complex logic, and new modules are documented</td>\n</tr>\n<tr>\n<td><strong>Test coverage</strong></td>\n<td>New or changed logic has sufficient tests (see Step 4)</td>\n</tr>\n<tr>\n<td><strong>Style</strong></td>\n<td>Code matches the project's style guide and linting rules</td>\n</tr>\n<tr>\n<td><strong>Existing code</strong></td>\n<td>If the new changes look fine, also review surrounding <strong>existing (unchanged) code</strong> for smells and suggest refactors where relevant</td>\n</tr>\n</tbody>\n</table>\n<p>For <strong>generated files</strong> (e.g., <code>*.g.dart</code>, <code>*.freezed.dart</code>): confirm they are up-to-date and not manually modified.</p>\n<blockquote>\n<p><strong>Scope discipline:</strong> Your job is <strong>not</strong> to comment on every change — it's to find errors and concrete improvement areas and comment on those. Don't manufacture comments where the code is fine.</p>\n</blockquote>\n<h4>Flutter-specific checks</h4>\n<p><em>(Note: The following is just an example using Bloc/Cubit; apply similar principles to Riverpod, Provider, or your chosen state management package.)</em></p>\n<pre><code>// BAD — rebuilds entire tree on every state change\nBlocBuilder&lt;MyCubit, MyState&gt;(\n  builder: (context, state) =&gt; EntireScreen(state: state),\n);\n\n// GOOD — scope rebuilds to the widget that actually changes\nBlocSelector&lt;MyCubit, MyState, String&gt;(\n  selector: (state) =&gt; state.title,\n  builder: (context, title) =&gt; Text(title),\n);\n</code></pre>\n<ul>\n<li>Verify <code>Key</code> usage on dynamically generated widgets.</li>\n<li>Check that <code>dispose()</code> is called for controllers, streams, and animation controllers.</li>\n<li>Confirm <code>const</code> constructors are used where possible.</li>\n</ul>\n<h4>Code Smells Reference</h4>\n<p>For each file, check for common code smells. Use <a href=\"https://refactoring.guru/refactoring/smells\">refactoring.guru/refactoring/smells</a> for definitions and suggested refactorings.</p>\n<table>\n<thead>\n<tr>\n<th>Category</th>\n<th>Smells</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><strong>Bloaters</strong></td>\n<td>Long Method, Large Class, Primitive Obsession, Long Parameter List, Data Clumps</td>\n</tr>\n<tr>\n<td><strong>Object-Orientation Abusers</strong></td>\n<td>Alternative Classes with Different Interfaces, Refused Bequest, Temporary Field, Switch Statements</td>\n</tr>\n<tr>\n<td><strong>Change Preventers</strong></td>\n<td>Divergent Change, Parallel Inheritance Hierarchies, Shotgun Surgery</td>\n</tr>\n<tr>\n<td><strong>Dispensables</strong></td>\n<td>Comments (redundant), Duplicate Code, Data Class, Dead Code, Lazy Class, Speculative Generality</td>\n</tr>\n<tr>\n<td><strong>Couplers</strong></td>\n<td>Feature Envy, Inappropriate Intimacy, Incomplete Library Class, Message Chains, Middle Man</td>\n</tr>\n</tbody>\n</table>\n<h3>Step 4 — Evaluate the overall change set</h3>\n<ol>\n<li>Verify the change set is <strong>focused and scoped</strong> to its stated purpose — no unrelated changes.</li>\n<li>Check that the <strong>PR/MR description</strong> accurately reflects the changes.</li>\n</ol>\n<h4>Test coverage</h4>\n<p>Verify test coverage <strong>explicitly</strong> — this is easy to skip and easy to fake, so be deliberate:</p>\n<ul>\n<li>For any new logic or significant change, <strong>search for the corresponding test file(s)</strong> and confirm tests actually exist.</li>\n<li>Check that tests cover the changed functionality <strong>including edge cases</strong>, not just the happy path.</li>\n<li>Evaluate whether tests could <strong>actually fail</strong> against real code, or only verify mocked behavior (a test that asserts a mock returns what the mock was told to return proves nothing).</li>\n<li>If tests are <strong>missing or insufficient</strong>, comment on the lack of coverage — don't let it pass silently.</li>\n</ul>\n<h3>Step 5 — Verify CI and tests</h3>\n<ol>\n<li>Ensure <strong>all tests pass</strong> in CI.</li>\n<li>Check for new analyzer warnings or lint violations.</li>\n<li>Fetch <strong>official documentation</strong> when unsure about best practices for a package.</li>\n</ol>\n<p><strong>Checkpoint:</strong> If CI is red or tests are missing for new logic, flag as a blocking issue.</p>\n<hr>\n<h2>Wrap-Up</h2>\n<p>After the per-file pass, decide the outcome:</p>\n<ul>\n<li><strong>If everything looks good and no changes are needed:</strong> post an <strong>overall conclusion comment</strong> summarizing what the MR is about (what was done) plus any observations, and approve the MR.</li>\n<li><strong>If the new changes are clean but you spotted smells in existing code:</strong> include those as optional refactor suggestions rather than blockers.</li>\n<li><strong>If issues were found:</strong> summarize the <strong>key concerns</strong> clearly so the author knows what to address first.</li>\n</ul>\n<hr>\n<h2>Feedback Standards</h2>\n<ul>\n<li>Be <strong>objective and reasonable</strong> — avoid automatic praise or flattery.</li>\n<li>Take a <strong>devil's advocate approach</strong>: give honest, thoughtful feedback.</li>\n<li>Provide <strong>clear, constructive suggestions</strong> for every issue found.</li>\n<li>Include <strong>requests for clarification</strong> for anything unclear.</li>\n<li>Classify each finding by severity: <code>suggestion</code>, <code>minor</code>, or <code>major</code>.</li>\n</ul>\n<hr>\n<h2>Output Format</h2>\n<p><strong>By default, provide the review as a chat response</strong> — a structured response covering each file:</p>\n<ol>\n<li><strong>Summary</strong> — what changed and why.</li>\n<li><strong>Issues</strong> — each with severity (<code>suggestion</code> / <code>minor</code> / <code>major</code>) and a concrete fix suggestion.</li>\n<li><strong>Questions</strong> — specific clarification requests per file.</li>\n<li><strong>Verdict</strong> — one of: <code>Approved</code>, <code>Approved with suggestions</code>, or <code>Changes requested</code>.</li>\n</ol>\n<blockquote>\n<p><strong>Posting comments online (opt-in only).</strong> After presenting the chat review, <strong>ask the user whether they'd prefer you to also post these comments online</strong> on the PR/MR — so the team can see them, review them, and reply. <strong>Only post online if the user explicitly says yes.</strong> Never post to the platform on your own initiative.</p>\n<p>When the user does opt in, post issues as <strong>inline comments</strong> anchored to the right file and line (use proper position fields), with the conclusion/key-concerns as a top-level review comment and an approval when warranted. This requires a <strong>review-bot access token</strong> for the platform (GitHub/GitLab); if one isn't configured, let the user know and ask them to set it up before posting.</p>\n<p><strong>Token safety.</strong> The token is a secret. You may check whether it <strong>exists</strong> and report its <strong>length</strong> to confirm it's configured, but <strong>never read, echo, log, print, or otherwise reveal the token value</strong> — not in chat, not in a file, not in a commit. Pass it to <code>curl</code> only by referencing the env var (e.g. <code>$GITLAB_TOKEN</code>), never by inlining the literal value, and avoid <code>curl -v</code>/<code>--verbose</code> (it prints the auth header). This is enforced by a <code>PreToolUse</code> hook (<code>scripts/protect-token.sh</code>) that blocks any Bash command which would expose the value. See the \"Handling the token safely\" section in each reference file for the safe existence/length check.</p>\n<p>The hook fires in both the Claude Code CLI and the Agent SDK. (SDK apps that set <code>settingSources</code>/<code>setting_sources</code> explicitly must include <code>\"project\"</code> for skill hooks to load; it's included by default.)</p>\n<p>For platform-specific API details, curl formats, and approval steps, follow:</p>\n<ul>\n<li>GitLab → <a href=\"references/gitlab-posting.md\">references/gitlab-posting.md</a> (uses the <code>GITLAB_TOKEN</code> env var)</li>\n<li>GitHub → <a href=\"references/github-posting.md\">references/github-posting.md</a> (uses the <code>GITHUB_TOKEN</code> env var)</li>\n</ul>\n</blockquote>\n","files":[{"path":"references/github-posting.md","sizeBytes":5489,"isText":true},{"path":"references/gitlab-posting.md","sizeBytes":4327,"isText":true},{"path":"scripts/protect-token.sh","sizeBytes":2721,"isText":true},{"path":"SKILL.md","sizeBytes":9608,"isText":true}],"reviewScore":null,"reviewSummary":null,"trust":{"provenance":"trusted-source-unreviewed","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow.","bodySource":null},"bodyLocked":false,"purchaseUrl":null,"sourceUrl":null,"report":{"provenance":"trusted-source-unreviewed","screen":{"ran":true,"outcome":"clean","suspicious":0,"notes":0,"hiddenCharacters":false},"virusScan":{"engine":"clamav","status":"clean","scannedAt":"2026-08-30T09:58:04.683073Z","sha256":"0B97C1C71DB965CF6CB07BB8110A1143C71CC5F5E739118BAF7140E7652A18FE","sizeBytes":10334},"review":null,"source":{"repositoryUrl":"https://github.com/evanca/flutter-ai-rules","path":"skills/code-review","license":"MIT","commit":"7b9cce235714ae17acbae896b1e8c8627e128f4c","subtreeSha":"21A045EDBAB12225E28831544407B8B4F23A7D1399D5575DEAA26907E761809B","lastSyncedAt":"2026-09-29T23:32:26.661053Z"},"reviewedAt":"2026-08-30T10:13:23.350978Z","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow."},"install":[{"target":"skills-cli","command":"npx skills add https://github.com/evanca/flutter-ai-rules/tree/main/skills/code-review"},{"target":"claude-code","command":"claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install evanca-flutter-ai-rules@llmmart"},{"target":"git","command":"git clone https://github.com/evanca/flutter-ai-rules.git"}]}