runok init
runok init creates a runok.yml configuration file through an interactive setup wizard. It can also detect existing Claude Code Bash permissions and migrate them to runok rules.
runok init [options]--scope <scope>
Section titled “--scope <scope>”Configuration scope. Available values:
user— Create~/.config/runok/runok.ymlfor global rules that apply to all projects. Also registers the runok PreToolUse hook in~/.claude/settings.jsonif Claude Code is detected, and therunok hook --agent codexhook in the Codex config directory’shooks.json($CODEX_HOME, or~/.codexwhen that variable is unset) if one is detected.project— Createrunok.ymlin the current directory for project-specific rules.
When omitted, the wizard prompts you to choose.
-y, --yes
Section titled “-y, --yes”Accept all defaults without prompting. Useful for scripted setups.
What the wizard does
Section titled “What the wizard does”- Scope selection — Choose
userorprojectscope (skipped if--scopeis given). - Claude Code detection — If a
.claude/settings.jsonexists with a missing runok hook or a hook entry registered under the pre-runok hookcommand, the wizard offers to act on it. Bash permissions only trigger this step whenrunok.ymldoesn’t already exist yet at the selected scope (see below); ifrunok.ymlalready exists and that’s the only thing settings.json has to offer, the wizard prints a note that it’s leaving the permissions in place instead. Where triggered, the wizard offers to:- Migrate Bash permissions — Convert
permissions.allowandpermissions.denyentries forBash(...)patterns into runok rules, and remove them fromsettings.json. Only offered whenrunok.ymldoesn’t already exist yet at the selected scope — init never writes to an existing one, so this step doesn’t appear if you already have arunok.ymlthere; migrate the rules into it by hand instead. - Register the hook — Add the
runok hookPreToolUse hook tosettings.json(user scope only). - Migrate the hook command — Rewrite an existing
runok check --input-format claude-code-hookentry (registered beforerunok hookexisted) torunok hook --agent claude-code, in place. - Track ask approvals (opt-in) — Also register the same command as a PostToolUse hook so approvals of
askdecisions are recorded in the audit log (user scope only). See Track ask approvals.
- Migrate Bash permissions — Convert
- Codex detection — If a Codex config directory exists (
$CODEX_HOME, or~/.codexwhen that variable is unset), the wizard registers therunok hook --agent codexcommand for both thePreToolUseandPermissionRequestevents in<codex_home>/hooks.json(user scope only). Skipped entirely — without asking or writing anything — if the directory doesn’t exist, since that means Codex isn’t installed or used. Re-runningrunok initis idempotent and won’t duplicate an already-registered entry. You may need to approve the newly-registered hook in Codex before it takes effect. - Preview and confirm — Show a unified diff of all proposed changes and ask for confirmation.
- Create
runok.yml— Write a fresh configuration file with migrated rules (if any) or a boilerplate template, but only whenrunok.ymldoesn’t already exist yet at the selected scope. An existingrunok.yml— hand-written or otherwise — is never overwritten or modified by init, with or without-y. - Conflicting hook detection — The wizard checks for other PreToolUse hooks that also match
Bash. Due to a known Claude Code issue, runok’s sandbox may not work when multiple PreToolUse hooks match Bash — commands that should be sandboxed could run without any restrictions. If conflicts are found, a warning is displayed advising you to merge all Bash-matching hooks into a single entry.
Examples
Section titled “Examples”Interactive setup (prompts for scope and options):
runok initSet up user-global configuration non-interactively:
runok init --scope user -ySet up project-local configuration:
runok init --scope projectRelated
Section titled “Related”- Quick Start — Getting started with runok.
- Claude Code Integration — Manual hook setup and sandbox configuration.
- Configuration — Full configuration reference.