
Autoresearch Hooks
Author pre/post-iteration hooks for an autoresearch session.
Install
npx skills add davebcn87/pi-autoresearch --skill autoresearch-hooks -g -a claude-code -y- Repository
- davebcn87/pi-autoresearch8.2k
- Category
- Writing
- Updated
- 28d ago
- License
- MIT
- Context cost
- Mediumabout 1,575 tokens
- Runs scripts
- Yes, review before use
What it does
Author pre/post-iteration hooks for an autoresearch session. Use when the user asks to add research fetching, Slack/webhook notifications, persistent learnings, auto-tagging, anti-thrash intervention, idea rotation, or any side effect around iterations.
autoresearch-hooks
Optional scripts that run at iteration boundaries in an autoresearch session. Two hooks, both transparent to the loop-running agent, their effect is a file on disk or a steer message.
.auto/hooks/
before.sh # fires before each iteration (prospective)
after.sh # fires after each log_experiment (retrospective)
Both files are optional. Files without the executable bit are silently ignored.
Contract
Stdin, before.sh
One JSON line. Parse with jq. Realistic example:
{
"event": "before",
"cwd": "/path/to/workdir",
"next_run": 6,
"last_run": {
"run": 5,
"status": "discard",
"metric": 42.1,
"description": "Simplified to sorted(arr), copy cost dominates",
"asi": {
"hypothesis": "Built-in sort avoids Python overhead",
"next_focus": "list copy avoidance"
}
},
"session": {
"metric_name": "total_ms",
"metric_unit": "ms",
"direction": "lower",
"baseline_metric": 40.7,
"best_metric": 33.5,
"run_count": 5,
"goal": "optimize sort speed"
}
}
| Field | Notes |
|---|---|
last_run | The most recent run entry. null on a fresh session. |
session.direction | "lower" or "higher", which end of the scale wins. |
session.baseline_metric | First run of the current segment. null until one run exists. |
session.best_metric | Optimal metric across kept runs only. null until one is kept. |
session.goal | The session name set by init_experiment. |
session.run_count | Total runs logged so far (any status). |
