Python-based automation framework with dual-layer architecture: native hooks for real-time prompt modification and advanced command system for intelligent workflows including security scanning, PR creation, documentation generation, and project cleanup.
A sophisticated Python-based automation framework for Claude Code with dual-layer architecture for intelligent development workflows.
This framework implements two complementary layers:
**Layer 1: Native Claude Code Hooks**
**Layer 2: Advanced Command System**
1. **Create `.claude/settings.json`** with hook configuration:
```json
{
"hooks": {
"UserPromptSubmit": [
{
"hooks": [
{
"type": "command",
"command": "python \".claude/hooks/UserPromptSubmit/flag_dispatcher.py\""
},
{
"type": "command",
"command": "python \".claude/hooks/UserPromptSubmit/append_ultrathink.py\""
},
{
"type": "command",
"command": "python \".claude/hooks/UserPromptSubmit/answer_in_short.py\""
}
]
}
]
}
}
```
2. **Create hook scripts in `.claude/hooks/UserPromptSubmit/`** directory
3. **Hooks execute sequentially**, each receiving modified prompt from previous hook
Implement intelligent shortcuts for response control:
**Core Performance Flags:**
**Development Focus Flags:**
**Flag Conflict Resolution:**
```python
#!/usr/bin/env python3
import sys
def main():
try:
# Read prompt from stdin
prompt = sys.stdin.read().strip()
# Apply your logic
if should_modify_prompt(prompt):
modified_prompt = modify_prompt(prompt)
print(modified_prompt)
else:
print(prompt) # Output unchanged
sys.exit(0) # Success
except Exception:
sys.exit(1) # Error
if __name__ == "__main__":
main()
```
Implement these specialized commands in `core/command_registry.py`:
**1. `/security`** - Multi-layered security analysis
**2. `/create-PR`** - Intelligent PR creation
**3. `/refactor`** - Context-aware refactoring
**4. `/file-review`** - Comprehensive code analysis
**5. `/push-to-github`** - Validated git push
**6. `/header-comments`** - Intelligent file headers
**7. `/explain-pull-request`** - Architectural documentation
**8. `/create-readme`** - Bilingual README generation
**9. `/update-readme`** - README updates with content preservation
**10. `/git-commit`** - Ultra think-powered commits
**11. `/clean-project`** - Safe project cleanup
Create these core modules:
**`core/context_manager.py`** - Project detection
```python
class ContextManager:
def detect_project_type(self):
# Detect Python, Node.js, Java, Rust, Go, Docker
pass
def get_git_state(self):
# Branch, uncommitted changes, main branch
pass
def check_tool_availability(self):
# git, docker, npm, pip availability
pass
```
**`core/command_registry.py`** - Command execution
```python
class CommandRegistry:
def register_command(self, name, handler, params):
pass
def execute_command(self, name, args):
# Parameter validation
# Prerequisite checking
# Pre/post hooks
pass
```
**`core/hook_dispatcher.py`** - Command hooks
```python
class HookDispatcher:
def execute_pre_command(self, command):
pass
def execute_post_command(self, command, result):
pass
def on_file_change(self, files):
pass
def on_git_action(self, action):
pass
```
Create settings in `.claude/settings/`:
**1. `global.json`** - System-wide defaults
**2. `project.json`** - Project-specific overrides
**3. `hooks.json`** - Hook priorities and conditions
**4. `commands.json`** - Command parameters and validation
Example `commands.json`:
```json
{
"security": {
"enabled": true,
"checks": ["secrets", "dependencies", "static-analysis", "config"]
},
"create-readme": {
"languages": ["en", "zh", "both"],
"styles": ["minimal", "standard", "comprehensive"],
"default_language": "en",
"default_style": "standard"
},
"git-commit": {
"styles": ["conventional", "semantic", "angular"],
"default_style": "conventional",
"auto_detect_type": true
}
}
```
Implement automatic project environment detection:
```python
PROJECT_INDICATORS = {
"python": ["requirements.txt", "setup.py", "pyproject.toml", "Pipfile"],
"node": ["package.json", "webpack.config.js", "yarn.lock"],
"java": ["pom.xml", "build.gradle", "gradlew"],
"rust": ["Cargo.toml"],
"go": ["go.mod", "go.sum"],
"docker": ["Dockerfile", "docker-compose.yml"]
}
```
```bash
"Analyze the authentication system architecture -ut"
"Why is this API call failing? -debug"
"What does this function do? -quick"
"Implement user login function -code -secure"
"Review this algorithm -review -optimize"
```
```bash
/security
/create-PR --draft --base=develop
/create-readme --lang=both --style=comprehensive
/update-readme --lang=both
/git-commit --style=conventional
/git-commit --style=semantic --dry-run
/clean-project --mode=safe --dry-run
/clean-project --mode=moderate
```
When setting up this framework:
1. **Hook System**
- [ ] Create `.claude/settings.json` with hook configuration
- [ ] Implement `flag_dispatcher.py` for flag processing
- [ ] Create mode-specific hooks (ultrathink, short, explain, default)
- [ ] Test hook execution order
2. **Command System**
- [ ] Implement `core/context_manager.py` for project detection
- [ ] Implement `core/command_registry.py` for command execution
- [ ] Implement `core/hook_dispatcher.py` for command hooks
- [ ] Create configuration files in `.claude/settings/`
3. **Commands**
- [ ] Implement security analysis command
- [ ] Implement PR creation workflow
- [ ] Implement refactoring system
- [ ] Implement bilingual README generation
- [ ] Implement intelligent git commit
- [ ] Implement safe project cleanup
4. **Testing**
- [ ] Test flag conflict resolution
- [ ] Test command parameter validation
- [ ] Test context detection accuracy
- [ ] Test bilingual content generation
- [ ] Test cleanup safety measures
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/claude-code-automation-framework-lwde3l/raw