Files
claude-howto/07-hooks/validate-prompt.sh
Luong NGUYEN 6238744478 Add comprehensive Claude Code advanced features
Added three new major feature categories with complete documentation and examples:

## New Features

### 07-hooks/
- Event-driven automation with 6 example hook scripts
- Pre/post tool hooks, session hooks, and git hooks
- Auto-formatting, security scanning, test automation
- Complete documentation with best practices

### 08-checkpoints/
- Conversation state snapshots and rewind capability
- Safe experimentation and approach comparison
- Real-world examples: DB migration, performance optimization, UI iteration
- Checkpoint management commands and workflows

### 09-advanced-features/
- Planning Mode: detailed implementation plans before coding
- Extended Thinking: deep reasoning for complex problems
- Background Tasks: long-running operations without blocking
- Permission Modes: unrestricted, confirm, read-only, custom
- Headless Mode: CI/CD integration and automation
- Session Management: multiple work sessions
- Interactive Features: keyboard shortcuts, command history
- 10+ configuration examples for different scenarios

## Documentation Updates

- README.md: Added sections for all new features with examples
- INDEX.md: Updated with new categories, file listings, and search keywords
- QUICK_REFERENCE.md: Added quick reference for new features
- claude_concepts_guide.md: Comprehensive guide sections for new concepts

## Statistics

- Total files: 90+ (up from 71)
- Categories: 9 (up from 6)
- New hook scripts: 6
- New documentation files: 10+
- Configuration examples: 10+ scenarios

All examples are production-ready and follow Claude Code best practices.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-08 00:27:53 +01:00

44 lines
996 B
Bash

#!/bin/bash
# Validate user prompts
# Hook: UserPromptSubmit
# Read prompt from stdin
PROMPT=$(cat)
echo "🔍 Validating prompt..."
# Check for dangerous operations
DANGEROUS_PATTERNS=(
"rm -rf /"
"delete database"
"drop database"
"format disk"
"dd if="
)
for pattern in "${DANGEROUS_PATTERNS[@]}"; do
if echo "$PROMPT" | grep -qi "$pattern"; then
echo "❌ Blocked: Dangerous operation detected: $pattern"
exit 1
fi
done
# Check for production deployments
if echo "$PROMPT" | grep -qiE "(deploy|push).*production"; then
if [ ! -f ".deployment-approved" ]; then
echo "❌ Blocked: Production deployment requires approval"
echo "Create .deployment-approved file to proceed"
exit 1
fi
fi
# Check for required context in certain operations
if echo "$PROMPT" | grep -qi "refactor"; then
if [ ! -f "tests/" ] && [ ! -f "test/" ]; then
echo "⚠️ Warning: Refactoring without tests may be risky"
fi
fi
echo "✅ Prompt validation passed"
exit 0