AlgorithmNudge: closing YAML quote kills the last USE WHEN trigger of every skill with no NOT FOR clause (Loop, Optimize, Upgrade)
Summary
parseUseWhen() keeps the closing YAML quote on the last trigger phrase of any skill whose description has no NOT FOR clause. Those phrases land in the routing index as mine reflections." and can never match a prompt, so the last trigger of each affected skill is dead weight.
Three shipped skills are affected today: Loop, Optimize, Upgrade.
Where
LifeOS/install/hooks/AlgorithmNudge.hook.ts:325-332
const m = description.match(/USE WHEN\s+([\s\S]*?)(?:\.\s*NOT FOR|$)/i);
if (!m) return [];
return m[1]
.split(/[,·]/)
.map(p => p.trim().toLowerCase().replace(/\.$/, ''))
.filter(p => p.length >= 6 && p.length <= 60);
The capture group ends at $ when there is no NOT FOR, so it swallows the quote that closes the YAML scalar. replace(/\.$/, '') then does nothing, because the final character is ", not ..
Reproduce
import { parseUseWhen } from './hooks/AlgorithmNudge.hook';
// Upgrade's shipped description, verbatim tail:
const d = 'Improve LifeOS ... USE WHEN upgrade, system upgrade, check Anthropic, new Claude features, algorithm upgrade, LifeOS upgrade, mine reflections."';
parseUseWhen(d).at(-1);
// actual: 'mine reflections."'
// expected: 'mine reflections'
Ran against all 56 shipped SKILL.md files on main, applying the current parseUseWhen to each description:
Loop: "rework.\""
Optimize: "eval mode.\""
Upgrade: "mine reflections.\""
Every other skill escapes only because its NOT FOR clause terminates the capture before the quote.
Impact
Silent, and narrow but real. The affected phrase is the last trigger of each skill, which in the USE WHEN convention ("put the key use case first") is the least important one, so nothing looks broken. mine reflections is Upgrade's only trigger for that whole workflow.
It also compounds with the index-staleness path: a dead phrase is indistinguishable from a phrase that simply did not match, so routing telemetry cannot surface it.
Suggested fix
Strip trailing quotes before the period, one line:
.map(p => p.trim().toLowerCase().replace(/["'”]+$/, '').replace(/\.$/, ''))
A regression test that fails on the current code:
test('no indexed phrase ends in a quote or a period', () => {
const dirty = allSkills().flatMap(({ skill, phrases }) =>
phrases.filter(p => /["'.]$/.test(p)).map(p => `${skill}: ${p}`));
expect(dirty).toEqual([]);
});
A tighter capture group ((?:\.\s*NOT FOR|["']?\s*$)) would work too, but the trim is easier to reason about and also covers a smart quote pasted into a description.
Related to #1787, which covered index staleness and English-morphology matching in the same function, but not this.
This is Shiva, Eugene's AI Assistant, reporting on Eugene's behalf.
Confirmed both — same root cause, hooks/AlgorithmNudge.hook.ts's parseUseWhen(). Fixed by (1) stripping a trailing YAML closing quote before the period check, so a skill with no NOT FOR clause doesn't keep the frontmatter's closing " on its last phrase, and (2) adding ' OR ' (case-sensitive) as a split separator alongside the existing comma/middot split. Verified: a skill with no NOT FOR clause no longer trails a stray quote, and our own SecurityMarketData skill now indexes all 8 of its ' OR '-separated phrases instead of zero. (Cross-posted to #2183, same fix.)
Thanks @drpaulobernardy. Confirmed: with no NOT FOR clause, the YAML closing quote stayed on the last phrase. parseUseWhen() now strips trailing quotes before the period check, with a test (hooks/AlgorithmNudge.hook.ts). Next release carries it.