skill-activation-prompt Hook
Purpose: Automatically suggests relevant skills based on user prompts and file context
How It Works
- Reads
skill-rules.jsonto understand skill trigger patterns - Matches user prompts against configured patterns
- Checks which files the user is working with
- Injects skill suggestions into Claude's context automatically
Why This Hook Is Essential
This hook makes skill auto-activation work seamlessly. Instead of manually invoking skills, Claude automatically recognizes when a skill would be relevant and suggests it to you.
Installation
Step 1: Copy Hook Files
Copy both the shell script and TypeScript implementation to your project's hooks directory:
# Copy both files from the claudecode-toolkit hooks folder
cp skill-activation-prompt.sh your-project/.claude/hooks/
cp skill-activation-prompt.ts your-project/.claude/hooks/
# Make the shell script executable
chmod +x your-project/.claude/hooks/skill-activation-prompt.sh
Step 2: Install Dependencies
Navigate to your hooks directory and install dependencies:
cd your-project/.claude/hooks
npm install
Step 3: Configure Claude Code
Add the hook to your .claude/settings.json:
{
"hooks": {
"UserPromptSubmit": [
{
"hooks": [
{
"type": "command",
"command": "$CLAUDE_PROJECT_DIR/.claude/hooks/skill-activation-prompt.sh"
}
]
}
]
}
}
Configuration
The hook looks for a skill-rules.json file in your .claude/hooks directory to understand which skills to suggest. This file defines patterns that trigger skill suggestions.
Example skill-rules.json:
{
"rules": [
{
"patterns": ["spreadsheet", "excel", "csv", "xlsx"],
"skills": ["xlsx"],
"filePatterns": ["**/*.xlsx", "**/*.csv"]
},
{
"patterns": ["pdf", "document", "ocr"],
"skills": ["pdf-processing-pro"],
"filePatterns": ["**/*.pdf"]
}
]
}
How the Hook Triggers
The hook activates on the UserPromptSubmit event, which occurs every time you submit a prompt to Claude. It:
- Analyzes your prompt text for relevant keywords
- Checks your current project files for context
- Matches against configured rules
- Suggests applicable skills before Claude processes your request
Troubleshooting
Hook not triggering:
- Verify the shell script is executable:
chmod +x skill-activation-prompt.sh - Check settings.json is properly formatted
- Ensure
skill-rules.jsonexists in.claude/hooks/
npm install fails:
- Make sure you're in the
.claude/hooks/directory - Verify Node.js is installed:
node --version - Try clearing npm cache:
npm cache clean --force
Skills not being suggested:
- Review
skill-rules.jsonpatterns - Check that skill names match installed skills
- Verify file patterns match your project structure