feat: Enhanced Claude Code configuration with comprehensive best practices
- Updated project CLAUDE.md with detailed commands, workflows, and guidelines - Added environment configuration and performance monitoring commands - Enhanced security guidelines and commit message conventions - Created 5 custom slash commands for common MEV bot development tasks: * /analyze-performance - Comprehensive performance analysis * /debug-issue - Structured debugging workflow * /implement-feature - Feature implementation framework * /security-audit - Security audit checklist * /optimize-performance - Performance optimization strategy - Updated global CLAUDE.md with universal best practices - Improved file organization and development standards 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
34
.claude/commands/analyze-performance.md
Normal file
34
.claude/commands/analyze-performance.md
Normal file
@@ -0,0 +1,34 @@
|
||||
# Analyze Performance Issues
|
||||
|
||||
Perform a comprehensive performance analysis of the MEV bot: $ARGUMENTS
|
||||
|
||||
## Analysis Steps:
|
||||
1. **Memory Profiling**: Check for memory leaks and high allocation patterns
|
||||
2. **CPU Profiling**: Identify CPU bottlenecks and hot paths
|
||||
3. **Goroutine Analysis**: Look for goroutine leaks and blocking operations
|
||||
4. **I/O Performance**: Analyze network and disk I/O patterns
|
||||
5. **Concurrency Issues**: Check for race conditions and lock contention
|
||||
|
||||
## Performance Commands to Run:
|
||||
```bash
|
||||
# Memory profile
|
||||
go tool pprof http://localhost:9090/debug/pprof/heap
|
||||
|
||||
# CPU profile
|
||||
go tool pprof http://localhost:9090/debug/pprof/profile?seconds=30
|
||||
|
||||
# Goroutine analysis
|
||||
go tool pprof http://localhost:9090/debug/pprof/goroutine
|
||||
|
||||
# Enable race detector
|
||||
go run -race ./cmd/mev-bot
|
||||
```
|
||||
|
||||
## Analysis Focus Areas:
|
||||
- Worker pool efficiency in `pkg/market/pipeline.go`
|
||||
- Event parsing performance in `pkg/events/`
|
||||
- Uniswap math calculations in `pkg/uniswap/`
|
||||
- Memory usage in large transaction processing
|
||||
- Rate limiting effectiveness in `internal/ratelimit/`
|
||||
|
||||
Please provide specific performance metrics and recommendations for optimization.
|
||||
43
.claude/commands/debug-issue.md
Normal file
43
.claude/commands/debug-issue.md
Normal file
@@ -0,0 +1,43 @@
|
||||
# Debug MEV Bot Issue
|
||||
|
||||
Debug the following MEV bot issue: $ARGUMENTS
|
||||
|
||||
## Debugging Protocol:
|
||||
1. **Issue Understanding**: Analyze the problem description and expected vs actual behavior
|
||||
2. **Log Analysis**: Examine relevant log files in `logs/` directory
|
||||
3. **Code Investigation**: Review related source code and recent changes
|
||||
4. **Reproduction**: Attempt to reproduce the issue in a controlled environment
|
||||
5. **Root Cause**: Identify the underlying cause and contributing factors
|
||||
|
||||
## Debugging Commands:
|
||||
```bash
|
||||
# Check logs
|
||||
tail -f logs/mev-bot.log
|
||||
|
||||
# Run with debug logging
|
||||
LOG_LEVEL=debug ./mev-bot start
|
||||
|
||||
# Check system resources
|
||||
htop
|
||||
iostat -x 1 5
|
||||
|
||||
# Network connectivity
|
||||
nc -zv arbitrum-mainnet.core.chainstack.com 443
|
||||
|
||||
# Go runtime stats
|
||||
curl http://localhost:9090/debug/vars | jq
|
||||
```
|
||||
|
||||
## Investigation Areas:
|
||||
- **Connection Issues**: RPC endpoint connectivity and WebSocket stability
|
||||
- **Parsing Errors**: Transaction and event parsing failures
|
||||
- **Performance**: High CPU/memory usage or processing delays
|
||||
- **Concurrency**: Race conditions or deadlocks
|
||||
- **Configuration**: Environment variables and configuration issues
|
||||
|
||||
## Output Requirements:
|
||||
- Clear problem identification
|
||||
- Step-by-step reproduction instructions
|
||||
- Root cause analysis
|
||||
- Proposed solution with implementation steps
|
||||
- Test plan to verify the fix
|
||||
38
.claude/commands/implement-feature.md
Normal file
38
.claude/commands/implement-feature.md
Normal file
@@ -0,0 +1,38 @@
|
||||
# Implement MEV Bot Feature
|
||||
|
||||
Implement the following feature for the MEV bot: $ARGUMENTS
|
||||
|
||||
## Implementation Framework:
|
||||
1. **Requirements Analysis**: Break down the feature requirements and acceptance criteria
|
||||
2. **Architecture Design**: Design the solution following existing patterns
|
||||
3. **Interface Design**: Define clean interfaces between components
|
||||
4. **Implementation**: Write the code following Go best practices
|
||||
5. **Testing**: Create comprehensive unit and integration tests
|
||||
6. **Documentation**: Update relevant documentation and examples
|
||||
|
||||
## Implementation Standards:
|
||||
- **Code Quality**: Follow Go conventions and project coding standards
|
||||
- **Error Handling**: Implement robust error handling with context
|
||||
- **Logging**: Add appropriate logging with structured fields
|
||||
- **Testing**: Achieve >90% test coverage
|
||||
- **Performance**: Consider performance implications and add metrics
|
||||
- **Security**: Validate all inputs and handle edge cases
|
||||
|
||||
## File Organization:
|
||||
- **Core Logic**: Place in appropriate `pkg/` subdirectory
|
||||
- **Configuration**: Add to `internal/config/` if needed
|
||||
- **Tests**: Co-locate with source files (`*_test.go`)
|
||||
- **Documentation**: Update `docs/` and inline comments
|
||||
|
||||
## Integration Points:
|
||||
- **Event System**: Integrate with `pkg/events/` for transaction processing
|
||||
- **Market Pipeline**: Connect to `pkg/market/pipeline.go` for processing
|
||||
- **Monitoring**: Add metrics and health checks
|
||||
- **Configuration**: Add necessary environment variables
|
||||
|
||||
## Deliverables:
|
||||
- Working implementation with tests
|
||||
- Updated documentation
|
||||
- Configuration updates
|
||||
- Performance benchmarks if applicable
|
||||
- Migration guide for existing deployments
|
||||
84
.claude/commands/optimize-performance.md
Normal file
84
.claude/commands/optimize-performance.md
Normal file
@@ -0,0 +1,84 @@
|
||||
# Optimize MEV Bot Performance
|
||||
|
||||
Optimize the performance of the MEV bot in the following area: $ARGUMENTS
|
||||
|
||||
## Performance Optimization Strategy:
|
||||
|
||||
### 1. **Profiling and Measurement**
|
||||
```bash
|
||||
# CPU profiling
|
||||
go tool pprof http://localhost:9090/debug/pprof/profile?seconds=30
|
||||
|
||||
# Memory profiling
|
||||
go tool pprof http://localhost:9090/debug/pprof/heap
|
||||
|
||||
# Trace analysis
|
||||
go tool trace trace.out
|
||||
|
||||
# Benchmark testing
|
||||
go test -bench=. -benchmem ./...
|
||||
```
|
||||
|
||||
### 2. **Optimization Areas**
|
||||
|
||||
#### **Concurrency Optimization**
|
||||
- Worker pool sizing and configuration
|
||||
- Channel buffer optimization
|
||||
- Goroutine pooling and reuse
|
||||
- Lock contention reduction
|
||||
- Context cancellation patterns
|
||||
|
||||
#### **Memory Optimization**
|
||||
- Object pooling for frequent allocations
|
||||
- Buffer reuse patterns
|
||||
- Garbage collection tuning
|
||||
- Memory leak prevention
|
||||
- Slice and map pre-allocation
|
||||
|
||||
#### **I/O Optimization**
|
||||
- Connection pooling for RPC calls
|
||||
- Request batching and pipelining
|
||||
- Caching frequently accessed data
|
||||
- Asynchronous processing patterns
|
||||
- Rate limiting optimization
|
||||
|
||||
#### **Algorithm Optimization**
|
||||
- Uniswap math calculation efficiency
|
||||
- Event parsing performance
|
||||
- Data structure selection
|
||||
- Caching strategies
|
||||
- Indexing improvements
|
||||
|
||||
### 3. **MEV Bot Specific Optimizations**
|
||||
|
||||
#### **Transaction Processing Pipeline**
|
||||
- Parallel transaction processing
|
||||
- Event filtering optimization
|
||||
- Batch processing strategies
|
||||
- Pipeline stage optimization
|
||||
|
||||
#### **Market Analysis**
|
||||
- Price calculation caching
|
||||
- Pool data caching
|
||||
- Historical data indexing
|
||||
- Real-time processing optimization
|
||||
|
||||
#### **Arbitrage Detection**
|
||||
- Opportunity scanning efficiency
|
||||
- Profit calculation optimization
|
||||
- Market impact analysis speed
|
||||
- Cross-DEX comparison performance
|
||||
|
||||
## Implementation Guidelines:
|
||||
- Measure before optimizing (baseline metrics)
|
||||
- Focus on bottlenecks identified through profiling
|
||||
- Maintain code readability and maintainability
|
||||
- Add performance tests for regressions
|
||||
- Document performance characteristics
|
||||
|
||||
## Deliverables:
|
||||
- Performance benchmark results (before/after)
|
||||
- Optimized code with maintained functionality
|
||||
- Performance monitoring enhancements
|
||||
- Optimization documentation
|
||||
- Regression test suite
|
||||
72
.claude/commands/security-audit.md
Normal file
72
.claude/commands/security-audit.md
Normal file
@@ -0,0 +1,72 @@
|
||||
# MEV Bot Security Audit
|
||||
|
||||
Perform a comprehensive security audit of the MEV bot focusing on: $ARGUMENTS
|
||||
|
||||
## Security Audit Checklist:
|
||||
|
||||
### 1. **Code Security Analysis**
|
||||
```bash
|
||||
# Static security analysis
|
||||
gosec ./...
|
||||
|
||||
# Dependency vulnerabilities
|
||||
go list -json -m all | nancy sleuth
|
||||
|
||||
# Secret scanning
|
||||
git-secrets --scan
|
||||
```
|
||||
|
||||
### 2. **Input Validation Review**
|
||||
- Transaction data parsing validation
|
||||
- RPC response validation
|
||||
- Configuration parameter validation
|
||||
- Mathematical overflow/underflow checks
|
||||
- Buffer overflow prevention
|
||||
|
||||
### 3. **Cryptographic Security**
|
||||
- Private key handling and storage
|
||||
- Signature verification processes
|
||||
- Random number generation
|
||||
- Hash function usage
|
||||
- Encryption at rest and in transit
|
||||
|
||||
### 4. **Network Security**
|
||||
- RPC endpoint authentication
|
||||
- TLS/SSL configuration
|
||||
- Rate limiting implementation
|
||||
- DDoS protection mechanisms
|
||||
- WebSocket connection security
|
||||
|
||||
### 5. **Runtime Security**
|
||||
- Memory safety in Go code
|
||||
- Goroutine safety and race conditions
|
||||
- Resource exhaustion protection
|
||||
- Error information disclosure
|
||||
- Logging security (no sensitive data)
|
||||
|
||||
## Specific MEV Bot Security Areas:
|
||||
|
||||
### **Transaction Processing**
|
||||
- Validate all transaction inputs
|
||||
- Prevent transaction replay attacks
|
||||
- Secure handling of swap calculations
|
||||
- Protection against malicious contract calls
|
||||
|
||||
### **Market Data Integrity**
|
||||
- Price feed validation
|
||||
- Oracle manipulation detection
|
||||
- Historical data integrity
|
||||
- Real-time data verification
|
||||
|
||||
### **Financial Security**
|
||||
- Gas estimation accuracy
|
||||
- Slippage protection
|
||||
- Minimum profit validation
|
||||
- MEV protection mechanisms
|
||||
|
||||
## Output Requirements:
|
||||
- Detailed security findings report
|
||||
- Risk assessment (Critical/High/Medium/Low)
|
||||
- Remediation recommendations
|
||||
- Implementation timeline for fixes
|
||||
- Security testing procedures
|
||||
Reference in New Issue
Block a user