Overview
Fromcore/models.py:27-33:
1. Explicit Triggers
Purpose: Verify that directly naming the skill activates it. Explicit triggers use the$skill-name syntax to request a specific skill by name. This is the clearest form of activation and should always work.
Example Test Case
Characteristics
- Clarity: Highest - skill name is explicit in the prompt
- Real-world usage: Common when users know which skill they want
- Expected behavior: Should always trigger the named skill
The
$ prefix is a convention used by some agent runtimes (like Claude CLI) to explicitly invoke skills.2. Implicit Triggers
Purpose: Test that the skill activates when the scenario matches perfectly without naming it. Implicit triggers describe exactly what the skill does without mentioning the skill name. The agent must match the prompt to the skill based on the description alone.Example Test Case
Characteristics
- Clarity: High - clear intent but no skill name
- Real-world usage: Very common - users describe what they want
- Expected behavior: Should trigger if description matches well
Best Practices for Implicit Tests
- Use phrasing that closely mirrors the skill’s description
- Include key terms and concepts from the skill documentation
- Avoid ambiguity - make the intent clear
3. Contextual Triggers
Purpose: Validate activation in realistic, noisy prompts with extra context. Contextual triggers simulate real-world scenarios where the user provides additional context, background information, or constraints alongside the core request. These test the skill’s robustness to noise.Example Test Case
Characteristics
- Clarity: Medium - intent is clear but buried in context
- Real-world usage: Very common - users provide background and constraints
- Expected behavior: Should still trigger despite extra context
Best Practices for Contextual Tests
- Include realistic domain-specific details
- Add constraints, preferences, or requirements
- Mix the core request with background information
- Test with different levels of “noise” to find activation thresholds
4. Negative Triggers
Purpose: Ensure the skill does NOT activate for unrelated tasks (catch false positives). Negative triggers test that the skill correctly stays inactive when the user’s request doesn’t match. This prevents over-eager activation and ensures skill specificity.Example Test Case
Characteristics
- Clarity: Varies - prompt is clear but for a different task
- Real-world usage: Common - users have diverse needs
- Expected behavior: Skill should remain inactive
Best Practices for Negative Tests
- Test with tasks that are similar but distinct from the skill’s purpose
- Include prompts that might share keywords but have different intent
- Cover edge cases where activation would be incorrect
- Test with tasks that other skills should handle instead
Negative tests are crucial for preventing false positives in multi-skill environments where multiple skills might seem relevant.
Test Case Structure
Trigger tests are defined in.skill-lab/tests/triggers.yaml:
Expectation Fields
Fromcore/models.py:156-163:
| Field | Type | Description |
|---|---|---|
skill_triggered | boolean | Whether the skill should activate |
exit_code | int | Expected process exit code (optional) |
commands_include | list[string] | Commands that should appear in trace (optional) |
files_created | list[string] | Files that should be created (optional) |
no_loops | boolean | Verify no retry loops occurred (optional) |
Running Trigger Tests
To run trigger tests for a skill:Trigger testing requires the Claude CLI to be installed and configured. See the Trigger Testing guide for setup instructions.
Test Generation
Skill Lab can automatically generate trigger test cases using an LLM:Trigger Test Reports
After running trigger tests, you’ll get a summary by type:core/models.py:237-269, the TriggerReport includes:
- Overall pass rate
- Breakdown by trigger type
- Individual test results with trace paths
- Detailed failure messages
Best Practices
Coverage Guidelines
A well-tested skill should include:| Trigger Type | Recommended Count | Why |
|---|---|---|
| Explicit | 1-2 | Verify basic name-based activation |
| Implicit | 2-3 | Test core scenario matching |
| Contextual | 2-4 | Validate robustness to real-world noise |
| Negative | 2-4 | Prevent false positives |
Writing Effective Tests
- Start with explicit - Ensure basic activation works
- Add implicit tests - Cover the main use cases from your description
- Include contextual tests - Simulate realistic user prompts
- Don’t skip negative tests - Prevent false positives early
Common Pitfalls
Related Concepts
- Trigger Testing Guide - How to write and run trigger tests
- Test Generation - Using LLMs to generate test cases