rust-code-review

Liste de vérification et cadre de décision pour la revue de code Rust des PRs, dérivés de rust-best-practices.

npx skills add https://github.com/apollographql/rust-best-practices --skill rust-code-review

Rust Code Review

Use this for Rust review work where consistency, safety, and maintainability matter.

Follow ths standards in https://github.com/apollographql/rust-best-practices

Mandatory pre-merge checks

  • Ownership and data flow are intentional.
  • Error handling is explicit and aligns with crate/binary boundaries.
  • Clippy and format quality are clean in touched files.
  • Performance changes are measured before acceptance.
  • Public APIs are documented; docs match runtime behavior.
  • Tests cover intended behavior and error paths.
  • Unsafe or raw-pointer usage is justified and constrained.

Severity matrix

  • P0: unsafe memory bug, panic in recoverable production path, silent data corruption.
  • P1: correctness bug, missing error propagation, invalid API contract.
  • P2: likely performance regression, missing public API docs, flaky tests.
  • P3: style/readability issues, avoidable clone/allocation, unnecessary complexity.

Review skills

Ownership-first coding

  • Prefer borrowing (&T, &mut T) over cloning.
  • Use Clone only when ownership is required or snapshots are explicitly needed.
  • Treat unnecessary clones (especially in loops) as likely regressions.
  • Reject clone on Copy types.

Value vs reference

  • Pass Copy/small POD types by value.
  • Pass large heap-backed or non-trivial objects by reference.
  • Surface ownership intent in function signatures.
  • Use Cow<'_, T> when input may be borrowed or owned.

Fallible control flow

  • Use let PATTERN = EXPR else { ... } for expected early exits.
  • Use if let ... else when divergence needs additional logic.
  • Prefer ? for bubbling errors.
  • Avoid unwrap/expect in production except when impossible-by-design cases are documented.

Allocation and allocation timing

  • Prefer _else APIs to avoid eager allocation (ok_or_else, map_or_else, etc.).
  • Keep iterator chains lazy; allocate only when required by terminal ops.
  • Do not collect and allocate only to throw away data.

Iterator vs loop

  • Use iterator chains for data transformation and composition.
  • Use for for early exits and side-effect-heavy or control-heavy loops.
  • Require readable formatting; avoid long unreadable chains.

Lints and static checks

  • Run and fix warnings from:
    • cargo clippy --all-targets --all-feature --locked -- -D warnings
  • Do not globally silence useful lints.
  • Prefer #[expect(clippy::...)] with rationale instead of #[allow(...)] unless fully justified.

Error discipline

  • Libraries: prefer typed errors (thiserror and #[from] conversions).
  • Binaries: anyhow acceptable, but keep context rich and actionable.
  • Test both success and error behavior.

Tests as behavior docs

  • One behavior per test.
  • One core assertion per test where possible.
  • Names should be descriptive sentence-like statements.
  • Prefer unit tests for internals, integration tests for public behavior.
  • Use snapshot tests only for complex, stable structured outputs.

Documentation and comments

  • Use //////! for API behavior and constraints.
  • Use // for why, safety rationale, platform constraints, and assumptions.
  • Remove stale comments; prefer smaller functions over narrative comments.
  • Link TODOs to issues instead of leaving bare TODO:.

Pointers and concurrency

  • Prefer &/&mut before any heap pointer.
  • Use Arc for cross-thread shared ownership; Rc for single-threaded.
  • Use Box for recursive/heap allocation needs.
  • Review raw pointer usage as unsafe boundaries with explicit invariants.

Quick rejection triggers

  • Unnecessary clones in hot paths.
  • Unjustified allow(clippy::...).
  • Silent recovery from Err that discards root cause.
  • Copying large types by value without a proof of intent.
  • Comments that simply restate what code already expresses.
  • TODOs without ownership/context.

Plus de skills de apollographql

apollo-client
apollographql
Apollo Client est une bibliothèque complète de gestion d'état pour JavaScript qui vous permet de gérer à la fois les données locales et distantes avec GraphQL. La version 4.x apporte une mise en cache améliorée, un meilleur support de TypeScript et une compatibilité avec React 19.
official
apollo-client
apollographql
Guide complet pour créer des applications React avec Apollo Client 4.x, couvrant les requêtes, mutations, mise en cache et gestion d'état. Prend en charge plusieurs frameworks et configurations React : applications côté client (Vite, CRA), Next.js App Router avec React Server Components, React Router 7 avec SSR en streaming, et TanStack Start. Inclut des hooks pour les requêtes (useQuery, useLazyQuery), mutations (useMutation) et motifs basés sur Suspense (useSuspenseQuery, useBackgroundQuery) pour React 18+ et 19...
official
apollo-connectors
apollographql
Intégrer des API REST dans des supergraphes GraphQL à l'aide des directives @source et @connect. Propose un processus structuré en 5 étapes : recherche de la structure de l'API, implémentation du schéma avec directives, validation via rover supergraph compose, exécution des connecteurs et test de couverture. Prend en charge la configuration des requêtes incluant les en-têtes, les corps de charge utile, le regroupement pour les motifs N+1 et l'injection de variables d'environnement via $env. Gère le mappage des réponses avec la sélection de champs, l'aliasing, les sous-sélections pour les données imbriquées et les entités...
official
apollo-federation
apollographql
Apollo Federation permet de composer plusieurs API GraphQL (sous-graphes) en un super
official
apollo-ios
apollographql
Apollo iOS est un client GraphQL fortement typé pour les plateformes Apple. Il génère des types Swift à partir de vos opérations et schémas GraphQL, et fournit un client async/await, un cache normalisé (en mémoire ou basé sur SQLite), un transport HTTP basé sur des intercepteurs pluggables qui gère les requêtes, mutations et abonnements multipart, ainsi qu'un transport WebSocket optionnel (graphql-transport-ws) pouvant prendre en charge tout type d'opération.
official
apollo-kotlin
apollographql
Apollo Kotlin est un client GraphQL fortement typé qui génère des modèles Kotlin à partir de vos opérations et schémas GraphQL, pouvant être utilisé dans des projets Android, JVM et Kotlin Multiplatform.
official
apollo-mcp-server
apollographql
We need to translate the given text from English to French. The text describes an agent skill that connects AI agents to GraphQL APIs via MCP. It mentions specific terms: "Model Context Protocol", "GraphQL", "MCP", "GraphOS Studio", etc. These should be preserved as is. Also "apollo-mcp-server" is the name to preserve but it's not in the text, so we ignore. The text includes technical terms like "introspection", "operation tools", "minification mode", "token usage", "authentication", "static headers". We need to translate the rest naturally. The text: "Connect AI agents to GraphQL APIs through the Model Context Protocol with built-in introspection and operation tools. Exposes GraphQL operations as MCP tools; supports three operation sources: local files, GraphOS Studio collections, and persisted query manifests Provides four introspection tools (introspect, search, validate, execute) for schema exploration and ad-hoc query testing; minification mode reduces token usage with compact notation Configurable authentication via static headers,..." We'll translate
official
apollo-router
apollographql
Apollo Router est un routeur de graphes haute performance écrit en Rust pour exécuter les supergraphes Apollo Federation 2. Il se place devant vos sous-graphes et gère la planification des requêtes, l'exécution et la composition des réponses.
official