Skill Rule Definitions
Skill Rule Configuration
The Skill Evaluation Engine uses a centralized configuration file, skill-rules.json, to determine when specific domain knowledge (Skills) should be injected into Claude's context. By defining rules based on keywords, file paths, and intent patterns, you can ensure Claude always has the right documentation for the task at hand without manual activation.
Configuration Schema
The skill-rules.json file consists of individual skill definitions and a global scoring configuration. Each skill entry defines how the evaluator should identify relevant prompts.
{
"skills": {
"skill-name": {
"triggers": {
"keywords": ["term1", "term2"],
"keywordPatterns": ["regex-pattern"],
"globs": ["src/components/**/*.tsx"]
},
"excludePatterns": ["ignore-this-pattern"],
"priority": 5
}
},
"scoring": {
"keyword": 10,
"keywordPattern": 15,
"pathMatch": 20
}
}
Trigger Definitions
Triggers are the primary mechanism for matching a user's prompt to a skill. You can combine multiple trigger types to increase matching accuracy.
Keywords
An array of exact strings. The evaluator performs a case-insensitive search for these terms within the user's prompt.
- Usage: Best for unique library names or specific domain terms (e.g.,
"GraphQL","Tailwind","Maestro").
Keyword Patterns
An array of regular expression strings. This allows for more flexible matching of complex phrases or variable naming conventions.
- Usage: Best for detecting intent or action-based requests (e.g.,
"create.*component","fix.*test").
Glob Patterns
The engine extracts file paths mentioned in the prompt and matches them against simplified glob patterns.
- Usage: Best for directory-specific skills (e.g.,
src/hooks/**for a React Hooks skill). - Supported Wildcards:
*: Matches any character except forward slashes.**: Matches any character across multiple directory levels.
Exclusion Patterns
To prevent false positives, use excludePatterns. If a prompt matches any regex pattern in this list, the skill will not be activated, regardless of other positive triggers.
"excludePatterns": ["^ignore", "draft"]
Scoring and Activation
The evaluation engine calculates a confidence score for every skill based on the scoring weights defined in the configuration.
- Weighting: Every time a keyword matches, the
keywordscore is added. Pattern matches typically carry higher weights. - Prioritization: The
priorityfield (defaulting to 5) acts as a tie-breaker or multiplier when multiple skills match a single prompt. - Activation: Skills that exceed the internal confidence threshold are output as a "Skill Reminder" to Claude, instructing it to pull in the relevant Markdown documentation from
.claude/skills/.
Implementation Example
If you want Claude to automatically load your GraphQL documentation whenever you mention a .gql file or use the word "mutation," your rule would look like this:
{
"skills": {
"graphql-schema": {
"triggers": {
"keywords": ["mutation", "query", "resolver"],
"keywordPatterns": ["gql", "apollo"],
"globs": ["**/*.gql", "src/graphql/**/*"]
},
"priority": 10
}
}
}
Best Practices
- Specific over General: Use specific keywords (e.g.,
useQuery) rather than generic ones (e.g.,data) to avoid over-triggering. - Path Awareness: Use
globsliberally. If a user says "fix the bug in src/ui/Button.tsx," the system can automatically trigger your UI library skill because of the file path match. - Regex Testing: Ensure
keywordPatternsare valid JavaScript regex strings to prevent the evaluation engine from skipping the rule.