Skip to content

Commit a46652a

Browse files
committed
feat: add comprehensive hooks system with Claude Code integration and AI decision making
- Add 7 new Claude Code hook types for complete lifecycle integration - Implement native system notifications with cross-platform support - Add AI-powered hook decisions for security and automation - Create comprehensive hook management CLI commands - Add examples and documentation for all hook features - Integrate with beeep library for system notifications - Support configurable notifications with custom titles and icons - Enable AI analysis of hook outputs for tool approval/blocking - Add test commands for validating hook configurations
1 parent 1728083 commit a46652a

11 files changed

Lines changed: 667 additions & 301 deletions

File tree

.workie.yaml

Lines changed: 4 additions & 202 deletions
Original file line numberDiff line numberDiff line change
@@ -1,205 +1,7 @@
1-
# Workie Configuration File
2-
# =========================
3-
# This file defines how Workie manages your development worktrees.
4-
# Uncomment and customize the settings below for your project.
5-
6-
# Core Configuration - Files to Copy to New Worktrees
7-
# ====================================================
8-
files_to_copy:
9-
# Environment files (commonly needed in all worktrees)
10-
- .env.example
11-
# - .env.dev.example
12-
# - .env.test.example
13-
# - .env.local.example
14-
15-
# Configuration files
16-
# - config/development.yaml
17-
# - config/testing.yaml
18-
# - config/staging.yaml
19-
# - .editorconfig
20-
# - .gitignore
21-
22-
# Documentation
23-
# - README.md
24-
# - docs/setup.md
25-
# - docs/development.md
26-
# - CONTRIBUTING.md
27-
28-
# Scripts and tools (use trailing slash for directories)
29-
# - scripts/
30-
# - tools/
31-
# - bin/
32-
33-
# Language-specific files
34-
# Node.js/JavaScript
35-
# - package.json
36-
# - package-lock.json
37-
# - yarn.lock
38-
# - .eslintrc.js
39-
# - .prettierrc
40-
# - tsconfig.json
41-
# - jest.config.js
42-
43-
# Python
44-
# - requirements.txt
45-
# - requirements-dev.txt
46-
# - pyproject.toml
47-
# - setup.py
48-
# - tox.ini
49-
# - .flake8
50-
51-
# Go
52-
# - go.mod
53-
# - go.sum
54-
# - Makefile
55-
56-
# Ruby
57-
# - Gemfile
58-
# - Gemfile.lock
59-
# - .ruby-version
60-
61-
# Docker files
62-
# - Dockerfile
63-
# - Dockerfile.dev
64-
# - docker-compose.yml
65-
# - docker-compose.dev.yml
66-
# - docker-compose.test.yml
67-
# - .dockerignore
68-
69-
# CI/CD files
70-
# - .github/
71-
# - .gitlab-ci.yml
72-
# - .travis.yml
73-
# - circle.yml
74-
75-
# IDE/Editor settings (uncomment if your team uses these)
76-
# - .vscode/
77-
# - .idea/
78-
# - .sublime-project
79-
80-
# Hooks - Run custom commands at various stages
81-
# =============================================
82-
# Workie lifecycle hooks and Claude Code integration hooks
831
hooks:
84-
post_create:
85-
- 'echo "🚀 Starting work session in $(basename $(pwd))"'
86-
- 'echo "📁 Working directory: $(pwd)"'
87-
pre_remove:
88-
- 'echo "👋 Finishing work session"'
89-
- 'git status --short'
90-
# Claude Code hooks (https://docs.anthropic.com/en/docs/claude-code/hooks)
91-
claude_pre_tool_use: # Before Claude uses any tool (Bash, Edit, Read, etc.)
92-
- 'echo "🔧 Claude Code is about to use a tool: $TOOL_NAME"'
93-
- 'test "$TOOL_NAME" = "Write" && echo "⚠️ WARNING: Write operation detected" >&2 || true'
94-
- 'echo "$TOOL_NAME" | grep -E "^(Write|Edit|Delete)" && echo "📝 File modification tool" || echo "✅ Read-only tool"'
95-
claude_post_tool_use: # After Claude successfully uses a tool
96-
- 'echo "✅ Claude Code finished using tool: $TOOL_NAME"'
97-
claude_user_prompt_submit: # When user submits a prompt to Claude
98-
- 'echo "💬 User submitted prompt"'
99-
claude_stop: # When Claude finishes responding
100-
- 'echo "🏁 Claude Code finished responding"'
101-
# claude_notification: # On Claude notifications (permissions, idle)
102-
# claude_subagent_stop: # When a subagent (Task tool) finishes
103-
# claude_pre_compact: # Before context compaction
2+
claude_notification:
3+
- 'echo "Notification hook executed: $MESSAGE"'
1044

105-
timeout_minutes: 2 # Timeout for all hooks (default: 5)
106-
107-
# AI-powered decision making for Claude Code hooks
108-
ai_decision:
109-
enabled: true # Enable AI to analyze hook outputs and make decisions
110-
strict_mode: false # If true, any hook failure results in automatic block
111-
112-
# AI Configuration (Ollama-based Assistant)
113-
# =========================================
114-
# Configure AI features for intelligent code assistance
115-
ai:
116-
enabled: true
117-
model:
118-
provider: "ollama"
119-
name: "zephyr"
120-
temperature: 0.7
121-
max_tokens: 2048
122-
# ollama:
123-
# base_url: "http://localhost:11434"
124-
# keep_alive: "5m"
125-
# features:
126-
# code_analysis: true
127-
# code_generation: true
128-
# commit_message_generation: true
129-
# documentation_generation: true
130-
131-
# Tips for Customizing Your Configuration:
132-
# ========================================
133-
# 1. Start simple - uncomment just the files you need most
134-
# 2. Use relative paths from your repository root
135-
# 3. For directories, include the trailing slash (/)
136-
# 4. Test your configuration with a temporary branch first
137-
# 5. Add comments to explain project-specific choices
138-
# 6. Consider different needs for different branch types
139-
# 7. Keep the file under version control so your team can share it
140-
141-
# Common Patterns:
142-
# ===============
143-
# - Always copy environment examples and config files
144-
# - Include package manager files for dependency installation
145-
# - Copy scripts and tools that help with development
146-
# - Include documentation that developers need to reference
147-
# - Add IDE settings if your team standardizes on specific tools
148-
# - Be selective with CI/CD files to avoid conflicts
149-
150-
# Troubleshooting:
151-
# ===============
152-
# - If a file doesn't exist, Workie will show a warning but continue
153-
# - Use 'workie --verbose' to see detailed copy operations
154-
# - Check file permissions if copies fail
155-
# - Use 'workie --list' to see all your worktrees
156-
# - Use 'workie finish <branch>' to clean up test worktrees
157-
158-
# Issue Provider Configuration (Optional)
159-
# ======================================
160-
# Connect to GitHub, Jira, or Linear to work with issues
161-
162-
# Default provider to use when no provider is specified in issue commands
163-
# default_provider: github
164-
165-
providers:
166-
github:
5+
system_notifications:
1676
enabled: true
168-
settings:
169-
token_env: "WORKIE_GITHUB_TOKEN" # Environment variable containing GitHub personal access token
170-
owner: "agoodway" # Repository owner/organization
171-
repo: "workie" # Repository name
172-
branch_prefix:
173-
bug: "fix/"
174-
feature: "feat/"
175-
default: "issue/"
176-
#
177-
# jira:
178-
# enabled: false
179-
# settings:
180-
# base_url: "https://your-company.atlassian.net"
181-
# email_env: "JIRA_EMAIL" # Environment variable for Jira email
182-
# api_token_env: "JIRA_TOKEN" # Environment variable for Jira API token
183-
# project: "PROJ" # Default project key
184-
# branch_prefix:
185-
# bug: "bugfix/"
186-
# story: "feature/"
187-
# task: "task/"
188-
# default: "jira/"
189-
#
190-
# linear:
191-
# enabled: false
192-
# settings:
193-
# api_key_env: "LINEAR_API_KEY" # Environment variable for Linear API key
194-
# team_id: "TEAM" # Optional: filter by team
195-
# branch_prefix:
196-
# bug: "fix/"
197-
# feature: "feat/"
198-
# default: "linear/"
199-
200-
# Issue Provider Usage:
201-
# ===================
202-
# - List issues: workie issues
203-
# - View issue: workie issues github:123
204-
# - Create worktree from issue: workie issues github:123 --create
205-
# - Filter issues: workie issues --assignee me --status open
7+
title: "Workie Test"

README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,34 @@ hooks:
503503
claude_pre_compact: # Before context compaction
504504
```
505505

506+
### System Notifications
507+
508+
Workie can send system notifications when Claude Code events occur. This is particularly useful for the `claude_notification` hook to alert you when Claude needs your attention.
509+
510+
```yaml
511+
hooks:
512+
# Claude notification hooks
513+
claude_notification:
514+
- 'echo "Notification: $MESSAGE" >> ~/.workie/notifications.log'
515+
- 'play-sound.sh' # Your custom notification sound
516+
517+
# Enable system notifications
518+
system_notifications:
519+
enabled: true
520+
title: "Workie - Claude Code" # Optional: custom title
521+
icon: "assets/icon.png" # Optional: custom icon path
522+
```
523+
524+
When enabled, Workie will:
525+
1. Execute all configured `claude_notification` hooks
526+
2. Send a native system notification with the Claude message
527+
3. Support cross-platform notifications (macOS, Linux, Windows)
528+
529+
The notification will appear as a system alert with:
530+
- **Title**: "Workie - Claude Code" (or your custom title)
531+
- **Message**: The actual notification from Claude (e.g., "Claude needs your permission to use Bash")
532+
- **Icon**: Platform default or your custom icon
533+
506534
### AI-Powered Tool Use Decisions 🤖
507535

508536
Workie can use AI to analyze hook outputs and decide whether to approve or block tool usage:
@@ -654,6 +682,16 @@ To integrate Workie with Claude Code's native hook system, you need to modify yo
654682
}
655683
]
656684
}
685+
],
686+
"Notification": [
687+
{
688+
"hooks": [
689+
{
690+
"type": "command",
691+
"command": "workie hooks run claude_notification"
692+
}
693+
]
694+
}
657695
]
658696
}
659697
}

0 commit comments

Comments
 (0)