feat(skills): detect ambiguous-trigger verbs in bundled skill descriptions#3008
Open
ricardo-leiva wants to merge 2 commits into
Open
feat(skills): detect ambiguous-trigger verbs in bundled skill descriptions#3008ricardo-leiva wants to merge 2 commits into
ricardo-leiva wants to merge 2 commits into
Conversation
…tions Bundled PostHog analytics skills whose descriptions contain coding-overlap verbs (investigate, debug, explore, etc.) without an explicit TRIGGER guard bias the model toward analytics skill invocations during unrelated coding sessions. This adds static analysis to catch and enforce those guards. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Open
2 tasks
Contributor
|
Reviews (1): Last reviewed commit: "feat(skills): detect ambiguous-trigger v..." | Re-trigger Greptile |
…per it.each - Address Greptile review: fix comment on hasAmbiguousTrigger (was listing "DO NOT TRIGGER" as an accepted guard but the regex requires "when" after it), and extend the regex to also accept "Use whenever" / "TRIGGER whenever" as valid guards (debugging-surveys uses this phrasing). - Address Greptile review: split the AMBIGUOUS_TRIGGER_VERBS sentinel into a length check plus an it.each for the core verb set, per team convention. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Bundled PostHog analytics skills (101 of them) are injected into every agent session context regardless of whether the user is doing analytics work or coding. Skills whose descriptions contain coding-overlap verbs like
investigate,debug, orexplore— with no trigger guard — give the model no basis to distinguish a PostHog analytics intent from an unrelated coding request. The result is false-positive skill invocations during coding sessions (~10,920 tokens of context bias).Changes
analyzeSkills.ts— extended with:AMBIGUOUS_TRIGGER_VERBSconst: the 8 coding-overlap verbs that cause false invocations (investigate,diagnose,debug,explore,analyze,audit,instrument,set up)hasAmbiguousTrigger(skill): returns true for bundled skills that contain one of those verbs without an accepted trigger guard (TRIGGER when,Use when, orRead when)"ambiguous-trigger"issue type inanalyzeSkills()reporting which verbs matchedanalyzeSkills.test.ts— 11 new unit tests covering the ambiguous-trigger detection path: bundled vs. non-bundled sources, each guard pattern variant, matched-verb reporting, and a sentinel on the verb list.bundled-skill-corpus.test.ts(new) — integration tests that load the real built skill files from.vite/build/plugins/posthog/skills/and assert corpus-level properties:analyzeSkillsreports zero issues on the full corpusThe corpus tests skip automatically on fresh checkouts (before
pnpm build) usingdescribe.skipIf.biome.jsonc— added one override: core*.test.tsfiles are exempt from thenode:*import restriction, since Vitest always runs in Node.js. Production source files in@posthog/coreremain fully restricted.How did you test this?
Agent-run automated tests only — I'm not a human tester and won't claim manual verification.
pnpm --filter @posthog/core test— 1774 tests pass including all 11 new unit tests and all 5 corpus integration testspnpm --filter @posthog/core typecheck— no errorspnpm lint— no errors on changed filesThe corpus tests run against the actual built skill files, so they catch regressions whenever a new skill is added or an existing description is changed without a trigger guard.
Automatic notifications
🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Authored with Claude Code (claude-sonnet-4-6) in a session driven by @ricardo-leiva. The user identified that 101 bundled PostHog analytics skills loaded into every agent session context without trigger guards could bias the model toward analytics skill invocations on coding tasks. I analyzed the skill corpus, designed the static analysis approach (deterministic, no model calls), implemented the
hasAmbiguousTriggerdetector, wrote the corpus integration test, and fixed the 5 skills in the PostHog repo that were genuinely missing guards (see companion PR there). No skills were added or removed — the fix is purely descriptor-quality enforcement. The biome.jsonc override for core test files was required because the corpus test reads from disk usingnode:fs, which the core purity rule otherwise blocks for production code.