This skill installs a complete Claude Code skill tracking system using hooks to automatically log skill usage, execution duration, token usage, and user prompts for later analysis...
This skill automates the installation of a skill tracking system for Claude Code projects. The system uses Claude Code hooks to automatically log all skill invocations, their duration, and the prompts that triggered them. This data enables pattern analysis to identify frequently repeated workflows that could become new skills.
Use this skill when:
Create the necessary directories for hooks, scripts, and logs:
mkdir -p .claude/hooks .claude/scripts .claude/activity-logs
Copy the hook scripts from this skill's scripts/ directory to .claude/hooks/:
Make the hook scripts executable:
chmod +x .claude/hooks/*.sh
Copy the analysis script from this skill's scripts/ directory to .claude/scripts/:
Make the analysis script executable:
chmod +x .claude/scripts/analyze-skills.py
Copy the settings.json template from this skill's assets/ directory to .claude/settings.json. This configuration registers three hooks:
Copy the README.md from this skill's assets/ directory to .claude/README.md. This provides documentation on:
Add the activity logs directory to .gitignore to prevent tracking log files:
echo ".claude/activity-logs/" >> .gitignore
echo ".claude/settings.local.json" >> .gitignore
Confirm all files are in place:
ls -la .claude/hooks/
ls -la .claude/scripts/
cat .claude/settings.json
After installation, the tracking system operates automatically:
.claude/activity-logs/ as JSONL filesWhat Gets Tracked (v1.2):
Run the analysis scripts to generate insights:
Pattern and Performance Analysis:
.claude/scripts/analyze-skills.py
Token Usage and Cost Analysis (v1.2):
.claude/scripts/show-skill-tokens.sh
The analysis reports include:
# Skill Usage Analysis Report
**Total skill invocations:** 15
## Most Used Skills
- **microsim-p5**: 7x
- **learning-graph-generator**: 5x
- **glossary-generator**: 3x
## Skill Performance (Average Duration)
- **learning-graph-generator**
- Average: 2m 34s
- Total time: 12m 50s
- Invocations: 5x
## Insights & Suggestions
### Frequently Used Skills
- **microsim-p5** (7x): Could benefit from optimization or templates
### Total Time Automated
Skills have automated **45m 23s** of work
The system creates two JSONL log files:
Logs user prompts with session correlation:
{"timestamp": "2025-11-22 14:23:45", "epoch": "1732299825", "session": "abc123", "prompt": "create a learning graph"}
Logs skill start/end events with duration and token usage:
{"timestamp": "2025-11-22 14:23:46", "epoch": "1732299826", "session": "abc123", "skill": "learning-graph-generator", "event": "start"}
{"timestamp": "2025-11-22 14:26:20", "epoch": "1732299980", "session": "abc123", "skill": "learning-graph-generator", "event": "end", "duration_seconds": "154", "input_tokens": 12000, "output_tokens": 8500, "total_tokens": 84200, "cache_read_tokens": 62400, "cache_creation_tokens": 1300}
Current setup: Project-specific tracking (logs in .claude/activity-logs/)
For global tracking across all projects:
settings.json to ~/.claude/settings.jsonLOG_DIR in hook scripts to ~/.claude/activity-logsExtend the hook scripts to capture:
Hooks receive full JSON context via stdin with tool names, parameters, and outputs.
All tracking data is stored locally:
.claude/activity-logs/.gitignoreTo delete all tracking data:
rm -rf .claude/activity-logs
IMPORTANT FIX (v1.1): The hook scripts now use jq -nc instead of jq -n to generate compact JSON output. This is critical for proper JSONL format.
If you encounter errors like:
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes
Your existing log files may have pretty-printed JSON. Fix with:
jq -c '.' .claude/activity-logs/prompts.jsonl > temp && mv temp .claude/activity-logs/prompts.jsonl
jq -c '.' .claude/activity-logs/skill-usage.jsonl > temp && mv temp .claude/activity-logs/skill-usage.jsonl
Verify hook configuration:
cat .claude/settings.json
Check script permissions:
ls -l .claude/hooks/*.sh
Ensure directories exist:
mkdir -p .claude/activity-logs
Use a skill to trigger logging, then check:
ls -la .claude/activity-logs/
Logs are created only after skill usage. Run any skill first, then execute the analysis script.
For comprehensive troubleshooting, see the README.md in this skill directory, which includes:
-c flag fixThis skill includes:
.claude/settings.json