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:
199
CLAUDE.md
199
CLAUDE.md
@@ -1,6 +1,49 @@
|
||||
# MEV Bot Project - Claude Context
|
||||
# MEV Bot Project - Claude Code Configuration
|
||||
|
||||
This file contains context information for Claude about the MEV Bot project.
|
||||
This file contains comprehensive Claude Code configuration and context information for the MEV Bot project.
|
||||
|
||||
## 🚀 Quick Start Commands
|
||||
|
||||
### Essential Build & Test Commands
|
||||
```bash
|
||||
# Build the MEV bot binary
|
||||
make build
|
||||
|
||||
# Run tests
|
||||
make test
|
||||
|
||||
# Start development server with hot reload
|
||||
./scripts/run.sh
|
||||
|
||||
# Build and run with logging
|
||||
./scripts/build.sh && ./mev-bot start
|
||||
|
||||
# Check for Go modules issues
|
||||
go mod tidy && go mod verify
|
||||
|
||||
# Run linter
|
||||
golangci-lint run
|
||||
|
||||
# Run security analysis
|
||||
gosec ./...
|
||||
```
|
||||
|
||||
### Development Workflow Commands
|
||||
```bash
|
||||
# Setup development environment
|
||||
export ARBITRUM_RPC_ENDPOINT="wss://arbitrum-mainnet.core.chainstack.com/73bc682fe9c5bd23b42ef40f752fa89a"
|
||||
export ARBITRUM_WS_ENDPOINT="wss://arbitrum-mainnet.core.chainstack.com/73bc682fe9c5bd23b42ef40f752fa89a"
|
||||
export METRICS_ENABLED="false"
|
||||
|
||||
# Run with timeout for testing
|
||||
timeout 30 ./mev-bot start
|
||||
|
||||
# Debug with verbose logging
|
||||
LOG_LEVEL=debug ./mev-bot start
|
||||
|
||||
# Profile performance
|
||||
go tool pprof http://localhost:6060/debug/pprof/profile
|
||||
```
|
||||
|
||||
## Project Overview
|
||||
This is an MEV (Maximal Extractable Value) bot written in Go 1.24+ that monitors the Arbitrum sequencer for potential swap opportunities. When a potential swap is detected, the bot scans the market to determine if the swap is large enough to move the price using off-chain methods.
|
||||
@@ -30,12 +73,34 @@ This is an MEV (Maximal Extractable Value) bot written in Go 1.24+ that monitors
|
||||
- Use the universal message bus for inter-module communication
|
||||
- Adhere to the standards defined in the project plan
|
||||
|
||||
## Development Guidelines
|
||||
- Focus on implementing the features outlined in the project plan
|
||||
- Ensure all code follows Go best practices
|
||||
- Write comprehensive tests for all functionality
|
||||
- Document all public APIs and complex algorithms
|
||||
- Follow the performance requirements outlined in COMMON.md
|
||||
## 📋 Development Guidelines & Code Style
|
||||
|
||||
### Go Best Practices
|
||||
- **Error Handling**: Always wrap errors with context using `fmt.Errorf("operation failed: %w", err)`
|
||||
- **Concurrency**: Use worker pools for processing large datasets (see `pkg/market/pipeline.go`)
|
||||
- **Interfaces**: Keep interfaces small and focused (1-3 methods maximum)
|
||||
- **Testing**: Aim for >90% test coverage with table-driven tests
|
||||
- **Logging**: Use structured logging with `slog` package
|
||||
- **Performance**: Profile regularly with `go tool pprof`
|
||||
|
||||
### Code Organization Rules
|
||||
- **File Size**: Keep files under 500 lines (split larger files into logical components)
|
||||
- **Package Structure**: Follow Go standard layout (cmd/, internal/, pkg/)
|
||||
- **Naming**: Use Go naming conventions (PascalCase for exports, camelCase for private)
|
||||
- **Documentation**: Document all exported functions with examples
|
||||
- **Constants**: Group related constants in blocks with `iota` when appropriate
|
||||
|
||||
### Required Checks Before Commit
|
||||
```bash
|
||||
# Run all checks before committing
|
||||
make test && make lint && go mod tidy
|
||||
|
||||
# Security scan
|
||||
gosec ./...
|
||||
|
||||
# Dependency vulnerability check
|
||||
go list -json -m all | nancy sleuth
|
||||
```
|
||||
|
||||
## System Architecture
|
||||
The MEV Bot follows a modular architecture with clearly defined components that communicate through well-defined interfaces.
|
||||
@@ -112,4 +177,120 @@ As Claude, you're particularly skilled at:
|
||||
- Designing for horizontal scalability
|
||||
- Ensuring code follows established patterns and conventions
|
||||
|
||||
When working on this project, please focus on these areas where your strengths will be most beneficial.
|
||||
When working on this project, please focus on these areas where your strengths will be most beneficial.
|
||||
|
||||
## 🛠 Claude Code Optimization Settings
|
||||
|
||||
### Workflow Preferences
|
||||
- **Always commit changes**: Use `git commit -am "descriptive message"` after significant changes
|
||||
- **Branch naming**: Use hyphens (`feat-add-new-parser`, `fix-memory-leak`)
|
||||
- **Context management**: Use `/compact` to manage long conversations
|
||||
- **Parallel processing**: Leverage Go's concurrency patterns extensively
|
||||
|
||||
### File Organization Preferences
|
||||
- **Never save temporary files to root**: Use `/tmp/` or `internal/temp/`
|
||||
- **Log files**: Always save to `logs/` directory
|
||||
- **Test files**: Place alongside source files with `_test.go` suffix
|
||||
- **Documentation**: Keep in `docs/` with clear naming
|
||||
|
||||
### Performance Monitoring
|
||||
```bash
|
||||
# Enable metrics endpoint
|
||||
export METRICS_ENABLED="true"
|
||||
export METRICS_PORT="9090"
|
||||
|
||||
# Monitor memory usage
|
||||
go tool pprof http://localhost:9090/debug/pprof/heap
|
||||
|
||||
# Monitor CPU usage
|
||||
go tool pprof http://localhost:9090/debug/pprof/profile?seconds=30
|
||||
|
||||
# Monitor goroutines
|
||||
go tool pprof http://localhost:9090/debug/pprof/goroutine
|
||||
```
|
||||
|
||||
## 🔧 Environment Configuration
|
||||
|
||||
### Required Environment Variables
|
||||
```bash
|
||||
# Arbitrum RPC Configuration
|
||||
export ARBITRUM_RPC_ENDPOINT="wss://arbitrum-mainnet.core.chainstack.com/73bc682fe9c5bd23b42ef40f752fa89a"
|
||||
export ARBITRUM_WS_ENDPOINT="wss://arbitrum-mainnet.core.chainstack.com/73bc682fe9c5bd23b42ef40f752fa89a"
|
||||
|
||||
# Application Configuration
|
||||
export LOG_LEVEL="info"
|
||||
export METRICS_ENABLED="false"
|
||||
export METRICS_PORT="9090"
|
||||
|
||||
# Development Configuration
|
||||
export GO_ENV="development"
|
||||
export DEBUG="true"
|
||||
```
|
||||
|
||||
### Optional Environment Variables
|
||||
```bash
|
||||
# Performance Tuning
|
||||
export GOMAXPROCS=4
|
||||
export GOGC=100
|
||||
|
||||
# Logging Configuration
|
||||
export LOG_FORMAT="json"
|
||||
export LOG_OUTPUT="logs/mev-bot.log"
|
||||
|
||||
# Rate Limiting
|
||||
export MAX_RPS=100
|
||||
export RATE_LIMIT_BURST=200
|
||||
```
|
||||
|
||||
## 📝 Commit Message Conventions
|
||||
|
||||
### Format
|
||||
```
|
||||
type(scope): brief description
|
||||
|
||||
- Detailed explanation of changes
|
||||
- Why the change was needed
|
||||
- Any breaking changes or migration notes
|
||||
|
||||
🤖 Generated with [Claude Code](https://claude.ai/code)
|
||||
Co-Authored-By: Claude <noreply@anthropic.com>
|
||||
```
|
||||
|
||||
### Types
|
||||
- `feat`: New feature implementation
|
||||
- `fix`: Bug fix
|
||||
- `perf`: Performance improvement
|
||||
- `refactor`: Code restructuring without feature changes
|
||||
- `test`: Adding or updating tests
|
||||
- `docs`: Documentation updates
|
||||
- `build`: Build system or dependency changes
|
||||
- `ci`: CI/CD pipeline changes
|
||||
|
||||
## 🚨 Security Guidelines
|
||||
|
||||
### Never Commit
|
||||
- Private keys or wallet seeds
|
||||
- API keys or secrets
|
||||
- RPC endpoints with authentication
|
||||
- Personal configuration files
|
||||
|
||||
### Always Validate
|
||||
- Input parameters for all functions
|
||||
- RPC responses before processing
|
||||
- Mathematical calculations for overflow
|
||||
- Memory allocations for bounds
|
||||
|
||||
### Security Commands
|
||||
```bash
|
||||
# Scan for secrets
|
||||
git-secrets --scan
|
||||
|
||||
# Security audit
|
||||
gosec ./...
|
||||
|
||||
# Dependency vulnerabilities
|
||||
go list -json -m all | nancy sleuth
|
||||
|
||||
# Check for hardcoded credentials
|
||||
grep -r "password\|secret\|key" --exclude-dir=.git .
|
||||
```
|
||||
Reference in New Issue
Block a user