Skip to content

Commit b9ecfd9

Browse files
feat(linters): wire tool field name validation into all component linters
Integrates ValidateToolFieldName() checks into agent, command, and skill linters: - agents.go: Validates agents use 'tools:' not 'allowed-tools:' - commands.go: Validates commands use 'allowed-tools:' not 'tools:' - skills.go: Validates skills use 'allowed-tools:' not 'tools:' - singlefile.go: Properly handles error severity in skill validation Fixes skills.go and singlefile.go to separate errors from suggestions based on severity field, ensuring tool naming violations are reported as errors. This enforces Anthropic's documented field naming conventions across all component types at lint time.
1 parent 8ba7ad1 commit b9ecfd9

4 files changed

Lines changed: 29 additions & 5 deletions

File tree

internal/cli/agents.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,9 @@ func validateAgentSpecific(data map[string]interface{}, filePath string, content
238238
}
239239
}
240240

241+
// Validate tool field naming (agents use 'tools:', not 'allowed-tools:')
242+
errors = append(errors, ValidateToolFieldName(data, filePath, contents, "agent")...)
243+
241244
// Best practice checks
242245
errors = append(errors, validateAgentBestPractices(filePath, contents, data)...)
243246

internal/cli/commands.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ func validateCommandSpecific(data map[string]interface{}, filePath string, conte
129129
}
130130
}
131131

132+
// Validate tool field naming (commands use 'allowed-tools:', not 'tools:')
133+
errors = append(errors, ValidateToolFieldName(data, filePath, contents, "command")...)
134+
132135
return errors
133136
}
134137

internal/cli/singlefile.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,8 +530,15 @@ func lintSingleSkill(ctx *SingleFileLinterContext) LintResult {
530530
}
531531

532532
// Best practice checks
533-
suggestions := validateSkillBestPractices(ctx.File.RelPath, ctx.File.Contents, fmData)
534-
result.Suggestions = append(result.Suggestions, suggestions...)
533+
allResults := validateSkillBestPractices(ctx.File.RelPath, ctx.File.Contents, fmData)
534+
// Separate errors from suggestions based on severity
535+
for _, r := range allResults {
536+
if r.Severity == "error" {
537+
result.Errors = append(result.Errors, r)
538+
} else {
539+
result.Suggestions = append(result.Suggestions, r)
540+
}
541+
}
535542

536543
// Cross-file validation (outgoing refs)
537544
crossValidator := ctx.EnsureCrossFileValidator()

internal/cli/skills.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,17 @@ func LintSkills(rootPath string, quiet bool, verbose bool) (*LintSummary, error)
102102
if fmData == nil {
103103
fmData = make(map[string]interface{})
104104
}
105-
suggestions := validateSkillBestPractices(file.RelPath, file.Contents, fmData)
106-
result.Suggestions = append(result.Suggestions, suggestions...)
107-
summary.TotalSuggestions += len(suggestions)
105+
allResults := validateSkillBestPractices(file.RelPath, file.Contents, fmData)
106+
// Separate errors from suggestions based on severity
107+
for _, r := range allResults {
108+
if r.Severity == "error" {
109+
result.Errors = append(result.Errors, r)
110+
summary.TotalErrors++
111+
} else {
112+
result.Suggestions = append(result.Suggestions, r)
113+
summary.TotalSuggestions++
114+
}
115+
}
108116

109117
// Cross-file validation (missing agents)
110118
crossErrors := ctx.CrossValidator.ValidateSkill(file.RelPath, file.Contents)
@@ -284,6 +292,9 @@ func validateSkillBestPractices(filePath string, contents string, fmData map[str
284292
})
285293
}
286294

295+
// Validate tool field naming (skills use 'allowed-tools:', not 'tools:')
296+
suggestions = append(suggestions, ValidateToolFieldName(fmData, filePath, contents, "skill")...)
297+
287298
// Merge warnings into suggestions for return
288299
suggestions = append(suggestions, warnings...)
289300

0 commit comments

Comments
 (0)