init-hooks

init-hooks is a skill for Claude Code, Codex from Songhonglei/better-agent-skills. It costs 201 tokens per session (2,526 once invoked), scanned A, original, MIT.

A manager for startup scripts in OpenClaw, an AI-agent runtime that can run inside containers or pods. It stores hooks in the workspace so they can run again after gateway, container, or pod restarts.

In plain words
What is it for?
Use it to register inline commands, local shell or Python scripts, or downloadable ZIP and TAR.GZ hooks that should run during startup.
Why use it?
It keeps required startup actions from being lost when the runtime restarts or is rebuilt. It also records execution logs and supports enabling, disabling, editing, and testing hooks.

Skill for Claude CodeCodex

Which agent this was written for is unclear — built for openclaw. Also seen: built for openclaw.

Good fit Use it to register inline commands, local shell or Python scripts, or downloadable ZIP and TAR.GZ hooks that should run during startup.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/songhonglei/better-agent-skills/init-hooks
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add Songhonglei/better-agent-skills --skill init-hooks
Clone the repo
git clone --depth 1 https://github.com/Songhonglei/better-agent-skills

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for init-hooks

README.md
[![agentmods](https://agentmods.dev/badge/skills/songhonglei/better-agent-skills/init-hooks/github.svg)](https://agentmods.dev/skills/songhonglei/better-agent-skills/init-hooks)
Your own site
<a href="https://agentmods.dev/skills/songhonglei/better-agent-skills/init-hooks"><img src="https://agentmods.dev/badge/skills/songhonglei/better-agent-skills/init-hooks/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for init-hooks

Your own site · 80×15
<a href="https://agentmods.dev/skills/songhonglei/better-agent-skills/init-hooks"><img src="https://agentmods.dev/badge/skills/songhonglei/better-agent-skills/init-hooks.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 201 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,526 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00201 $0.02526
Opus 5 $0.00101 $0.01263
Sonnet 5 $0.00040 $0.00505
Haiku 4.5 $0.00020 $0.00253

Measured 10d ago against content hash ed94cf1c717b, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-10, from the pricing page.

Security

Grade A, and why

init-hooks scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 10d ago.

The scan reads SKILL.md. This mod also ships 2 executable files (scripts/manage.py, scripts/sync_openclaw_config.py), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/init-hooks/SKILL.md · 228 lines

How it starts

The opening of the file, as written. The whole thing — 228 lines — stays where its author put it; the contents beside it link to each section on GitHub.

init-hooks

管理 OpenClaw 容器/主机启动时自动执行的脚本钩子。gateway 重启、容器重启、容器重建均不丢失(数据持久化在 workspace/.init-hooks/)。支持 inline 命令 / 本地脚本(shell·python)/ CDN URL(zip·tar.gz 自动下载解压)三种钩子类型。

路径约定

~/.openclaw/workspace/.init-hooks/
├── hooks.json        # 注册表(truth)
├── dispatcher.sh     # 自动生成,post-init.sh 调用这个
├── last-run.log      # 每次启动执行日志
└── downloads/        # CDN URL 钩子下载缓存
    └── hook_<id>.*

脚本路径:

~/.openclaw/workspace/skills/init-hooks/scripts/
├── manage.py               # 主入口(所有 CRUD + run + install)
└── sync_openclaw_config.py # openclaw.json 多路径同步工具

操作命令速查

所有操作通过 exec 运行,工作目录任意:

SCRIPT="$HOME/.openclaw/workspace/skills/init-hooks/scripts/manage.py"

python3 $SCRIPT install          # 首次安装
python3 $SCRIPT list             # 列出所有钩子
python3 $SCRIPT show <id>        # 查看钩子详情
python3 $SCRIPT add ...          # 新增(见下方)
python3 $SCRIPT edit <id> ...    # 修改
python3 $SCRIPT enable <id>      # 启用
python3 $SCRIPT disable <id>     # 禁用
python3 $SCRIPT delete <id>      # 删除(需二次确认)
python3 $SCRIPT delete <id> --force  # 强制删除不确认
python3 $SCRIPT run              # 立即运行所有启用的钩子
python3 $SCRIPT run <id>         # 立即运行指定钩子
python3 $SCRIPT status           # 查看安装状态

新增钩子:三种类型

inline(内嵌 shell 命令)

python3 $SCRIPT add \
  --name "初始化日志目录" \
  --type inline \
  --content "mkdir -p ~/logs && echo 'started' >> ~/logs/boot.log"

多行命令用 \n 分隔:

python3 $SCRIPT add \
  --name "环境变量初始化" \
  --type inline \
  --content $'export MY_VAR=hello\nmkdir -p ~/tmp'

script(本地 shell 脚本)

python3 $SCRIPT add \
  --name "凭证/账号启动恢复" \
  --type script \
  --path "~/.openclaw/workspace/scripts/restore-credentials.sh"

python(本地 Python 脚本)

python3 $SCRIPT add \
  --name "Agent workspace 配置" \
  --type python \
  --path "~/.openclaw/workspace/scripts/set-agents.py"

Read the full file on GitHub · 228 lines

Files

What ships with it

5 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 10d ago First seen · 228 lines · 201 tokens per session scan A ed94cf1c717b

Subscribe to this mod's changes

init-hooks is a skill published in the GitHub repository Songhonglei/better-agent-skills (3 stars, last pushed 3d ago), licensed MIT. It adds 201 tokens to every session and 2,526 once invoked, about $0.0010 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.