{"hooks":{"PostToolUse":[{"hooks":[{"type":"command","command":".claude/hooks/track-activity.sh","description":"Log all tool usage for pattern analysis"}]}],"UserPromptSubmit":[{"hooks":[{"type":"command","command":".claude/hooks/track-prompts.sh","description":"Log user prompts for task analysis"}]}],"SessionStart":[{"hooks":[{"type":"command","command":".claude/hooks/session-start.sh","description":"Initialize activity tracking for session"}]}]}}```##2.ActivityTrackingScripts.claude/hooks/track-activity.sh(logstoolusage):```sh#!/bin/bashHOOK_INPUT=$(cat)TOOL_NAME=$(echo"$HOOK_INPUT"|jq-r'.tool_name')SESSION_ID=$(echo"$HOOK_INPUT"|jq-r'.session_id')CWD=$(echo"$HOOK_INPUT"|jq-r'.cwd')TIMESTAMP=$(date'+%Y-%m-%d%H:%M:%S')#Createlogdirectorymkdir-p~/.claude/activity-logs#LogasJSONLforeasyprocessingLOG_FILE=~/.claude/activity-logs/tool-usage.jsonlecho"{\"timestamp\":\"$TIMESTAMP\",\"tool\":\"$TOOL_NAME\",\"session\":\"$SESSION_ID\",\"project\":\"$CWD\"}">>"$LOG_FILE"exit0
.claude/hooks/track-prompts.sh (logs user requests):
1 2 3 4 5 6 7 8 91011121314151617181920
#!/bin/bashHOOK_INPUT=$(cat)PROMPT=$(echo"$HOOK_INPUT"|jq-r'.prompt')SESSION_ID=$(echo"$HOOK_INPUT"|jq-r'.session_id')TIMESTAMP=$(date'+%Y-%m-%d %H:%M:%S')# Create log directory
mkdir-p~/.claude/activity-logs
# Log prompt with metadataLOG_FILE=~/.claude/activity-logs/prompts.jsonl
jq-n\--argts"$TIMESTAMP"\--argsid"$SESSION_ID"\--argp"$PROMPT"\'{timestamp: $ts, session: $sid, prompt: $p}'>>"$LOG_FILE"# Allow the prompt to continueexit0
#!/usr/bin/env python3"""Analyze Claude Code activity logs to suggest new skills."""importjsonfromcollectionsimportCounter,defaultdictfromdatetimeimportdatetimefrompathlibimportPathLOG_DIR=Path.home()/".claude"/"activity-logs"defload_jsonl(filepath):"""Load JSONL file into list of dicts."""ifnotfilepath.exists():return[]withopen(filepath)asf:return[json.loads(line)forlineinfifline.strip()]defanalyze_tool_usage():"""Find most-used tool combinations (potential skill patterns)."""tool_log=load_jsonl(LOG_DIR/"tool-usage.jsonl")# Group tools by sessionsessions=defaultdict(list)forentryintool_log:sessions[entry['session']].append(entry['tool'])# Find common sequences (2-tool and 3-tool patterns)sequences_2=[]sequences_3=[]fortoolsinsessions.values():foriinrange(len(tools)-1):sequences_2.append(f"{tools[i]} → {tools[i+1]}")foriinrange(len(tools)-2):sequences_3.append(f"{tools[i]} → {tools[i+1]} → {tools[i+2]}")print("## Most Common Tool Sequences\n")print("### 2-Tool Patterns:")forseq,countinCounter(sequences_2).most_common(10):print(f" {count:3d}x {seq}")print("\n### 3-Tool Patterns:")forseq,countinCounter(sequences_3).most_common(10):print(f" {count:3d}x {seq}")returnCounter(sequences_2),Counter(sequences_3)defanalyze_prompts():"""Identify common task types from user prompts."""prompt_log=load_jsonl(LOG_DIR/"prompts.jsonl")# Simple keyword analysiskeywords=[]forentryinprompt_log:prompt_lower=entry['prompt'].lower()keywords.extend(prompt_lower.split())# Find action verbs (common commands)action_verbs=['create','generate','build','update','analyze','fix','debug','refactor','test','deploy','write','read','search','find','review']verb_counts=Counter()forverbinaction_verbs:verb_counts[verb]=sum(1forpinprompt_logifverbinp['prompt'].lower())print("\n## Common Task Types (Action Verbs)\n")forverb,countinverb_counts.most_common(15):ifcount>0:print(f" {count:3d}x {verb}")returnverb_countsdefsuggest_skills(tool_patterns,prompt_verbs):"""Suggest potential new skills based on activity patterns."""print("\n## Suggested New Skills\n")# Look for repetitive patternssuggestions=[]# Pattern-based suggestionsforpattern,countintool_patterns.most_common(5):ifcount>=3:# Repeated at least 3 timessuggestions.append({'name':f"Automated: {pattern.replace(' → ','-')}",'reason':f"You've done this sequence {count} times",'pattern':pattern})# Verb-based suggestionscommon_verbs=[vforv,cinprompt_verbs.items()ifc>=5]if'generate'incommon_verbs:suggestions.append({'name':'Content generator for your domain','reason':f"You request generation {prompt_verbs['generate']} times",'pattern':'generate-*'})if'analyze'incommon_verbs:suggestions.append({'name':'Analysis automation skill','reason':f"You run analysis {prompt_verbs['analyze']} times",'pattern':'analyze-*'})fori,suggestioninenumerate(suggestions,1):print(f"{i}. **{suggestion['name']}**")print(f" - Reason: {suggestion['reason']}")print(f" - Pattern: `{suggestion['pattern']}`\n")defmain():print("# Claude Code Activity Analysis\n")print(f"Log directory: {LOG_DIR}\n")# Analyze tool usage patternsseq2,seq3=analyze_tool_usage()# Analyze prompt patternsverbs=analyze_prompts()# Generate skill suggestionssuggest_skills(seq3ifseq3elseseq2,verbs)if__name__=="__main__":main()
4. How to Use This System
Step 1: Set up the hooks
# Create hook directory
mkdir -p .claude/hooks
# Create the tracking scripts (I can create these for you)
chmod +x .claude/hooks/*.sh
Step 2: Work normally in Claude Code
- All tool usage and prompts are automatically logged
- No disruption to your workflow
- Logs accumulate in ~/.claude/activity-logs/
Step 3: Analyze your patterns weekly
python .claude/scripts/analyze-activity.py
Step 4: Review with Claude
- Share the analysis output with me
- I'll identify specific repetitive workflows
- We'll design custom skills for your most common patterns
Example Output
After a week of use, you might see:
## Most Common Tool Sequences
## Common Task Types
15x fix
12x update
8x analyze
## Suggested New Skills
Code Fix Automation
Reason: You do Grep→Read→Edit 12 times
Pattern: grep-read-edit
Analysis Report Generator
Reason: You run analysis 8 times
Pattern: analyze-*
Then I can help you create skills like:
- bug-fix-assistant - automates your grep→read→edit pattern
- code-analysis-reporter - generates analysis reports in your style