mirror of
https://github.com/garrytan/gstack.git
synced 2026-05-05 05:05:08 +02:00
fix: auto-trigger guard in gen-skill-docs.ts
Inject explicit trigger criteria into every generated skill description to prevent Claude Code from auto-firing skills based on semantic similarity. Generator-only change — templates stay clean. Preserves existing "Use when" and "Proactively suggest" text (both are validated by skill-validation.test.ts trigger phrase tests). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -2968,6 +2968,17 @@ function processTemplate(tmplPath: string, host: Host = 'claude'): { outputPath:
|
||||
throw new Error(`Unresolved placeholders in ${relTmplPath}: ${remaining.join(', ')}`);
|
||||
}
|
||||
|
||||
// Inject auto-trigger guard into skill descriptions.
|
||||
// Adds explicit trigger criteria so Claude Code doesn't auto-fire skills
|
||||
// based on semantic similarity. Preserves existing "Use when" and
|
||||
// "Proactively suggest" text (both are tested in skill-validation.test.ts).
|
||||
const triggerGuard = ` MANUAL TRIGGER ONLY: only run this skill when the user explicitly types /${skillName} in their message.\n Do not auto-trigger this skill from semantic similarity alone.\n`;
|
||||
const descMatch = content.match(/^(description:\s*\|?\s*\n)/m);
|
||||
if (descMatch && descMatch.index !== undefined) {
|
||||
const insertAt = descMatch.index + descMatch[0].length;
|
||||
content = content.slice(0, insertAt) + triggerGuard + content.slice(insertAt);
|
||||
}
|
||||
|
||||
// For codex host: transform frontmatter and replace Claude-specific paths
|
||||
if (host === 'codex') {
|
||||
// Extract hook safety prose BEFORE transforming frontmatter (which strips hooks)
|
||||
|
||||
Reference in New Issue
Block a user