Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Optimize crew composition using CWICR labor norms. Balance productivity, cost, and skill requirements for construction crews.
.claude/skills/datadrivenconstruction-cwicr-crew-optimizer/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | 133% | 0% |
| case-07 | ✗→✓ | ▲ Improved | 128% | 0% |
| case-09 | ✗→✓ | ▲ Improved | 162% | 0% |
| case-10 | ✗→✓ | ▲ Improved | 137% | 0% |
| case-11 | ✗→✓ | ▲ Improved | 75% | 0% |
Crew planning challenges:
Optimize crew composition using CWICR labor productivity data to balance cost, output, and skill requirements.
pythonimport pandas as pd import numpy as np from typing import Dict, Any, List, Optional, Tuple from dataclasses import dataclass, field from enum import Enum from datetime import date, timedelta class WorkerType(Enum): """Types of workers.""" FOREMAN = "foreman" JOURNEYMAN = "journeyman" APPRENTICE = "apprentice" LABORER = "laborer" OPERATOR = "operator" HELPER = "helper" class Trade(Enum): """Construction trades.""" CONCRETE = "concrete" CARPENTRY = "carpentry" MASONRY = "masonry" STEEL = "steel" ELECTRICAL = "electrical" PLUMBING = "plumbing" HVAC = "hvac" PAINTING = "painting" ROOFING = "roofing" GENERAL = "general" @dataclass class Worker: """Worker definition.""" worker_type: WorkerType trade: Trade hourly_rate: float productivity_factor: float = 1.0 overtime_multiplier: float = 1.5 @dataclass class CrewComposition: """Crew composition.""" name: str trade: Trade workers: List[Tuple[WorkerType, int]] # (type, count) base_productivity: float # Output per hour hourly_cost: float daily_output: float @dataclass class CrewOptimizationResult: """Result of crew optimization.""" work_item: str quantity: float unit: str recommended_crew: CrewComposition alternative_crews: List[CrewComposition] duration_days: float total_labor_cost: float cost_per_unit: float # Standard crew compositions STANDARD_CREWS = { 'concrete_small': { 'trade': Trade.CONCRETE, 'workers': [(WorkerType.FOREMAN, 1), (WorkerType.JOURNEYMAN, 2), (WorkerType.LABORER, 2)], 'productivity': 1.0 }, 'concrete_large': { 'trade': Trade.CONCRETE, 'workers': [(WorkerType.FOREMAN, 1), (WorkerType.JOURNEYMAN, 4), (WorkerType.LABORER, 4), (WorkerType.OPERATOR, 1)], 'productivity': 1.8 }, 'masonry_standard': { 'trade': Trade.MASONRY, 'workers': [(WorkerType.FOREMAN, 1), (WorkerType.JOURNEYMAN, 2), (WorkerType.HELPER, 2)], 'productivity': 1.0 }, 'carpentry_framing': { 'trade': Trade.CARPENTRY, 'workers': [(WorkerType.FOREMAN, 1), (WorkerType.JOURNEYMAN, 3), (WorkerType.APPRENTICE, 1)], 'productivity': 1.0 }, 'electrical_rough': { 'trade': Trade.ELECTRICAL, 'workers': [(WorkerType.FOREMAN, 1), (WorkerType.JOURNEYMAN, 2), (WorkerType.APPRENTICE, 1)], 'productivity': 1.0 }, 'plumbing_rough': { 'trade': Trade.PLUMBING, 'workers': [(WorkerType.FOREMAN, 1), (WorkerType.JOURNEYMAN, 2), (WorkerType.APPRENTICE, 1)], 'productivity': 1.0 } } # Default hourly rates by worker type DEFAULT_RATES = { WorkerType.FOREMAN: 65, WorkerType.JOURNEYMAN: 55, WorkerType.APPRENTICE: 35, WorkerType.LABORER: 30, WorkerType.OPERATOR: 60, WorkerType.HELPER: 28 } class CWICRCrewOptimizer: """Optimize crew composition using CWICR data.""" HOURS_PER_DAY = 8 def __init__(self, cwicr_data: pd.DataFrame = None, custom_rates: Dict[WorkerType, float] = None): self.cost_data = cwicr_data self.rates = custom_rates or DEFAULT_RATES if cwicr_data is not None: self._index_data() def _index_data(self): """Index cost data.""" if 'work_item_code' in self.cost_data.columns: self._code_index = self.cost_data.set_index('work_item_code') else: self._code_index = None def get_labor_norm(self, code: str) -> Tuple[float, str]: """Get labor hours per unit from CWICR.""" if self._code_index is None or code not in self._code_index.index: return (1.0, 'unit') item = self._code_index.loc[code] norm = float(item.get('labor_norm', item.get('labor_hours', 1)) or 1) unit = str(item.get('unit', 'unit')) return (norm, unit) def calculate_crew_cost(self, workers: List[Tuple[WorkerType, int]]) -> float: """Calculate hourly cost of crew.""" total = 0 for worker_type, count in workers: rate = self.rates.get(worker_type, 40) total += rate * count return total def build_crew(self, name: str, trade: Trade, workers: List[Tuple[WorkerType, int]], base_productivity: float = 1.0) -> CrewComposition: """Build crew composition.""" hourly_cost = self.calculate_crew_cost(workers) daily_output = base_productivity * self.HOURS_PER_DAY return CrewComposition( name=name, trade=trade, workers=workers, base_productivity=base_productivity, hourly_cost=hourly_cost, daily_output=daily_output ) def optimize_for_work(self, work_item_code: str, quantity: float, target_days: int = None, max_crew_size: int = 10) -> CrewOptimizationResult: """Optimize crew for specific work item.""" labor_norm, unit = self.get_labor_norm(work_item_code) total_hours = quantity * labor_norm # Detect trade from code trade = self._detect_trade(work_item_code) # Generate crew options crews = [] # Small crew small_workers = [(WorkerType.FOREMAN, 1), (WorkerType.JOURNEYMAN, 2), (WorkerType.LABORER, 1)] small_crew = self.build_crew("Small Crew", trade, small_workers, 1.0) crews.append(small_crew) # Medium crew med_workers = [(WorkerType.FOREMAN, 1), (WorkerType.JOURNEYMAN, 3), (WorkerType.LABORER, 2)] med_crew = self.build_crew("Medium Crew", trade, med_workers, 1.4) crews.append(med_crew) # Large crew large_workers = [(WorkerType.FOREMAN, 1), (WorkerType.JOURNEYMAN, 5), (WorkerType.LABORER, 3)] large_crew = self.build_crew("Large Crew", trade, large_workers, 2.0) crews.append(large_crew) # Calculate metrics for each crew results = [] for crew in crews: # Adjusted productivity considering crew efficiency crew_workers = sum(count for _, count in crew.workers) efficiency = self._crew_efficiency(crew_workers) effective_productivity = crew.base_productivity * efficiency hours_needed = total_hours / effective_productivity days_needed = hours_needed / self.HOURS_PER_DAY labor_cost = hours_needed * crew.hourly_cost cost_per_unit = labor_cost / quantity if quantity > 0 else 0 results.append({ 'crew': crew, 'days': days_needed, 'cost': labor_cost, 'cost_per_unit': cost_per_unit, 'efficiency': efficiency }) # Select best crew based on target if target_days: # Find crew that meets target with lowest cost valid = [r for r in results if r['days'] <= target_days] if valid: best = min(valid, key=lambda x: x['cost']) else: best = min(results, key=lambda x: x['days']) else: # Optimize for cost best = min(results, key=lambda x: x['cost']) recommended = best['crew'] alternatives = [r['crew'] for r in results if r['crew'] != recommended] return CrewOptimizationResult( work_item=work_item_code, quantity=quantity, unit=unit, recommended_crew=recommended, alternative_crews=alternatives, duration_days=round(best['days'], 1), total_labor_cost=round(best['cost'], 2), cost_per_unit=round(best['cost_per_unit'], 2) ) def _detect_trade(self, code: str) -> Trade: """Detect trade from work item code.""" code_lower = code.lower() trade_map = { 'conc': Trade.CONCRETE, 'carp': Trade.CARPENTRY, 'mason': Trade.MASONRY, 'steel': Trade.STEEL, 'strl': Trade.STEEL, 'elec': Trade.ELECTRICAL, 'plumb': Trade.PLUMBING, 'hvac': Trade.HVAC, 'paint': Trade.PAINTING, 'roof': Trade.ROOFING } for key, trade in trade_map.items(): if key in code_lower: return trade return Trade.GENERAL def _crew_efficiency(self, crew_size: int) -> float: """Calculate crew efficiency based on size (law of diminishing returns).""" if crew_size <= 4: return 1.0 elif crew_size <= 6: return 0.95 elif crew_size <= 8: return 0.90 elif crew_size <= 10: return 0.85 else: return 0.80 def analyze_overtime(self, result: CrewOptimizationResult, available_days: int, max_overtime_hours: float = 2) -> Dict[str, Any]: """Analyze if overtime can meet schedule.""" if result.duration_days <= available_days: return { 'overtime_needed': False, 'regular_days': result.duration_days, 'overtime_hours': 0, 'overtime_cost': 0, 'total_cost': result.total_labor_cost } # Calculate overtime needed regular_hours = available_days * self.HOURS_PER_DAY total_hours_available = available_days * (self.HOURS_PER_DAY + max_overtime_hours) labor_norm, _ = self.get_labor_norm(result.work_item) total_hours_needed = result.quantity * labor_norm / result.recommended_crew.base_productivity if total_hours_needed > total_hours_available: # Can't meet schedule even with overtime overtime_hours = available_days * max_overtime_hours shortage = total_hours_needed - total_hours_available else: overtime_hours = total_hours_needed - regular_hours shortage = 0 overtime_cost = overtime_hours * result.recommended_crew.hourly_cost * 1.5 return { 'overtime_needed': True, 'regular_days': available_days, 'overtime_hours_per_day': max_overtime_hours, 'total_overtime_hours': round(overtime_hours, 1), 'overtime_cost': round(overtime_cost, 2), 'total_cost': round(result.total_labor_cost + overtime_cost, 2), 'shortage_hours': round(shortage, 1) if shortage > 0 else 0, 'can_meet_schedule': shortage == 0 } def export_crew_plan(self, results: List[CrewOptimizationResult], output_path: str) -> str: """Export crew plan to Excel.""" with pd.ExcelWriter(output_path, engine='openpyxl') as writer: # Summary summary_data = [] for r in results: workers_str = ", ".join(f"{count}x {wt.value}" for wt, count in r.recommended_crew.workers) summary_data.append({ 'Work Item': r.work_item, 'Quantity': r.quantity, 'Unit': r.unit, 'Crew': r.recommended_crew.name, 'Workers': workers_str, 'Duration Days': r.duration_days, 'Labor Cost': r.total_labor_cost, 'Cost/Unit': r.cost_per_unit }) summary_df = pd.DataFrame(summary_data) summary_df.to_excel(writer, sheet_name='Crew Plan', index=False) # Totals totals_df = pd.DataFrame([{ 'Total Duration': max(r.duration_days for r in results), 'Total Labor Cost': sum(r.total_labor_cost for r in results) }]) totals_df.to_excel(writer, sheet_name='Totals', index=False) return output_path
python# Load CWICR data cwicr = pd.read_parquet("TR_workitems_costs_resources_DDC_CWICR.parquet") # Initialize optimizer optimizer = CWICRCrewOptimizer(cwicr) # Optimize crew for work item result = optimizer.optimize_for_work( work_item_code="CONC-SLAB-001", quantity=500, # m2 target_days=10 ) print(f"Recommended: {result.recommended_crew.name}") print(f"Duration: {result.duration_days} days") print(f"Labor Cost: ${result.total_labor_cost:,.2f}")
pythonovertime = optimizer.analyze_overtime(result, available_days=8) print(f"Overtime needed: {overtime['overtime_needed']}") print(f"Total cost: ${overtime['total_cost']:,.2f}")
pythonfor crew in [result.recommended_crew] + result.alternative_crews: print(f"{crew.name}: ${crew.hourly_cost}/hr")
pythoncustom = optimizer.build_crew( name="Custom Concrete", trade=Trade.CONCRETE, workers=[ (WorkerType.FOREMAN, 1), (WorkerType.JOURNEYMAN, 4), (WorkerType.LABORER, 2) ], base_productivity=1.5 )
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-05 | pass→pass | 16,950 | 21,573 | +27% | 1 | 1 | 0% | 3,761 | 8,967 | +138% | 0 | 0 | — |
case-01 | fail→pass | 17,413 | 53,402 | +207% | 1 | 1 | 0% | 4,012 | 9,331 | +133% | 0 | 0 | — |
case-02 | pass→pass | 12,611 | 17,488 | +39% | 1 | 1 | 0% | 2,685 | 7,901 | +194% | 0 | 0 | — |
case-03 | fail→fail | 37,002 | 35,645 | -4% | 1 | 1 | 0% | 8,261 | 12,296 | +49% | 0 | 0 | — |
case-04 | pass→pass | 17,277 | 22,889 | +32% | 1 | 1 | 0% | 2,990 | 8,737 | +192% | 0 | 0 | — |
case-06 | pass→pass | 8,635 | 8,651 | +0% | 1 | 1 | 0% | 1,843 | 5,881 | +219% | 0 | 0 | — |
case-07 | fail→pass | 16,920 | 14,632 | -14% | 1 | 1 | 0% | 2,952 | 6,728 | +128% | 0 | 0 | — |
case-08 | pass→pass | 7,861 | 7,311 | -7% | 1 | 1 | 0% | 1,564 | 5,475 | +250% | 0 | 0 | — |
case-09 | fail→pass | 16,338 | 20,200 | +24% | 1 | 1 | 0% | 2,923 | 7,645 | +162% | 0 | 0 | — |
case-10 | fail→pass | 17,660 | 17,632 | -0% | 1 | 1 | 0% | 2,959 | 7,006 | +137% | 0 | 0 | — |
case-11 | fail→pass | 14,879 | 3,392 | -77% | 1 | 1 | 0% | 2,639 | 4,631 | +75% | 0 | 0 | — |
case-12 | pass→pass | 13,657 | 5,142 | -62% | 1 | 1 | 0% | 2,117 | 4,822 | +128% | 0 | 0 | — |
case-13 | fail→pass | 17,780 | 8,922 | -50% | 1 | 1 | 0% | 2,779 | 5,871 | +111% | 0 | 0 | — |
case-14 | pass→pass | 4,170 | 2,890 | -31% | 1 | 1 | 0% | 735 | 4,521 | +515% | 0 | 0 | — |
case-15 | fail→fail | 9,521 | 5,171 | -46% | 1 | 1 | 0% | 1,869 | 5,057 | +171% | 0 | 0 | — |
case-16 | fail→pass | 19,008 | 3,308 | -83% | 1 | 1 | 0% | 1,532 | 4,638 | +203% | 0 | 0 | — |
case-17 | fail→fail | 5,511 | 9,519 | +73% | 1 | 1 | 0% | 1,044 | 5,919 | +467% | 0 | 0 | — |
case-18 | pass→pass | 4,628 | 10,221 | +121% | 1 | 1 | 0% | 893 | 6,101 | +583% | 0 | 0 | — |
case-19 | pass→pass | 5,493 | 3,683 | -33% | 1 | 1 | 0% | 826 | 4,714 | +471% | 0 | 0 | — |
case-20 | fail→pass | 13,981 | 6,799 | -51% | 1 | 1 | 0% | 2,239 | 5,358 | +139% | 0 | 0 | — |
case-21 | pass→pass | 5,359 | 9,461 | +77% | 1 | 1 | 0% | 990 | 5,796 | +485% | 0 | 0 | — |
case-22 | fail→pass | 12,264 | 4,235 | -65% | 1 | 1 | 0% | 1,899 | 4,640 | +144% | 0 | 0 | — |
case-23 | pass→pass | 14,277 | 2,679 | -81% | 1 | 1 | 0% | 2,331 | 4,533 | +94% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 23 cases were attempted. The headline lift of +39 percentage points is the difference between those two pass rates over the 23 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
| Model | Method | Date | Lift |
|---|---|---|---|
| gemini-3.6-flash | verified | 8/22/2026 | +63% |
Other measured skills in the registry, with their headline benchmark lift.