New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

tool-mock

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tool-mock

Mock framework for Claude Code tool responses — test hooks and Sentinel state transitions without real side effects

latest
npmnpm
Version
0.1.1
Version published
Maintainers
1
Created
Source

tool-mock

Mock framework for testing Claude Code hooks. Build fake payloads, run hooks against them, assert decisions.

Install

npm install -g tool-mock

Library Usage

import { preToolUse, postToolUse, runHook, expectAllow, expectDeny } from 'tool-mock'

// Build a mock payload
const payload = preToolUse('Read', { file_path: '/etc/passwd' })

// Run a hook against it
const response = await runHook('~/.claude/hooks/my-hook.sh', payload)

// Assert the decision
expectDeny(response.unwrap())

CLI

# Generate payloads
tool-mock payload pre Read --input '{"file_path":"/etc/passwd"}'
tool-mock payload post Bash --input '{"command":"cat .env"}' --response 'SECRET=abc'

# Run a scenario file
tool-mock run scenario.json

Scenarios

Define multi-step test scenarios in JSON:

{
  "name": "scope-lock denies .env access",
  "steps": [
    {
      "description": "Reading .env should be denied",
      "hook": "~/.claude/hooks/scope-lock.sh",
      "event": "PreToolUse",
      "toolName": "Read",
      "toolInput": { "file_path": ".env" },
      "expect": "deny"
    }
  ]
}

Requirements

  • Node.js >= 22, ESM only

License

MIT

FAQs

Package last updated on 22 Mar 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts