autoresearch-hooks
Skill này làm gì
Skill này giúp AI của bạn viết các script tùy chọn chạy ở đầu và cuối mỗi thử nghiệm trong phiên autoresearch. Dành cho người muốn có thông báo, ghi chú đã lưu hoặc các bước phụ quanh vòng lặp.
Khi nào nên dùng
- ✓Khi bạn muốn gửi tin nhắn Slack hoặc webhook sau mỗi thử nghiệm.
- ✓Khi bạn muốn vòng lặp lưu lại những điều đã học hoặc lấy tài liệu nghiên cứu trước khi bắt đầu lần lặp mới.
- ✓Khi vòng lặp thử nghiệm có vẻ bị kẹt và bạn muốn thêm một bước để đổi hướng.
Liên kết skill
https://github.com/davebcn87/pi-autoresearch/blob/main/skills/autoresearch-hooks/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Thêm một hook gửi tin nhắn cho tôi sau khi mỗi thử nghiệm kết thúc.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Các script hook nhận một bản tóm tắt ngắn của lần chạy gần nhất dưới dạng văn bản, và chúng có thể lưu file hoặc gửi ghi chú. Các script không được đánh dấu là thực thi được sẽ bị bỏ qua.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
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). |
Stdin — after.sh
{
"event": "after",
"cwd": "/path/to/workdir",
"run_entry": {
"run": 6,
"status": "discard",
"metric": 38.9,
"description": "Timsort hybrid slower on random",
"asi": {
"hypothesis": "Partial-sort heuristic on input distribution",
"learned": "Overhead dominates on random arrays"
}
},
"session": {
"metric_name": "total_ms",
"metric_unit": "ms",
"direction": "lower",
"baseline_metric": 40.7,
"best_metric": 33.5,
"run_count": 6,
"goal": "optimize sort speed"
}
}
| Field | Notes |
|---|---|
run_entry |
The run just logged. Always present. |
session |
Same shape as in before.sh, reflecting state after the run. |
Output
- Stdout (up to 8 KB) — delivered to the agent as a steer message on the next turn. Empty = silent.
- Stderr + non-zero exit — surfaced as an error steer.
- Timeout — 30 s hard kill; flagged in the observability entry.
Preservation
.auto/** survives the auto-revert — the entire .auto/ folder is preserved. (Legacy autoresearch.* paths are still preserved too, for in-flight sessions.)
Examples
Runnable reference scripts live in this skill's examples/ directory — one file per pattern. Paths are resolved against the skill directory (parent of SKILL.md). Browse them for inspiration; they're not policy.
examples/before/— external search, qmd document search, anti-thrash, idea rotator, hypothesis reflection, context rotationexamples/after/— learnings journal, macOS notification on new best, auto-tag winning commits
Each example is a complete, self-contained script with named constants, short helper functions, guard clauses, and intention-revealing names. Read the header comment for its purpose, copy to .auto/hooks/<stage>.sh, adapt.
Steps to add a hook
Understand the session. Read
.auto/prompt.mdfor the objective and metric; glance at.auto/measure.shfor the workload. Your hook should complement the loop, not duplicate it.Clarify the user's intent. What should happen, at which boundary? Research before / log after / notify on wins / intervene on thrash / etc.
Start from an example in
examples/that's closest to the intent (resolve against the skill directory). If nothing fits, write from scratch following the same style (named constants, short functions, guard clauses, JSON stdin par
Câu hỏi thường gặp
Các script này chạy khi nào?
Script before chạy trước mỗi lần lặp, còn script after chạy sau mỗi thử nghiệm đã ghi nhật ký.
Script nhận được thông tin gì?
Nó nhận một bản tóm tắt JSON ngắn về lần chạy gần nhất, số thứ tự lần chạy tiếp theo và chi tiết phiên.
Các hook có bắt buộc không?
Không. Cả hai file hook đều là tùy chọn.
Chi tiết
Mô tả gốc của tác giả
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.
Độ phổ biến
- Sao GitHub
- 8.2k
- Vị trí xếp hạng
- #12524
- Giấy phép
- MIT
- Cập nhật
- 7/10/2026
Bình luận
- …
Thêm skill từ kho mã này
autoresearch-create
8.2kGiúp agent của bạn chạy một vòng thử nghiệm tự động, thử các ý tưởng, giữ lại những gì cải thiện mục tiêu đã chọn và loại bỏ phần còn lại.
autoresearch-finalize
8.2kGiúp agent của bạn biến chuỗi thay đổi thử nghiệm lộn xộn thành các nhánh riêng biệt, gọn gàng và sẵn sàng để xem xét.
Skill tương tự
add-model-provider
394kGiúp agent của bạn kết nối nhà cung cấp mô hình AI mới với OpenClaw bằng lệnh an toàn, giữ API key khỏi văn bản thuần và chạy thử.
acp-router
394kGiúp agent của bạn gửi một tác vụ đến trợ lý lập trình như Claude Code hoặc Cursor qua OpenClaw, để công việc chạy ngay trong công cụ đó.
browser-automation
394kHướng dẫn agent của bạn điều khiển trang web từng bước, gồm đăng nhập, tab và cách khôi phục khi trang ngừng phản hồi.