Skip to content

Commit a224778

Browse files
lkronecker13claude
andcommitted
docs: update CLAUDE.md with improved development patterns
- Add consolidation pattern guidance for similar components - Include unified approach as recommended alternative to individual implementations - Add consolidation/refactoring commit message template - Update predictor integration process with cleaner structure - Remove branch-specific content to keep documentation general Development Guide: Enhanced with proven architectural patterns Documentation: Focused on permanent, project-agnostic guidance Process: Streamlined integration phases for better developer experience 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent f399bad commit a224778

1 file changed

Lines changed: 43 additions & 11 deletions

File tree

CLAUDE.md

Lines changed: 43 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ Complete development guide consolidating essential information for efficient dev
110110
- Maintain a clean modular structure across services, pipelines, or libraries
111111
- Each module or class should encapsulate a distinct, well-defined purpose
112112
- Do not mix unrelated responsibilities within the same abstraction
113+
- **Consolidation Pattern**: When multiple classes share >90% identical logic, consider a unified approach with configuration-driven behavior
113114

114115
### 6. Production Readiness by Default
115116
- Assume all code is production-bound:
@@ -139,11 +140,20 @@ Complete development guide consolidating essential information for efficient dev
139140
- **Environment mapping** via `alias` parameter
140141

141142
### Component Development
143+
144+
#### Traditional Approach (Individual Components)
142145
1. Add to relevant enum for registration
143146
2. Implement with proper interface/signature
144147
3. Add to factory function in registry
145148
4. Create config subclass if needed
146149

150+
#### Unified Approach (Recommended for Similar Components)
151+
1. **Evaluate for Consolidation**: If new component shares >90% logic with existing ones, consider unified pattern
152+
2. **Add to Enum**: Register component type in configuration enum
153+
3. **Configure Behavior**: Add component-specific behavior to unified implementation
154+
4. **Update Factory**: Leverage existing factory logic where possible
155+
5. **Verify Tests**: Ensure parametrized tests automatically cover new component type
156+
147157
## Testing Guidelines
148158

149159
### Test Architecture & Organization
@@ -284,6 +294,28 @@ type: brief description
284294
- `test`: Testing improvements or additions
285295
- `docs`: Documentation updates
286296

297+
#### Consolidation/Refactoring Template
298+
For significant code consolidation and architectural improvements:
299+
300+
```
301+
refactor: consolidate {ComponentType} with unified {PatternName} architecture
302+
303+
- Replace {N} individual {ComponentType} classes with unified {NewClass}
304+
- Achieve {percentage}% code reduction while maintaining full functionality
305+
- Consolidate test files into parametrized approach
306+
- Fix type safety issues through consistent patterns
307+
- Simplify factory pattern implementation
308+
- Remove redundant docstrings following CLAUDE.md principles
309+
310+
Code Reduction: {total_lines} lines removed ({total_percentage}% reduction)
311+
Quality: 100% MyPy compliance maintained, test coverage preserved
312+
Architecture: Single responsibility principle applied, maintainability improved
313+
314+
🤖 Generated with [Claude Code](https://claude.ai/code)
315+
316+
Co-Authored-By: Claude <noreply@anthropic.com>
317+
```
318+
287319
#### Feature Integration Template
288320
For major feature additions like new predictors, use this concrete structure:
289321

@@ -366,7 +398,7 @@ This guide provides comprehensive information needed for effective development,
366398

367399
## Adding New Predictors - Complete Integration Process
368400

369-
This documents the exact process we followed to integrate the Random Forest predictor, which should be repeated for future predictors (Decision Tree, XGBoost, etc.).
401+
This documents the exact process for integrating new predictors, which should be followed for all model types.
370402

371403
### Phase 1: Predictor Implementation
372404

@@ -381,8 +413,8 @@ This documents the exact process we followed to integrate the Random Forest pred
381413

382414
**Example Structure**:
383415
```python
384-
# ml_production_service/predictors/random_forest.py
385-
class RandomForestPredictor(BasePredictor):
416+
# ml_production_service/predictors/{algorithm_name}.py
417+
class NewAlgorithmPredictor(BasePredictor):
386418
def __init__(self, model_path: str) -> None:
387419
# Model loading with error handling
388420

@@ -394,7 +426,7 @@ class RandomForestPredictor(BasePredictor):
394426
- **File**: `ml_production_service/predictors/__init__.py`
395427
- **Action**: Export new predictor class
396428
```python
397-
from .random_forest import RandomForestPredictor
429+
from .new_algorithm import NewAlgorithmPredictor
398430
```
399431

400432
#### 1.3 Add Comprehensive Unit Tests
@@ -466,9 +498,9 @@ ls -la registry/prd/
466498
- **Content**: Only production-ready, tested models
467499
- **Size Consideration**: Keep Docker images lean (include only implemented predictors)
468500

469-
### Phase 5: Testing Integration
501+
### Phase 4: Testing Integration
470502

471-
#### 5.1 Update API Integration Tests
503+
#### 4.1 Update API Integration Tests
472504
- **File**: `tests/test_api_layer.py`
473505
- **Action**: Add new model type to parametrized fixtures
474506
```python
@@ -479,12 +511,12 @@ ls -la registry/prd/
479511
])
480512
```
481513

482-
#### 5.2 Run Comprehensive Test Suite
514+
#### 4.2 Run Comprehensive Test Suite
483515
```bash
484516
make all-test-validate-branch # Must pass 90% coverage
485517
```
486518

487-
### Phase 6: Docker Integration
519+
### Phase 5: Docker Integration
488520

489521
#### 6.1 Update Docker Configuration
490522
- **Files**: `Dockerfile`, `.dockerignore`
@@ -495,7 +527,7 @@ docker build -t ml-production-service:test .
495527
MPS_MODEL_TYPE=new_algorithm docker run --rm ml-production-service:test
496528
```
497529

498-
### Phase 7: Documentation and Deployment
530+
### Phase 6: Documentation and Deployment
499531

500532
#### 7.1 Update Environment Configuration
501533
- **File**: `docker-compose.yml`
@@ -513,7 +545,7 @@ environment:
513545
choices=["heuristic", "random_forest", "new_algorithm"]
514546
```
515547

516-
### Phase 8: Validation Checklist
548+
### Phase 7: Validation Checklist
517549

518550
Before committing new predictor integration:
519551

@@ -527,7 +559,7 @@ Before committing new predictor integration:
527559
- [ ] **Validation**: `make all-test-validate-branch` passes
528560
- [ ] **Manual Testing**: API responds correctly with new predictor
529561

530-
### Phase 9: Commit Structure
562+
### Phase 8: Commit Structure
531563

532564
Follow this commit pattern for predictor integration:
533565

0 commit comments

Comments
 (0)