| name | conditional-skill-activation |
|---|---|
| description | Protocol for path-based and context-triggered skill activation to reduce prompt bloat. |
| created | 2026-03-31 |
| source | Claude Code loadSkillsDir.ts — conditional skills via paths frontmatter |
Source: Claude Code
loadSkillsDir.ts(2026-03-31). Problem: All 30+ skills are listed in the system prompt → ~4K tokens of skill metadata that's irrelevant 90% of the time. Solution: Skills with acontext_triggerfrontmatter field are dormant by default and only activate when matching conditions are met.
Add these optional fields to any SKILL.md:
---
name: skill-name
description: What it does
# CONDITIONAL ACTIVATION
context_trigger:
paths: # Glob patterns — skill activates when matching files are touched
- "*.sql"
- "supabase/**"
topics: # Keyword triggers — skill activates when these appear in user messages
- "database"
- "migration"
- "schema"
projects: # Project codes — skill activates when these projects are active
- "E##"
- "A##"
always_active: false # Override: if true, always in prompt (default for skills without context_trigger)
---- Load all skill frontmatter (name, description, context_trigger)
- Partition into:
- Unconditional skills (no
context_triggeroralways_active: true) → Include in prompt immediately - Conditional skills (has
context_trigger) → Store in dormant registry
- Unconditional skills (no
- Check initial context against dormant skills:
- Scan
activeContext.mdfor active project codes → match againstprojects: - Scan recent file history → match against
paths:globs
- Scan
When a user message or tool result arrives:
- Check the message content against all dormant skills'
topics:keywords - Check any file paths touched against dormant skills'
paths:globs - If a match is found:
- Move skill from dormant → active
- Log:
[skills] Activated conditional skill '{name}' (matched: {trigger}) - Skill is now available for invocation
A skill, once activated, remains active for the rest of the session. No deactivation mid-session.
| Category | Skills | Trigger Type |
|---|---|---|
| Domain-specific | statistical-analysis, trade-journal-analyzer, zenith-execution |
topics: + projects: |
| Tool-specific | seo-auditor, visual-verify-ui |
topics: |
| Workflow-specific | academic-delivery, academic-humanizer |
projects: (academic engagements only) |
| Always Active | context-compactor, red-team-review, micro-commit |
No trigger (always loaded) |
| Rare/Expensive | marketing-swarm, git-worktree-swarm |
topics: |
| State | Skills in Prompt | ~Tokens |
|---|---|---|
| Before (all loaded) | 30+ | ~4,000 |
| After (conditional) | ~10 unconditional + 0-5 activated | ~1,500-2,500 |
| Savings | — | ~40-60% |
- This protocol is advisory for human-in-the-loop agents (Antigravity, Cursor). The agent reads all skill metadata from AGENTS.md; the filtering happens at prompt construction time.
- For true autonomous agents (worktree swarms), conditional activation prevents prompt pollution across workers that only need 2-3 skills each.
- The
paths:glob evaluation uses the same ignore-pattern matching as.gitignore.
- Phase 1 (NOW): Document which skills are conditional candidates (this file)
- Phase 2: Add
context_triggerfrontmatter to 15+ skill SKILL.md files - Phase 3: Update
/startworkflow to partition skills at boot - Phase 4: Add dynamic activation hook to main query loop
#protocol #architecture #skill-system #token-optimization