|
| 1 | +--- |
| 2 | +title: "Agent rules" |
| 3 | +sidebarTitle: "Agent rules" |
| 4 | +description: "Learn how to use the Trigger.dev agent rules with the MCP server" |
| 5 | +tag: "new" |
| 6 | +--- |
| 7 | + |
| 8 | +## What are Trigger.dev agent rules? |
| 9 | + |
| 10 | +Trigger.dev agent rules are comprehensive instruction sets that guide AI assistants to write optimal Trigger.dev code. These rules ensure your AI assistant understands best practices, current APIs, and recommended patterns when working with Trigger.dev projects. |
| 11 | + |
| 12 | +## Installation |
| 13 | + |
| 14 | +Install the agent rules with the following command: |
| 15 | + |
| 16 | +```bash |
| 17 | +npx trigger.dev@latest install-rules |
| 18 | +``` |
| 19 | + |
| 20 | +## Available rule sets |
| 21 | + |
| 22 | +We provide five specialized rule sets, each optimized for different aspects of Trigger.dev development: |
| 23 | + |
| 24 | +| Rule set | Tokens | Description | GitHub | |
| 25 | +|:---------|:-------|:------------|:------------| |
| 26 | +| **Basic tasks** | 1,200 | Essential rules for writing basic Trigger.dev tasks and fundamental patterns | [View](https://github.com/triggerdotdev/trigger.dev/blob/main/rules/4.0.0/basic-tasks.md) | |
| 27 | +| **Advanced tasks** | 3,000 | Comprehensive rules for complex workflows, error handling, and advanced task patterns | [View](https://github.com/triggerdotdev/trigger.dev/blob/main/rules/4.0.0/advanced-tasks.md) | |
| 28 | +| **Scheduled tasks** | 780 | Specialized guidance for cron jobs, scheduled workflows, and time-based triggers | [View](https://github.com/triggerdotdev/trigger.dev/blob/main/rules/4.0.0/scheduled-tasks.md) | |
| 29 | +| **Configuration** | 1,900 | Complete guide for trigger.config.ts setup, environment configuration, and project structure | [View](https://github.com/triggerdotdev/trigger.dev/blob/main/rules/4.0.0/config.md) | |
| 30 | +| **Realtime** | 1,700 | Using Trigger.dev Realtime features and frontend integration patterns | [View](https://github.com/triggerdotdev/trigger.dev/blob/main/rules/4.0.0/realtime.md) | |
| 31 | + |
| 32 | +## Claude Code subagent |
| 33 | + |
| 34 | +For Claude Code users, we provide a subagent called `trigger-dev-expert` that's an expert at writing well-structured Trigger.dev code. |
| 35 | + |
| 36 | +### Installation |
| 37 | + |
| 38 | +The subagent is available as an option when running the rules installation command. Select "Claude Code" as your client and choose to include the subagent when prompted. |
| 39 | + |
| 40 | +### Usage |
| 41 | + |
| 42 | +Activate the subagent in your prompts by requesting it explicitly: |
| 43 | + |
| 44 | +```markdown |
| 45 | +use the trigger-dev-expert subagent to create a trigger.dev job that accepts a video url, processes it with ffmpeg to extract the audio, runs the audio through a text-to-speech API like openai, and then uploads both the transcription and the audio to s3 |
| 46 | +``` |
| 47 | + |
| 48 | +The subagent works best when combined with the appropriate rule sets installed alongside it, providing both high-level architectural guidance and detailed implementation knowledge. |
| 49 | + |
| 50 | +## Supported AI clients |
| 51 | + |
| 52 | +The Trigger.dev rules work across a wide range of AI coding assistants and editors: |
| 53 | + |
| 54 | +| Client | Rule activation | Docs | |
| 55 | +|:--------|:----------------|:--------------| |
| 56 | +| **Cursor** | Automatic when working in trigger directories | [Link](https://docs.cursor.com/en/context/rules#rules/) | |
| 57 | +| **Claude Code** | Context-aware activation + custom subagent | [Link](https://docs.anthropic.com/en/docs/claude-code) | |
| 58 | +| **VSCode Copilot** | Integration with GitHub Copilot chat | [Link](https://code.visualstudio.com/docs/copilot/overview) | |
| 59 | +| **Windsurf** | Automatic activation in Trigger.dev projects | [Link](https://docs.windsurf.com/windsurf/cascade/memories#rules) | |
| 60 | +| **Gemini CLI** | Command-line integration | [Link](https://ai.google.dev/gemini-api/docs) | |
| 61 | +| **Cline** | Automatic context detection | [Link](https://github.com/cline/cline) | |
| 62 | +| **Sourcegraph AMP** | Code intelligence integration | [Link](https://sourcegraph.com/docs) | |
| 63 | +| **Kilo** | Custom rule integration | [Link](https://kilocode.ai/docs/advanced-usage/custom-rules) | |
| 64 | +| **Ruler** | Rule management | [Link](https://github.com/intellectronica/ruler) | |
| 65 | +| **AGENTS.md** | Universal format for OpenAI Codex, Jules, OpenCode, etc. | | |
| 66 | + |
| 67 | +### Rule activation behavior |
| 68 | + |
| 69 | +Different AI tools handle rules differently: |
| 70 | + |
| 71 | +- **Automatic Activation**: Cursor, Windsurf, VSCode Copilot, and Cline automatically apply relevant rules when working in Trigger.dev projects or when `trigger.config.ts` is detected |
| 72 | +- **Context-Aware**: Claude Code intelligently applies rules based on the current context and file types |
| 73 | +- **Manual Integration**: AGENTS.md clients and others append rules to configuration files for manual activation |
| 74 | + |
| 75 | +## Keeping rules updated |
| 76 | + |
| 77 | +Trigger.dev rules are regularly updated to reflect new features, API changes, and best practices. The CLI includes automatic update detection. |
| 78 | + |
| 79 | +### Automatic update notifications |
| 80 | + |
| 81 | +When running `npx trigger.dev@latest dev`, you'll receive notifications when newer rule versions are available with a simple update command. |
| 82 | + |
| 83 | +### Manual updates |
| 84 | + |
| 85 | +Update rules anytime with: |
| 86 | + |
| 87 | +```bash |
| 88 | +npx trigger.dev@latest install-rules |
| 89 | +``` |
| 90 | + |
| 91 | +The update process replaces existing rules without creating duplicates, keeping your configuration files clean and organized. |
| 92 | + |
| 93 | +### Why updates matter |
| 94 | + |
| 95 | +- **Current API patterns**: Access the latest Trigger.dev APIs and features |
| 96 | +- **Performance optimizations**: Benefit from improved patterns and practices |
| 97 | +- **Deprecated pattern avoidance**: Prevent AI assistants from generating outdated code |
| 98 | +- **New feature support**: Immediate access to newly released capabilities |
| 99 | + |
| 100 | +## Getting started |
| 101 | + |
| 102 | +1. Install the rules: |
| 103 | + |
| 104 | +```bash |
| 105 | +npx trigger.dev@latest install-rules |
| 106 | +``` |
| 107 | + |
| 108 | +2. Follow the prompts to install the rules for your AI client. |
| 109 | + |
| 110 | +3. Consider installing the `trigger-dev-expert` subagent if using Claude Code. |
| 111 | + |
| 112 | +## Next steps |
| 113 | + |
| 114 | +- [Install the MCP server](/mcp-introduction) for complete Trigger.dev integration |
| 115 | +- [Explore MCP tools](/mcp-tools) for project management and task execution |
| 116 | + |
0 commit comments