@paulduvall/claude-dev-toolkit 0.0.1-alpha.2 → 0.0.1-alpha.21
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.
- package/LICENSE +21 -0
- package/README.md +88 -37
- package/bin/claude-commands +307 -65
- package/commands/active/xarchitecture.md +393 -0
- package/commands/active/xconfig.md +127 -0
- package/commands/active/xcontinue.md +92 -0
- package/commands/active/xdebug.md +130 -0
- package/commands/active/xdocs.md +178 -0
- package/commands/active/xexplore.md +94 -0
- package/commands/active/xgit.md +149 -0
- package/commands/active/xpipeline.md +152 -0
- package/commands/active/xquality.md +96 -0
- package/commands/active/xrefactor.md +198 -0
- package/commands/active/xrelease.md +142 -0
- package/commands/active/xsecurity.md +92 -0
- package/commands/active/xspec.md +174 -0
- package/commands/active/xtdd.md +151 -0
- package/commands/active/xtest.md +89 -0
- package/commands/active/xverify.md +80 -0
- package/commands/experiments/xact.md +742 -0
- package/commands/experiments/xanalytics.md +113 -0
- package/commands/experiments/xanalyze.md +70 -0
- package/commands/experiments/xapi.md +161 -0
- package/commands/experiments/xatomic.md +112 -0
- package/commands/experiments/xaws.md +85 -0
- package/commands/experiments/xcicd.md +337 -0
- package/commands/experiments/xcommit.md +122 -0
- package/commands/experiments/xcompliance.md +182 -0
- package/commands/experiments/xconstraints.md +89 -0
- package/commands/experiments/xcoverage.md +90 -0
- package/commands/experiments/xdb.md +102 -0
- package/commands/experiments/xdesign.md +121 -0
- package/commands/experiments/xdevcontainer.md +238 -0
- package/commands/experiments/xevaluate.md +111 -0
- package/commands/experiments/xfootnote.md +12 -0
- package/commands/experiments/xgenerate.md +117 -0
- package/commands/experiments/xgovernance.md +149 -0
- package/commands/experiments/xgreen.md +66 -0
- package/commands/experiments/xiac.md +118 -0
- package/commands/experiments/xincident.md +137 -0
- package/commands/experiments/xinfra.md +115 -0
- package/commands/experiments/xknowledge.md +115 -0
- package/commands/experiments/xmaturity.md +120 -0
- package/commands/experiments/xmetrics.md +118 -0
- package/commands/experiments/xmonitoring.md +128 -0
- package/commands/experiments/xnew.md +903 -0
- package/commands/experiments/xobservable.md +114 -0
- package/commands/experiments/xoidc.md +165 -0
- package/commands/experiments/xoptimize.md +115 -0
- package/commands/experiments/xperformance.md +112 -0
- package/commands/experiments/xplanning.md +131 -0
- package/commands/experiments/xpolicy.md +115 -0
- package/commands/experiments/xproduct.md +98 -0
- package/commands/experiments/xreadiness.md +75 -0
- package/commands/experiments/xred.md +55 -0
- package/commands/experiments/xrisk.md +128 -0
- package/commands/experiments/xrules.md +124 -0
- package/commands/experiments/xsandbox.md +120 -0
- package/commands/experiments/xscan.md +102 -0
- package/commands/experiments/xsetup.md +123 -0
- package/commands/experiments/xtemplate.md +116 -0
- package/commands/experiments/xtrace.md +212 -0
- package/commands/experiments/xux.md +171 -0
- package/commands/experiments/xvalidate.md +104 -0
- package/commands/experiments/xworkflow.md +113 -0
- package/hooks/.smellrc.example.json +19 -0
- package/hooks/README.md +263 -0
- package/hooks/check-commit-signing.py +127 -0
- package/hooks/check-complexity.py +38 -0
- package/hooks/check-security.py +37 -0
- package/hooks/claude-wrapper.sh +29 -0
- package/hooks/config.py +110 -0
- package/hooks/file-logger.sh +100 -0
- package/hooks/lib/argument-parser.sh +427 -0
- package/hooks/lib/config-constants.sh +230 -0
- package/hooks/lib/context-manager.sh +560 -0
- package/hooks/lib/error-handler.sh +423 -0
- package/hooks/lib/execution-engine.sh +444 -0
- package/hooks/lib/execution-results.sh +113 -0
- package/hooks/lib/execution-simulation.sh +114 -0
- package/hooks/lib/field-validators.sh +104 -0
- package/hooks/lib/file-utils.sh +398 -0
- package/hooks/lib/subagent-discovery.sh +468 -0
- package/hooks/lib/subagent-validator.sh +407 -0
- package/hooks/lib/validation-reporter.sh +134 -0
- package/hooks/on-error-debug.sh +226 -0
- package/hooks/pre-commit-quality.sh +204 -0
- package/hooks/pre-commit-test-runner.sh +132 -0
- package/hooks/pre-write-security.sh +115 -0
- package/hooks/prevent-credential-exposure.sh +279 -0
- package/hooks/security_bandit.py +177 -0
- package/hooks/security_checks.py +97 -0
- package/hooks/security_secrets.py +81 -0
- package/hooks/security_trojan.py +61 -0
- package/hooks/settings.example.json +52 -0
- package/hooks/smell_checks.py +238 -0
- package/hooks/smell_javascript.py +231 -0
- package/hooks/smell_python.py +110 -0
- package/hooks/smell_ruff.py +70 -0
- package/hooks/smell_types.py +72 -0
- package/hooks/subagent-trigger-simple.sh +202 -0
- package/hooks/subagent-trigger.sh +253 -0
- package/hooks/suppression.py +82 -0
- package/hooks/tab-color.sh +70 -0
- package/hooks/verify-before-edit.sh +135 -0
- package/lib/backup-restore-command.js +140 -0
- package/lib/base/base-command.js +252 -0
- package/lib/base/command-result.js +184 -0
- package/lib/config/constants.js +255 -0
- package/lib/config.js +48 -6
- package/lib/configure-command.js +428 -0
- package/lib/dependency-validator.js +64 -5
- package/lib/hook-installer-core.js +2 -2
- package/lib/installation-instruction-generator.js +213 -495
- package/lib/installer.js +134 -56
- package/lib/oidc-command.js +740 -0
- package/lib/services/backup-list-service.js +226 -0
- package/lib/services/backup-service.js +230 -0
- package/lib/services/command-installer-service.js +217 -0
- package/lib/services/logger-service.js +201 -0
- package/lib/services/package-manager-service.js +319 -0
- package/lib/services/platform-instruction-service.js +294 -0
- package/lib/services/recovery-instruction-service.js +348 -0
- package/lib/services/restore-service.js +221 -0
- package/lib/setup-command.js +359 -0
- package/lib/setup-wizard.js +155 -262
- package/lib/uninstall-command.js +100 -0
- package/lib/utils/claude-path-config.js +184 -0
- package/lib/utils/file-system-utils.js +152 -0
- package/lib/utils.js +8 -4
- package/lib/verify-command.js +430 -0
- package/package.json +7 -3
- package/scripts/postinstall.js +172 -157
- package/subagents/debug-specialist.md +7 -0
- package/templates/README.md +115 -0
- package/templates/basic-settings.json +30 -0
- package/templates/comprehensive-settings.json +57 -0
- package/templates/global-claude.md +344 -0
- package/templates/hybrid-hook-config.yaml +132 -0
- package/templates/security-focused-settings.json +62 -0
- package/templates/subagent-hooks.yaml +188 -0
- package/lib/package-manager-service.js +0 -270
- package/subagents/debug-context.md +0 -197
|
@@ -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,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"thresholds": {
|
|
3
|
+
"max_complexity": 10,
|
|
4
|
+
"max_function_lines": 20,
|
|
5
|
+
"max_nesting_depth": 3,
|
|
6
|
+
"max_parameters": 4,
|
|
7
|
+
"max_file_lines": 300,
|
|
8
|
+
"duplicate_min_lines": 4
|
|
9
|
+
},
|
|
10
|
+
"security": {
|
|
11
|
+
"enabled": true,
|
|
12
|
+
"trojan_enabled": true
|
|
13
|
+
},
|
|
14
|
+
"suppress_files": [
|
|
15
|
+
"tests/**",
|
|
16
|
+
"*_test.py",
|
|
17
|
+
"*.generated.*"
|
|
18
|
+
]
|
|
19
|
+
}
|
package/hooks/README.md
ADDED
|
@@ -0,0 +1,263 @@
|
|
|
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
|
+
### Lifecycle & Event Hooks
|
|
76
|
+
|
|
77
|
+
The following hooks provide logging, validation, and cleanup at various Claude Code lifecycle events. All are non-blocking and log to `~/.claude/logs/`.
|
|
78
|
+
|
|
79
|
+
| Hook | Event | Purpose |
|
|
80
|
+
|------|-------|---------|
|
|
81
|
+
| `backup-before-edit.sh` | PreToolUse (Edit/Write) | Preserves file state before modifications |
|
|
82
|
+
| `audit-bash-commands.sh` | PreToolUse (Bash) | Logs shell commands for security audit trail |
|
|
83
|
+
| `log-all-operations.sh` | PostToolUse (*) | Audit trail for all tool usage |
|
|
84
|
+
| `validate-changes.sh` | PostToolUse (Edit/Write) | Post-edit validation of changes |
|
|
85
|
+
| `handle-notifications.sh` | Notification | Security event notification logging |
|
|
86
|
+
| `prompt-analysis.sh` | UserPromptSubmit | Validates prompts for security concerns |
|
|
87
|
+
| `prompt-security-scan.sh` | UserPromptSubmit | Scans prompts for credential exposure risks |
|
|
88
|
+
| `cleanup-on-stop.sh` | Stop | Cleans temporary state on execution stop |
|
|
89
|
+
| `subagent-cleanup.sh` | SubagentStop | Cleans subagent resources on completion |
|
|
90
|
+
| `session-cleanup.sh` | SessionEnd | End-of-session security cleanup |
|
|
91
|
+
| `pre-compact-backup.sh` | PreCompact | Checkpoint before context compaction |
|
|
92
|
+
| `session-init.sh` | SessionStart | Validates environment at session start |
|
|
93
|
+
| `security-session-init.sh` | SessionStart | Enhanced security posture validation |
|
|
94
|
+
|
|
95
|
+
### Quality & Workflow Hooks
|
|
96
|
+
|
|
97
|
+
| Hook | Event | Purpose |
|
|
98
|
+
|------|-------|---------|
|
|
99
|
+
| `pre-commit-quality.sh` | PreToolUse (Bash) | Code quality checks before commits |
|
|
100
|
+
| `pre-commit-test-runner.sh` | PreToolUse (Bash) | Auto-detects test framework, blocks commits on failure |
|
|
101
|
+
| `pre-write-security.sh` | PreToolUse (Write) | Security scan before file writes |
|
|
102
|
+
| `verify-before-edit.sh` | PreToolUse (Edit/Write) | Warns about fabricated references (non-blocking) |
|
|
103
|
+
| `on-error-debug.sh` | Manual invocation | Debug context capture on errors |
|
|
104
|
+
| `subagent-trigger.sh` | PostToolUse (*) | Triggers subagent workflows |
|
|
105
|
+
| `subagent-trigger-simple.sh` | PostToolUse (*) | Simplified subagent trigger |
|
|
106
|
+
|
|
107
|
+
## Hook Installation
|
|
108
|
+
|
|
109
|
+
### Option 1: Global Installation (Recommended)
|
|
110
|
+
```bash
|
|
111
|
+
# Copy to Claude Code hooks directory
|
|
112
|
+
cp hooks/file-logger.sh ~/.claude/hooks/
|
|
113
|
+
|
|
114
|
+
# Make executable
|
|
115
|
+
chmod +x ~/.claude/hooks/file-logger.sh
|
|
116
|
+
|
|
117
|
+
# Configure in ~/.claude/settings.json
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Option 2: Project-Specific Installation
|
|
121
|
+
```bash
|
|
122
|
+
# Use relative path in project settings
|
|
123
|
+
# Add to .claude/settings.json in your project
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Configuration Examples
|
|
127
|
+
|
|
128
|
+
### Basic Security Configuration
|
|
129
|
+
```json
|
|
130
|
+
{
|
|
131
|
+
"hooks": {
|
|
132
|
+
"PreToolUse": [
|
|
133
|
+
{
|
|
134
|
+
"matcher": "Edit|Write|MultiEdit",
|
|
135
|
+
"hooks": [
|
|
136
|
+
{
|
|
137
|
+
"type": "command",
|
|
138
|
+
"command": "~/.claude/hooks/file-logger.sh",
|
|
139
|
+
"blocking": false
|
|
140
|
+
}
|
|
141
|
+
]
|
|
142
|
+
}
|
|
143
|
+
]
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Enhanced Configuration with Notifications
|
|
149
|
+
```bash
|
|
150
|
+
# Set webhook for security alerts
|
|
151
|
+
export SECURITY_WEBHOOK_URL="https://hooks.slack.com/services/YOUR/SLACK/WEBHOOK"
|
|
152
|
+
|
|
153
|
+
# Add to your shell profile for persistence
|
|
154
|
+
echo 'export SECURITY_WEBHOOK_URL="https://hooks.slack.com/services/YOUR/SLACK/WEBHOOK"' >> ~/.zshrc
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Testing the Hook
|
|
158
|
+
|
|
159
|
+
### Test 1: Basic Credential Detection
|
|
160
|
+
```bash
|
|
161
|
+
# Create a test file with a fake API key
|
|
162
|
+
echo 'API_KEY="sk-ant-1234567890abcdef"' > test-credentials.txt
|
|
163
|
+
|
|
164
|
+
# Try to edit with Claude Code - should be blocked
|
|
165
|
+
claude edit test-credentials.txt
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Test 2: Environment Variable Exposure
|
|
169
|
+
```bash
|
|
170
|
+
# Create a test file with environment exposure
|
|
171
|
+
echo 'const apiKey = process.env.SECRET_API_KEY;' > test-env.js
|
|
172
|
+
|
|
173
|
+
# Try to edit with Claude Code - should be blocked
|
|
174
|
+
claude edit test-env.js
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### Test 3: Emergency Override
|
|
178
|
+
```bash
|
|
179
|
+
# Enable override (use sparingly!)
|
|
180
|
+
export CLAUDE_SECURITY_OVERRIDE=true
|
|
181
|
+
|
|
182
|
+
# Now the operation will proceed with warnings
|
|
183
|
+
claude edit test-credentials.txt
|
|
184
|
+
|
|
185
|
+
# Disable override immediately after
|
|
186
|
+
unset CLAUDE_SECURITY_OVERRIDE
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## Security Patterns Detected
|
|
190
|
+
|
|
191
|
+
The hook detects these credential patterns:
|
|
192
|
+
- **Anthropic API Keys**: `sk-ant-...`
|
|
193
|
+
- **OpenAI API Keys**: `sk-...`
|
|
194
|
+
- **GitHub Tokens**: `ghp_...`, `gho_...`
|
|
195
|
+
- **AWS Access Keys**: `AKIA...`
|
|
196
|
+
- **Database URLs**: `postgres://user:pass@host`
|
|
197
|
+
- **JWT Tokens**: `eyJ...`
|
|
198
|
+
- **Private Keys**: `-----BEGIN PRIVATE KEY-----`
|
|
199
|
+
- **Generic API Keys**: Pattern-based detection
|
|
200
|
+
- **Environment Variable Exposure**: `process.env.SECRET_*`
|
|
201
|
+
|
|
202
|
+
## Logs and Monitoring
|
|
203
|
+
|
|
204
|
+
### Log Locations
|
|
205
|
+
- **General Hook Logs**: `~/.claude/logs/security-hooks.log`
|
|
206
|
+
- **Security Violations**: `~/.claude/logs/credential-violations.log`
|
|
207
|
+
|
|
208
|
+
### Monitoring Commands
|
|
209
|
+
```bash
|
|
210
|
+
# View recent security events
|
|
211
|
+
tail -f ~/.claude/logs/security-hooks.log
|
|
212
|
+
|
|
213
|
+
# Check for violations
|
|
214
|
+
cat ~/.claude/logs/credential-violations.log
|
|
215
|
+
|
|
216
|
+
# Count violations by type
|
|
217
|
+
grep "VIOLATION:" ~/.claude/logs/credential-violations.log | cut -d: -f3 | sort | uniq -c
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
## Best Practices
|
|
221
|
+
|
|
222
|
+
1. **Always Review**: Examine the detected pattern before overriding
|
|
223
|
+
2. **Use Environment Variables**: Store credentials in environment variables
|
|
224
|
+
3. **Secrets Management**: Use proper secrets management systems (1Password, HashiCorp Vault, etc.)
|
|
225
|
+
4. **Emergency Override**: Only use `CLAUDE_SECURITY_OVERRIDE` in genuine emergencies
|
|
226
|
+
5. **Regular Audits**: Review violation logs regularly for patterns
|
|
227
|
+
6. **Team Training**: Educate team on secure coding practices
|
|
228
|
+
|
|
229
|
+
## Troubleshooting
|
|
230
|
+
|
|
231
|
+
### Hook Not Running
|
|
232
|
+
- Verify executable permissions: `ls -la ~/.claude/hooks/`
|
|
233
|
+
- Check Claude Code settings: `cat ~/.claude/settings.json`
|
|
234
|
+
- Review hook logs: `tail ~/.claude/logs/security-hooks.log`
|
|
235
|
+
|
|
236
|
+
### False Positives
|
|
237
|
+
- Review the detected pattern in logs
|
|
238
|
+
- Consider if the pattern is actually a security risk
|
|
239
|
+
- Use environment variables instead of hardcoded values
|
|
240
|
+
- Add file to `.gitignore` if it's test data
|
|
241
|
+
|
|
242
|
+
### Performance Issues
|
|
243
|
+
- The hook runs quickly but can be optimized for large files
|
|
244
|
+
- Consider adding file size limits if needed
|
|
245
|
+
- Use async execution for non-blocking notifications
|
|
246
|
+
|
|
247
|
+
## Contributing
|
|
248
|
+
|
|
249
|
+
To add new credential patterns or improve detection:
|
|
250
|
+
|
|
251
|
+
1. Add new patterns to the `CREDENTIAL_PATTERNS` array
|
|
252
|
+
2. Test with realistic examples
|
|
253
|
+
3. Update documentation
|
|
254
|
+
4. Submit changes for review
|
|
255
|
+
|
|
256
|
+
## Security Notice
|
|
257
|
+
|
|
258
|
+
This hook is designed to prevent accidental credential exposure. It should be part of a comprehensive security strategy that includes:
|
|
259
|
+
- Proper secrets management
|
|
260
|
+
- Regular security training
|
|
261
|
+
- Code review processes
|
|
262
|
+
- Automated security scanning in CI/CD
|
|
263
|
+
- Incident response procedures
|