Skip to main content
Trigger testing validates whether your skill activates when it should (and doesn’t activate when it shouldn’t). Skill Lab runs your trigger test cases through a real agent runtime and analyzes execution traces to verify correct skill invocation.

Overview

Trigger testing uses 4 prompt types to ensure robust skill activation:
Trigger testing requires the Claude CLI (npm install -g @anthropic-ai/claude-code) or Codex CLI. Both runtimes are supported.

Prerequisites

1

Install Claude CLI

Install the Claude Code CLI tool:
Verify installation:
2

Create or generate tests

You need trigger test definitions in .skill-lab/tests/triggers.yaml.Either create them manually or use LLM-powered test generation:

Test Definition Format

Trigger tests are defined in .skill-lab/tests/triggers.yaml:
triggers.yaml

Required Fields

Optional Fields

Running Trigger Tests

Basic Usage

The command will:
  1. Load test cases from .skill-lab/tests/triggers.yaml
  2. Execute each prompt through the Claude runtime
  3. Analyze execution traces for skill invocations
  4. Report pass/fail for each test

Example Output

Filter by Trigger Type

Run only tests of a specific type:
Valid types: explicit, implicit, contextual, negative

JSON Output

Generate machine-readable JSON output:

How It Works

1

Test execution

For each test case, Skill Lab:
  1. Launches the Claude CLI with the test prompt
  2. Records the execution trace to .skill-lab/traces/{test-id}.jsonl
  3. Captures the agent’s tool calls and skill invocations
2

Trace analysis

The trace analyzer examines the JSONL trace file:
  • Scans for skill invocation events
  • Identifies which skills were loaded
  • Tracks the order of tool calls
3

Result validation

Compares actual behavior against expected outcome:
  • Positive tests (expected: trigger): Skill must be invoked
  • Negative tests (expected: no_trigger): Skill must NOT be invoked
Execution traces are saved to .skill-lab/traces/ for debugging. If a test fails, examine the trace file to understand why the skill was (or wasn’t) triggered.

Best Practices

Write Diverse Test Cases

Cover all 4 trigger types for comprehensive validation:
  • Explicit (3+ tests): Direct invocations with variations
  • Implicit (3+ tests): Scenario descriptions without naming the skill
  • Contextual (3+ tests): Realistic prompts with noise and domain context
  • Negative (4+ tests): Adjacent tasks that should NOT trigger

Test Edge Cases

Include negative tests for:
  • Similar domains but different tasks
  • Ambiguous prompts that could match multiple skills
  • Common questions unrelated to your skill’s purpose
Example: Testing Boundaries

Optimize Test Runtime

Skill Lab automatically stops execution when the expected skill is triggered (for positive tests). This reduces runtime and API costs.
Trigger testing incurs LLM API costs. Each test runs a full agent session. Use --type filters during development to test specific trigger types.

Interpreting Results

Pass Rates by Type

Common Failure Patterns

Implicit tests failing: Skill description may be too narrow or unclear
  • Update skill description to cover implicit scenarios
  • Add more examples to SKILL.md
Negative tests failing: Skill is over-triggering (false positives)
  • Refine skill description to be more specific
  • Add explicit prerequisites or constraints
Contextual tests failing: Skill doesn’t handle noisy, realistic prompts
  • Add domain keywords to skill description
  • Include contextual examples in SKILL.md

CI/CD Integration

Next Steps

Test Generation

Auto-generate trigger tests using LLMs instead of writing them manually

Static Analysis

Validate skill structure and content quality