|
| 1 | +--- |
| 2 | +title: "Using Cursor with Trigger.dev" |
| 3 | +sidebarTitle: "Cursor rules" |
| 4 | +description: "This guide shows how to add Cursor rules to a project to help you write Trigger.dev tasks faster and more accurately." |
| 5 | +icon: "hexagon" |
| 6 | +--- |
| 7 | + |
| 8 | +## Overview |
| 9 | + |
| 10 | +[Cursor](https://www.cursor.com/) is a powerful AI coding editor which understands your codebase and can help you write code faster and more accurately. This guide shows you how to add our Cursor rules to your project to help you write Trigger.dev tasks. |
| 11 | + |
| 12 | +## Prerequisites |
| 13 | + |
| 14 | +- [Cursor](https://www.cursor.com/) installed on your machine |
| 15 | + |
| 16 | +## Installing our Cursor rules |
| 17 | + |
| 18 | +1. Locate the `.cursor/rules` folder in your project root, or click the "add new rule" button in `Cursor Settings` > `Rules`. |
| 19 | +2. Download the [writing-tasks.mdc](https://github.com/triggerdotdev/trigger.dev/blob/main/.cursor/rules/writing-tasks.mdc) file and place it in the `.cursor/rules` folder |
| 20 | +3. For more help installing Cursor rules, see [Cursor's docs](https://docs.cursor.com/context/rules-for-ai) |
| 21 | + |
| 22 | +<video |
| 23 | + src="https://content.trigger.dev/cursor-rules-write-task.mp4" |
| 24 | + preload="auto" |
| 25 | + controls={true} |
| 26 | + loop |
| 27 | + muted |
| 28 | + autoPlay={true} |
| 29 | + width="100%" |
| 30 | + height="100%" |
| 31 | +/> |
| 32 | + |
| 33 | +| <span style={{ color: '#28BF5C' }}>Helps with</span> | <span style={{ color: '#E11D48' }}>Don't use it for</span> | |
| 34 | +| ---------------------------------------------------- | ---------------------------------------------------------- | |
| 35 | +| Creating basic tasks | Deploying | |
| 36 | +| Creating scheduled tasks | Project setup | |
| 37 | +| Creating schema tasks | Infrastructure configuration | |
| 38 | +| Triggering tasks from backend | API keys | |
| 39 | +| Task lifecycle functions | Using tags | |
| 40 | +| Using Realtime | | |
| 41 | +| Idempotency patterns | | |
| 42 | +| Metadata handling | | |
| 43 | +| Using build extensions | | |
| 44 | + |
| 45 | +## Tips for making the most of Cursor |
| 46 | + |
| 47 | +1. **Turn on auto-run** in Cursor settings. This allows Cursor to act more like an agent that checks for errors, fixes them, runs commands to install packages, and it won't stop until the code is error-free and running. _NB: Use this mode with caution, as it can make changes without your approval._ |
| 48 | + |
| 49 | +2. **Use version control like GitHub or GitLab**, and commit frequently, so you can roll-back if something changes unexpectedly. Cursor can make changes to multiple files at once, so it's best to commit often to keep track of all your changes. |
| 50 | + |
| 51 | +3. **Explicitly add context when needed** - Cursor should know when to use the rules file, but I recommend selecting it from the "@ Add context" button above the prompt window. Then select "Cursor Rules" and select your rules file. |
0 commit comments