mirror of
https://github.com/cexll/myclaude.git
synced 2026-02-04 02:20:42 +08:00
## Overview Complete implementation of enterprise-level workflow features including multi-backend execution (Codex/Claude/Gemini), GitHub issue-to-PR automation, hooks system, and comprehensive documentation. ## Major Changes ### 1. Multi-Backend Support (codeagent-wrapper) - Renamed codex-wrapper → codeagent-wrapper - Backend interface with Codex/Claude/Gemini implementations - Multi-format JSON stream parser (auto-detects backend) - CLI flag: --backend codex|claude|gemini (default: codex) - Test coverage: 89.2% **Files:** - codeagent-wrapper/backend.go - Backend interface - codeagent-wrapper/parser.go - Multi-format parser - codeagent-wrapper/config.go - CLI parsing with backend selection - codeagent-wrapper/executor.go - Process execution - codeagent-wrapper/logger.go - Async logging - codeagent-wrapper/utils.go - Utilities ### 2. GitHub Workflow Commands - /gh-create-issue - Create structured issues via guided dialogue - /gh-implement - Issue-to-PR automation with full dev lifecycle **Files:** - github-workflow/commands/gh-create-issue.md - github-workflow/commands/gh-implement.md - skills/codeagent/SKILL.md ### 3. Hooks System - UserPromptSubmit hook for skill activation - Pre-commit example with code quality checks - merge_json operation in install.py for settings.json merging **Files:** - hooks/skill-activation-prompt.sh|.js - hooks/pre-commit.sh - hooks/hooks-config.json - hooks/test-skill-activation.sh ### 4. Skills System - skill-rules.json for auto-activation - codeagent skill for multi-backend wrapper **Files:** - skills/skill-rules.json - skills/codeagent/SKILL.md - skills/codex/SKILL.md (updated) ### 5. Installation System - install.py: Added merge_json operation - config.json: Added "gh" module - config.schema.json: Added op_merge_json schema ### 6. CI/CD - GitHub Actions workflow for testing and building **Files:** - .github/workflows/ci.yml ### 7. Comprehensive Documentation - Architecture overview with ASCII diagrams - Codeagent-wrapper complete usage guide - GitHub workflow detailed examples - Hooks customization guide **Files:** - docs/architecture.md (21KB) - docs/CODEAGENT-WRAPPER.md (9KB) - docs/GITHUB-WORKFLOW.md (9KB) - docs/HOOKS.md (4KB) - docs/enterprise-workflow-ideas.md - README.md (updated with doc links) ## Test Results - All tests passing ✅ - Coverage: 89.2% - Security scan: 0 issues (gosec) ## Breaking Changes - codex-wrapper renamed to codeagent-wrapper - Default backend: codex (documented in README) ## Migration Guide Users with codex-wrapper installed should: 1. Run: python3 install.py --module dev --force 2. Update shell aliases if any 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
3.8 KiB
3.8 KiB
Claude Code Hooks Guide
Hooks are shell scripts or commands that execute in response to Claude Code events.
Available Hook Types
1. UserPromptSubmit
Runs after user submits a prompt, before Claude processes it.
Use cases:
- Auto-activate skills based on keywords
- Add context injection
- Log user requests
2. PostToolUse
Runs after Claude uses a tool.
Use cases:
- Validate tool outputs
- Run additional checks (linting, formatting)
- Log tool usage
3. Stop
Runs when Claude Code session ends.
Use cases:
- Cleanup temporary files
- Generate session reports
- Commit changes automatically
Configuration
Hooks are configured in .claude/settings.json:
{
"hooks": {
"UserPromptSubmit": [
{
"hooks": [
{
"type": "command",
"command": "$CLAUDE_PROJECT_DIR/hooks/skill-activation-prompt.sh"
}
]
}
],
"PostToolUse": [
{
"hooks": [
{
"type": "command",
"command": "$CLAUDE_PROJECT_DIR/hooks/post-tool-check.sh"
}
]
}
]
}
}
Creating Custom Hooks
Example: Pre-Commit Hook
File: hooks/pre-commit.sh
#!/bin/bash
set -e
# Get staged files
STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM)
# Run tests on Go files
GO_FILES=$(echo "$STAGED_FILES" | grep '\.go$' || true)
if [ -n "$GO_FILES" ]; then
go test ./... -short || exit 1
fi
# Validate JSON files
JSON_FILES=$(echo "$STAGED_FILES" | grep '\.json$' || true)
if [ -n "$JSON_FILES" ]; then
for file in $JSON_FILES; do
jq empty "$file" || exit 1
done
fi
echo "✅ Pre-commit checks passed"
Register in settings.json:
{
"hooks": {
"PostToolUse": [
{
"hooks": [
{
"type": "command",
"command": "$CLAUDE_PROJECT_DIR/hooks/pre-commit.sh"
}
]
}
]
}
}
Example: Auto-Format Hook
File: hooks/auto-format.sh
#!/bin/bash
# Format Go files
find . -name "*.go" -exec gofmt -w {} \;
# Format JSON files
find . -name "*.json" -exec jq --indent 2 . {} \; -exec mv {} {}.tmp \; -exec mv {}.tmp {} \;
echo "✅ Files formatted"
Environment Variables
Hooks have access to:
$CLAUDE_PROJECT_DIR- Project root directory$PWD- Current working directory- All shell environment variables
Best Practices
- Keep hooks fast - Slow hooks block Claude Code
- Handle errors gracefully - Return non-zero on failure
- Use absolute paths - Reference
$CLAUDE_PROJECT_DIR - Make scripts executable -
chmod +x hooks/script.sh - Test independently - Run hooks manually first
- Document behavior - Add comments explaining logic
Debugging Hooks
Enable verbose logging:
# Add to your hook
set -x # Print commands
set -e # Exit on error
Test manually:
cd /path/to/project
./hooks/your-hook.sh
echo $? # Check exit code
Built-in Hooks
This repository includes:
| Hook | File | Purpose |
|---|---|---|
| Skill Activation | skill-activation-prompt.sh |
Auto-suggest skills |
| Pre-commit | pre-commit.sh |
Code quality checks |
Disabling Hooks
Remove hook configuration from .claude/settings.json or set empty array:
{
"hooks": {
"UserPromptSubmit": []
}
}
Troubleshooting
Hook not running?
- Check
.claude/settings.jsonsyntax - Verify script is executable:
ls -l hooks/ - Check script path is correct
Hook failing silently?
- Add
set -eto script - Check exit codes:
echo $? - Add logging:
echo "debug" >> /tmp/hook.log