Evaluate costs vs benefits of a proposed change, investment, or decision with quantified ROI
Use this skill when tasked with evaluating whether a proposed change, investment, initiative, or decision is worth pursuing. This applies to technology migrations, process changes, vendor selections, staffing decisions, feature investments, or any scenario where costs must be weighed against expected benefits.
# Cost-Benefit Analysis: [Subject]
**Date:** YYYY-MM-DD
**Analyst:** [agent name]
**Decision:** [what is being evaluated]
**Recommendation:** [Proceed / Do Not Proceed / Proceed with Conditions]
## Executive Summary
[2-3 sentences: what was analyzed, what the numbers show, what is recommended]
## Cost Analysis
| # | Cost Item | Category | One-Time | Recurring (/yr) | Years | Total |
|---|-----------|----------|----------|------------------|-------|-------|
| C1 | ... | direct | $N | $N | N | $N |
**Total Costs:** $N
## Benefit Analysis
| # | Benefit Item | Category | One-Time | Recurring (/yr) | Years | Total |
|---|-------------|----------|----------|------------------|-------|-------|
| B1 | ... | tangible | $N | $N | N | $N |
**Total Benefits:** $N
## Financial Summary
- **Net Present Value (NPV):** $N
- **Return on Investment (ROI):** N%
- **Payback Period:** N months
- **Benefit-Cost Ratio:** N:1
## Risk Factors
| Risk | Impact on Analysis | Adjusted Estimate |
|------|-------------------|-------------------|
| ... | ... | ... |
## Sensitivity Analysis
[How results change if key assumptions vary by +/-20%]
## Recommendation
[Proceed / Do Not Proceed / Proceed with Conditions — with rationale]
# Read the proposal or decision description
PROPOSAL="${1:-/home/shared/proposal.md}"
echo "=== Proposal ==="
cat "$PROPOSAL" 2>/dev/null || echo "No proposal file found at $PROPOSAL"
echo ""
echo "=== Related Artifacts ==="
bash /home/shared/scripts/artifact.sh list 2>/dev/null | jq -r '.[] | "\(.path) — \(.description)"' 2>/dev/null
echo ""
echo "=== Related Tasks ==="
bash /home/shared/scripts/task.sh list 2>/dev/null | jq '.[] | {id: .id, subject: .subject, status: .status}' 2>/dev/null
echo ""
echo "=== Check for Prior Analysis ==="
find /home/shared -name "*cost*" -o -name "*benefit*" -o -name "*roi*" -o -name "*budget*" 2>/dev/null
Identify costs in three categories:
# Create structured cost inventory
cat > /tmp/costs.csv <<'EOF'
id,item,category,one_time,recurring_yearly,years,notes
C1,Software licenses,direct,0,24000,3,Annual SaaS subscription
C2,Migration labor (480 hrs),direct,72000,0,1,3 engineers x 8 weeks x 20 hrs/wk x $150/hr
C3,Staff training,indirect,15000,0,1,2-day workshop for 20 people
C4,Productivity dip during transition,indirect,0,30000,1,Estimated 10% slowdown for 6 months
C5,Feature delay (opportunity cost),opportunity,50000,0,1,3-month delay to roadmap items
EOF
echo "=== Cost Inventory ==="
column -t -s',' /tmp/costs.csv
Identify benefits in two categories:
# Create structured benefit inventory
cat > /tmp/benefits.csv <<'EOF'
id,item,category,one_time,recurring_yearly,years,notes
B1,Reduced infrastructure costs,tangible,0,36000,3,Eliminate 3 legacy servers
B2,Developer productivity gain,tangible,0,60000,3,15% faster feature delivery (4 devs x $100K x 15%)
B3,Reduced incident response time,tangible,0,20000,3,50% fewer P1 incidents x $2K avg cost
B4,Improved developer satisfaction,intangible,0,10000,3,Estimated retention value
B5,Better security posture,intangible,0,15000,3,Reduced breach risk probability
EOF
echo "=== Benefit Inventory ==="
column -t -s',' /tmp/benefits.csv
python3 <<'PYEOF'
import csv
import json
def load_items(path):
with open(path) as f:
return list(csv.DictReader(f))
costs = load_items("/tmp/costs.csv")
benefits = load_items("/tmp/benefits.csv")
def total_value(items):
"""Compute undiscounted total for each item and overall."""
results = []
for item in items:
one_time = float(item["one_time"])
recurring = float(item["recurring_yearly"])
years = int(item["years"])
total = one_time + (recurring * years)
results.append({**item, "total": total})
grand_total = sum(r["total"] for r in results)
return results, grand_total
cost_items, total_costs = total_value(costs)
benefit_items, total_benefits = total_value(benefits)
print("=" * 60)
print("COST SUMMARY")
print("=" * 60)
for c in cost_items:
print(f" {c['id']}: {c['item']:<45} ${c['total']:>10,.0f}")
print(f" {'TOTAL COSTS':<49} ${total_costs:>10,.0f}")
print()
print("=" * 60)
print("BENEFIT SUMMARY")
print("=" * 60)
for b in benefit_items:
print(f" {b['id']}: {b['item']:<45} ${b['total']:>10,.0f}")
print(f" {'TOTAL BENEFITS':<49} ${total_benefits:>10,.0f}")
# Simple ROI
net_benefit = total_benefits - total_costs
roi = (net_benefit / total_costs * 100) if total_costs > 0 else 0
bcr = total_benefits / total_costs if total_costs > 0 else 0
print()
print("=" * 60)
print("FINANCIAL SUMMARY (undiscounted)")
print("=" * 60)
print(f" Total Costs: ${total_costs:>12,.0f}")
print(f" Total Benefits: ${total_benefits:>12,.0f}")
print(f" Net Benefit: ${net_benefit:>12,.0f}")
print(f" ROI: {roi:>11.1f}%")
print(f" Benefit-Cost Ratio: {bcr:>11.2f}:1")
# Write summary as JSON for downstream use
summary = {
"total_costs": total_costs,
"total_benefits": total_benefits,
"net_benefit": net_benefit,
"roi_percent": round(roi, 1),
"benefit_cost_ratio": round(bcr, 2)
}
with open("/tmp/cba-summary.json", "w") as f:
json.dump(summary, f, indent=2)
print()
print("Summary written to /tmp/cba-summary.json")
PYEOF
python3 <<'PYEOF'
import csv
import json
DISCOUNT_RATE = 0.08 # 8% annual discount rate
HORIZON_YEARS = 3
def load_items(path):
with open(path) as f:
return list(csv.DictReader(f))
costs = load_items("/tmp/costs.csv")
benefits = load_items("/tmp/benefits.csv")
def yearly_cashflows(items, horizon):
"""Build array of cashflows per year from item definitions."""
flows = [0.0] * (horizon + 1) # year 0 through year N
for item in items:
one_time = float(item["one_time"])
recurring = float(item["recurring_yearly"])
years = min(int(item["years"]), horizon)
flows[0] += one_time
for y in range(1, years + 1):
flows[y] += recurring
return flows
cost_flows = yearly_cashflows(costs, HORIZON_YEARS)
benefit_flows = yearly_cashflows(benefits, HORIZON_YEARS)
print(f"Discount rate: {DISCOUNT_RATE*100:.0f}%")
print(f"Horizon: {HORIZON_YEARS} years")
print()
print(f"{'Year':<6} {'Costs':>12} {'Benefits':>12} {'Net':>12} {'PV Factor':>10} {'PV Net':>12}")
print("-" * 66)
npv = 0.0
cumulative = 0.0
payback_year = None
for y in range(HORIZON_YEARS + 1):
c = cost_flows[y]
b = benefit_flows[y]
net = b - c
pv_factor = 1 / ((1 + DISCOUNT_RATE) ** y)
pv_net = net * pv_factor
npv += pv_net
cumulative += net
if payback_year is None and cumulative >= 0 and y > 0:
payback_year = y
print(f" {y:<4} ${c:>10,.0f} ${b:>10,.0f} ${net:>10,.0f} {pv_factor:>9.4f} ${pv_net:>10,.0f}")
print("-" * 66)
print(f" NPV: ${npv:>10,.0f}")
if payback_year is not None:
# Interpolate for partial year
prev_cumulative = cumulative - (benefit_flows[payback_year] - cost_flows[payback_year])
net_in_year = benefit_flows[payback_year] - cost_flows[payback_year]
if net_in_year > 0:
fraction = abs(prev_cumulative) / net_in_year
payback_months = ((payback_year - 1) + fraction) * 12
else:
payback_months = payback_year * 12
print(f" Payback period: ~{payback_months:.0f} months")