Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Fetch construction material prices from open APIs. Track price trends, regional variations, and update cost databases.
.claude/skills/datadrivenconstruction-price-api/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | 119% | 0% |
| case-22 | ✗→✓ | ▲ Improved | 283% | 0% |
| case-02 | ✗→✓ | ▲ Improved | 230% | 0% |
| case-03 | ✗→✓ | ▲ Improved | 151% | 0% |
| case-04 | ✗→✓ | ▲ Improved | 386% | 0% |
Material prices fluctuate constantly. This skill fetches prices from open sources, tracks trends, and updates cost databases with current market data.
pythonimport requests import pandas as pd from typing import Dict, Any, List, Optional from dataclasses import dataclass, field from datetime import datetime, timedelta from enum import Enum import json class MaterialCategory(Enum): """Construction material categories.""" CONCRETE = "concrete" STEEL = "steel" LUMBER = "lumber" COPPER = "copper" ALUMINUM = "aluminum" CEMENT = "cement" AGGREGATES = "aggregates" ASPHALT = "asphalt" @dataclass class MaterialPrice: """Material price point.""" material: str price: float unit: str currency: str source: str date: datetime region: str = "" @dataclass class PriceTrend: """Price trend analysis.""" material: str current_price: float week_change: float month_change: float year_change: float trend_direction: str # 'up', 'down', 'stable' class OpenPriceAPI: """Client for open material price APIs.""" # Commodity price sources FRED_BASE = "https://api.stlouisfed.org/fred/series/observations" # FRED Series IDs for construction commodities FRED_SERIES = { 'steel': 'WPU101', 'lumber': 'WPS0811', 'concrete': 'WPU133', 'copper': 'PCOPPUSDM', 'aluminum': 'PALUMUSDM' } def __init__(self, fred_api_key: Optional[str] = None): self.fred_api_key = fred_api_key def get_fred_prices(self, material: str, start_date: str = None, end_date: str = None) -> List[MaterialPrice]: """Get prices from FRED API.""" if material.lower() not in self.FRED_SERIES: return [] series_id = self.FRED_SERIES[material.lower()] if start_date is None: start_date = (datetime.now() - timedelta(days=365)).strftime('%Y-%m-%d') if end_date is None: end_date = datetime.now().strftime('%Y-%m-%d') params = { 'series_id': series_id, 'observation_start': start_date, 'observation_end': end_date, 'file_type': 'json' } if self.fred_api_key: params['api_key'] = self.fred_api_key try: response = requests.get(self.FRED_BASE, params=params) if response.status_code != 200: return [] data = response.json() observations = data.get('observations', []) prices = [] for obs in observations: try: price = float(obs['value']) prices.append(MaterialPrice( material=material, price=price, unit='index', currency='USD', source='FRED', date=datetime.strptime(obs['date'], '%Y-%m-%d'), region='US' )) except (ValueError, KeyError): continue return prices except Exception as e: print(f"Error fetching FRED data: {e}") return [] def to_dataframe(self, prices: List[MaterialPrice]) -> pd.DataFrame: """Convert prices to DataFrame.""" data = [{ 'material': p.material, 'price': p.price, 'unit': p.unit, 'currency': p.currency, 'source': p.source, 'date': p.date, 'region': p.region } for p in prices] return pd.DataFrame(data) class ConstructionPriceTracker: """Track and analyze construction material prices.""" # Default regional factors REGIONAL_FACTORS = { 'US_National': 1.0, 'US_Northeast': 1.15, 'US_Southeast': 0.95, 'US_Midwest': 0.92, 'US_West': 1.10, 'Germany': 1.25, 'UK': 1.20, 'France': 1.18 } def __init__(self): self.price_cache: Dict[str, pd.DataFrame] = {} def calculate_trend(self, prices: pd.DataFrame) -> PriceTrend: """Calculate price trend from historical data.""" if prices.empty or 'price' not in prices.columns: return None prices = prices.sort_values('date') current = prices['price'].iloc[-1] # Calculate changes week_ago_idx = len(prices) - 7 if len(prices) >= 7 else 0 month_ago_idx = len(prices) - 30 if len(prices) >= 30 else 0 year_ago_idx = len(prices) - 365 if len(prices) >= 365 else 0 week_price = prices['price'].iloc[week_ago_idx] month_price = prices['price'].iloc[month_ago_idx] year_price = prices['price'].iloc[year_ago_idx] week_change = ((current - week_price) / week_price * 100) if week_price else 0 month_change = ((current - month_price) / month_price * 100) if month_price else 0 year_change = ((current - year_price) / year_price * 100) if year_price else 0 # Determine trend if month_change > 5: trend = 'up' elif month_change < -5: trend = 'down' else: trend = 'stable' return PriceTrend( material=prices['material'].iloc[0], current_price=current, week_change=round(week_change, 2), month_change=round(month_change, 2), year_change=round(year_change, 2), trend_direction=trend ) def apply_regional_factor(self, base_price: float, region: str) -> float: """Apply regional price factor.""" factor = self.REGIONAL_FACTORS.get(region, 1.0) return base_price * factor def update_cost_database(self, cost_df: pd.DataFrame, price_updates: Dict[str, float], date_column: str = 'last_updated') -> pd.DataFrame: """Update cost database with new prices.""" updated = cost_df.copy() for material, price in price_updates.items(): # Find rows with this material mask = updated['material'].str.lower() == material.lower() if mask.any(): # Calculate adjustment factor old_price = updated.loc[mask, 'unit_price'].mean() factor = price / old_price if old_price > 0 else 1 # Update prices updated.loc[mask, 'unit_price'] *= factor updated.loc[mask, date_column] = datetime.now() return updated class MaterialPriceEstimator: """Estimate material prices when API data unavailable.""" # Reference prices (USD per unit, as of 2024) REFERENCE_PRICES = { 'concrete_m3': 120, 'rebar_ton': 800, 'structural_steel_ton': 1200, 'lumber_mbf': 450, 'copper_wire_kg': 12, 'brick_1000': 550, 'cement_ton': 130, 'sand_m3': 35, 'gravel_m3': 40, 'drywall_m2': 8, 'insulation_m2': 25 } def estimate_price(self, material: str, region: str = 'US_National', inflation_adjustment: float = 0) -> float: """Estimate current price for material.""" base_price = self.REFERENCE_PRICES.get(material, 0) if base_price == 0: return 0 # Apply inflation adjusted = base_price * (1 + inflation_adjustment) # Apply regional factor tracker = ConstructionPriceTracker() return tracker.apply_regional_factor(adjusted, region) def bulk_estimate(self, materials: List[str], region: str = 'US_National') -> pd.DataFrame: """Estimate prices for multiple materials.""" estimates = [] for material in materials: price = self.estimate_price(material, region) estimates.append({ 'material': material, 'estimated_price': price, 'region': region, 'source': 'estimate', 'date': datetime.now() }) return pd.DataFrame(estimates)
python# Initialize price API api = OpenPriceAPI(fred_api_key="your_key") # Get steel prices steel_prices = api.get_fred_prices('steel') df = api.to_dataframe(steel_prices) print(df.tail()) # Analyze trend tracker = ConstructionPriceTracker() trend = tracker.calculate_trend(df) print(f"Steel trend: {trend.trend_direction}, YoY: {trend.year_change}%")
pythontracker = ConstructionPriceTracker() # New prices from market updates = {'steel': 1250, 'concrete': 135, 'lumber': 480} # Update database updated_db = tracker.update_cost_database(cost_df, updates)
pythonbase_price = 120 # concrete USD/m3 berlin_price = tracker.apply_regional_factor(base_price, 'Germany') print(f"Berlin price: ${berlin_price}/m3")
pythonestimator = MaterialPriceEstimator() materials = ['concrete_m3', 'rebar_ton', 'lumber_mbf'] estimates = estimator.bulk_estimate(materials, region='US_West') print(estimates)
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-06 | pass→pass | 4,059 | 2,105 | -48% | 1 | 1 | 0% | 665 | 3,012 | +353% | 0 | 0 | — |
case-01 | fail→pass | 11,028 | 12,109 | +10% | 1 | 1 | 0% | 2,311 | 5,058 | +119% | 0 | 0 | — |
case-22 | fail→pass | 5,025 | 2,584 | -49% | 1 | 1 | 0% | 812 | 3,110 | +283% | 0 | 0 | — |
case-02 | fail→pass | 6,149 | 4,049 | -34% | 1 | 1 | 0% | 1,077 | 3,552 | +230% | 0 | 0 | — |
case-03 | fail→pass | 8,186 | 8,108 | -1% | 1 | 1 | 0% | 1,759 | 4,415 | +151% | 0 | 0 | — |
case-04 | fail→pass | 12,705 | 6,447 | -49% | 1 | 1 | 0% | 791 | 3,843 | +386% | 0 | 0 | — |
case-05 | fail→pass | 5,893 | 3,428 | -42% | 1 | 1 | 0% | 981 | 3,075 | +213% | 0 | 0 | — |
case-07 | fail→pass | 9,373 | 4,868 | -48% | 1 | 1 | 0% | 1,755 | 3,616 | +106% | 0 | 0 | — |
case-08 | pass→pass | 5,113 | 2,515 | -51% | 1 | 1 | 0% | 846 | 3,072 | +263% | 0 | 0 | — |
case-09 | pass→pass | 6,491 | 2,417 | -63% | 1 | 1 | 0% | 1,211 | 3,034 | +151% | 0 | 0 | — |
case-10 | fail→pass | 10,613 | 2,473 | -77% | 1 | 1 | 0% | 1,714 | 3,172 | +85% | 0 | 0 | — |
case-11 | fail→pass | 13,461 | 3,225 | -76% | 1 | 1 | 0% | 2,354 | 3,226 | +37% | 0 | 0 | — |
case-12 | fail→pass | 8,964 | 2,760 | -69% | 1 | 1 | 0% | 1,412 | 3,111 | +120% | 0 | 0 | — |
case-13 | fail→pass | 8,696 | 2,269 | -74% | 1 | 1 | 0% | 1,536 | 3,003 | +96% | 0 | 0 | — |
case-14 | fail→pass | 8,240 | 2,295 | -72% | 1 | 1 | 0% | 1,248 | 3,038 | +143% | 0 | 0 | — |
case-15 | fail→pass | 6,738 | 3,468 | -49% | 1 | 1 | 0% | 1,151 | 3,367 | +193% | 0 | 0 | — |
case-16 | pass→pass | 8,738 | 2,884 | -67% | 1 | 1 | 0% | 1,561 | 3,207 | +105% | 0 | 0 | — |
case-17 | fail→pass | 5,757 | 2,772 | -52% | 1 | 1 | 0% | 914 | 3,147 | +244% | 0 | 0 | — |
case-18 | fail→pass | 12,293 | 1,774 | -86% | 1 | 1 | 0% | 2,318 | 2,966 | +28% | 0 | 0 | — |
case-19 | fail→fail | 9,296 | 14,749 | +59% | 1 | 1 | 0% | 1,730 | 5,597 | +224% | 0 | 0 | — |
case-20 | fail→fail | 17,538 | 19,943 | +14% | 1 | 1 | 0% | 3,474 | 6,630 | +91% | 0 | 0 | — |
case-21 | fail→fail | 17,679 | 18,687 | +6% | 1 | 1 | 0% | 3,180 | 6,195 | +95% | 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. 22 cases were attempted. The headline lift of +68 percentage points is the difference between those two pass rates over the 22 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.
Other measured skills in the registry, with their headline benchmark lift.