Configure automatic self-improvement triggers for AI coding agents.
Hooks enable proactive learning capture by injecting reminders at key moments:
- UserPromptSubmit: Reminder after each prompt to evaluate learnings
- PostToolUse (Bash): Error detection when commands fail
Create .claude/settings.json in your project root:
{
"hooks": {
"UserPromptSubmit": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "./skills/self-improvement/scripts/activator.sh"
}
]
}
],
"PostToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "./skills/self-improvement/scripts/error-detector.sh"
}
]
}
]
}
}
Add to ~/.claude/settings.json for global activation:
{
"hooks": {
"UserPromptSubmit": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "~/.claude/skills/self-improvement/scripts/activator.sh"
}
]
}
]
}
}
For lower overhead, use only the UserPromptSubmit hook:
{
"hooks": {
"UserPromptSubmit": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "./skills/self-improvement/scripts/activator.sh"
}
]
}
]
}
}
Codex uses the same hook system as Claude Code. Create .codex/settings.json:
{
"hooks": {
"UserPromptSubmit": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "./skills/self-improvement/scripts/activator.sh"
}
]
}
]
}
}
Copilot doesn't support hooks directly. Instead, add guidance to .github/copilot-instructions.md:
## Self-Improvement
After completing tasks that involved:
- Debugging non-obvious issues
- Discovering workarounds
- Learning project-specific patterns
- Resolving unexpected errors
Consider logging the learning to `.learnings/` using the format from the self-improvement skill.
For high-value learnings that would benefit other sessions, consider skill extraction.
<self-improvement-reminder> in the contextls /nonexistent/path<error-detected> reminder./skills/self-improvement/scripts/extract-skill.sh test-skill --dry-run
Expected output shows the skill scaffold that would be created.
chmod +x scripts/*.shchmod +x ./skills/self-improvement/scripts/activator.sh
chmod +x ./skills/self-improvement/scripts/error-detector.sh
chmod +x ./skills/self-improvement/scripts/extract-skill.sh
If using relative paths, ensure you're in the correct directory or use absolute paths:
{
"command": "/absolute/path/to/skills/self-improvement/scripts/activator.sh"
}
If the activator feels intrusive:
{
"matcher": "fix|debug|error|issue",
"hooks": [...]
}
The activator is designed to be lightweight:
- Target: ~50-100 tokens per activation
- Content: Structured reminder, not verbose instructions
- Format: XML tags for easy parsing
If you need to reduce overhead further, you can edit activator.sh to output less text.
CLAUDE_TOOL_OUTPUT environment variableTo temporarily disable without removing configuration:
Comment out in settings:json { "hooks": { // "UserPromptSubmit": [...] } }
Or delete the settings file: Hooks won't run without configuration