Claude Code Integration
runok integrates with Claude Code through the PreToolUse hook system. When configured, runok evaluates every Bash command that Claude Code attempts to run, enforcing your allow/deny rules before execution.
How it works
Section titled “How it works”- Claude Code triggers a PreToolUse hook before executing any tool.
- runok receives the tool invocation as JSON via stdin.
- For
Bashtool calls, runok extracts the command string and evaluates it against yourrunok.ymlrules. - runok returns an
approve,deny, oraskdecision back to Claude Code.
Step 1: Set up runok
Section titled “Step 1: Set up runok”If you haven’t already, follow the Quick Start to install runok and create a runok.yml.
Step 2: Configure the PreToolUse hook
Section titled “Step 2: Configure the PreToolUse hook”Add the runok hook to your Claude Code settings file (.claude/settings.json):
{ "hooks": { "PreToolUse": [ { "matcher": "Bash", "hooks": [ { "type": "command", "command": "runok check --input-format claude-code-hook" } ] } ] }}What each field means
Section titled “What each field means”"matcher": "Bash"— Only triggers the hook for Bash tool calls. Other tools (file edits, web searches, etc.) are not affected."hooks"— The command(s) to run. Claude Code pipes the tool invocation as JSON to stdin.runok check --input-format claude-code-hookparses this JSON format and returns the evaluation result.
Step 3: Verify the integration
Section titled “Step 3: Verify the integration”Start a Claude Code session in your project directory. Ask Claude to run a command that your rules cover:
- Allowed command: Ask Claude to run
git status. It should execute without prompting. - Denied command: Ask Claude to run
git push --force origin main. It should be blocked with the configured message. - Ask command: Ask Claude to run
git push origin main. It should prompt you for confirmation.
Sandbox execution
Section titled “Sandbox execution”runok can enforce OS-level sandboxing (file system and network restrictions) on commands that Claude Code runs. When an allow rule has a sandbox field, runok automatically rewrites the command so that Claude Code executes it inside a sandbox.
Define a sandbox preset in your runok.yml:
definitions: sandbox: restricted: fs: writable: [./tmp, /tmp] network: allow: trueThen attach it to a rule:
rules: - allow: 'python3 *' sandbox: restrictedWhen Claude Code runs python3 script.py, runok’s hook response tells Claude Code to execute runok exec --sandbox restricted -- 'python3 script.py' instead, transparently applying the sandbox.
You can also set a default sandbox for all allowed commands:
defaults: action: ask sandbox: restrictedSee Sandbox for the full reference on sandbox presets and platform support (macOS Seatbelt, Linux Landlock/seccomp).
Settings file locations
Section titled “Settings file locations”The .claude/settings.json file can be placed at different scopes:
| Location | Scope |
|---|---|
.claude/settings.json (project root) | Project-specific, shared with the team |
~/.claude/settings.json | User-global, applies to all projects |
For team-wide enforcement, commit .claude/settings.json alongside your runok.yml in the project repository.
See runok check for full command reference.
Claude Code plugin
Section titled “Claude Code plugin”The runok Claude Code plugin gives Claude Code knowledge of runok — its configuration format, pattern syntax, and rule evaluation model. With the plugin installed, Claude Code can answer questions about runok and manage your runok.yml through natural language.
What the plugin provides
Section titled “What the plugin provides”- Configuration reading — Discovers and reads global (
~/.config/runok/runok.yml), project (./runok.yml), and override (./runok.local.yml) configuration files. - Rule management — Add, edit, and remove
allow/deny/askrules with full pattern syntax support (wildcards, alternation, negation, optional groups, quoted literals,whenclauses). - Definitions management — Manage
paths,wrappers,sandboxpresets, andcommandsunder thedefinitionssection. - Extends management — Add and remove shared presets via local paths, GitHub shorthand (
github:org/repo@ref), or Git URLs. - Initialization — Generate a starter
runok.ymlfor new projects with sensible defaults.
Install the plugin
Section titled “Install the plugin”In Claude Code chat
Section titled “In Claude Code chat”-
Add the marketplace:
/plugin marketplace add fohte/runok-claude-code-plugin -
Install the plugin:
/plugin install runok@runok-claude-code-plugin
From the CLI
Section titled “From the CLI”-
Add the marketplace:
Terminal window claude plugin marketplace add fohte/runok-claude-code-plugin -
Install the plugin:
Terminal window claude plugin install runok@runok-claude-code-plugin
The plugin activates automatically when you work with runok configuration or mention “runok” in conversation. You can also invoke the skill directly:
/runokFor example, you can ask Claude Code to:
- “Add a rule to allow
cargo test” - “Deny force pushes with a helpful message”
- “Show me my current runok rules”
- “Initialize runok for this project”