Metadata-Version: 2.4
Name: claudehub-hooks
Version: 0.1.1
Summary: Claude Code hook dispatcher — forwards lifecycle events to Claude Monitor
Author-email: Pandiyaraj Karuppasamy <pandiyarajk@live.com>
License-Expression: MIT
Keywords: claude,claude-code,claudehub,hooks,monitor,dispatcher
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# claudehub-hooks

Pip-installable [Claude Code](https://docs.anthropic.com/en/docs/claude-code) hook dispatcher.
Install once, then wire any repository to a Claude Monitor HTTP
endpoint in one command — no manual script copying or JSON editing.

Events flow: **Claude Code → claudehub-hooks dispatcher → Claude Monitor**.

## Install

```bash
pip install claudehub-hooks
```

Requires Python 3.10+. No third-party runtime dependencies (stdlib only).

## Quick start

```bash
claudehub-hooks install
```

Run from a repository root (or pass `--repo`). The command is **idempotent** — safe to re-run.

```bash
claudehub-hooks install --repo /path/to/repo
claudehub-hooks install --url http://192.168.1.50:7070/event
claudehub-hooks install --dry-run
```

### What it writes

| File | Purpose |
|------|---------|
| `.claude/hooks/claude_hook.py` | Hook dispatcher (invoked by Claude Code) |
| `.claude/hooks/monitor_config.json` | Transport config with the monitor URL |
| `.claude/settings.json` | Nine hook entries merged in (existing entries kept) |

## Change the monitor URL

Edit `.claude/hooks/monitor_config.json` in the repo:

```json
{
  "transport": {
    "http": { "url": "http://192.168.1.50:7070/event" }
  }
}
```

Or set an environment variable (overrides the file):

```bash
export CLAUDE_HUB_URL="http://192.168.1.50:7070/event"
```

On Windows (persistent):

```bat
setx CLAUDE_HUB_URL "http://192.168.1.50:7070/event"
```

## Test connectivity

```bash
python .claude/hooks/claude_hook.py --test
```

## Hooks installed

| Event | Trigger |
|-------|---------|
| `SessionStart` | Claude session begins |
| `UserPromptSubmit` | User sends a message |
| `Notification` | Claude needs input |
| `PostToolUse` | File read/edited (Edit · Write · NotebookEdit · MultiEdit · Read) |
| `Stop` | Turn completes |
| `StopFailure` | API error |
| `PermissionRequest` | Allow/deny dialog shown |
| `PermissionDenied` | User denied a tool |
| `PreToolUse` | Tool about to run (resolves permission) |

## Configuration

| Variable | Default | Meaning |
|----------|---------|---------|
| `CLAUDE_HUB_URL` | `http://127.0.0.1:7070/event` | Monitor endpoint |
| `CLAUDE_HUB_TIMEOUT` | `2.0` | HTTP timeout (seconds) |
| `CLAUDE_HUB_HTTP_ENABLED` | `true` | Set to `false` to silence all hooks |
| `CLAUDE_HOOK_LOG_LEVEL` | `INFO` | Dispatcher log level |
| `CLAUDE_HOOK_LOG_FILE` | `~/.claude/claude_hook.log` | Override log path |
| `CLAUDE_HUB_CONFIG` | — | Path to a `monitor_config.json` override |

## License

MIT — see [LICENSE](LICENSE).

**Author:** Pandiyaraj Karuppasamy · pandiyarajk@live.com
