skill-learner
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSkill Learner
Skill Learner
Automatically analyze completed work, extract reusable patterns, and create/enhance skills for continual organizational learning.
自动分析已完成的工作,提取可复用模式,并创建/增强技能以实现组织的持续学习。
Quick Start
快速开始
bash
undefinedbash
undefinedManual trigger after commit
Manual trigger after commit
/skill-learner
/skill-learner
Auto-triggers after:
Auto-triggers after:
- git commit (via post-commit hook)
- git commit (via post-commit hook)
- Task completion
- Task completion
- Feature implementation
- Feature implementation
Review learning
Review learning
cat .claude/skill-learning-log.md
undefinedcat .claude/skill-learning-log.md
undefinedWhen to Use
适用场景
AUTO-EXECUTES (via hook):
- After every git commit
- After task completion
- After feature implementation
- After bug fixes with significant patterns
- After refactoring work
MANUAL TRIGGER:
- To analyze recent work history
- To review learning opportunities
- To create skills from existing patterns
- After completing a project phase
- During knowledge capture sessions
自动执行(通过钩子):
- 每次git提交后
- 任务完成后
- 功能实现后
- 修复带有重要模式的bug后
- 重构工作后
手动触发:
- 分析近期工作历史
- 审视学习机会
- 从现有模式创建技能
- 完成项目阶段后
- 知识捕获会议期间
Prerequisites
前置条件
- Git repository with commit history
- Access to committed files and diffs
- (Optional) Skills directory for new skill creation
- (Optional) Internet for pattern research
- 带有提交历史的Git仓库
- 可访问已提交的文件和差异内容
- (可选)用于创建新技能的技能目录
- (可选)用于模式研究的网络连接
Overview
概述
The skill-learner performs post-commit analysis to identify reusable patterns, common workflows, and valuable techniques from completed work. It automatically creates new skills or enhances existing ones, ensuring continuous organizational learning.
Skill Learner执行提交后分析,从已完成的工作中识别可复用模式、通用工作流和有价值的技术。它会自动创建新技能或增强现有技能,确保组织的持续学习。
What It Analyzes
分析内容
- Commit Content: Files changed, code added, patterns used
- Commit Message: Task description, context, intent
- Work Patterns: Repeated workflows, common operations
- Problem Solutions: How bugs were fixed, how features were built
- Tool Usage: Libraries, frameworks, techniques employed
- Documentation: Comments, docs added, conventions followed
- 提交内容:修改的文件、添加的代码、使用的模式
- 提交信息:任务描述、上下文、意图
- 工作模式:重复的工作流、常见操作
- 问题解决方案:bug修复方式、功能构建方法
- 工具使用:采用的库、框架、技术
- 文档:添加的注释、文档、遵循的规范
Output
输出内容
Generates:
- Pattern analysis report
- Skill creation recommendations
- Enhanced existing skills
- Learning log with insights
- Knowledge base entries
生成:
- 模式分析报告
- 技能创建建议
- 增强后的现有技能
- 包含见解的学习日志
- 知识库条目
Core Operations
核心操作
1. Commit Analysis
1. 提交分析
Analyzes Last Commit:
bash
undefined分析最近一次提交:
bash
undefinedExtract commit metadata
Extract commit metadata
COMMIT_HASH=$(git rev-parse HEAD)
COMMIT_MSG=$(git log -1 --pretty=%B)
COMMIT_AUTHOR=$(git log -1 --pretty=%an)
COMMIT_DATE=$(git log -1 --pretty=%ai)
COMMIT_HASH=$(git rev-parse HEAD)
COMMIT_MSG=$(git log -1 --pretty=%B)
COMMIT_AUTHOR=$(git log -1 --pretty=%an)
COMMIT_DATE=$(git log -1 --pretty=%ai)
Get changed files
Get changed files
git diff-tree --no-commit-id --name-only -r HEAD
git diff-tree --no-commit-id --name-only -r HEAD
Get diff content
Get diff content
git diff HEAD^ HEAD
**Example Analysis:**
```markdowngit diff HEAD^ HEAD
**分析示例:**
```markdownCommit Analysis
Commit Analysis
Commit: a1b2c3d4
Message: Add interactive NPV calculator with Plotly visualization
Author: Developer
Date: 2026-01-07 14:30:00
Commit: a1b2c3d4
Message: Add interactive NPV calculator with Plotly visualization
Author: Developer
Date: 2026-01-07 14:30:00
Files Changed (12)
Files Changed (12)
- src/modules/npv/calculator.py (new)
- src/modules/npv/visualizer.py (new)
- src/modules/npv/init.py (new)
- tests/unit/test_npv_calculator.py (new)
- config/input/npv_analysis.yaml (new)
- scripts/run_npv_analysis.sh (new)
- docs/npv_calculator.md (new)
- ... 5 more files
- src/modules/npv/calculator.py (new)
- src/modules/npv/visualizer.py (new)
- src/modules/npv/init.py (new)
- tests/unit/test_npv_calculator.py (new)
- config/input/npv_analysis.yaml (new)
- scripts/run_npv_analysis.sh (new)
- docs/npv_calculator.md (new)
- ... 5 more files
Code Additions
Code Additions
- Lines added: 847
- Lines removed: 23
- Net change: +824
- Lines added: 847
- Lines removed: 23
- Net change: +824
Technologies Used
Technologies Used
- Plotly for interactive visualization
- Pandas for data handling
- NumPy for NPV calculations
- pytest for testing
undefined- Plotly for interactive visualization
- Pandas for data handling
- NumPy for NPV calculations
- pytest for testing
undefined2. Pattern Extraction
2. 模式提取
Identifies Reusable Patterns:
Pattern Types:
markdown
1. **Workflow Patterns**
- YAML config → Script execution → HTML report
- Data load → Process → Validate → Visualize → Save
2. **Code Patterns**
- Interactive plotting with Plotly
- CSV data loading with relative paths
- Modular calculator structure
- TDD test-first approach
3. **Tool Patterns**
- UV environment management
- Bash script execution
- YAML configuration files
- Plotly visualization
4. **Problem-Solving Patterns**
- NPV calculation with multiple discount rates
- Handling missing data gracefully
- Interactive parameter adjustment
- Real-time visualization updatesExample Extraction:
markdown
undefined识别可复用模式:
模式类型:
markdown
1. **Workflow Patterns**
- YAML config → Script execution → HTML report
- Data load → Process → Validate → Visualize → Save
2. **Code Patterns**
- Interactive plotting with Plotly
- CSV data loading with relative paths
- Modular calculator structure
- TDD test-first approach
3. **Tool Patterns**
- UV environment management
- Bash script execution
- YAML configuration files
- Plotly visualization
4. **Problem-Solving Patterns**
- NPV calculation with multiple discount rates
- Handling missing data gracefully
- Interactive parameter adjustment
- Real-time visualization updates提取示例:
markdown
undefinedPattern: Interactive Financial Calculator
Pattern: Interactive Financial Calculator
Problem Solved
Problem Solved
Need to calculate NPV with multiple scenarios and visualize results interactively.
Need to calculate NPV with multiple scenarios and visualize results interactively.
Solution Pattern
Solution Pattern
- YAML configuration with parameters
- Python calculator module
- Plotly visualization
- Bash execution wrapper
- HTML report generation
- YAML configuration with parameters
- Python calculator module
- Plotly visualization
- Bash execution wrapper
- HTML report generation
Reusability Score: 95/100
Reusability Score: 95/100
- Applicable to: IRR, ROI, payback period, sensitivity analysis
- Generic enough: Yes
- Well-documented: Yes
- Tested: Yes (85% coverage)
undefined- Applicable to: IRR, ROI, payback period, sensitivity analysis
- Generic enough: Yes
- Well-documented: Yes
- Tested: Yes (85% coverage)
undefined3. Skill Identification
3. 技能识别
Determines Skill Creation Need:
Decision Matrix:
CREATE NEW SKILL if:
✓ Pattern used 3+ times across commits
✓ Workflow is complex (5+ steps)
✓ Domain-specific knowledge required
✓ Significant time savings (>30 min per use)
✓ No existing skill covers it
ENHANCE EXISTING SKILL if:
✓ Pattern similar to existing skill
✓ New technique for known problem
✓ Updated best practices
✓ New tool/library version
✓ Improved approach discovered
SKIP if:
✗ One-time solution
✗ Trivial pattern (<3 steps)
✗ Already well-covered
✗ Repository-specific onlyExample Decision:
markdown
undefined判断是否需要创建技能:
决策矩阵:
CREATE NEW SKILL if:
✓ Pattern used 3+ times across commits
✓ Workflow is complex (5+ steps)
✓ Domain-specific knowledge required
✓ Significant time savings (>30 min per use)
✓ No existing skill covers it
ENHANCE EXISTING SKILL if:
✓ Pattern similar to existing skill
✓ New technique for known problem
✓ Updated best practices
✓ New tool/library version
✓ Improved approach discovered
SKIP if:
✗ One-time solution
✗ Trivial pattern (<3 steps)
✗ Already well-covered
✗ Repository-specific only决策示例:
markdown
undefinedSkill Decision: NPV Calculator
Skill Decision: NPV Calculator
Analysis
Analysis
- Frequency: Used 5 times in last month
- Complexity: 8-step workflow
- Domain Knowledge: Financial engineering
- Time Savings: ~2 hours per use
- Existing Skills: None for financial calculators
- Frequency: Used 5 times in last month
- Complexity: 8-step workflow
- Domain Knowledge: Financial engineering
- Time Savings: ~2 hours per use
- Existing Skills: None for financial calculators
Recommendation: CREATE NEW SKILL
Recommendation: CREATE NEW SKILL
Skill Name: financial-calculator-builder
Category: development/finance
Priority: High
Rationale:
- High reusability across energy economic analysis
- Complex enough to warrant skill documentation
- Significant time savings
- Establishes pattern for future financial tools
undefinedSkill Name: financial-calculator-builder
Category: development/finance
Priority: High
Rationale:
- High reusability across energy economic analysis
- Complex enough to warrant skill documentation
- Significant time savings
- Establishes pattern for future financial tools
undefined4. Skill Creation
4. 技能创建
Automatically Creates Skills:
Creation Process:
bash
1. Generate skill name from pattern
2. Extract workflow steps
3. Create SKILL.md with template
4. Document code examples
5. Add usage instructions
6. Link related skills
7. Update skills README
8. Commit new skillExample Skill Created:
markdown
---
name: financial-calculator-builder
description: Build interactive financial calculators (NPV, IRR, ROI) with Plotly visualization, YAML configuration, and HTML reporting.
version: 1.0.0
category: development/finance
created_from: commit a1b2c3d4
pattern_source: npv_calculator implementation
---自动创建技能:
创建流程:
bash
1. Generate skill name from pattern
2. Extract workflow steps
3. Create SKILL.md with template
4. Document code examples
5. Add usage instructions
6. Link related skills
7. Update skills README
8. Commit new skill创建的技能示例:
markdown
---
name: financial-calculator-builder
description: Build interactive financial calculators (NPV, IRR, ROI) with Plotly visualization, YAML configuration, and HTML reporting.
version: 1.0.0
category: development/finance
created_from: commit a1b2c3d4
pattern_source: npv_calculator implementation
---Financial Calculator Builder
Financial Calculator Builder
Create interactive financial analysis tools with visualization and reporting.
Create interactive financial analysis tools with visualization and reporting.
Quick Start
Quick Start
bash
undefinedbash
undefinedCreate NPV calculator
Create NPV calculator
/financial-calculator-builder npv
/financial-calculator-builder npv
Create IRR calculator
Create IRR calculator
/financial-calculator-builder irr
/financial-calculator-builder irr
Custom calculator
Custom calculator
/financial-calculator-builder custom --config config/calc.yaml
undefined/financial-calculator-builder custom --config config/calc.yaml
undefinedPattern
Pattern
- Define calculation in YAML config
- Implement calculator class
- Add Plotly visualization
- Create bash execution wrapper
- Generate HTML report
- Write tests (TDD)
[... full skill documentation ...]
undefined- Define calculation in YAML config
- Implement calculator class
- Add Plotly visualization
- Create bash execution wrapper
- Generate HTML report
- Write tests (TDD)
[... full skill documentation ...]
undefined5. Skill Enhancement
5. 技能增强
Updates Existing Skills:
Enhancement Types:
markdown
1. **Version Updates**
- New tool versions (Plotly 5.17 → 5.18)
- Updated APIs
- Deprecated method replacements
2. **Best Practice Improvements**
- Better error handling
- Performance optimizations
- Security enhancements
3. **New Examples**
- Additional use cases
- Real-world implementations
- Edge case handling
4. **Integration Points**
- New tool integrations
- Cross-skill workflows
- Automation hooksExample Enhancement:
markdown
undefined更新现有技能:
增强类型:
markdown
1. **Version Updates**
- New tool versions (Plotly 5.17 → 5.18)
- Updated APIs
- Deprecated method replacements
2. **Best Practice Improvements**
- Better error handling
- Performance optimizations
- Security enhancements
3. **New Examples**
- Additional use cases
- Real-world implementations
- Edge case handling
4. **Integration Points**
- New tool integrations
- Cross-skill workflows
- Automation hooks增强示例:
markdown
undefinedEnhancement: plotly-visualization skill
Enhancement: plotly-visualization skill
Commit: a1b2c3d4
Commit: a1b2c3d4
Pattern Found: Multi-scenario NPV visualization
Pattern Found: Multi-scenario NPV visualization
Enhancement Applied:
Enhancement Applied:
Added section "Financial Visualizations" to plotly-visualization skill:
New Example: Multi-Scenario Analysis
python
import plotly.graph_objects as goAdded section "Financial Visualizations" to plotly-visualization skill:
New Example: Multi-Scenario Analysis
python
import plotly.graph_objects as goCreate multi-scenario NPV plot
Create multi-scenario NPV plot
fig = go.Figure()
for scenario in scenarios:
fig.add_trace(go.Scatter(
x=scenario['years'],
y=scenario['npv'],
name=scenario['name'],
mode='lines+markers'
))
fig.update_layout(
title='NPV Analysis: Multiple Scenarios',
xaxis_title='Year',
yaxis_title='Net Present Value ($M)'
)
**Version**: 1.2.0 → 1.3.0
**Reason**: Added financial visualization patternsfig = go.Figure()
for scenario in scenarios:
fig.add_trace(go.Scatter(
x=scenario['years'],
y=scenario['npv'],
name=scenario['name'],
mode='lines+markers'
))
fig.update_layout(
title='NPV Analysis: Multiple Scenarios',
xaxis_title='Year',
yaxis_title='Net Present Value ($M)'
)
**Version**: 1.2.0 → 1.3.0
**Reason**: Added financial visualization patterns6. Knowledge Synthesis
6. 知识合成
Builds Organizational Knowledge:
Knowledge Base Structure:
.claude/knowledge/
├── patterns/
│ ├── financial-calculations.md
│ ├── interactive-visualization.md
│ └── data-pipelines.md
├── techniques/
│ ├── npv-calculation.md
│ ├── scenario-analysis.md
│ └── sensitivity-testing.md
└── lessons/
├── 2026-01-07-npv-calculator.md
└── ...Example Knowledge Entry:
markdown
undefined构建组织知识:
知识库结构:
.claude/knowledge/
├── patterns/
│ ├── financial-calculations.md
│ ├── interactive-visualization.md
│ └── data-pipelines.md
├── techniques/
│ ├── npv-calculation.md
│ ├── scenario-analysis.md
│ └── sensitivity-testing.md
└── lessons/
├── 2026-01-07-npv-calculator.md
└── ...知识库条目示例:
markdown
undefinedPattern: Interactive Financial Calculator
Pattern: Interactive Financial Calculator
Discovered: 2026-01-07 (commit a1b2c3d4)
Category: Financial Engineering
Reusability: High
Discovered: 2026-01-07 (commit a1b2c3d4)
Category: Financial Engineering
Reusability: High
Problem
Problem
Need to perform financial calculations (NPV, IRR, ROI) with:
- Multiple scenarios
- Interactive parameter adjustment
- Visual comparison
- Exportable reports
Need to perform financial calculations (NPV, IRR, ROI) with:
- Multiple scenarios
- Interactive parameter adjustment
- Visual comparison
- Exportable reports
Solution Pattern
Solution Pattern
1. Configuration (YAML)
1. Configuration (YAML)
yaml
calculation:
type: npv
discount_rates: [0.05, 0.08, 0.10, 0.12]
cash_flows: data/cash_flows.csv
scenarios:
- base
- optimistic
- pessimisticyaml
calculation:
type: npv
discount_rates: [0.05, 0.08, 0.10, 0.12]
cash_flows: data/cash_flows.csv
scenarios:
- base
- optimistic
- pessimistic2. Calculator Module (Python)
2. Calculator Module (Python)
python
class NPVCalculator:
def calculate(self, cash_flows, discount_rate):
return np.npv(discount_rate, cash_flows)
def multi_scenario(self, scenarios, rates):
results = {}
for scenario in scenarios:
for rate in rates:
npv = self.calculate(scenario.cash_flows, rate)
results[(scenario.name, rate)] = npv
return resultspython
class NPVCalculator:
def calculate(self, cash_flows, discount_rate):
return np.npv(discount_rate, cash_flows)
def multi_scenario(self, scenarios, rates):
results = {}
for scenario in scenarios:
for rate in rates:
npv = self.calculate(scenario.cash_flows, rate)
results[(scenario.name, rate)] = npv
return results3. Visualization (Plotly)
3. Visualization (Plotly)
Interactive multi-scenario comparison with hover tooltips.
Interactive multi-scenario comparison with hover tooltips.
4. Execution (Bash)
4. Execution (Bash)
bash
./scripts/run_npv_analysis.sh config/npv.yamlbash
./scripts/run_npv_analysis.sh config/npv.yamlLessons Learned
Lessons Learned
- YAML configuration makes calculators flexible
- Plotly enables interactive scenario exploration
- Modular design allows easy extension to other metrics
- TDD catches calculation errors early
- YAML configuration makes calculators flexible
- Plotly enables interactive scenario exploration
- Modular design allows easy extension to other metrics
- TDD catches calculation errors early
Applications
Applications
- ✅ NPV Calculator (implemented)
- 🔲 IRR Calculator (recommended)
- 🔲 ROI Calculator (recommended)
- 🔲 Payback Period Calculator (recommended)
- 🔲 Sensitivity Analysis Tool (high value)
- ✅ NPV Calculator (implemented)
- 🔲 IRR Calculator (recommended)
- 🔲 ROI Calculator (recommended)
- 🔲 Payback Period Calculator (recommended)
- 🔲 Sensitivity Analysis Tool (high value)
Related Skills
Related Skills
- financial-calculator-builder (created)
- plotly-visualization (enhanced)
- yaml-workflow-executor (existing)
undefined- financial-calculator-builder (created)
- plotly-visualization (enhanced)
- yaml-workflow-executor (existing)
undefinedLearning Log
学习日志
Maintains Continuous Learning Record:
Log Format:
markdown
undefined维护持续学习记录:
日志格式:
markdown
undefinedSkill Learning Log
Skill Learning Log
2026-01-07
2026-01-07
Commit: a1b2c3d4 - NPV Calculator Implementation
Commit: a1b2c3d4 - NPV Calculator Implementation
Patterns Extracted: 3
- Interactive financial calculator
- Multi-scenario analysis
- YAML-driven calculations
Skills Created: 1
- financial-calculator-builder (v1.0.0)
Skills Enhanced: 2
- plotly-visualization (v1.2.0 → v1.3.0)
- Added financial visualization examples
- yaml-workflow-executor (v2.1.0 → v2.1.1)
- Added financial config examples
Knowledge Added: 1
- patterns/interactive-financial-calculator.md
Reusability Score: 95/100
Time Savings: ~2 hours per future use
Learning Value: High - establishes financial tool pattern
Patterns Extracted: 3
- Interactive financial calculator
- Multi-scenario analysis
- YAML-driven calculations
Skills Created: 1
- financial-calculator-builder (v1.0.0)
Skills Enhanced: 2
- plotly-visualization (v1.2.0 → v1.3.0)
- Added financial visualization examples
- yaml-workflow-executor (v2.1.0 → v2.1.1)
- Added financial config examples
Knowledge Added: 1
- patterns/interactive-financial-calculator.md
Reusability Score: 95/100
Time Savings: ~2 hours per future use
Learning Value: High - establishes financial tool pattern
2026-01-06
2026-01-06
Commit: e5f6g7h8 - Marine Safety Data Processor
Commit: e5f6g7h8 - Marine Safety Data Processor
Patterns Extracted: 2
- CSV data validation
- Safety incident categorization
Skills Enhanced: 1
- data-pipeline-processor (v3.0.0 → v3.1.0)
- Added safety data validation patterns
Knowledge Added: 1
- techniques/safety-data-validation.md
Reusability Score: 75/100
Time Savings: ~1 hour per future use
Learning Value: Medium - domain-specific but valuable
undefinedPatterns Extracted: 2
- CSV data validation
- Safety incident categorization
Skills Enhanced: 1
- data-pipeline-processor (v3.0.0 → v3.1.0)
- Added safety data validation patterns
Knowledge Added: 1
- techniques/safety-data-validation.md
Reusability Score: 75/100
Time Savings: ~1 hour per future use
Learning Value: Medium - domain-specific but valuable
undefinedExecution Checklist
执行检查清单
Pre-Analysis:
- Git repository is valid
- At least one commit exists
- Access to skills directory
- Access to knowledge base
Analysis Phase:
- Extract commit metadata
- Analyze changed files
- Review code diff
- Identify patterns used
- Assess reusability
Decision Phase:
- Check for existing similar skills
- Calculate reusability score
- Determine create vs enhance vs skip
- Prioritize recommendations
Action Phase:
- Create new skills (if warranted)
- Enhance existing skills
- Update knowledge base
- Append to learning log
- Commit skill changes
Post-Analysis:
- Report generation
- Metrics tracking
- User notification (optional)
分析前:
- Git仓库有效
- 至少存在一次提交
- 可访问技能目录
- 可访问知识库
分析阶段:
- 提取提交元数据
- 分析修改的文件
- 查看代码差异
- 识别使用的模式
- 评估可复用性
决策阶段:
- 检查是否存在类似的现有技能
- 计算可复用性得分
- 决定创建/增强/跳过
- 对建议进行优先级排序
执行阶段:
- 创建新技能(如有必要)
- 增强现有技能
- 更新知识库
- 添加到学习日志
- 提交技能变更
分析后:
- 生成报告
- 指标跟踪
- 用户通知(可选)
Hook Integration
钩子集成
Post-Commit Hook
提交后钩子
Hook Configuration:
bash
undefined钩子配置:
bash
undefined.claude/hooks/post-commit.sh
.claude/hooks/post-commit.sh
#!/bin/bash
#!/bin/bash
Auto-execute skill learning after commits
Auto-execute skill learning after commits
REPO_PATH="$(pwd)"
SKILL_PATH="${HOME}/.claude/skills/workspace-hub/skill-learner"
REPO_PATH="$(pwd)"
SKILL_PATH="${HOME}/.claude/skills/workspace-hub/skill-learner"
Allow bypassing skill learning
Allow bypassing skill learning
if [ "${SKIP_SKILL_LEARNING:-0}" = "1" ]; then
echo "Skill learning skipped (SKIP_SKILL_LEARNING=1)"
exit 0
fi
if [ "${SKIP_SKILL_LEARNING:-0}" = "1" ]; then
echo "Skill learning skipped (SKIP_SKILL_LEARNING=1)"
exit 0
fi
Only run on significant commits
Only run on significant commits
LINES_CHANGED=$(git diff HEAD^ HEAD --shortstat | grep -oE '[0-9]+ insertion' | grep -oE '[0-9]+' || echo 0)
if [ "$LINES_CHANGED" -lt 50 ]; then
echo "Small commit (<50 lines), skipping skill learning"
exit 0
fi
LINES_CHANGED=$(git diff HEAD^ HEAD --shortstat | grep -oE '[0-9]+ insertion' | grep -oE '[0-9]+' || echo 0)
if [ "$LINES_CHANGED" -lt 50 ]; then
echo "Small commit (<50 lines), skipping skill learning"
exit 0
fi
Run skill learning
Run skill learning
echo "Analyzing commit for learning opportunities..."
"$SKILL_PATH/analyze_commit.sh" "$REPO_PATH"
exit 0
**Trigger Conditions:**
- After git commit (>50 lines changed)
- After task completion
- After feature merges
- Manual trigger via `/skill-learner`
**Bypass Hook:**
```bashecho "Analyzing commit for learning opportunities..."
"$SKILL_PATH/analyze_commit.sh" "$REPO_PATH"
exit 0
**触发条件:**
- git提交后(修改行数>50)
- 任务完成后
- 功能合并后
- 通过`/skill-learner`手动触发
**跳过钩子:**
```bashSkip learning for trivial commits
Skip learning for trivial commits
SKIP_SKILL_LEARNING=1 git commit -m "Fix typo"
SKIP_SKILL_LEARNING=1 git commit -m "Fix typo"
Or disable temporarily
Or disable temporarily
mv .claude/hooks/post-commit.sh .claude/hooks/post-commit.sh.disabled
undefinedmv .claude/hooks/post-commit.sh .claude/hooks/post-commit.sh.disabled
undefinedAutomation Scripts
自动化脚本
1. Commit Analyzer
1. 提交分析器
Location:
analyze_commit.shbash
#!/bin/bash位置:
analyze_commit.shbash
#!/bin/bashAnalyze recent commit for learning opportunities
Analyze recent commit for learning opportunities
REPO_PATH="${1:-.}"
COMMIT_HASH="${2:-HEAD}"
REPO_PATH="${1:-.}"
COMMIT_HASH="${2:-HEAD}"
Extract commit info
Extract commit info
analyze_commit() {
echo "Analyzing commit: $COMMIT_HASH"
# Get commit metadata
local msg=$(git log -1 --pretty=%B $COMMIT_HASH)
local author=$(git log -1 --pretty=%an $COMMIT_HASH)
local date=$(git log -1 --pretty=%ai $COMMIT_HASH)
# Get changed files
local files=$(git diff-tree --no-commit-id --name-only -r $COMMIT_HASH)
# Analyze patterns
extract_patterns "$files"
# Make skill decisions
decide_skill_actions
# Generate report
generate_learning_report}
analyze_commit() {
echo "Analyzing commit: $COMMIT_HASH"
# Get commit metadata
local msg=$(git log -1 --pretty=%B $COMMIT_HASH)
local author=$(git log -1 --pretty=%an $COMMIT_HASH)
local date=$(git log -1 --pretty=%ai $COMMIT_HASH)
# Get changed files
local files=$(git diff-tree --no-commit-id --name-only -r $COMMIT_HASH)
# Analyze patterns
extract_patterns "$files"
# Make skill decisions
decide_skill_actions
# Generate report
generate_learning_report}
Extract reusable patterns
Extract reusable patterns
extract_patterns() {
local files="$1"
# Check for workflow patterns
if echo "$files" | grep -q "config/input/.*\.yaml"; then
echo "Pattern: YAML-driven workflow"
fi
if echo "$files" | grep -q "scripts/.*\.sh"; then
echo "Pattern: Bash execution script"
fi
# Check for code patterns
if git diff $COMMIT_HASH^ $COMMIT_HASH | grep -q "import plotly"; then
echo "Pattern: Plotly visualization"
fi
# More pattern detection...}
extract_patterns() {
local files="$1"
# Check for workflow patterns
if echo "$files" | grep -q "config/input/.*\.yaml"; then
echo "Pattern: YAML-driven workflow"
fi
if echo "$files" | grep -q "scripts/.*\.sh"; then
echo "Pattern: Bash execution script"
fi
# Check for code patterns
if git diff $COMMIT_HASH^ $COMMIT_HASH | grep -q "import plotly"; then
echo "Pattern: Plotly visualization"
fi
# More pattern detection...}
Decide whether to create/enhance skills
Decide whether to create/enhance skills
decide_skill_actions() {
# Reusability scoring
local score=0
# Check commit history for similar patterns
local pattern_count=$(git log --all --grep="similar pattern" | wc -l)
if [ $pattern_count -ge 3 ]; then
((score += 30))
fi
# Check code complexity
local lines_added=$(git diff $COMMIT_HASH^ $COMMIT_HASH --shortstat | grep -oE '[0-9]+ insertion' | grep -oE '[0-9]+')
if [ $lines_added -gt 100 ]; then
((score += 20))
fi
# Decision
if [ $score -ge 70 ]; then
echo "Recommendation: CREATE NEW SKILL"
elif [ $score -ge 40 ]; then
echo "Recommendation: ENHANCE EXISTING SKILL"
else
echo "Recommendation: SKIP (low reusability)"
fi}
decide_skill_actions() {
# Reusability scoring
local score=0
# Check commit history for similar patterns
local pattern_count=$(git log --all --grep="similar pattern" | wc -l)
if [ $pattern_count -ge 3 ]; then
((score += 30))
fi
# Check code complexity
local lines_added=$(git diff $COMMIT_HASH^ $COMMIT_HASH --shortstat | grep -oE '[0-9]+ insertion' | grep -oE '[0-9]+')
if [ $lines_added -gt 100 ]; then
((score += 20))
fi
# Decision
if [ $score -ge 70 ]; then
echo "Recommendation: CREATE NEW SKILL"
elif [ $score -ge 40 ]; then
echo "Recommendation: ENHANCE EXISTING SKILL"
else
echo "Recommendation: SKIP (low reusability)"
fi}
Generate learning report
Generate learning report
generate_learning_report() {
local report_file=".claude/learning-reports/$(date +%Y-%m-%d)-$COMMIT_HASH.md"
mkdir -p "$(dirname "$report_file")"
{
echo "# Learning Report"
echo "**Commit**: $COMMIT_HASH"
echo "**Date**: $(date)"
echo ""
echo "## Patterns Extracted"
# ... pattern details ...
echo ""
echo "## Recommendations"
# ... recommendations ...
} > "$report_file"
echo "Learning report saved: $report_file"}
main "$@"
undefinedgenerate_learning_report() {
local report_file=".claude/learning-reports/$(date +%Y-%m-%d)-$COMMIT_HASH.md"
mkdir -p "$(dirname "$report_file")"
{
echo "# Learning Report"
echo "**Commit**: $COMMIT_HASH"
echo "**Date**: $(date)"
echo ""
echo "## Patterns Extracted"
# ... pattern details ...
echo ""
echo "## Recommendations"
# ... recommendations ...
} > "$report_file"
echo "Learning report saved: $report_file"}
main "$@"
undefined2. Skill Creator (from Pattern)
2. 从模式创建技能
Location:
create_skill_from_pattern.shbash
#!/bin/bash位置:
create_skill_from_pattern.shbash
#!/bin/bashCreate new skill from extracted pattern
Create new skill from extracted pattern
PATTERN_NAME="$1"
CATEGORY="${2:-development}"
SOURCE_COMMIT="$3"
PATTERN_NAME="$1"
CATEGORY="${2:-development}"
SOURCE_COMMIT="$3"
Generate skill from template
Generate skill from template
generate_skill() {
local skill_dir="${HOME}/.claude/skills/${CATEGORY}/${PATTERN_NAME}"
mkdir -p "$skill_dir"
# Create SKILL.md
cat > "${skill_dir}/SKILL.md" << EOFname: ${PATTERN_NAME} description: Auto-generated skill from commit pattern version: 1.0.0 category: ${CATEGORY} created_from: ${SOURCE_COMMIT}
generate_skill() {
local skill_dir="${HOME}/.claude/skills/${CATEGORY}/${PATTERN_NAME}"
mkdir -p "$skill_dir"
# Create SKILL.md
cat > "${skill_dir}/SKILL.md" << EOFname: ${PATTERN_NAME} description: Auto-generated skill from commit pattern version: 1.0.0 category: ${CATEGORY} created_from: ${SOURCE_COMMIT}
${PATTERN_NAME^} Skill
${PATTERN_NAME^} Skill
Auto-generated from repeated commit pattern
Auto-generated from repeated commit pattern
Pattern Source
Pattern Source
Commit: ${SOURCE_COMMIT}
Extracted: $(date)
[... skill template ...]
EOF
echo "Skill created: $skill_dir"}
generate_skill
undefinedCommit: ${SOURCE_COMMIT}
Extracted: $(date)
[... skill template ...]
EOF
echo "Skill created: $skill_dir"}
generate_skill
undefined3. Bulk Learning Analysis
3. 批量学习分析
Analyzes Recent Commit History:
bash
#!/bin/bash分析近期提交历史:
bash
#!/bin/bashAnalyze last N commits for learning opportunities
Analyze last N commits for learning opportunities
REPO_PATH="${1:-.}"
COMMIT_COUNT="${2:-10}"
echo "Analyzing last $COMMIT_COUNT commits..."
for commit in $(git log -n $COMMIT_COUNT --pretty=%H); do
echo "Commit: $commit"
./analyze_commit.sh "$REPO_PATH" "$commit"
echo ""
done
REPO_PATH="${1:-.}"
COMMIT_COUNT="${2:-10}"
echo "Analyzing last $COMMIT_COUNT commits..."
for commit in $(git log -n $COMMIT_COUNT --pretty=%H); do
echo "Commit: $commit"
./analyze_commit.sh "$REPO_PATH" "$commit"
echo ""
done
Generate aggregate report
Generate aggregate report
echo "Generating aggregate learning report..."
./generate_aggregate_report.sh
undefinedecho "Generating aggregate learning report..."
./generate_aggregate_report.sh
undefinedError Handling
错误处理
No Patterns Found
未找到模式
ℹ️ Info: No reusable patterns detected in commit
Reason: Commit too small or repository-specific changes
Action: No skills created, logged for future pattern detectionℹ️ Info: No reusable patterns detected in commit
Reason: Commit too small or repository-specific changes
Action: No skills created, logged for future pattern detectionSkill Already Exists
技能已存在
⚠️ Warning: Skill 'financial-calculator-builder' already exists
Action Options:
1. Enhance existing skill (recommended)
2. Create variant skill (e.g., 'financial-calculator-builder-v2')
3. Skip creation
Recommendation: ENHANCE⚠️ Warning: Skill 'financial-calculator-builder' already exists
Action Options:
1. Enhance existing skill (recommended)
2. Create variant skill (e.g., 'financial-calculator-builder-v2')
3. Skip creation
Recommendation: ENHANCEInvalid Pattern
无效模式
❌ Error: Pattern extraction failed
Reason: Unable to identify coherent workflow or technique
Action: Manual review required - see .claude/learning-reports/error-*.md❌ Error: Pattern extraction failed
Reason: Unable to identify coherent workflow or technique
Action: Manual review required - see .claude/learning-reports/error-*.mdSkills Directory Not Found
技能目录未找到
⚠️ Warning: Skills directory not accessible
Location Expected: ~/.claude/skills/ or .claude/skills/
Action: Create skills directory or configure SKILLS_PATH⚠️ Warning: Skills directory not accessible
Location Expected: ~/.claude/skills/ or .claude/skills/
Action: Create skills directory or configure SKILLS_PATHMetrics & Success Criteria
指标与成功标准
Learning Metrics
学习指标
| Metric | Target | Measurement |
|---|---|---|
| Patterns Extracted/Week | 5-10 | Count from learning log |
| Skills Created/Month | 2-5 | New skills in directory |
| Skills Enhanced/Month | 5-10 | Version bumps recorded |
| Reusability Score Avg | > 70 | Average across patterns |
| Time Savings | > 10 hrs/month | Estimated from usage |
| 指标 | 目标 | 测量方式 |
|---|---|---|
| 每周提取的模式数量 | 5-10 | 从学习日志统计 |
| 每月创建的技能数量 | 2-5 | 目录中的新技能 |
| 每月增强的技能数量 | 5-10 | �记录的版本更新 |
| 平均可复用性得分 | > 70 | 所有模式的平均值 |
| 时间节省 | > 10小时/月 | 根据使用情况估算 |
Quality Metrics
质量指标
| Metric | Target | Measurement |
|---|---|---|
| Pattern Accuracy | > 90% | Correct pattern identification |
| Skill Usefulness | > 80% | Skills used after creation |
| Enhancement Value | > 70% | Enhanced skills improve workflow |
| False Positives | < 10% | Incorrect skill creation rate |
| 指标 | 目标 | 测量方式 |
|---|---|---|
| 模式准确率 | > 90% | 正确识别模式的比例 |
| 技能实用性 | > 80% | 创建后被使用的技能比例 |
| 增强价值 | > 70% | 增强后的技能对工作流的提升程度 |
| 误报率 | < 10% | 错误创建技能的比例 |
Adoption Metrics
采用指标
| Metric | Target | Current |
|---|---|---|
| Hook Installation | 100% repos | Track per repo |
| Learning Log Size | Growing | Lines in log |
| Knowledge Base Growth | +10 entries/month | Count entries |
| Skill Library Size | +3-5 skills/month | Total skills |
| 指标 | 目标 | 当前值 |
|---|---|---|
| 钩子安装率 | 100%仓库 | 按仓库统计 |
| 学习日志规模 | 持续增长 | 日志行数 |
| 知识库增长 | +10条目/月 | 条目数量 |
| 技能库规模 | +3-5技能/月 | 总技能数量 |
Integration Points
集成点
With Session Start Routine
与会话启动流程集成
bash
undefinedbash
undefinedReview recent learning at session start
Review recent learning at session start
/session-start-routine
/session-start-routine
Includes:
Includes:
- Recent patterns extracted
- Recent patterns extracted
- Skills created/enhanced
- Skills created/enhanced
- Learning opportunities
- Learning opportunities
undefinedundefinedWith Skill Creator
与技能创建器集成
bash
undefinedbash
undefinedManual skill creation uses patterns
Manual skill creation uses patterns
/skill-creator new-feature
/skill-creator new-feature
Skill learner provides:
Skill learner provides:
- Similar existing patterns
- Similar existing patterns
- Related skills
- Related skills
- Best practices from learning log
- Best practices from learning log
undefinedundefinedWith Repo Sync
与仓库同步集成
bash
undefinedbash
undefinedLearning across all repos
Learning across all repos
./bulk_learning_analysis.sh
./bulk_learning_analysis.sh
Aggregate patterns from entire workspace
Aggregate patterns from entire workspace
undefinedundefinedBest Practices
最佳实践
1. Review Learning Log Regularly
1. 定期查看学习日志
bash
undefinedbash
undefinedWeekly review
Weekly review
cat .claude/skill-learning-log.md | head -100
cat .claude/skill-learning-log.md | head -100
Identify high-value patterns
Identify high-value patterns
grep "Reusability Score: 9" .claude/skill-learning-log.md
undefinedgrep "Reusability Score: 9" .claude/skill-learning-log.md
undefined2. Refine Patterns
2. 优化模式
bash
undefinedbash
undefinedIf pattern is too specific, generalize
If pattern is too specific, generalize
If pattern is too generic, specialize
If pattern is too generic, specialize
Document edge cases
Document edge cases
undefinedundefined3. Link Related Knowledge
3. 关联相关知识
bash
undefinedbash
undefinedCross-reference skills
Cross-reference skills
Update related documentation
Update related documentation
Share patterns across teams
Share patterns across teams
undefinedundefined4. Validate Skill Usefulness
4. 验证技能实用性
bash
undefinedbash
undefinedTrack skill usage
Track skill usage
Deprecate unused skills
Deprecate unused skills
Enhance frequently-used skills
Enhance frequently-used skills
undefinedundefinedRelated Skills
相关技能
- skill-creator - Manual skill creation
- session-start-routine - Session initialization
- repo-readiness - Repository preparation
- compliance-check - Standards validation
- skill-creator - 手动创建技能
- session-start-routine - 会话初始化
- repo-readiness - 仓库准备
- compliance-check - 标准验证
References
参考资料
- Skill Template
- Pattern Library
- Learning Framework
- Skill Template
- Pattern Library
- Learning Framework
Version History
版本历史
- 1.0.0 (2026-01-07): Initial release - post-commit skill learning with pattern extraction, skill creation/enhancement, knowledge synthesis, auto-hook integration, learning log, metrics tracking, and continual learning capabilities
- 1.0.0 (2026-01-07): 初始版本 - 提交后技能学习,包含模式提取、技能创建/增强、知识合成、自动钩子集成、学习日志、指标跟踪和持续学习功能