Skip to content

Instantly share code, notes, and snippets.

@towry
Last active May 27, 2025 07:25
Show Gist options
  • Save towry/46b1c4ef018f9d416301d1d58b77b023 to your computer and use it in GitHub Desktop.
Save towry/46b1c4ef018f9d416301d1d58b77b023 to your computer and use it in GitHub Desktop.
Towry's cursor rules
  • Do not add sensitive information about the user or the user's machine to the code or comments
  • Break down large tasks into smaller steps. After completing each step, verify it works before continuing. Do not attempt to complete the entire task in one pass without intermediate validation.
  • Prefer rg or fd command when grepping file content or searching for files
  • Before running a package manager in the project, please detect which package manager is currently being used, like npm or pnpm
  • You can run killport to kill the process that owns a port
  • Follow the DRY coding rule
  • Never use a variable or method that you are not sure exists
  • Do not change the implementation to satisfy the tests
  • Avoid deduplicating mock logic in tests; reimplement when needed to preserve clarity
  • Consider the impact of changes across the module or file
  • Avoid duplicating logic across abstraction boundaries
  • Consolidate similar logic into reusable functions
  • Maintain a single source of truth for business rules
  • Make function contracts clear
  • First ,makethe code correct, then make it efficient
  • When refactoring, validate behavior preservation
  • Favor explicit control flow over hidden dependencies
  • Preserve existing code structures and adhere to project coding styles, unless the existing code is flawed.
  • Whether responding in code comments, documentation, or UI prompts, always aim to be concise and focused. Eliminate unnecessary details that don't aid understanding or action
  • Never remove or modify code in a way that could break existing functionality without fully understanding how those changes will affect the code.
  • Please feel free to ask for help if you need more details to decide.
  • When searching for relevant modules, first look for relevant files by their file names. Then, use grep to search for specific content. Utilize the fd command to list files in a case-insensitive manner.
  • When searching for relevant modules or components in a directory, make sure your search is case insensitive to achieve broader results.
  • In Agent mode, automatically apply edits without prompting for confirmation on the first pass
  • Always check your implementation and changes against the available documentation or existing code to ensure accuracy and adherence to standards.
  • Review the existing style and conventions used in the surrounding code to ensure that the new code aligns well and maintains readability.
  • Do not rely on a single example; always verify consistent patterns to ensure accuracy and reliability.
  • Avoid making assumptions about how components function without analyzing their actual usage.
  • Avoid reproducing only part of a pattern; ensure all critical fields and behaviors are included to maintain integrity and accuracy.
  • When changing existing code, do not remove code that you do not understand what it does
  • Ensure error handling is consistent and graceful; prefer explicit error propagation over silent failure
  • When adding significant logic or refactoring, update or write accompanying documentation if necessary
  • Add or update tests to reflect critical logic paths affected by your changes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment