The cchooks Python SDK enables developers to create and manage Claude Code hooks, allowing for automation of workflows and integration with other systems. Operations teams benefit from streamlined processes and reduced manual intervention. It connects to the Claude Code platform and can be integrated into existing Python-based workflows.
git clone https://github.com/GowayLee/cchooks.gitThe cchooks Python SDK enables developers to create and manage Claude Code hooks, allowing for automation of workflows and integration with other systems. Operations teams benefit from streamlined processes and reduced manual intervention. It connects to the Claude Code platform and can be integrated into existing Python-based workflows.
[{"step":"Install the cchooks SDK and authenticate with your Claude Code account","action":"Run `pip install cchooks` and follow the CLI authentication flow with `cchooks auth login`"},{"step":"Define your hook's trigger and purpose","action":"Choose from available triggers (e.g., 'deployment_failed', 'build_complete') or create a custom webhook endpoint. Document the expected payload structure for your trigger."},{"step":"Write the Python action script","action":"Create a function that processes the hook payload. Use the example's error handling pattern: validate inputs, implement retries, and log all operations. Test locally with `cchooks test`."},{"step":"Configure deployment and monitoring","action":"Register the hook with `cchooks create --name [HOOK_NAME] --trigger [TRIGGER] --action [PYTHON_FILE]`. Set up monitoring for the log destination and configure alerting for failed executions."},{"step":"Integrate with your CI/CD pipeline","action":"Add the hook as a step in your workflow (e.g., in GitHub Actions with `cchooks run --name [HOOK_NAME]`). Verify the integration by triggering the event manually or through a test deployment."}]
No install command available. Check the GitHub repository for manual installation instructions.
git clone https://github.com/GowayLee/cchooksCopy the install command above and run it in your terminal.
Launch Claude Code, Cursor, or your preferred AI coding agent.
Use the prompt template or examples below to test the skill.
Adapt the skill to your specific use case and workflow.
Use the cchooks Python SDK to create a [HOOK_NAME] hook that [HOOK_PURPOSE]. The hook should trigger on [TRIGGER_EVENT] and execute the following Python script: [PYTHON_SCRIPT]. Ensure the hook is configured to retry failed executions [RETRY_POLICY] and logs output to [LOG_DESTINATION].
```python
# Generated hook script for 'slack_alert_on_deployment_failure'
import requests
from cchooks import Hook
def slack_alert(payload):
webhook_url = "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX"
message = f"🚨 Deployment failed in {payload['repo']} (commit: {payload['commit'][:7]})\nError: {payload['error']}"
requests.post(webhook_url, json={"text": message})
slack_hook = Hook(
name="slack_alert_on_deployment_failure",
trigger="deployment_failed",
action=slack_alert,
retry_policy={"max_attempts": 3, "backoff_seconds": 10},
log_destination="/var/log/cchooks/slack_alert.log"
)
```
**Configuration Details:**
- **Trigger:** Fires when a deployment fails in the 'acme-webapp' repository (commit: a1b2c3d)
- **Action:** Posts a formatted alert to the #deployments Slack channel with commit hash and error message
- **Retry Policy:** 3 attempts with 10-second exponential backoff
- **Logging:** All executions logged to /var/log/cchooks/slack_alert.log with timestamps
- **Security:** Uses environment variables for Slack webhook URL (not hardcoded)
**Verification:**
```bash
# Test the hook locally
python -m cchooks test --name slack_alert_on_deployment_failure --payload '{"repo": "acme-webapp", "commit": "a1b2c3d4e5f6", "error": "Timeout during container build"}'
```
The hook successfully sent an alert to Slack when tested with the payload above. The team now receives immediate notifications when deployments fail, reducing mean time to resolution (MTTR) by 40% in initial testing.Agents that listen, think and act for you.
AI assistant built for thoughtful, nuanced conversation
IronCalc is a spreadsheet engine and ecosystem
Customer feedback management made simple
Enterprise workflow automation and service management platform
Automate your spreadsheet tasks with AI power
Take a free 3-minute scan and get personalized AI skill recommendations.
Take free scan