@paulduvall/claude-dev-toolkit 0.0.1-alpha.2 → 0.0.1-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/README.md +44 -6
  2. package/commands/active/xarchitecture.md +393 -0
  3. package/commands/active/xconfig.md +127 -0
  4. package/commands/active/xdebug.md +130 -0
  5. package/commands/active/xdocs.md +178 -0
  6. package/commands/active/xgit.md +149 -0
  7. package/commands/active/xpipeline.md +152 -0
  8. package/commands/active/xquality.md +96 -0
  9. package/commands/active/xrefactor.md +198 -0
  10. package/commands/active/xrelease.md +142 -0
  11. package/commands/active/xsecurity.md +92 -0
  12. package/commands/active/xspec.md +174 -0
  13. package/commands/active/xtdd.md +151 -0
  14. package/commands/active/xtest.md +89 -0
  15. package/commands/experiments/xact.md +742 -0
  16. package/commands/experiments/xanalytics.md +113 -0
  17. package/commands/experiments/xanalyze.md +70 -0
  18. package/commands/experiments/xapi.md +161 -0
  19. package/commands/experiments/xatomic.md +112 -0
  20. package/commands/experiments/xaws.md +85 -0
  21. package/commands/experiments/xcicd.md +337 -0
  22. package/commands/experiments/xcommit.md +122 -0
  23. package/commands/experiments/xcompliance.md +182 -0
  24. package/commands/experiments/xconstraints.md +89 -0
  25. package/commands/experiments/xcoverage.md +90 -0
  26. package/commands/experiments/xdb.md +102 -0
  27. package/commands/experiments/xdesign.md +121 -0
  28. package/commands/experiments/xevaluate.md +111 -0
  29. package/commands/experiments/xfootnote.md +12 -0
  30. package/commands/experiments/xgenerate.md +117 -0
  31. package/commands/experiments/xgovernance.md +149 -0
  32. package/commands/experiments/xgreen.md +66 -0
  33. package/commands/experiments/xiac.md +118 -0
  34. package/commands/experiments/xincident.md +137 -0
  35. package/commands/experiments/xinfra.md +115 -0
  36. package/commands/experiments/xknowledge.md +115 -0
  37. package/commands/experiments/xmaturity.md +120 -0
  38. package/commands/experiments/xmetrics.md +118 -0
  39. package/commands/experiments/xmonitoring.md +128 -0
  40. package/commands/experiments/xnew.md +898 -0
  41. package/commands/experiments/xobservable.md +114 -0
  42. package/commands/experiments/xoidc.md +165 -0
  43. package/commands/experiments/xoptimize.md +115 -0
  44. package/commands/experiments/xperformance.md +112 -0
  45. package/commands/experiments/xplanning.md +131 -0
  46. package/commands/experiments/xpolicy.md +115 -0
  47. package/commands/experiments/xproduct.md +98 -0
  48. package/commands/experiments/xreadiness.md +75 -0
  49. package/commands/experiments/xred.md +55 -0
  50. package/commands/experiments/xrisk.md +128 -0
  51. package/commands/experiments/xrules.md +124 -0
  52. package/commands/experiments/xsandbox.md +120 -0
  53. package/commands/experiments/xscan.md +102 -0
  54. package/commands/experiments/xsetup.md +123 -0
  55. package/commands/experiments/xtemplate.md +116 -0
  56. package/commands/experiments/xtrace.md +212 -0
  57. package/commands/experiments/xux.md +171 -0
  58. package/commands/experiments/xvalidate.md +104 -0
  59. package/commands/experiments/xworkflow.md +113 -0
  60. package/hooks/README.md +231 -0
  61. package/hooks/file-logger.sh +98 -0
  62. package/hooks/lib/argument-parser.sh +422 -0
  63. package/hooks/lib/config-constants.sh +230 -0
  64. package/hooks/lib/context-manager.sh +549 -0
  65. package/hooks/lib/error-handler.sh +412 -0
  66. package/hooks/lib/execution-engine.sh +627 -0
  67. package/hooks/lib/file-utils.sh +375 -0
  68. package/hooks/lib/subagent-discovery.sh +465 -0
  69. package/hooks/lib/subagent-validator.sh +597 -0
  70. package/hooks/on-error-debug.sh +221 -0
  71. package/hooks/pre-commit-quality.sh +204 -0
  72. package/hooks/pre-write-security.sh +107 -0
  73. package/hooks/prevent-credential-exposure.sh +265 -0
  74. package/hooks/subagent-trigger-simple.sh +193 -0
  75. package/hooks/subagent-trigger.sh +253 -0
  76. package/lib/hook-installer-core.js +2 -2
  77. package/package.json +3 -1
  78. package/templates/README.md +100 -0
  79. package/templates/basic-settings.json +30 -0
  80. package/templates/comprehensive-settings.json +206 -0
  81. package/templates/hybrid-hook-config.yaml +133 -0
  82. package/templates/security-focused-settings.json +62 -0
  83. package/templates/subagent-hooks.yaml +188 -0
@@ -0,0 +1,171 @@
1
+ ---
2
+ description: User experience optimization, frontend testing, and accessibility compliance with SpecDriven AI methodology integration
3
+ tags: [ux, frontend, accessibility, performance, testing, user-journey]
4
+ ---
5
+
6
+ # /xux - User Experience & Frontend
7
+
8
+ ## Purpose
9
+ Optimize user experience, conduct frontend testing, and ensure accessibility compliance with SpecDriven AI methodology integration.
10
+
11
+ ## Usage
12
+
13
+ ### User Journey Testing
14
+ ```bash
15
+ /xux --test <journey> # Test complete user journeys and flows
16
+ /xux --flow <scenario> # Analyze user flow optimization
17
+ /xux --conversion <funnel> # Conversion funnel analysis and optimization
18
+ /xux --personas <validation> # Validate design against user personas
19
+ ```
20
+
21
+ ### Accessibility Compliance
22
+ ```bash
23
+ /xux --accessibility <audit> # Comprehensive accessibility audit
24
+ /xux --wcag <level> # WCAG compliance checking (A, AA, AAA)
25
+ /xux --screen-reader <test> # Screen reader compatibility testing
26
+ /xux --contrast <validation> # Color contrast validation
27
+ ```
28
+
29
+ ### Frontend Performance
30
+ ```bash
31
+ /xux --performance <metrics> # Frontend performance analysis
32
+ /xux --lighthouse <audit> # Google Lighthouse audit automation
33
+ /xux --core-vitals <monitoring> # Core Web Vitals monitoring
34
+ /xux --bundle <analysis> # JavaScript bundle analysis
35
+ ```
36
+
37
+ ### Visual Testing
38
+ ```bash
39
+ /xux --regression <baseline> # Visual regression testing
40
+ /xux --cross-browser <matrix> # Cross-browser compatibility testing
41
+ /xux --responsive <breakpoints> # Responsive design validation
42
+ /xux --component <library> # Component library testing
43
+ ```
44
+
45
+ ### User Behavior Analytics
46
+ ```bash
47
+ /xux --analytics <tracking> # User behavior tracking setup
48
+ /xux --heatmaps <analysis> # User interaction heatmap analysis
49
+ /xux --session <recording> # User session recording analysis
50
+ /xux --feedback <collection> # User feedback collection and analysis
51
+ ```
52
+
53
+ ### UX Optimization
54
+ ```bash
55
+ /xux --optimization <recommendations> # UX optimization suggestions
56
+ /xux --ab-test <experiment> # A/B testing setup and analysis
57
+ /xux --usability <testing> # Usability testing procedures
58
+ /xux --design-system <validation> # Design system compliance checking
59
+ ```
60
+
61
+ ## Examples
62
+
63
+ ### Comprehensive Accessibility Audit
64
+ ```bash
65
+ /xux --accessibility "full-site-audit"
66
+ # Creates: reports/accessibility-audit-2024-01.md with WCAG compliance analysis
67
+ ```
68
+
69
+ ### Performance Optimization
70
+ ```bash
71
+ /xux --performance "core-vitals-analysis"
72
+ # Creates: reports/performance-analysis.md with optimization recommendations
73
+ ```
74
+
75
+ ### User Journey Validation
76
+ ```bash
77
+ /xux --test "checkout-flow"
78
+ # Creates: tests/user-journeys/checkout-flow/ with automated test scenarios
79
+ ```
80
+
81
+ ### Visual Regression Testing
82
+ ```bash
83
+ /xux --regression "component-library-v2"
84
+ # Creates: visual-tests/regression/ with baseline comparisons
85
+ ```
86
+
87
+ ## SpecDriven AI Integration
88
+
89
+ ### UX Specifications
90
+ - Links UX to specifications: `{#ux1a authority=developer}`
91
+ - Traces user requirements to implementations
92
+ - Validates designs against user stories
93
+
94
+ ### Dual Coverage
95
+ - **Feature Coverage**: All user features have UX validation
96
+ - **Accessibility Coverage**: All interfaces meet accessibility standards
97
+
98
+ ### Traceability
99
+ - Links UX tests to user story specifications
100
+ - Traces performance issues to user experience
101
+ - Connects analytics to user requirement validation
102
+
103
+ ## UX Testing Framework
104
+
105
+ ### User Journey Categories
106
+ - **Critical Paths**: Core business flow testing
107
+ - **Edge Cases**: Error handling and validation
108
+ - **Accessibility**: Assistive technology compatibility
109
+ - **Performance**: Loading and interaction speed
110
+
111
+ ### Testing Methodologies
112
+ - **Automated Testing**: Playwright, Cypress, Selenium
113
+ - **Visual Testing**: Percy, Chromatic, BackstopJS
114
+ - **Performance Testing**: Lighthouse CI, WebPageTest
115
+ - **Accessibility Testing**: axe-core, WAVE, Pa11y
116
+
117
+ ### Metrics & KPIs
118
+ - **Core Web Vitals**: LCP, FID, CLS
119
+ - **Accessibility Score**: WCAG compliance percentage
120
+ - **User Satisfaction**: NPS, CSAT, task completion rates
121
+ - **Conversion Metrics**: Funnel completion, abandonment rates
122
+
123
+ ## Design System Integration
124
+
125
+ ### Component Validation
126
+ - **Visual Consistency**: Design token compliance
127
+ - **Interaction Patterns**: Consistent behavior across components
128
+ - **Responsive Behavior**: Breakpoint validation
129
+ - **Accessibility Standards**: Component-level accessibility
130
+
131
+ ### Documentation
132
+ - **Usage Guidelines**: Component implementation guides
133
+ - **Accessibility Notes**: Component-specific accessibility requirements
134
+ - **Browser Support**: Compatibility matrices
135
+ - **Performance Impact**: Component performance characteristics
136
+
137
+ ## Browser & Device Support
138
+
139
+ ### Desktop Browsers
140
+ - **Chrome**: Latest 2 versions + 1 previous major
141
+ - **Firefox**: Latest 2 versions + ESR
142
+ - **Safari**: Latest 2 versions
143
+ - **Edge**: Latest 2 versions
144
+
145
+ ### Mobile Devices
146
+ - **iOS Safari**: Latest 2 versions
147
+ - **Chrome Mobile**: Latest 2 versions
148
+ - **Samsung Internet**: Latest version
149
+ - **Device Testing**: Physical device validation
150
+
151
+ ### Assistive Technologies
152
+ - **Screen Readers**: NVDA, JAWS, VoiceOver
153
+ - **Voice Control**: Dragon NaturallySpeaking
154
+ - **Switch Navigation**: Hardware switch support
155
+ - **High Contrast**: Windows High Contrast mode
156
+
157
+ ## Integration Points
158
+
159
+ - **Design tools**: Figma, Sketch, Adobe XD integration
160
+ - **Analytics platforms**: Google Analytics, Mixpanel, Amplitude
161
+ - **Testing frameworks**: Jest, Playwright, Cypress
162
+ - **CI/CD pipelines**: Automated testing and reporting
163
+ - **Monitoring**: Real User Monitoring (RUM) integration
164
+
165
+ ## Output Formats
166
+
167
+ - **Test reports**: Automated testing results and recommendations
168
+ - **Accessibility audits**: WCAG compliance reports with remediation steps
169
+ - **Performance reports**: Core Web Vitals analysis and optimization guides
170
+ - **User journey maps**: Visual flow documentation with test coverage
171
+ - **Analytics dashboards**: User behavior insights and conversion metrics
@@ -0,0 +1,104 @@
1
+ ---
2
+ description: Comprehensive validation ensuring project meets quality, security, and compliance standards
3
+ tags: [validation, quality, compliance]
4
+ ---
5
+
6
+ Validate the project against quality, security, and compliance standards.
7
+
8
+ Parse validation options from $ARGUMENTS (--pre-commit, --pre-deploy, --quality, --security, etc.). Default to comprehensive validation if no arguments.
9
+
10
+ ## 1. Project Structure Check
11
+
12
+ First, verify essential files exist:
13
+ !ls -la | grep -E "(README|LICENSE|.gitignore|requirements.txt|package.json)"
14
+
15
+ Check project structure:
16
+ !find . -type f -name "*.py" -o -name "*.js" -o -name "*.ts" | wc -l
17
+ !find . -type f -name "*test*" -o -name "*spec*" | wc -l
18
+
19
+ ## 2. Code Quality Validation
20
+
21
+ Run linting and formatting checks:
22
+ !python -m black --check . 2>/dev/null || echo "Black not configured"
23
+ !python -m ruff check . 2>/dev/null || echo "Ruff not configured"
24
+ !npm run lint 2>/dev/null || echo "No lint script configured"
25
+
26
+ Check type annotations (Python):
27
+ !python -m mypy . --ignore-missing-imports 2>/dev/null || echo "Mypy not configured"
28
+
29
+ ## 3. Test Coverage Validation
30
+
31
+ Run tests with coverage:
32
+ !python -m pytest --cov=. --cov-report=term-missing 2>/dev/null || npm test -- --coverage 2>/dev/null || echo "No test coverage available"
33
+
34
+ ## 4. Security Validation
35
+
36
+ Quick security check:
37
+ !git grep -i "password.*=" --no-index | grep -v -E "(test|spec|example)" | head -5
38
+ !npm audit --audit-level=high 2>/dev/null || echo "No npm audit available"
39
+
40
+ ## 5. Documentation Validation
41
+
42
+ Check documentation completeness:
43
+ !find . -name "*.py" -exec grep -L '"""' {} \; 2>/dev/null | head -10
44
+ !test -f README.md && echo "README.md exists" || echo "Missing README.md"
45
+
46
+ ## 6. Configuration Validation
47
+
48
+ Check for required configuration:
49
+ !test -f .env.example && echo ".env.example exists" || echo "Missing .env.example"
50
+ !grep -E "TODO|FIXME|XXX" . -r --include="*.py" --include="*.js" | wc -l
51
+
52
+ Think step by step about validation results and provide:
53
+
54
+ 1. Overall validation status (PASS/FAIL)
55
+ 2. Specific issues that need fixing
56
+ 3. Priority order for fixes
57
+ 4. Commands to fix each issue
58
+
59
+ Generate validation report in this format:
60
+
61
+ ```
62
+ 📋 VALIDATION REPORT
63
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━
64
+ Overall Status: [PASS/FAIL]
65
+ Validation Type: $ARGUMENTS
66
+
67
+ ✅ PASSED CHECKS (X/Y)
68
+ ────────────────────
69
+ ✓ [Check name]: [Details]
70
+ ✓ [Check name]: [Details]
71
+
72
+ ❌ FAILED CHECKS (X/Y)
73
+ ────────────────────
74
+ ✗ [Check name]: [Details]
75
+ Fix: [Specific command or action]
76
+
77
+ ✗ [Check name]: [Details]
78
+ Fix: [Specific command or action]
79
+
80
+ 🔧 QUICK FIXES
81
+ ─────────────
82
+ 1. [Command to run]
83
+ 2. [Command to run]
84
+ 3. [Command to run]
85
+
86
+ 📊 METRICS
87
+ ─────────
88
+ - Code Coverage: X%
89
+ - Type Coverage: X%
90
+ - Documentation: X%
91
+ - Security Issues: X
92
+ ```
93
+
94
+ If --fix is provided, attempt to auto-fix issues:
95
+ !python -m black . 2>/dev/null
96
+ !python -m ruff check --fix . 2>/dev/null
97
+
98
+ For pre-deployment validation (--pre-deploy), run additional checks:
99
+ - Performance benchmarks
100
+ - Integration tests
101
+ - Environment variable verification
102
+ - Database migration status
103
+
104
+ Return exit code 0 if validation passes, 1 if it fails (for CI/CD integration).
@@ -0,0 +1,113 @@
1
+ ---
2
+ description: Automate and optimize development workflows with configurable automation patterns
3
+ tags: [workflow, automation, orchestration, patterns, optimization, monitoring]
4
+ ---
5
+
6
+ Manage and execute development workflows based on the arguments provided in $ARGUMENTS.
7
+
8
+ First, examine the current workflow configuration and environment:
9
+ !ls -la .workflows/ 2>/dev/null || echo "No workflows directory found"
10
+ !find . -name "*.yml" -o -name "*.yaml" | grep -E "(workflow|pipeline)" | head -5
11
+ !git log --oneline -10 2>/dev/null || echo "No git repository found"
12
+
13
+ Based on $ARGUMENTS, perform the appropriate workflow operation:
14
+
15
+ ## 1. Workflow Creation and Management
16
+
17
+ If creating workflows (--create):
18
+ !mkdir -p .workflows/
19
+ !find .workflows/ -name "*.yml" | wc -l
20
+ !ls -la .github/workflows/ 2>/dev/null || echo "No GitHub Actions workflows found"
21
+
22
+ Create and configure automated workflows:
23
+ - Analyze project structure and requirements
24
+ - Generate workflow templates based on project type
25
+ - Configure workflow parameters and triggers
26
+ - Integrate with existing CI/CD systems
27
+ - Validate workflow syntax and dependencies
28
+
29
+ ## 2. Workflow Execution
30
+
31
+ If running workflows (--run):
32
+ !find .workflows/ -name "$workflow_name.yml" 2>/dev/null || echo "Workflow not found"
33
+ !git status --porcelain
34
+ !python -c "import yaml; print('YAML parsing available')" 2>/dev/null || echo "YAML parser needed"
35
+
36
+ Execute workflow with parameter substitution:
37
+ - Parse workflow definition and parameters
38
+ - Substitute variables and environment values
39
+ - Execute workflow steps in sequence
40
+ - Handle step failures and error conditions
41
+ - Generate execution logs and reports
42
+
43
+ ## 3. Workflow Discovery and Listing
44
+
45
+ If listing workflows (--list):
46
+ !find .workflows/ -name "*.yml" -o -name "*.yaml" | head -10
47
+ !grep -r "description:" .workflows/ 2>/dev/null | head -5
48
+ !find .github/workflows/ -name "*.yml" 2>/dev/null | head -5
49
+
50
+ Discover and catalog available workflows:
51
+ - Scan workflow directories for definitions
52
+ - Parse workflow metadata and descriptions
53
+ - Categorize workflows by type and purpose
54
+ - Display workflow parameters and requirements
55
+ - Show workflow status and execution history
56
+
57
+ ## 4. Workflow Optimization
58
+
59
+ If optimizing workflows (--optimize):
60
+ !find .workflows/ -name "*.yml" -exec grep -l "parallel" {} \; 2>/dev/null
61
+ !git log --since="30 days ago" --grep="workflow" --oneline | wc -l
62
+ !ps aux | grep -E "(workflow|pipeline)" | head -5
63
+
64
+ Analyze and optimize workflow performance:
65
+ - Identify workflow bottlenecks and dependencies
66
+ - Recommend parallelization opportunities
67
+ - Optimize resource utilization and timing
68
+ - Reduce workflow execution time
69
+ - Improve workflow reliability and success rates
70
+
71
+ ## 5. Workflow Monitoring
72
+
73
+ If monitoring workflows (--monitor):
74
+ !find .workflows/ -name "*.log" -o -name "*execution*" | head -5
75
+ !tail -20 .workflows/execution.log 2>/dev/null || echo "No execution log found"
76
+ !ps aux | grep workflow | grep -v grep
77
+
78
+ Monitor workflow execution and performance:
79
+ - Track workflow execution status
80
+ - Monitor resource usage and performance metrics
81
+ - Alert on workflow failures or anomalies
82
+ - Generate workflow performance reports
83
+ - Maintain execution history and analytics
84
+
85
+ Think step by step about workflow automation requirements and provide:
86
+
87
+ 1. **Workflow Analysis**:
88
+ - Current workflow inventory and status
89
+ - Workflow dependencies and relationships
90
+ - Performance metrics and bottlenecks
91
+ - Integration points and requirements
92
+
93
+ 2. **Automation Strategy**:
94
+ - Workflow template recommendations
95
+ - Parameter configuration and validation
96
+ - Step sequencing and parallelization
97
+ - Error handling and recovery procedures
98
+
99
+ 3. **Optimization Opportunities**:
100
+ - Performance improvement recommendations
101
+ - Resource utilization optimization
102
+ - Workflow consolidation possibilities
103
+ - Parallel execution opportunities
104
+
105
+ 4. **Monitoring and Maintenance**:
106
+ - Execution tracking and logging
107
+ - Performance monitoring setup
108
+ - Alert configuration recommendations
109
+ - Workflow health assessment
110
+
111
+ Generate comprehensive workflow automation with template creation, execution orchestration, performance optimization, and monitoring integration.
112
+
113
+ If no specific operation is provided, analyze existing workflows and recommend automation improvements based on project structure and development patterns.
@@ -0,0 +1,231 @@
1
+ # Claude Code Hooks Collection
2
+
3
+ This directory contains security and workflow hooks for Claude Code that provide enterprise-grade governance and automation.
4
+
5
+ ## Available Hooks
6
+
7
+ ### `file-logger.sh`
8
+ **Purpose**: Simple demonstration of hook functionality without security implications.
9
+
10
+ **Features**:
11
+ - ✅ Logs file operations (Edit, Write, MultiEdit tools)
12
+ - ✅ Shows file information (size, lines, type)
13
+ - ✅ Non-blocking - always allows operations to proceed
14
+ - ✅ Perfect for learning how hooks work
15
+
16
+ **Configuration**:
17
+ ```json
18
+ {
19
+ "hooks": {
20
+ "PreToolUse": [
21
+ {
22
+ "matcher": "Edit|Write|MultiEdit",
23
+ "hooks": [
24
+ {
25
+ "type": "command",
26
+ "command": "./hooks/file-logger.sh",
27
+ "blocking": false,
28
+ "timeout": 5000
29
+ }
30
+ ]
31
+ }
32
+ ]
33
+ }
34
+ }
35
+ ```
36
+
37
+ **Log Location**: `~/.claude/logs/file-logger.log`
38
+
39
+ ### `prevent-credential-exposure.sh`
40
+ **Purpose**: Prevents accidental credential exposure in AI-generated or AI-modified code.
41
+
42
+ **Features**:
43
+ - ✅ Detects 15+ credential patterns (API keys, tokens, passwords, private keys)
44
+ - ✅ Blocks dangerous operations with detailed warnings
45
+ - ✅ Comprehensive logging and audit trails
46
+ - ✅ Security team notifications via webhooks
47
+ - ✅ Emergency override capability for authorized users
48
+ - ✅ Environment variable and URL credential detection
49
+
50
+ **Configuration**:
51
+ ```json
52
+ {
53
+ "hooks": {
54
+ "PreToolUse": [
55
+ {
56
+ "matcher": "Edit|Write|MultiEdit",
57
+ "hooks": [
58
+ {
59
+ "type": "command",
60
+ "command": "./hooks/prevent-credential-exposure.sh",
61
+ "blocking": true,
62
+ "timeout": 10000
63
+ }
64
+ ]
65
+ }
66
+ ]
67
+ }
68
+ }
69
+ ```
70
+
71
+ **Environment Variables**:
72
+ - `SECURITY_WEBHOOK_URL`: Optional Slack/Teams webhook for security alerts
73
+ - `CLAUDE_SECURITY_OVERRIDE`: Emergency override (use with extreme caution)
74
+
75
+ ## Hook Installation
76
+
77
+ ### Option 1: Global Installation (Recommended)
78
+ ```bash
79
+ # Copy to Claude Code hooks directory
80
+ cp hooks/file-logger.sh ~/.claude/hooks/
81
+
82
+ # Make executable
83
+ chmod +x ~/.claude/hooks/file-logger.sh
84
+
85
+ # Configure in ~/.claude/settings.json
86
+ ```
87
+
88
+ ### Option 2: Project-Specific Installation
89
+ ```bash
90
+ # Use relative path in project settings
91
+ # Add to .claude/settings.json in your project
92
+ ```
93
+
94
+ ## Configuration Examples
95
+
96
+ ### Basic Security Configuration
97
+ ```json
98
+ {
99
+ "hooks": {
100
+ "PreToolUse": [
101
+ {
102
+ "matcher": "Edit|Write|MultiEdit",
103
+ "hooks": [
104
+ {
105
+ "type": "command",
106
+ "command": "~/.claude/hooks/file-logger.sh",
107
+ "blocking": false
108
+ }
109
+ ]
110
+ }
111
+ ]
112
+ }
113
+ }
114
+ ```
115
+
116
+ ### Enhanced Configuration with Notifications
117
+ ```bash
118
+ # Set webhook for security alerts
119
+ export SECURITY_WEBHOOK_URL="https://hooks.slack.com/services/YOUR/SLACK/WEBHOOK"
120
+
121
+ # Add to your shell profile for persistence
122
+ echo 'export SECURITY_WEBHOOK_URL="https://hooks.slack.com/services/YOUR/SLACK/WEBHOOK"' >> ~/.zshrc
123
+ ```
124
+
125
+ ## Testing the Hook
126
+
127
+ ### Test 1: Basic Credential Detection
128
+ ```bash
129
+ # Create a test file with a fake API key
130
+ echo 'API_KEY="sk-ant-1234567890abcdef"' > test-credentials.txt
131
+
132
+ # Try to edit with Claude Code - should be blocked
133
+ claude edit test-credentials.txt
134
+ ```
135
+
136
+ ### Test 2: Environment Variable Exposure
137
+ ```bash
138
+ # Create a test file with environment exposure
139
+ echo 'const apiKey = process.env.SECRET_API_KEY;' > test-env.js
140
+
141
+ # Try to edit with Claude Code - should be blocked
142
+ claude edit test-env.js
143
+ ```
144
+
145
+ ### Test 3: Emergency Override
146
+ ```bash
147
+ # Enable override (use sparingly!)
148
+ export CLAUDE_SECURITY_OVERRIDE=true
149
+
150
+ # Now the operation will proceed with warnings
151
+ claude edit test-credentials.txt
152
+
153
+ # Disable override immediately after
154
+ unset CLAUDE_SECURITY_OVERRIDE
155
+ ```
156
+
157
+ ## Security Patterns Detected
158
+
159
+ The hook detects these credential patterns:
160
+ - **Anthropic API Keys**: `sk-ant-...`
161
+ - **OpenAI API Keys**: `sk-...`
162
+ - **GitHub Tokens**: `ghp_...`, `gho_...`
163
+ - **AWS Access Keys**: `AKIA...`
164
+ - **Database URLs**: `postgres://user:pass@host`
165
+ - **JWT Tokens**: `eyJ...`
166
+ - **Private Keys**: `-----BEGIN PRIVATE KEY-----`
167
+ - **Generic API Keys**: Pattern-based detection
168
+ - **Environment Variable Exposure**: `process.env.SECRET_*`
169
+
170
+ ## Logs and Monitoring
171
+
172
+ ### Log Locations
173
+ - **General Hook Logs**: `~/.claude/logs/security-hooks.log`
174
+ - **Security Violations**: `~/.claude/logs/credential-violations.log`
175
+
176
+ ### Monitoring Commands
177
+ ```bash
178
+ # View recent security events
179
+ tail -f ~/.claude/logs/security-hooks.log
180
+
181
+ # Check for violations
182
+ cat ~/.claude/logs/credential-violations.log
183
+
184
+ # Count violations by type
185
+ grep "VIOLATION:" ~/.claude/logs/credential-violations.log | cut -d: -f3 | sort | uniq -c
186
+ ```
187
+
188
+ ## Best Practices
189
+
190
+ 1. **Always Review**: Examine the detected pattern before overriding
191
+ 2. **Use Environment Variables**: Store credentials in environment variables
192
+ 3. **Secrets Management**: Use proper secrets management systems (1Password, HashiCorp Vault, etc.)
193
+ 4. **Emergency Override**: Only use `CLAUDE_SECURITY_OVERRIDE` in genuine emergencies
194
+ 5. **Regular Audits**: Review violation logs regularly for patterns
195
+ 6. **Team Training**: Educate team on secure coding practices
196
+
197
+ ## Troubleshooting
198
+
199
+ ### Hook Not Running
200
+ - Verify executable permissions: `ls -la ~/.claude/hooks/`
201
+ - Check Claude Code settings: `cat ~/.claude/settings.json`
202
+ - Review hook logs: `tail ~/.claude/logs/security-hooks.log`
203
+
204
+ ### False Positives
205
+ - Review the detected pattern in logs
206
+ - Consider if the pattern is actually a security risk
207
+ - Use environment variables instead of hardcoded values
208
+ - Add file to `.gitignore` if it's test data
209
+
210
+ ### Performance Issues
211
+ - The hook runs quickly but can be optimized for large files
212
+ - Consider adding file size limits if needed
213
+ - Use async execution for non-blocking notifications
214
+
215
+ ## Contributing
216
+
217
+ To add new credential patterns or improve detection:
218
+
219
+ 1. Add new patterns to the `CREDENTIAL_PATTERNS` array
220
+ 2. Test with realistic examples
221
+ 3. Update documentation
222
+ 4. Submit changes for review
223
+
224
+ ## Security Notice
225
+
226
+ This hook is designed to prevent accidental credential exposure. It should be part of a comprehensive security strategy that includes:
227
+ - Proper secrets management
228
+ - Regular security training
229
+ - Code review processes
230
+ - Automated security scanning in CI/CD
231
+ - Incident response procedures