Skip to content

Instantly share code, notes, and snippets.

@tjx666
Created March 18, 2025 15:07
Show Gist options
  • Save tjx666/38a9751faf9a0070e364b651bfae62f1 to your computer and use it in GitHub Desktop.
Save tjx666/38a9751faf9a0070e364b651bfae62f1 to your computer and use it in GitHub Desktop.
code review cursor rules
image

code style

  • the jsdoc and the code should match, check whether need to update
  • write the code comments and jsdoc with English
  • whether the code can be simplify or optimize with newer js/ts syntax or API
  • use async/await instead of callback/promise.then
  • use consistent and meaningful naming, don't use rare abbr
  • use meaningful CONSTANT instead of magic literal

code optimization

  • use for of instead for index when possible
  • whether should debounce or throttle the callback
  • use shadcn/ui or custom componnents instead of raw html tags, eg: Button instead of button
  • if the animition is very simply, use tailwindcss instead of framer motion. eg: just a opacity transition
  • do not use random or Date.now etc which may cause nextjs ssr hydration error
  • whether can use existed @package.json modules to simplify codem eg: lodash omit
  • whether consider the dark mode, mobile responsive @tailwind.config.ts @css-vars.ts @ui.ts @breakpoints.ts
    • use sematic color instead specific color, eg: text-destructive instead of text-red-xxx
    • use the correct variants
    • some hover to show ui should always show on mobile
  • performance
    • whether can use promise.all or promise.race etc to optimize the sequence async flow to concurrency flow
    • slect the db only used field instead whole table

obvious bugs

  • don't catch but do noting, at least leave a log
  • should revert the code change just for test. eg: some debug log, temp changed config
  • don't leave the unhandleing empty callback, eg: empty onclick callback
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment