Package Exports
- @polyhook/sdk
Readme
polyhook — TypeScript / JavaScript SDK
Write AI coding agent hooks once. Run them everywhere.
polyhook detects which AI coding tool invoked your hook binary, deserializes the event into a normalized struct, and serializes your response back in the format that tool expects. Your hook runs unchanged whether Claude Code, Cursor, Windsurf, Cline, or Amp invoked it.
Install
npm install @polyhook/sdkQuick Start
import { read, respond, block, approve } from "@polyhook/sdk";
const event = await read();
if (
event.tool === "bash" &&
/rm\s+-rf\s+\//.test((event.input?.command as string) ?? "")
) {
await respond(block("Refusing to delete from root"));
} else {
await respond(approve());
}More examples: examples/
Supported Tools
| Tool | Status |
|---|---|
| Claude Code | ✅ Supported |
| Cursor | ✅ Supported |
| Windsurf | ✅ Supported |
| Cline | ✅ Supported |
| Amp | ✅ Supported |
| Continue | 🚧 In progress |
| Aider | 🚧 In progress |
| Copilot | 📋 Planned |
Documentation
Full docs and API reference: https://github.com/tupe12334/polyhook
License
MIT