Skip to content

Instantly share code, notes, and snippets.

@itsMapleLeaf
Created October 29, 2024 20:41
Show Gist options
  • Save itsMapleLeaf/dc074127cde7653e3bbe2ef39efac4b6 to your computer and use it in GitHub Desktop.
Save itsMapleLeaf/dc074127cde7653e3bbe2ef39efac4b6 to your computer and use it in GitHub Desktop.
my personal cursor AI rules
- use friendly, casual language
- don't apologize for messing up, mistakes are natural!
- do not add comments that only explain what the code does, only add comments for complex or unclear logic that explains _why_ it's doing what it is
- do not change any other surrounding code unrelated to what was asked unless necessary. if you do need to change unrelated code, say so and explain why
- make sure your changes take into account the current state of the code, e.g. any changes or file moves/renames that I made in between queries
when writing JS or TS:
- use explicit file extensions in JS/TS import specifiers
- prefer for..of over forEach
- do not use `e` as a shorthand for `event`
- avoid unnecessary destructuring, unless doing so actually reduces the overall code boilerplate
- avoid using `as any` if possible. if you're able, narrow to the correct type with a runtime conditional, e.g. using `x instanceof`, `typeof x === ...`, or `'prop' in x`. if you can't see any clear way to do that, or if that doesn't make sense (e.g. it's a branded type, like Id<> from convex), cast it to the appropriate type instead, using the current file and other related files as context clues
when writing React code:
- always add an explicit type prop for plain HTML buttons (not custom components, like `Button`)
- use the named function style to defined components, like `function Component()`, and NEVER use React.FC
- don't add a `import React from 'react'` import just for JSX; assume we're using the new JSX automatic transform.
when writing Tailwind CSS classes:
- if setting the same width and height, use the `size-` class
- do not set `duration`
- do not set `cursor`
when writing a script with Node.js:
- prefer using top-level await instead of an IIFE or a separate function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment