Claude Code Hooks SDK
Description
[](https://packagist.org/packages/beyondcode/claude-hooks-sdk) [](https://github.com/beyondcode/claude-hooks-sdk/actions/workflows/run-tests.yml) [](https://packagist.org/packages/beyondcode/claude-hooks-sdk)
Installation
claude install-skill https://github.com/beyondcode/claude-hooks-sdk README
Claude Hooks SDK
[](https://packagist.org/packages/beyondcode/claude-hooks-sdk) [](https://github.com/beyondcode/claude-hooks-sdk/actions/workflows/run-tests.yml) [](https://packagist.org/packages/beyondcode/claude-hooks-sdk)
A Laravel-inspired PHP SDK for building Claude Code hook responses with a clean, fluent API. This SDK makes it easy to create structured JSON responses for Claude Code hooks using an expressive, chainable interface.
Claude Code hooks are user-defined shell commands that execute at specific points in Claude Code's lifecycle, providing deterministic control over its behavior. For more details, see the [Claude Code Hooks documentation](https://docs.anthropic.com/en/docs/claude-code/hooks).
Installation
You can install the package via composer:
composer require beyondcode/claude-hooks-sdk
Usage
Creating a Claude Hook
Here's how to create a PHP script that Claude Code can use as a hook:
Step 1: Create your PHP hook script
Create a new PHP file (e.g., `validate-code.php`) using the SDK:
toolName() === 'Bash') {
$command = $hook->toolInput('command', '');
// Check for potentially dangerous commands
if (str_contains($command, 'rm -rf')) {
// Block the tool call with feedback
$hook->response()->block('Dangerous command detected. Use caution with rm -rf commands.');
}
}
// Allow other tool calls to proceed
$hook->success();
Step 2: Register your hook in Claude Code
- undefined
...
Related Skills
使用 Git Worktrees
创建孤立的 Git worktrees,带有智能目录选择与安全验证。
Git community Claude skills github
[Building agent skills blog](https://www.anthropic.com/engineering/equipping-agents-for-the-real-world-with-agent-skills)
Git community #148
, [#161](https://github.com/affaan-m/everything-claude-code/pull/161))
Git community GitHub MCP
| Token | Repos, issues, PRs, workflows |
Git community GitHub MCP Server
Official first-party server to read repos, manage issues/PRs, and automate workflows.
Git community mcp-server-github
GitHub API integration for repos, issues, PRs.
Git community