Skip to content

Commit 1728083

Browse files
committed
docs: add Claude Code settings integration example for workie hooks
Add comprehensive documentation showing how to configure Claude Code's native hook system to call workie hooks, enabling users to leverage workie's configuration management and AI decision-making capabilities within Claude Code.
1 parent 3d748c5 commit 1728083

1 file changed

Lines changed: 116 additions & 16 deletions

File tree

README.md

Lines changed: 116 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -410,15 +410,15 @@ Here's how you can set hooks in your configuration file:
410410
```yaml
411411
hooks:
412412
timeout_minutes: 5 # Optional: Timeout in minutes for each hook command
413-
413+
414414
# Workie lifecycle hooks
415415
post_create:
416416
- "echo 'Welcome to your new environment!'"
417417
- "npm install"
418418
pre_remove:
419419
- "echo 'Cleaning up...'"
420420
- "git status"
421-
421+
422422
# Claude Code integration hooks
423423
claude_pre_tool_use:
424424
- 'echo "Tool being used: $TOOL_NAME"'
@@ -447,30 +447,30 @@ For detailed documentation on all available hooks and their usage, see [docs/hoo
447447
- Validate all inputs and paths to prevent injection attacks.
448448
- Limit the number of hooks and complexity to maintain performance.
449449

450-
## Claude Code Hooks Integration ⚠️
450+
## Claude Code Hooks Integration ⚠️
451451

452452
> ### 🚨 **EXPERIMENTAL FEATURE - USE AT YOUR OWN RISK** 🚨
453-
>
453+
>
454454
> **⚠️ CRITICAL WARNING ⚠️**
455-
>
456-
> The Claude Code hooks integration is an **EXPERIMENTAL** and **UNOFFICIAL** feature that interfaces with Claude Code's hook system.
457-
>
455+
>
456+
> The Claude Code hooks integration is an **EXPERIMENTAL** and **UNOFFICIAL** feature that interfaces with Claude Code's hook system.
457+
>
458458
> **THIS INTEGRATION:**
459459
> - ❌ Is **NOT** officially supported or endorsed by Anthropic
460460
> - ❌ May **BREAK** without warning when Claude Code updates
461461
> - ❌ Executes **ARBITRARY SHELL COMMANDS** based on AI decisions
462462
> - ❌ Could **INTERFERE** with Claude Code's normal operation
463463
> - ❌ Has **NOT** been extensively tested in production environments
464464
> - ❌ May cause **DATA LOSS** or **SECURITY VULNERABILITIES** if misconfigured
465-
>
465+
>
466466
> **BY USING THIS FEATURE, YOU EXPLICITLY ACKNOWLEDGE AND ACCEPT THAT:**
467467
> - ✋ You understand **ALL RISKS** involved
468468
> - ✋ You take **FULL RESPONSIBILITY** for any consequences
469469
> - ✋ You will **NOT** hold Workie maintainers or contributors liable
470470
> - ✋ You will implement proper **SECURITY MEASURES** and **TESTING**
471471
> - ✋ You are using this in a **SAFE, ISOLATED ENVIRONMENT**
472472
> - ✋ You have **BACKUPS** of all important data
473-
>
473+
>
474474
> **⚡ PROCEED WITH EXTREME CAUTION ⚡**
475475

476476
### Claude Code Hook Types
@@ -483,20 +483,20 @@ hooks:
483483
claude_pre_tool_use:
484484
- 'echo "[$(date)] Tool: $TOOL_NAME" >> ~/.workie/claude.log'
485485
- 'security-check.sh "$TOOL_NAME"'
486-
486+
487487
# After Claude successfully uses a tool
488488
claude_post_tool_use:
489489
- 'test "$TOOL_NAME" = "Edit" && npm run lint || true'
490-
490+
491491
# When user submits a prompt
492492
claude_user_prompt_submit:
493493
- 'echo "New prompt received" | notify-send'
494-
494+
495495
# When Claude finishes responding
496496
claude_stop:
497497
- 'npm test --silent'
498498
- 'git diff --stat'
499-
499+
500500
# Other supported hooks
501501
claude_notification: # On Claude notifications
502502
claude_subagent_stop: # When subagent finishes
@@ -514,7 +514,7 @@ hooks:
514514
- 'check-file-paths.sh'
515515
- 'validate-tool-params.sh'
516516
- 'policy-enforcer.sh'
517-
517+
518518
# Enable AI decision making
519519
ai_decision:
520520
enabled: true
@@ -588,17 +588,117 @@ hooks:
588588
# Auto-format on edit
589589
claude_post_tool_use:
590590
- 'test "$TOOL_NAME" = "Edit" && prettier --write . || true'
591-
591+
592592
# Run tests after Claude finishes
593593
claude_stop:
594594
- 'npm test'
595595
- 'echo "✅ Session complete. Test results above."'
596-
596+
597597
# Track Claude's activity
598598
claude_pre_tool_use:
599599
- 'echo "[$(date)] $TOOL_NAME" >> ~/.claude-activity.log'
600600
```
601601

602+
### Configuring Claude Code to Use Workie Hooks
603+
604+
To integrate Workie with Claude Code's native hook system, you need to modify your Claude settings file. Here's how:
605+
606+
1. **Locate your Claude settings file**:
607+
- User settings: `~/.claude/settings.json`
608+
- Project settings: `.claude/settings.json` (in your project root)
609+
- Local settings: `.claude/settings.local.json` (not committed to git)
610+
611+
2. **Add Workie hook commands to your Claude settings**:
612+
613+
```json
614+
{
615+
"hooks": {
616+
"PreToolUse": [
617+
{
618+
"matcher": "Write|Edit",
619+
"hooks": [
620+
{
621+
"type": "command",
622+
"command": "workie hooks run claude_pre_tool_use"
623+
}
624+
]
625+
}
626+
],
627+
"PostToolUse": [
628+
{
629+
"matcher": "Edit",
630+
"hooks": [
631+
{
632+
"type": "command",
633+
"command": "workie hooks run claude_post_tool_use"
634+
}
635+
]
636+
}
637+
],
638+
"UserPromptSubmit": [
639+
{
640+
"hooks": [
641+
{
642+
"type": "command",
643+
"command": "workie hooks run claude_user_prompt_submit"
644+
}
645+
]
646+
}
647+
],
648+
"Stop": [
649+
{
650+
"hooks": [
651+
{
652+
"type": "command",
653+
"command": "workie hooks run claude_stop"
654+
}
655+
]
656+
}
657+
]
658+
}
659+
}
660+
```
661+
662+
3. **Configure your Workie hooks** in `.workie.yaml`:
663+
664+
```yaml
665+
hooks:
666+
claude_pre_tool_use:
667+
- 'echo "Tool: $TOOL_NAME" >> ~/.workie/claude-activity.log'
668+
- 'security-check.sh "$TOOL_NAME"'
669+
670+
claude_post_tool_use:
671+
- 'test "$TOOL_NAME" = "Edit" && npm run lint || true'
672+
673+
claude_stop:
674+
- 'npm test'
675+
- 'git status --short'
676+
677+
# Enable AI decision making for security
678+
ai_decision:
679+
enabled: true
680+
model: "zephyr"
681+
```
682+
683+
4. **Test the integration**:
684+
685+
```bash
686+
# Test that Claude Code can call Workie hooks
687+
workie hooks test
688+
689+
# Manually test a specific hook type
690+
workie hooks run claude_pre_tool_use
691+
692+
# Test with Claude Code input simulation
693+
echo '{"tool_name":"Write","tool_input":{"file_path":"/tmp/test.txt"}}' | workie hooks claude-test --ai
694+
```
695+
696+
This setup allows you to:
697+
- Use Workie's configuration management for your Claude Code hooks
698+
- Leverage Workie's AI decision-making capabilities for tool approval/blocking
699+
- Maintain hook configurations in version control with your project
700+
- Test hooks independently before using them with Claude Code
701+
602702
### Best Practices for Claude Code Hooks
603703

604704
1. **Test Thoroughly**: Always test hooks in a safe environment first

0 commit comments

Comments
 (0)