🪝 Hooks & Learning
/programmatic-usage/hooks--learning
typescript
import { HooksService } from '@claude-flow/hooks';
const hooks = new HooksService({
enableLearning: true,
reasoningBank: true
});
// Route task to optimal agent
const routing = await hooks.route('implement caching layer');
console.log(`Recommended: ${routing.agent} (${routing.confidence}%)`);
// Record task outcome
await hooks.postTask({
taskId: 'task-123',
success: true,
quality: 0.95,
agent: routing.agent
});
// Start trajectory for RL learning
const trajectory = await hooks.startTrajectory('complex-feature');
await hooks.recordStep(trajectory, { action: 'created service', reward: 0.8 });
await hooks.endTrajectory(trajectory, { success: true });