openclaw - 💡(How to fix) Fix Feature Request: Skill Hook for Tool Execution [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#78062Fetched 2026-05-06 06:17:19
View on GitHub
Comments
1
Participants
2
Timeline
3
Reactions
2
Timeline (top)
closed ×1commented ×1labeled ×1

Add a Skill Hook mechanism that automatically invokes registered Skills before/after tool execution, enabling security checks, compression, and orchestration without manual intervention.

Error Message

if (result.blocked) throw new Error(Blocked by ${skill.name})

Root Cause

Add a Skill Hook mechanism that automatically invokes registered Skills before/after tool execution, enabling security checks, compression, and orchestration without manual intervention.

Code Example

// Before tool execution

async function executeTool(tool, input) {

  // Pre-execution Hook

  for (const skill of getSkillsForHook('tool:before-execute')) {

   const result = await skill.check(tool, input)

   if (result.blocked) throw new Error(`Blocked by ${skill.name}`)

  }

  

  // Execute tool

  return await tool.execute(input)

  

  // Post-execution Hook

  for (const skill of getSkillsForHook('tool:after-execute')) {

   await skill.onComplete(tool, result)

  }

}

### Problem to solve

OpenClaw`exec` 工具执行命令时无自动安全检查。用户只能事后手动调用 `bash-security` 等技能,存在安全漏洞。

### Proposed solution

引入 Skill Hook 系统,允许技能拦截工具执行:
RAW_BUFFERClick to expand / collapse

Summary

Feature Request: Skill Hook for Tool Execution

Summary

Add a Skill Hook mechanism that automatically invokes registered Skills before/after tool execution, enabling security checks, compression, and orchestration without manual intervention.

Problem

OpenClaw's exec tool executes commands with no automatic security checks. Users can only manually invoke skills like bash-security after the fact. This creates a security gap and poor UX.

Proposed Solution

Introduce a Skill Hook system that allows skills to intercept tool execution:


// Before tool execution

async function executeTool(tool, input) {

  // Pre-execution Hook

  for (const skill of getSkillsForHook('tool:before-execute')) {

   const result = await skill.check(tool, input)

   if (result.blocked) throw new Error(`Blocked by ${skill.name}`)

  }

  

  // Execute tool

  return await tool.execute(input)

  

  // Post-execution Hook

  for (const skill of getSkillsForHook('tool:after-execute')) {

   await skill.onComplete(tool, result)

  }

}

### Problem to solve

OpenClaw 的 `exec` 工具执行命令时无自动安全检查。用户只能事后手动调用 `bash-security` 等技能,存在安全漏洞。

### Proposed solution

引入 Skill Hook 系统,允许技能拦截工具执行:

```typescript

async function executeTool(tool, input) {

### Alternatives considered


# skills/bash-security/hook.yaml

hooks:

  - event: tool:before-execute

   filter: tool.name === 'exec'

   priority: 100

   async: true

### Impact

安全: 执行前自动拦截危险命令
成本: 自动压缩节省 Token
体验: "自动保护" 替代 "手动调用"

### Evidence/examples

_No response_

### Additional information

_No response_

extent analysis

TL;DR

Implement a Skill Hook system to automatically invoke registered skills before and after tool execution, enabling security checks and other features.

Guidance

  • Introduce a getSkillsForHook function to retrieve relevant skills for the 'tool:before-execute' and 'tool:after-execute' hooks.
  • Register skills like bash-security with the Skill Hook system, specifying the event and filter conditions, such as tool.name === 'exec'.
  • Modify the executeTool function to call the pre-execution and post-execution hooks, passing the tool and input as arguments.
  • Handle the results of the skill checks, throwing an error if a skill blocks the execution.

Example

async function executeTool(tool, input) {
  // Pre-execution Hook
  for (const skill of getSkillsForHook('tool:before-execute')) {
    const result = await skill.check(tool, input)
    if (result.blocked) throw new Error(`Blocked by ${skill.name}`)
  }
  // Execute tool
  const result = await tool.execute(input)
  // Post-execution Hook
  for (const skill of getSkillsForHook('tool:after-execute')) {
    await skill.onComplete(tool, result)
  }
  return result
}

Notes

The proposed solution assumes that the getSkillsForHook function and the skill registration mechanism are already implemented. Additional work may be required to integrate the Skill Hook system with the existing tool execution pipeline.

Recommendation

Apply the proposed Skill Hook system to enable automatic security checks and other features, as it provides a flexible and extensible way to intercept tool execution.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix Feature Request: Skill Hook for Tool Execution [1 comments, 2 participants]