opencode-hooks

Configure OpenCode PreToolUse and PostToolUse hooks in hooks.json.

4|1|Updated Apr 23, 2026
One-click install
npx skills add https://github.com/johnnyasantoss/opencode-config --skill opencode-hooks
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: opencode-hooks
Source: https://github.com/johnnyasantoss/opencode-config/tree/main/skills/opencode-hooks
Command: npx skills add https://github.com/johnnyasantoss/opencode-config --skill opencode-hooks

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Configure and manage hooks in OpenCode to intercept tool events, block dangerous commands, log activity, and enforce governance across the workspace.

Core Features & Use Cases

  • PreToolUse and PostToolUse hook configuration to block, log, and audit tool calls.
  • Create or modify hooks.json and manage hook conditions to meet security policies.
  • Debug and validate hook behavior across common OpenCode tools (bash, edit, write).

Quick Start

Create a simple PreToolUse hook to block rm commands and enable PostToolUse logging to monitor tool calls.

Frequently Asked Questions about opencode-hooks

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I configure OpenCode hooks to block dangerous bash commands?

To block dangerous bash commands in OpenCode, configure a PreToolUse hook in your hooks.json file with specific condition patterns that match restricted commands like rm, ensuring safe operation and policy enforcement.

What are PreToolUse and PostToolUse hooks used for in OpenCode?

PreToolUse and PostToolUse hooks intercept tool events in OpenCode to block dangerous commands before execution and log tool usage activity after execution, enabling security auditing and governance across the workspace.

Can I enforce security policies and audit tool calls using hooks.json?

Yes, you can enforce security policies and audit tool calls by creating or modifying hooks.json to define hook conditions that intercept, log, and block tool usage based on your specific governance requirements.

Does this approach work with common OpenCode tools like edit and write?

Yes, the hook configuration supports debugging and validating hook behavior across common OpenCode tools including bash, edit, and write, allowing you to intercept and log their usage consistently.

What's the best way to log tool usage activity for monitoring in OpenCode?

The best way to log tool usage activity is by enabling PostToolUse hooks in your hooks.json configuration, which automatically records tool calls and supports ongoing monitoring and audit trail generation.

How do I validate and debug hook behavior when policies are not applying correctly?

To validate and debug hook behavior when policies are not applying correctly, review your hook condition patterns in hooks.json and test the PreToolUse and PostToolUse events across common tools like bash and write.