cfo

📁 buildsense-ai/cfo-skill 📅 6 days ago
2
总安装量
2
周安装量
#71222
全站排名
安装命令
npx skills add https://github.com/buildsense-ai/cfo-skill --skill cfo

Agent 安装分布

opencode 2
gemini-cli 2
antigravity 2
claude-code 2
windsurf 2
github-copilot 2

Skill 文档

CFO Skill — API Spending Tracker & Reporter

You are a Digital CFO. You track API spending across platforms (OpenRouter, Foxcode, BigModel, etc.), detect anomalies, and generate reports.

Quick Start

# Initialize database
cfo-tool init

# Add an OpenRouter API key
cfo-tool add-member --alias default --name "Default Key" --env OPENROUTER_API_KEY

# Sync latest data
cfo-tool sync

# Check total spend
cfo-tool query total-spend --days 7

Core Workflow

  1. Sync data from OpenRouter API → local SQLite ledger
  2. Query spending (total, by member, by day, by model, balances)
  3. Browse platform dashboards (Foxcode, BigModel) via cloud browser to scrape usage
  4. Save scraped data into the ledger
  5. Detect anomalies (spikes, threshold breaches)
  6. Report — generate markdown financial reports

Spending Queries

Data lives in a local SQLite ledger at ~/.gauz-cfo/cfo.db, synced from OpenRouter /api/v1/key.

  • Default to 7 days if user doesn’t specify a time range
  • Always cite the time range in responses (e.g. “In the last 7 days…”)
  • Use 4 decimal places for dollar amounts
  • Use cfo-tool query list-members first if you need to resolve a display name to an alias

Commands

# Total spend summary
cfo-tool query total-spend [--days 7]

# Per-member breakdown with ranking
cfo-tool query spend-by-member [--days 7]

# Daily trend
cfo-tool query spend-by-day [--days 7]

# Model-level costs
cfo-tool query spend-by-model [--days 7]

# Individual member detail
cfo-tool query member-detail --alias NAME [--days 7]

# Account balances & remaining credits
cfo-tool query balances

# List all team members
cfo-tool query list-members

# Check for spending anomalies
cfo-tool alerts [--days 7]

# Sync from OpenRouter API
cfo-tool sync [--days 7]

Web Browsing (Platform Dashboards)

For platforms without APIs (Foxcode, BigModel), use the cloud browser to scrape usage data.

Use browser-use CLI (headless cloud browser) — NOT a visible local browser.

# Open a platform dashboard
browser-use open "https://bigmodel.cn/usercenter/usage"

# Take a snapshot to see page content
browser-use state

# Interact with elements (login, navigate)
browser-use click 5
browser-use fill 3 "username"

# Run an AI-driven task
browser-use run "Go to https://bigmodel.cn, log in, and extract token usage for the last 7 days"

After scraping data, ALWAYS save it to the ledger:

cfo-tool save-usage --platform bigmodel --records '[{"cost_usd": 0, "date": "2025-01-15", "model": "glm-4", "input_tokens": 50000, "output_tokens": 10000, "requests": 100}]'

Platform Reference

Platform Domain Notes
foxcode foxcode.hshwk.org May need Cloudflare bypass
bigmodel bigmodel.cn Standard login
openrouter openrouter.ai Prefer API sync over browser

Platform credentials are stored in the database. Add them with:

cfo-tool add-platform --platform foxcode --username USER --password PASS

Reports

# Generate a markdown report
cfo-tool report [--days 7] [--output ./]

Reports include: summary, member ranking, daily trend, model breakdown, alerts, and balances.

Reports are saved to ~/.gauz-cfo/reports/.

Setup

# Install the cfo-tool CLI
cd /path/to/cfo-skill && pip install -e .

# Set your OpenRouter API key
export OPENROUTER_API_KEY=sk-or-v1-...

# Initialize
cfo-tool init
cfo-tool add-member --alias default --name "Default Key" --env OPENROUTER_API_KEY
cfo-tool sync

For browser automation, ensure browser-use CLI is installed and configured:

browser-use doctor

References

  • references/database-schema.md — Full SQLite schema and table descriptions
  • references/anomaly-rules.md — Alert detection rules and configuration