fix(cli): stop chat.agent skills silently disappearing from trigger dev#3690
Conversation
Minimal reference covering skills.define + skill.local — one task that loads a SKILL.md and runs a bundled shell script. Useful as a sanity test for the dev + deploy skill-bundling pipeline.
The dev CLI ran a separate skill-discovery indexer pass with a bare process.env, while the actual worker indexer ran with the full execution env. Task files that read process.env at module top level imported cleanly in the worker pass and threw in the skill pass — the latter swallowed the error and skipped skill copying, so skill.local() failed at runtime with ENOENT. Drop the duplicate pass. The skill registry is already part of the worker manifest, so copy skill folders from there after initialize. A bad SKILL.md now surfaces as a startup error instead of silently disappearing skills.
🦋 Changeset detectedLatest commit: 13f51bb The changes in this PR will be included in the next version bump. This PR includes changesets to release 32 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
WalkthroughThis PR refactors skill folder bundling to execute at the correct lifecycle phase. It extracts a reusable Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/cli-v3/src/build/bundleSkills.ts (1)
71-80: ⚡ Quick winScope frontmatter validation to the frontmatter block.
The
\bname:and\bdescription:checks run against the entireSKILL.md, not the frontmatter block matched on Line 71. A SKILL.md body (which is prose intended for the LLM) can easily contain text likethe tool's name: …ordescription: …, which would let a file with a missing frontmatter field pass validation. Consider extracting the frontmatter block once and validating against that captured substring.♻️ Suggested approach
- if (!/^---\r?\n[\s\S]*?\r?\n---/.test(skillMd)) { + const frontmatterMatch = skillMd.match(/^---\r?\n([\s\S]*?)\r?\n---/); + if (!frontmatterMatch) { throw new Error( `Skill "${skill.id}": SKILL.md at ${skillMdPath} is missing a frontmatter block.` ); } - if (!/\bname:\s*\S/.test(skillMd) || !/\bdescription:\s*\S/.test(skillMd)) { + const frontmatter = frontmatterMatch[1] ?? ""; + if (!/^\s*name:\s*\S/m.test(frontmatter) || !/^\s*description:\s*\S/m.test(frontmatter)) { throw new Error( `Skill "${skill.id}": SKILL.md at ${skillMdPath} frontmatter must include both \`name\` and \`description\`.` ); }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/cli-v3/src/build/bundleSkills.ts` around lines 71 - 80, The frontmatter field checks are currently testing the whole SKILL.md (skillMd) so body text can falsely satisfy /\bname:/ and /\bdescription:/; change bundleSkills.ts to first extract the frontmatter block (use the existing frontmatter regex from the first if — e.g. run skillMd.match(/^---\r?\n([\s\S]*?)\r?\n---/)) and then validate that captured group for both name and description instead of testing skillMd; throw the same Error messages (using skill.id and skillMdPath) if either /\bname:\s*\S/ or /\bdescription:\s*\S/ fails on the extracted frontmatter string.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/cli-v3/src/build/bundleSkills.ts`:
- Around line 71-80: The frontmatter field checks are currently testing the
whole SKILL.md (skillMd) so body text can falsely satisfy /\bname:/ and
/\bdescription:/; change bundleSkills.ts to first extract the frontmatter block
(use the existing frontmatter regex from the first if — e.g. run
skillMd.match(/^---\r?\n([\s\S]*?)\r?\n---/)) and then validate that captured
group for both name and description instead of testing skillMd; throw the same
Error messages (using skill.id and skillMdPath) if either /\bname:\s*\S/ or
/\bdescription:\s*\S/ fails on the extracted frontmatter string.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: bb34c025-90f9-449d-810d-1b92f2f10bb9
⛔ Files ignored due to path filters (7)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yamlreferences/agent-skills/package.jsonis excluded by!references/**references/agent-skills/src/trigger/skills/greeter/SKILL.mdis excluded by!references/**references/agent-skills/src/trigger/skills/greeter/scripts/hello.shis excluded by!references/**references/agent-skills/src/trigger/test-skill.tsis excluded by!references/**references/agent-skills/trigger.config.tsis excluded by!references/**references/agent-skills/tsconfig.jsonis excluded by!references/**
📒 Files selected for processing (4)
.changeset/bundle-skills-single-pass.mdpackages/cli-v3/src/build/bundleSkills.tspackages/cli-v3/src/dev/devSession.tspackages/cli-v3/src/dev/devSupervisor.ts
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (27)
- GitHub Check: sdk-compat / Node.js 20.20 (ubuntu-latest)
- GitHub Check: webapp / 🧪 Unit Tests: Webapp (8, 8)
- GitHub Check: webapp / 🧪 Unit Tests: Webapp (2, 8)
- GitHub Check: webapp / 🧪 Unit Tests: Webapp (3, 8)
- GitHub Check: internal / 🧪 Unit Tests: Internal (2, 8)
- GitHub Check: internal / 🧪 Unit Tests: Internal (1, 8)
- GitHub Check: internal / 🧪 Unit Tests: Internal (8, 8)
- GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - npm)
- GitHub Check: internal / 🧪 Unit Tests: Internal (6, 8)
- GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - pnpm)
- GitHub Check: sdk-compat / Cloudflare Workers
- GitHub Check: internal / 🧪 Unit Tests: Internal (4, 8)
- GitHub Check: webapp / 🧪 Unit Tests: Webapp (1, 8)
- GitHub Check: typecheck / typecheck
- GitHub Check: e2e-webapp / 🧪 E2E Tests: Webapp
- GitHub Check: internal / 🧪 Unit Tests: Internal (7, 8)
- GitHub Check: webapp / 🧪 Unit Tests: Webapp (4, 8)
- GitHub Check: webapp / 🧪 Unit Tests: Webapp (5, 8)
- GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - pnpm)
- GitHub Check: internal / 🧪 Unit Tests: Internal (5, 8)
- GitHub Check: internal / 🧪 Unit Tests: Internal (3, 8)
- GitHub Check: sdk-compat / Node.js 22.12 (ubuntu-latest)
- GitHub Check: webapp / 🧪 Unit Tests: Webapp (7, 8)
- GitHub Check: webapp / 🧪 Unit Tests: Webapp (6, 8)
- GitHub Check: sdk-compat / Deno Runtime
- GitHub Check: packages / 🧪 Unit Tests: Packages (1, 1)
- GitHub Check: sdk-compat / Bun Runtime
🧰 Additional context used
📓 Path-based instructions (6)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.{ts,tsx}: Use types over interfaces for TypeScript
Avoid using enums; prefer string unions or const objects insteadAlways import tasks from
@trigger.dev/sdk. Never use@trigger.dev/sdk/v3or deprecatedclient.defineJob.
Files:
packages/cli-v3/src/dev/devSupervisor.tspackages/cli-v3/src/build/bundleSkills.tspackages/cli-v3/src/dev/devSession.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Use function declarations instead of default exports
**/*.{ts,tsx,js,jsx}: Inpackages/core(@trigger.dev/core), import subpaths only, never import from root.
Add crumbs as you write code using//@Crumbscomments or `// `#region` `@crumbsblocks for debug tracing. They should be stripped byagentcrumbs stripbefore merge.
Files:
packages/cli-v3/src/dev/devSupervisor.tspackages/cli-v3/src/build/bundleSkills.tspackages/cli-v3/src/dev/devSession.ts
**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/otel-metrics.mdc)
**/*.ts: When creating or editing OTEL metrics (counters, histograms, gauges), ensure metric attributes have low cardinality by using only enums, booleans, bounded error codes, or bounded shard IDs
Do not use high-cardinality attributes in OTEL metrics such as UUIDs/IDs (envId, userId, runId, projectId, organizationId), unbounded integers (itemCount, batchSize, retryCount), timestamps (createdAt, startTime), or free-form strings (errorMessage, taskName, queueName)
When exporting OTEL metrics via OTLP to Prometheus, be aware that the exporter automatically adds unit suffixes to metric names (e.g., 'my_duration_ms' becomes 'my_duration_ms_milliseconds', 'my_counter' becomes 'my_counter_total'). Account for these transformations when writing Grafana dashboards or Prometheus queries
Files:
packages/cli-v3/src/dev/devSupervisor.tspackages/cli-v3/src/build/bundleSkills.tspackages/cli-v3/src/dev/devSession.ts
packages/cli-v3/src/dev/**/*
📄 CodeRabbit inference engine (packages/cli-v3/CLAUDE.md)
Dev mode code should be located in
src/dev/and runs tasks locally in the user's Node.js process without containers
Files:
packages/cli-v3/src/dev/devSupervisor.tspackages/cli-v3/src/dev/devSession.ts
**/*.{js,jsx,ts,tsx,json,md,yml,yaml}
📄 CodeRabbit inference engine (AGENTS.md)
Code formatting must be enforced using Prettier before committing
Files:
packages/cli-v3/src/dev/devSupervisor.tspackages/cli-v3/src/build/bundleSkills.tspackages/cli-v3/src/dev/devSession.ts
packages/cli-v3/src/build/**/*
📄 CodeRabbit inference engine (packages/cli-v3/CLAUDE.md)
packages/cli-v3/src/build/**/*: Bundle worker code using the build system insrc/build/based on configuration fromtrigger.config.ts
Build system insrc/build/should use configuration fromtrigger.config.tsin user projects to determine bundling, build extensions, and output structure
Files:
packages/cli-v3/src/build/bundleSkills.ts
🧠 Learnings (4)
📚 Learning: 2026-03-22T13:26:12.060Z
Learnt from: ericallam
Repo: triggerdotdev/trigger.dev PR: 3244
File: apps/webapp/app/components/code/TextEditor.tsx:81-86
Timestamp: 2026-03-22T13:26:12.060Z
Learning: In the triggerdotdev/trigger.dev codebase, do not flag `navigator.clipboard.writeText(...)` calls for `missing-await`/`unhandled-promise` issues. These clipboard writes are intentionally invoked without `await` and without `catch` handlers across the project; keep that behavior consistent when reviewing TypeScript/TSX files (e.g., usages like in `apps/webapp/app/components/code/TextEditor.tsx`).
Applied to files:
packages/cli-v3/src/dev/devSupervisor.tspackages/cli-v3/src/build/bundleSkills.tspackages/cli-v3/src/dev/devSession.ts
📚 Learning: 2026-03-22T19:24:14.403Z
Learnt from: matt-aitken
Repo: triggerdotdev/trigger.dev PR: 3187
File: apps/webapp/app/v3/services/alerts/deliverErrorGroupAlert.server.ts:200-204
Timestamp: 2026-03-22T19:24:14.403Z
Learning: In the triggerdotdev/trigger.dev codebase, webhook URLs are not expected to contain embedded credentials/secrets (e.g., fields like `ProjectAlertWebhookProperties` should only hold credential-free webhook endpoints). During code review, if you see logging or inclusion of raw webhook URLs in error messages, do not automatically treat it as a credential-leak/secrets-in-logs issue by default—first verify the URL does not contain embedded credentials (for example, no username/password in the URL, no obvious secret/token query params or fragments). If the URL is credential-free per this project’s conventions, allow the logging.
Applied to files:
packages/cli-v3/src/dev/devSupervisor.tspackages/cli-v3/src/build/bundleSkills.tspackages/cli-v3/src/dev/devSession.ts
📚 Learning: 2026-05-18T08:21:27.694Z
Learnt from: d-cs
Repo: triggerdotdev/trigger.dev PR: 3632
File: apps/webapp/sentry.server.ts:4-21
Timestamp: 2026-05-18T08:21:27.694Z
Learning: When handling Prisma error P1001 ("Can't reach database server") in TypeScript, don’t assume a single error shape. Prisma can surface P1001 via two different error classes/fields: `PrismaClientKnownRequestError` exposes it as `err.code === "P1001"` (common during mid-query connection drops), while `PrismaClientInitializationError` exposes it as `err.errorCode === "P1001"` (common on client startup failure). Therefore, predicates should use `err.code === "P1001" || err.errorCode === "P1001"`. Do not flag `err.code === "P1001"` as “unreachable/never matches,” as it is expected in production.
Applied to files:
packages/cli-v3/src/dev/devSupervisor.tspackages/cli-v3/src/build/bundleSkills.tspackages/cli-v3/src/dev/devSession.ts
📚 Learning: 2026-05-18T08:21:27.694Z
Learnt from: d-cs
Repo: triggerdotdev/trigger.dev PR: 3632
File: apps/webapp/sentry.server.ts:4-21
Timestamp: 2026-05-18T08:21:27.694Z
Learning: When handling Prisma errors for P1001 ("Can't reach database server"), do not assume it only appears under a single property name. Prisma may surface P1001 via either `PrismaClientKnownRequestError` (`err.code === "P1001"`, e.g., mid-query connection drops) or `PrismaClientInitializationError` (`err.errorCode === "P1001"`, e.g., client startup connection failure). To reliably detect the condition, check `err.code === "P1001" || err.errorCode === "P1001"`, and avoid review rules that would incorrectly flag `err.code === "P1001"` as unreachable/never-matching.
Applied to files:
packages/cli-v3/src/dev/devSupervisor.tspackages/cli-v3/src/build/bundleSkills.tspackages/cli-v3/src/dev/devSession.ts
🔇 Additional comments (4)
packages/cli-v3/src/build/bundleSkills.ts (1)
23-50: LGTM!Also applies to: 82-160
packages/cli-v3/src/dev/devSupervisor.ts (1)
21-21: LGTM!Also applies to: 335-352
packages/cli-v3/src/dev/devSession.ts (1)
121-128: LGTM!.changeset/bundle-skills-single-pass.md (1)
1-5: LGTM!
## Summary 2 bug fixes. ## Bug fixes - Fix `chat.agent` skills silently missing in `trigger dev` for projects whose task files read `process.env` at module top level (e.g. a third-party SDK client initialized at import). Skill folders now bundle into `.trigger/skills/` reliably regardless of which env vars are set when the CLI launches. ([#3690](#3690)) - Fix `COULD_NOT_FIND_EXECUTOR` when a task's definition is loaded via `await import(...)` from inside another task's `run()`. The runtime workers now register such tasks with a sentinel file context, and the catalog logs a one-time warning per task id. ([#3688](#3688)) <details> <summary>Raw changeset output</summary>⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ `main` is currently in **pre mode** so this branch has prereleases rather than normal releases. If you want to exit prereleases, run `changeset pre exit` on `main`.⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ # Releases ## @trigger.dev/build@4.5.0-rc.1 ### Patch Changes - Updated dependencies: - `@trigger.dev/core@4.5.0-rc.1` ## trigger.dev@4.5.0-rc.1 ### Patch Changes - Fix `chat.agent` skills silently missing in `trigger dev` for projects whose task files read `process.env` at module top level (e.g. a third-party SDK client initialized at import). Skill folders now bundle into `.trigger/skills/` reliably regardless of which env vars are set when the CLI launches. ([#3690](#3690)) - Fix `COULD_NOT_FIND_EXECUTOR` when a task's definition is loaded via `await import(...)` from inside another task's `run()`. The runtime workers now register such tasks with a sentinel file context, and the catalog logs a one-time warning per task id. ([#3688](#3688)) - Updated dependencies: - `@trigger.dev/core@4.5.0-rc.1` - `@trigger.dev/build@4.5.0-rc.1` - `@trigger.dev/schema-to-json@4.5.0-rc.1` ## @trigger.dev/core@4.5.0-rc.1 ### Patch Changes - Fix `COULD_NOT_FIND_EXECUTOR` when a task's definition is loaded via `await import(...)` from inside another task's `run()`. The runtime workers now register such tasks with a sentinel file context, and the catalog logs a one-time warning per task id. ([#3688](#3688)) ## @trigger.dev/plugins@4.5.0-rc.1 ### Patch Changes - Updated dependencies: - `@trigger.dev/core@4.5.0-rc.1` ## @trigger.dev/python@4.5.0-rc.1 ### Patch Changes - Updated dependencies: - `@trigger.dev/core@4.5.0-rc.1` - `@trigger.dev/build@4.5.0-rc.1` - `@trigger.dev/sdk@4.5.0-rc.1` ## @trigger.dev/react-hooks@4.5.0-rc.1 ### Patch Changes - Updated dependencies: - `@trigger.dev/core@4.5.0-rc.1` ## @trigger.dev/redis-worker@4.5.0-rc.1 ### Patch Changes - Updated dependencies: - `@trigger.dev/core@4.5.0-rc.1` ## @trigger.dev/rsc@4.5.0-rc.1 ### Patch Changes - Updated dependencies: - `@trigger.dev/core@4.5.0-rc.1` ## @trigger.dev/schema-to-json@4.5.0-rc.1 ### Patch Changes - Updated dependencies: - `@trigger.dev/core@4.5.0-rc.1` ## @trigger.dev/sdk@4.5.0-rc.1 ### Patch Changes - Updated dependencies: - `@trigger.dev/core@4.5.0-rc.1` </details> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Summary
trigger.dev devwas silently dropping registeredchat.agentskills for any project whose task files readprocess.envat module top level — e.g. a third-party SDK client initialized at import. The agent would boot fine, butskill.local()failed at runtime withENOENTbecause the skill folder was never copied into.trigger/skills/.Design
The CLI ran two indexer passes in dev: the worker's own indexer (with the full env it eventually executes tasks in), and a separate skill-discovery indexer with only the CLI process's env. Top-level reads of vars like
TRIGGER_API_URLimported cleanly in the worker pass and threw in the skill pass — the latter caught the error, warned, and skipped skill copying. Failure was silent enough thatskill.local()only surfaced it at task runtime.The skill registry is already part of the worker manifest. This PR drops the duplicate pass and copies skill folders from that manifest after the worker initializes. One indexer instead of two; a bad
SKILL.mdnow surfaces as a startup error instead of silently disappearing skills.Deploy is unaffected — its skill discovery uses the project's environment variables (fetched via the API, which fills in
TRIGGER_API_URLetc.), so the dev failure mode doesn't reach there.Test plan
references/agent-skillsreference project withskills.define+ a task that callsskill.local()and runs a bundled scriptmain, adding a top-levelprocess.env.TRIGGER_API_URL!.includes(...)read in any task file reproduces the symptom: warning at dev startup, no.trigger/skills/folder,skill.local()fails with ENOENTskill.local()works end-to-end