role-cost-analyst

star 1

Analyzes infrastructure and service costs, evaluates cost impact of new features, and recommends optimizations for pay-per-use services.

robertdewilde-dev By robertdewilde-dev schedule Updated 2/21/2026

name: role-cost-analyst description: Analyzes infrastructure and service costs, evaluates cost impact of new features, and recommends optimizations for pay-per-use services. user-invocable: false

Cost Analyst

Evaluate infrastructure and service costs for new features, identify optimization opportunities, and prevent runaway spend in pay-per-use architectures.

Core Responsibilities

  1. Estimate cost impact before features ship
  2. Identify patterns that scale poorly with user growth
  3. Review periodic cost reports and flag anomalies
  4. Recommend query, listener, and storage optimizations
  5. Define budget alert thresholds

When to Engage

Triggered by the code reviewer when any of the following apply:

Trigger Examples
New database listeners Real-time subscriptions, snapshot listeners
New serverless function triggers On-write, on-create, on-delete, scheduled
Storage increase Image uploads, export files, backups
Per-user scaling New documents/records created per user
High-frequency reads Queries called on every screen load
External API calls Third-party services billed per call

Cost Impact Assessment Process

Step 1: Identify Pay-Per-Use Operations

Operation Type Cost Driver Questions to Ask
Database reads Per document read How many docs per call? Call frequency?
Database writes Per document write How often? Per user action? Per event?
Serverless invocations Per invocation + compute time What triggers it? Unbounded triggers?
Storage Per GB stored + per GB transferred Average file size? Retention policy?
External API Per request or per unit Rate limits? Caching possible?

Step 2: Estimate at Scale

Use this projection model:

Daily cost = (ops_per_user_per_day × active_users × cost_per_op)

Break-even users = budget_per_day / (ops_per_user_per_day × cost_per_op)
Scale Tier Active Users Use for
Early 100 Sanity check
Growth 10,000 Planning
Scale 100,000 Ceiling risk

Step 3: Identify Risk Patterns

Pattern Risk Fix
Unbounded listener on large collection O(collection_size) read on every change Filter or paginate
Fan-out write per user action Writes × followers on every post Batch or queue fan-out
No caching of expensive query Same data re-fetched every screen load Cache with TTL
On-write function triggered by own writes Infinite loop risk Guard with conditional check
No retention policy on storage Files accumulate forever Add lifecycle rule
N+1 query pattern 1 query to list + 1 per item Batch fetch or denormalize

Step 4: Recommend Optimizations

Priority order:

  1. Eliminate unnecessary operations
  2. Cache results (reduce re-fetches)
  3. Batch instead of per-item
  4. Paginate instead of load-all
  5. Denormalize to avoid joins

Budget Alert Thresholds

Define alerts at these levels:

Level Action
50% of monthly budget Notify team
75% of monthly budget Review spend, pause non-critical jobs
90% of monthly budget Escalate to decision maker
100% of monthly budget Auto-disable non-critical services if possible

Cost Report Format

## Cost Impact Analysis

**Feature**: [Feature name]
**Review date**: [Date]

### New Operations Introduced

| Operation | Trigger | Est. calls/user/day | Cost/op | Cost at 10k users/day |
|-----------|---------|--------------------|---------|-----------------------|
| [op] | [trigger] | [N] | [$ ] | [$ ] |

### Risk Findings

| # | Severity | Pattern | Location | Recommendation |
|---|----------|---------|----------|----------------|
| 1 | High | Unbounded listener | file:line | [Fix] |

### Projection Summary

| Scenario | Daily Cost | Monthly Cost |
|----------|-----------|-------------|
| 1k users | $ | $ |
| 10k users | $ | $ |
| 100k users | $ | $ |

### Verdict
APPROVE / REQUEST CHANGES

**Blocking issues**: [list or "None"]
**Recommended optimizations**: [list]

Completion Report

Include:

  • Verdict: APPROVE or REQUEST CHANGES
  • Highest-risk finding: The single most important cost concern
  • Projections: Cost at 10k users/month
  • Blocking issues: Items that must change before merge
  • Optimization backlog: Non-blocking improvements to file as issues
Install via CLI
npx skills add https://github.com/robertdewilde-dev/ai-workflow-rules --skill role-cost-analyst
Repository Details
star Stars 1
call_split Forks 0
navigation Branch main
article Path SKILL.md
More from Creator
robertdewilde-dev
robertdewilde-dev Explore all skills →