Skills: Triggers & Auto-Activation
Last updated: 2026-08-31
A good Skill should be like air — there when you need it, out of the way when you don't. Triggers are the "when you need it" switch.
1. Trigger Types
(1) Keyword Trigger
The most common trigger method, matching keywords in user input:
triggers:
- keyword: "review|code review"
- keyword: "debug|troubleshoot"
| Match Rule | Description | Example |
|---|---|---|
| Exact Match | Exactly equals keyword | "deploy" |
| Fuzzy Match | Contains the keyword | "review" matches "please review this" |
| Regex Match | Regular expression | "fix.*bug" |
| Multi-Keyword | Any match triggers | "refactor|restructure" |
(2) File Type Trigger
Auto-activates based on the extension or path of files being operated on:
triggers:
- file_pattern: "**/*.py"
- file_pattern: "src/components/**/*.tsx"
(3) Context Condition Trigger
Activates based on project environment or conversation state:
triggers:
- context: "git_diff_available"
- context: "test_failed"
- context: "has_package_json"
2. Trigger Priority
When multiple Skills match simultaneously, selection follows priority:
Priority from high to low:
1. Manual explicit call (user explicitly requests)
2. Keyword exact match
3. Context condition match
4. File type fuzzy match
5. Default fallback Skill
(1) Priority Configuration
triggers:
- keyword: "urgent fix"
priority: 100
- keyword: "fix"
priority: 50
(2) Conflict Resolution
When two Skills compete:
User input: "review this Python file for bugs"
Match results:
├── code-review Skill (keyword: "review") → Priority 80
├── python-review Skill (keyword: "review" + file: *.py) → Priority 90 ✅
└── debug Skill (keyword: "bug") → Priority 70
Result: Select python-review because it matches more precisely
3. Combined Triggers
(1) AND Combination
All conditions must be met simultaneously:
triggers:
- and:
- keyword: "deploy"
- context: "main_branch"
(2) OR Combination
Any condition being met triggers:
triggers:
- or:
- keyword: "test"
- file_pattern: "**/*test*.py"
(3) NOT Exclusion
Does not trigger when condition is met:
triggers:
- keyword: "refactor"
- not:
- context: "production_branch"
4. Trigger Practice
▶ Example: Intelligent Scheduling System
Alice designed an auto-trigger system for the team:
# .claude/skills/auto-test.md
---
name: auto-test
triggers:
- and:
- file_pattern: "src/**/*.py"
- context: "file_modified"
- not:
- file_pattern: "src/**/migrations/**"
---
After modifying Python source files, automatically run tests......
Bob commented: "This system means the team doesn't need to remember which Skill to call — just work normally, and the right support comes automatically."
(1) Common Trigger Scenarios
| Scenario | Trigger Method | Example Skill |
|---|---|---|
| Opening certain file types | File type | Python code review |
| Before committing code | Context condition | Pre-commit check |
| Test failure | Context condition | Auto-debug |
| Entering specific commands | Keyword | Deploy, release |
| PR creation | Context condition | Code review |
❓ FAQ
auto_trigger: false in the configuration; the Skill can then only be called manually.📖 Summary
- Three trigger types: keyword, file type, context condition
- Priority rules: manual > exact match > fuzzy match > fallback
- Combined triggers: AND (all must be met), OR (any is met), NOT (exclude)
- Design principle: Skills appear automatically when needed, don't intrude when not
📝 Exercises
- Basic (⭐): Add two different types of triggers to your previously created code-review Skill.
- Intermediate (⭐⭐): Design a combined trigger that automatically runs tests when Python test files are modified, but excludes migration files.
- Advanced (⭐⭐⭐): Design a team-level trigger scheduling system that handles priority and conflicts among 5+ Skills.