Skip to content

Commit 3694aa6

Browse files
fix(crossfile): detect skill refs inside code blocks
The plain pattern `^[^*]*\bSkill:` was only finding one skill per file because `[^*]` matches newlines in Go regex, causing greedy matching across multiple lines. Fix: Change to `[^*\n]*` to prevent matching across newlines. Also removed redundant code block pattern - the fixed plain pattern now correctly matches Skill: declarations regardless of context. Before: 100 "orphaned skills" (false positives) After: 19 genuinely unwired skills
1 parent 2ace4ce commit 3694aa6

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

internal/cli/crossfile.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,15 +303,14 @@ func findSkillReferences(content string) []string {
303303
// Patterns to match skill references
304304
skillPatterns := []*regexp.Regexp{
305305
// Skill: foo-bar (plain format, not inside bold markers)
306-
regexp.MustCompile(`(?m)^[^*]*\bSkill:\s*([a-z0-9][a-z0-9-]*)`),
306+
// Note: [^*\n]* prevents matching across newlines (Go regex quirk)
307+
regexp.MustCompile(`(?m)^[^*\n]*\bSkill:\s*([a-z0-9][a-z0-9-]*)`),
307308
// **Skill**: foo-bar (bold format)
308309
regexp.MustCompile(`(?m)\*\*Skill\*\*:\s*([a-z0-9][a-z0-9-]*)`),
309310
// Skill("foo-bar") or Skill(foo-bar) (function call format)
310311
regexp.MustCompile(`(?m)Skill\(\s*["']?([a-z0-9][a-z0-9-]*)["']?\s*\)`),
311312
// Skills: followed by list items
312313
regexp.MustCompile(`(?m)Skills?:\s*\n\s*[-*]\s*([a-z0-9][a-z0-9-]*)`),
313-
// Code block with Skill: declaration
314-
regexp.MustCompile("(?m)```[^`]*Skill:\\s*([a-z0-9][a-z0-9-]*)"),
315314
}
316315

317316
for _, pattern := range skillPatterns {

0 commit comments

Comments
 (0)