Component Improvement Scheduler Hook
Triggers the component improvement cycle based on schedule, quality thresholds, or manual invocation.
Hook Triggers
| Trigger | Condition | Action |
|---|---|---|
periodic.weekly | Every 7 days | Full improvement cycle |
periodic.daily | Every 24 hours | Quick analysis only |
threshold.quality_drop | Average score <60% | Emergency improvement |
threshold.p0_detected | P0 component found | Immediate attention |
manual.improvement | User invocation | On-demand cycle |
Hook Configuration
Add to .claude/settings.json:
{
"hooks": {
"component-improvement-scheduler": {
"enabled": true,
"schedule": {
"weekly": "sunday 02:00",
"daily_check": "06:00"
},
"thresholds": {
"quality_alert": 60,
"p0_trigger": true,
"min_components": 5
},
"actions": {
"weekly": "full_cycle",
"daily": "analysis_only",
"threshold": "priority_cycle"
}
}
}
}
Trigger Logic
Weekly Cycle (Full)
def weekly_improvement_cycle():
"""Run full improvement cycle every week."""
# 1. Check if cycle needed
last_run = get_last_improvement_run()
if days_since(last_run) < 7:
return "Skipped: Recent run exists"
# 2. Load retrospective data
retrospective = load_skill_learnings()
# 3. Identify components needing improvement
low_scoring = [s for s in retrospective['skills']
if s['success_rate'] < 0.7]
# 4. Run improvement cycle
if len(low_scoring) >= MIN_COMPONENTS:
run_improvement_cycle(low_scoring)
return "✅ Weekly improvement cycle complete"
return "Skipped: Insufficient components below threshold"
Daily Check (Analysis Only)
def daily_quality_check():
"""Daily check for quality drops."""
# 1. Get current quality metrics
metrics = get_quality_metrics()
# 2. Check for alerts
alerts = []
if metrics['average_score'] < QUALITY_ALERT_THRESHOLD:
alerts.append({
'type': 'quality_drop',
'message': f"Average score dropped to {metrics['average_score']}%"
})
if metrics['p0_count'] > 0:
alerts.append({
'type': 'p0_detected',
'message': f"{metrics['p0_count']} P0 components detected"
})
# 3. Report or trigger
if alerts:
send_improvement_alert(alerts)
if any(a['type'] == 'p0_detected' for a in alerts):
trigger_priority_improvement()
return alerts
Threshold Trigger (Priority)
def threshold_trigger(event_type, data):
"""Handle threshold-based triggers."""
if event_type == 'quality_drop':
# Run analysis and enhance critical components
components = get_critical_components()
run_priority_improvement(components, priority='P0')
elif event_type == 'p0_detected':
# Immediate improvement for P0 components
p0_components = get_p0_components()
for component in p0_components:
run_single_improvement(component)
Integration with Claude Code
Hook Registration
# In settings.json hooks section
{
"hooks": [
{
"command": "python3 hooks/component-improvement-scheduler.py",
"event": "periodic.weekly",
"description": "Weekly component improvement cycle"
},
{
"command": "python3 hooks/component-improvement-scheduler.py --check",
"event": "session.start",
"description": "Check for pending improvements"
}
]
}
Session Start Check
When a session starts, check if improvement is needed:
# Auto-check at session start
python3 hooks/component-improvement-scheduler.py --check
# Output if improvement needed:
# ⚠️ Component improvement recommended
# - 5 components below 70% threshold
# - Last improvement: 8 days ago
# Run: /improve-components
CLI Usage
# Check if improvement needed
python3 hooks/component-improvement-scheduler.py --check
# Trigger manual cycle
python3 hooks/component-improvement-scheduler.py --trigger manual
# View schedule status
python3 hooks/component-improvement-scheduler.py --status
# Force weekly cycle
python3 hooks/component-improvement-scheduler.py --force weekly
Output Examples
Check Output
============================================================
Component Improvement Status
============================================================
Last Run: 2026-01-01 02:00 UTC (2 days ago)
Next Scheduled: 2026-01-08 02:00 UTC (5 days)
Current Quality:
Average Score: 68%
P0 Components: 0
P1 Components: 4
Below Threshold: 12
Recommendation: No immediate action needed
Next check: Tomorrow 06:00 UTC
Trigger Output
============================================================
Component Improvement Hook Triggered
============================================================
Trigger: manual.improvement
Time: 2026-01-03T18:30:00Z
Starting improvement cycle...
✅ HOOK TRIGGERED: component-improvement-scheduler
Action: Full improvement cycle initiated
Monitor: /improve-components --status
Completion Checklist
Hook execution verified when:
- Trigger condition met
- Retrospective data available
- Minimum component threshold reached
- Improvement cycle started
- Results logged
Success Output
✅ HOOK TRIGGERED: component-improvement-scheduler
Trigger: periodic.weekly
Time: 2026-01-03T02:00:00Z
Action: Full improvement cycle
Cycle initiated for 12 components
Monitor progress: /improve-components --status
Failure Indicators
Hook has FAILED if:
- ❌ No retrospective data available
- ❌ Below minimum component threshold
- ❌ Improvement cycle failed to start
- ❌ Configuration error
Related Components
| Component | Purpose |
|---|---|
/improve-components | Executes improvement cycle |
component-analyzer | Analyzes components |
component-enhancer | Applies improvements |
session-retrospective.py | Provides quality data |
Principles
This hook embodies:
- #1 Recycle, Extend, Re-Use - Maintains existing components
- #9 Based on Facts - Uses metrics for decisions
- Complete Execution - Automated maintenance
Full Standard: CODITECT-STANDARD-AUTOMATION.md
Version: 1.0.0 | Created: 2026-01-03 | Author: CODITECT Team