cwicr-historical-cost
Track and analyze historical cost data using CWICR. Compare actual vs estimated costs, build project cost database, and improve future estimates.
What this skill does
# CWICR Historical Cost Tracker
## Business Case
### Problem Statement
Improving estimates requires:
- Actual cost feedback
- Historical comparisons
- Trend analysis
- Lessons learned
### Solution
Track actual costs against CWICR estimates, build historical database, and use data to improve future estimating accuracy.
### Business Value
- **Accuracy improvement** - Learn from actuals
- **Benchmarking** - Project comparisons
- **Trend analysis** - Cost movement patterns
- **Organizational knowledge** - Cost database
## Technical Implementation
```python
import pandas as pd
import numpy as np
from typing import Dict, Any, List, Optional
from dataclasses import dataclass, field
from datetime import datetime, date
from enum import Enum
import json
class ProjectStatus(Enum):
"""Project status."""
ESTIMATED = "estimated"
IN_PROGRESS = "in_progress"
COMPLETED = "completed"
CANCELLED = "cancelled"
@dataclass
class CostRecord:
"""Historical cost record."""
project_id: str
project_name: str
work_item_code: str
quantity: float
estimated_cost: float
actual_cost: float
variance: float
variance_percent: float
completion_date: date
notes: str = ""
@dataclass
class ProjectCostSummary:
"""Project cost summary."""
project_id: str
project_name: str
project_type: str
location: str
status: ProjectStatus
estimated_total: float
actual_total: float
variance: float
variance_percent: float
start_date: date
completion_date: Optional[date]
item_count: int
class CWICRHistoricalCost:
"""Track historical costs using CWICR data."""
def __init__(self, cwicr_data: pd.DataFrame = None):
self.cwicr = cwicr_data
self._projects: Dict[str, ProjectCostSummary] = {}
self._records: List[CostRecord] = []
if cwicr_data is not None:
self._index_cwicr()
def _index_cwicr(self):
"""Index CWICR data."""
if 'work_item_code' in self.cwicr.columns:
self._cwicr_index = self.cwicr.set_index('work_item_code')
else:
self._cwicr_index = None
def add_project(self,
project_id: str,
project_name: str,
project_type: str,
location: str,
estimated_total: float,
start_date: date) -> str:
"""Add new project to historical database."""
summary = ProjectCostSummary(
project_id=project_id,
project_name=project_name,
project_type=project_type,
location=location,
status=ProjectStatus.ESTIMATED,
estimated_total=estimated_total,
actual_total=0,
variance=0,
variance_percent=0,
start_date=start_date,
completion_date=None,
item_count=0
)
self._projects[project_id] = summary
return project_id
def record_actual_cost(self,
project_id: str,
work_item_code: str,
quantity: float,
actual_cost: float,
completion_date: date = None,
notes: str = "") -> CostRecord:
"""Record actual cost for work item."""
# Get estimated cost from CWICR
estimated_unit_cost = 0
if self._cwicr_index is not None and work_item_code in self._cwicr_index.index:
item = self._cwicr_index.loc[work_item_code]
labor = float(item.get('labor_cost', 0) or 0)
material = float(item.get('material_cost', 0) or 0)
equipment = float(item.get('equipment_cost', 0) or 0)
estimated_unit_cost = labor + material + equipment
estimated_cost = estimated_unit_cost * quantity
variance = actual_cost - estimated_cost
variance_pct = (variance / estimated_cost * 100) if estimated_cost > 0 else 0
record = CostRecord(
project_id=project_id,
project_name=self._projects.get(project_id, {}).project_name if project_id in self._projects else "",
work_item_code=work_item_code,
quantity=quantity,
estimated_cost=round(estimated_cost, 2),
actual_cost=round(actual_cost, 2),
variance=round(variance, 2),
variance_percent=round(variance_pct, 1),
completion_date=completion_date or date.today(),
notes=notes
)
self._records.append(record)
# Update project summary
if project_id in self._projects:
proj = self._projects[project_id]
proj.actual_total += actual_cost
proj.variance = proj.actual_total - proj.estimated_total
proj.variance_percent = (proj.variance / proj.estimated_total * 100) if proj.estimated_total > 0 else 0
proj.item_count += 1
proj.status = ProjectStatus.IN_PROGRESS
return record
def complete_project(self, project_id: str, completion_date: date = None):
"""Mark project as completed."""
if project_id in self._projects:
self._projects[project_id].status = ProjectStatus.COMPLETED
self._projects[project_id].completion_date = completion_date or date.today()
def get_work_item_history(self, work_item_code: str) -> Dict[str, Any]:
"""Get historical data for specific work item."""
records = [r for r in self._records if r.work_item_code == work_item_code]
if not records:
return {'work_item_code': work_item_code, 'records': 0}
variances = [r.variance_percent for r in records]
actual_costs = [r.actual_cost / r.quantity if r.quantity > 0 else 0 for r in records]
return {
'work_item_code': work_item_code,
'records': len(records),
'average_variance_pct': round(np.mean(variances), 1),
'variance_std': round(np.std(variances), 1),
'average_actual_unit_cost': round(np.mean(actual_costs), 2),
'min_actual_unit_cost': round(min(actual_costs), 2),
'max_actual_unit_cost': round(max(actual_costs), 2),
'projects': list(set(r.project_id for r in records)),
'trend': 'increasing' if len(records) > 2 and actual_costs[-1] > actual_costs[0] else 'stable'
}
def get_accuracy_metrics(self) -> Dict[str, Any]:
"""Calculate overall estimating accuracy metrics."""
if not self._records:
return {}
variances = [r.variance_percent for r in self._records]
# Accuracy by category
by_category = {}
for record in self._records:
category = record.work_item_code.split('-')[0] if '-' in record.work_item_code else 'Other'
if category not in by_category:
by_category[category] = []
by_category[category].append(record.variance_percent)
category_accuracy = {
cat: {
'average_variance': round(np.mean(vals), 1),
'count': len(vals)
}
for cat, vals in by_category.items()
}
return {
'total_records': len(self._records),
'average_variance_pct': round(np.mean(variances), 1),
'variance_std': round(np.std(variances), 1),
'within_5pct': sum(1 for v in variances if abs(v) <= 5) / len(variances) * 100,
'within_10pct': sum(1 for v in variances if abs(v) <= 10) / len(variances) * 100,
'overestimated_pct': sum(1 for v in variances if v < 0) / len(variances) * 100,
'underestimated_pct': sum(1 for v in variances if v > 0) / len(variances) * 100,
'by_category': category_accuracy
}
def suggest_adjustment_factors(self) -> Dict[str, float]:
"""Suggest adjustment Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.