Skip to content

Commit 220c610

Browse files
committed
Some tweaks to the rules and how they are installed
1 parent f6c5aa2 commit 220c610

File tree

6 files changed

+28
-22
lines changed

6 files changed

+28
-22
lines changed

packages/cli-v3/src/commands/install-rules.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -497,24 +497,25 @@ async function resolveRulesFileContentsForTarget(
497497
return $output(
498498
frontmatter({
499499
description: option.label,
500-
globs: "**/trigger/**/*.ts",
501-
alwaysApply: true,
500+
globs: option.applyTo ?? "**/trigger/**/*.ts",
501+
alwaysApply: false,
502502
}),
503503
option.contents
504504
);
505505
}
506506
case "vscode": {
507507
return $output(
508508
frontmatter({
509-
applyTo: "**/trigger/**/*.ts",
509+
applyTo: option.applyTo ?? "**/trigger/**/*.ts",
510510
}),
511511
option.contents
512512
);
513513
}
514514
case "windsurf": {
515515
return $output(
516516
frontmatter({
517-
trigger: "manual",
517+
trigger: "glob",
518+
globs: option.applyTo ?? "**/trigger/**/*.ts",
518519
}),
519520
option.contents
520521
);

packages/cli-v3/src/rules/manifest.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const RulesManifestDataSchema = z.object({
1919
tokens: z.number(),
2020
client: z.string().optional(),
2121
installStrategy: z.string().optional(),
22+
applyTo: z.string().optional(),
2223
})
2324
),
2425
})
@@ -35,6 +36,7 @@ export type RulesManifestVersionOption = {
3536
tokens: number;
3637
client: string | undefined;
3738
installStrategy: RulesFileInstallStrategy;
39+
applyTo: string | undefined;
3840
};
3941

4042
export type ManifestVersion = {

rules/4.0.0/basic-tasks.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ export const childTask = task({
129129
});
130130
```
131131

132+
> Never wrap triggerAndWait or batchTriggerAndWait calls in a Promise.all or Promise.allSettled as this is not supported in Trigger.dev tasks.
133+
132134
## Waits
133135

134136
```ts
@@ -160,6 +162,8 @@ export const taskWithWaits = task({
160162
});
161163
```
162164

165+
> Never wrap wait calls in a Promise.all or Promise.allSettled as this is not supported in Trigger.dev tasks.
166+
163167
## Key Points
164168

165169
- **Result vs Output**: `triggerAndWait()` returns a `Result` object with `ok`, `output`, `error` properties - NOT the direct task output

rules/4.0.0/claude-code-agent.md

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ color: green
77

88
You are an elite Trigger.dev framework expert with deep knowledge of building production-grade background job systems. You specialize in designing reliable, scalable workflows using Trigger.dev's async-first architecture. Tasks deployed to Trigger.dev generally run in Node.js 21+ and use the `@trigger.dev/sdk` package, along with the `@trigger.dev/build` package for build extensions and the `trigger.dev` CLI package to run the `dev` server and `deploy` command.
99

10+
> Never use `node-fetch` in your code, use the `fetch` function that's built into Node.js.
11+
1012
## Design Principles
1113

1214
When creating Trigger.dev solutions, you will:
@@ -17,6 +19,9 @@ When creating Trigger.dev solutions, you will:
1719
- When triggering a task from inside another task, consider whether to use the `triggerAndWait`/`batchTriggerAndWait` pattern or just the `trigger`/`batchTrigger` function. Use the "andWait" variants when the parent task needs the results of the child task.
1820
- When triggering a task, especially from inside another task, always consider whether to pass the `idempotencyKey` property to the `options` argument. This is especially important when inside another task and that task can be retried and you don't want to redo the work in children tasks (whether waiting for the results or not).
1921
- Use the `logger` system in Trigger.dev to log useful messages at key execution points.
22+
- Group subtasks that are only used from a single other task into the same file as the parent task, and don't export them.
23+
24+
> Important: Never wrap triggerAndWait or batchTriggerAndWait calls in a Promise.all or Promise.allSettled as this is not supported in Trigger.dev tasks.
2025
2126
## Triggering tasks
2227

@@ -183,12 +188,7 @@ When setting up Trigger.dev projects, you will configure the `trigger.config.ts`
183188
```ts
184189
import { defineConfig } from "@trigger.dev/sdk";
185190
import { playwright } from "@trigger.dev/build/extensions/playwright";
186-
import {
187-
ffmpeg,
188-
aptGet,
189-
additionalPackages,
190-
additionalFiles,
191-
} from "@trigger.dev/build/extensions/core";
191+
import { ffmpeg, aptGet, additionalFiles } from "@trigger.dev/build/extensions/core";
192192
import { prismaExtension } from "@trigger.dev/build/extensions/prisma";
193193
import { pythonExtension } from "@trigger.dev/python/extension";
194194
import { lightpanda } from "@trigger.dev/build/extensions/lightpanda";
@@ -197,7 +197,7 @@ import { sentryEsbuildPlugin } from "@sentry/esbuild-plugin";
197197

198198
export default defineConfig({
199199
project: "<project ref>",
200-
// Your other config settings...
200+
machine: "small-1x", // optional, default is small-1x
201201
build: {
202202
extensions: [
203203
playwright(),
@@ -209,9 +209,6 @@ export default defineConfig({
209209
}),
210210
pythonExtension(),
211211
lightpanda(),
212-
additionalPackages({
213-
packages: ["wrangler"],
214-
}),
215212
esbuildPlugin(
216213
sentryEsbuildPlugin({
217214
org: process.env.SENTRY_ORG,
@@ -234,8 +231,8 @@ export default defineConfig({
234231
You will produce code that:
235232

236233
- Uses modern TypeScript with strict type checking
234+
- When catching errors, remember that the type of the error is `unknown` and you need to check `error instanceof Error` to see if it's a real error instance
237235
- Follows Trigger.dev's recommended project structure
238-
- Implements comprehensive error handling and recovery
239-
- Includes inline documentation for complex logic
236+
- Don't go overboard with error handling
237+
- Write some inline documentation for complex logic
240238
- Uses descriptive task IDs following the pattern: 'domain.action.target'
241-
- Maintains separation between task logic and business logic

rules/4.0.0/config.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ export default defineConfig({
2727

2828
// Build configuration
2929
build: {
30-
external: ["header-generator"], // Exclude from bundling
3130
autoDetectExternal: true,
3231
keepNames: true,
3332
minify: false,
@@ -177,12 +176,14 @@ extensions: [
177176

178177
#### Additional NPM Packages
179178

179+
Only use this for installing CLI tools, NOT packages you import in your code.
180+
180181
```ts
181182
import { additionalPackages } from "@trigger.dev/build/extensions/core";
182183

183184
extensions: [
184185
additionalPackages({
185-
packages: ["wrangler", "[email protected]"], // CLI tools and specific versions
186+
packages: ["wrangler"], // CLI tools and specific versions
186187
}),
187188
];
188189
```
@@ -337,7 +338,7 @@ extensions: [
337338
## Best Practices
338339

339340
- **Use specific versions**: Pin extension versions for reproducible builds
340-
- **External packages**: Add native modules to `external` array
341+
- **External packages**: Add modules with native addons to the `build.external` array
341342
- **Environment sync**: Use `syncEnvVars` for dynamic secrets
342343
- **File paths**: Use glob patterns for flexible file inclusion
343344
- **Debug builds**: Use `--log-level debug --dry-run` for troubleshooting

rules/manifest.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@
2222
{
2323
"name": "config",
2424
"title": "Configuring Trigger.dev",
25-
"label": "How to configure Trigger.dev",
25+
"label": "Configure your Trigger.dev project with a trigger.config.ts file",
2626
"path": "4.0.0/config.md",
27-
"tokens": 1900
27+
"tokens": 1900,
28+
"applyTo": "**/trigger.config.ts"
2829
},
2930
{
3031
"name": "scheduled-tasks",

0 commit comments

Comments
 (0)