Skip to content

fix(cli): stop chat.agent skills silently disappearing from trigger dev#3690

Merged
ericallam merged 2 commits into
mainfrom
refactor/bundle-skills-single-pass
May 21, 2026
Merged

fix(cli): stop chat.agent skills silently disappearing from trigger dev#3690
ericallam merged 2 commits into
mainfrom
refactor/bundle-skills-single-pass

Conversation

@ericallam
Copy link
Copy Markdown
Member

Summary

trigger.dev dev was silently dropping registered chat.agent skills for any project whose task files read process.env at module top level — e.g. a third-party SDK client initialized at import. The agent would boot fine, but skill.local() failed at runtime with ENOENT because 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_URL imported 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 that skill.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.md now 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_URL etc.), so the dev failure mode doesn't reach there.

Test plan

  • New references/agent-skills reference project with skills.define + a task that calls skill.local() and runs a bundled script
  • On main, adding a top-level process.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 ENOENT
  • On this branch, same project boots clean and skill.local() works end-to-end
  • Deploy still works end-to-end with the new reference project

ericallam added 2 commits May 21, 2026 16:14
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-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 21, 2026

🦋 Changeset detected

Latest commit: 13f51bb

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 32 packages
Name Type
trigger.dev Patch
references-ai-chat Patch
d3-chat Patch
references-d3-openai-agents Patch
references-nextjs-realtime Patch
references-realtime-hooks-test Patch
references-realtime-streams Patch
references-telemetry Patch
@trigger.dev/build Patch
@trigger.dev/core Patch
@trigger.dev/plugins Patch
@trigger.dev/python Patch
@trigger.dev/react-hooks Patch
@trigger.dev/redis-worker Patch
@trigger.dev/rsc Patch
@trigger.dev/schema-to-json Patch
@trigger.dev/sdk Patch
@trigger.dev/database Patch
@trigger.dev/otlp-importer Patch
@trigger.dev/rbac Patch
@internal/cache Patch
@internal/clickhouse Patch
@internal/llm-model-catalog Patch
@internal/redis Patch
@internal/replication Patch
@internal/run-engine Patch
@internal/schedule-engine Patch
@internal/testcontainers Patch
@internal/tracing Patch
@internal/tsql Patch
@internal/zod-worker Patch
@internal/sdk-compat-tests Patch

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

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 21, 2026

Review Change Stack

Walkthrough

This PR refactors skill folder bundling to execute at the correct lifecycle phase. It extracts a reusable copySkillFolders helper that validates SKILL.md frontmatter and copies skill folders deterministically, moves skill copying from the dev rebuild phase into worker initialization, and removes the now-redundant bundling step from dev session rebuilds. These changes ensure skill folders are copied reliably into .trigger/skills/ regardless of environment variable state when the CLI starts.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main fix: preventing chat.agent skills from disappearing during trigger dev when projects have top-level process.env reads.
Description check ✅ Passed The description provides comprehensive context including summary, design rationale, test plan, and deployment impact, but omits required template sections like the checklist, issue reference, and explicit testing steps.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/bundle-skills-single-pass

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ericallam ericallam marked this pull request as ready for review May 21, 2026 15:16
github-advanced-security[bot]

This comment was marked as resolved.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/cli-v3/src/build/bundleSkills.ts (1)

71-80: ⚡ Quick win

Scope frontmatter validation to the frontmatter block.

The \bname: and \bdescription: checks run against the entire SKILL.md, not the frontmatter block matched on Line 71. A SKILL.md body (which is prose intended for the LLM) can easily contain text like the tool's name: … or description: …, 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

📥 Commits

Reviewing files that changed from the base of the PR and between acfba02 and 13f51bb.

⛔ Files ignored due to path filters (7)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
  • references/agent-skills/package.json is excluded by !references/**
  • references/agent-skills/src/trigger/skills/greeter/SKILL.md is excluded by !references/**
  • references/agent-skills/src/trigger/skills/greeter/scripts/hello.sh is excluded by !references/**
  • references/agent-skills/src/trigger/test-skill.ts is excluded by !references/**
  • references/agent-skills/trigger.config.ts is excluded by !references/**
  • references/agent-skills/tsconfig.json is excluded by !references/**
📒 Files selected for processing (4)
  • .changeset/bundle-skills-single-pass.md
  • packages/cli-v3/src/build/bundleSkills.ts
  • packages/cli-v3/src/dev/devSession.ts
  • packages/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 instead

Always import tasks from @trigger.dev/sdk. Never use @trigger.dev/sdk/v3 or deprecated client.defineJob.

Files:

  • packages/cli-v3/src/dev/devSupervisor.ts
  • packages/cli-v3/src/build/bundleSkills.ts
  • packages/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}: In packages/core (@trigger.dev/core), import subpaths only, never import from root.
Add crumbs as you write code using // @Crumbs comments or `// `#region` `@crumbs blocks for debug tracing. They should be stripped by agentcrumbs strip before merge.

Files:

  • packages/cli-v3/src/dev/devSupervisor.ts
  • packages/cli-v3/src/build/bundleSkills.ts
  • packages/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.ts
  • packages/cli-v3/src/build/bundleSkills.ts
  • packages/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.ts
  • packages/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.ts
  • packages/cli-v3/src/build/bundleSkills.ts
  • packages/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 in src/build/ based on configuration from trigger.config.ts
Build system in src/build/ should use configuration from trigger.config.ts in 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.ts
  • packages/cli-v3/src/build/bundleSkills.ts
  • packages/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.ts
  • packages/cli-v3/src/build/bundleSkills.ts
  • packages/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.ts
  • packages/cli-v3/src/build/bundleSkills.ts
  • packages/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.ts
  • packages/cli-v3/src/build/bundleSkills.ts
  • packages/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!

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 5 additional findings.

Open in Devin Review

@ericallam ericallam merged commit 5ddb81a into main May 21, 2026
51 checks passed
@ericallam ericallam deleted the refactor/bundle-skills-single-pass branch May 21, 2026 15:30
ericallam pushed a commit that referenced this pull request May 21, 2026
## 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants