add-pricing-field

Wire a new model-pricing field end-to-end through Bifrost's Go pricing engine, database, API, docs, and UI.

7.7k|1.1k|Updated Mar 19, 2025
One-click install
npx skills add https://github.com/maximhq/bifrost --skill add-pricing-field
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: add-pricing-field
Source: https://github.com/maximhq/bifrost/tree/main/.claude/skills/add-pricing-field
Command: npx skills add https://github.com/maximhq/bifrost --skill add-pricing-field

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Adding a new per-model pricing field to Bifrost requires touching roughly eight disconnected places (Go structs, DB migrations, sync upserts, cost calculation, overrides, OpenAPI, docs, UI), and missing any one produces a field that compiles but silently fails to bill, resync, or accept overrides.

Core Features & Use Cases

  • End-to-end wiring checklist: Guides edits across the Options struct, TableModelPricing, gorm migrations, datasheet sync upsert columns, patchPricing overrides, and cost.go calculation functions.
  • Silent-failure prevention: Explicitly guards the most-missed step (pricingSyncUpdateColumns in rdb.go) whose omission only breaks on the second 24h datasheet resync, plus regression tests for the ON CONFLICT DO UPDATE path.
  • Semantics-first workflow: Forces confirmation of whether a field is additive, a threshold tier, or a rate substitute before writing billing logic, including cache-hit billing behavior.
  • Use Case: When a provider datasheet adds a key like cost_per_request, invoke the skill to propagate it through the Go backend, OpenAPI bundle, MDX docs, TypeScript types, and the pricing override form, then verify with a repo-wide probe.

Quick Start

Ask the assistant to run /add-pricing-field cost_per_request to wire that new datasheet pricing field through Bifrost's entire pricing engine.

Frequently Asked Questions about add-pricing-field

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a new pricing field to Bifrost's cost engine?▼

Add the field to the Options struct in framework/modelcatalog/datasheet/types.go, mirror it into TableModelPricing with a gorm migration, register it in pricingSyncUpdateColumns, wire it into the relevant compute*Cost function, and update overrides, OpenAPI, docs, and the UI form.

Why does my new pricing field stop working after the datasheet resync?▼

The column is missing from pricingSyncUpdateColumns in framework/configstore/rdb.go. The initial Create writes every column, but the ON CONFLICT DO UPDATE path on resync only updates explicitly listed columns, silently reverting unlisted fields to null.

How do I add a database migration for a new pricing column in Bifrost?▼

Add a migrationAdd<Name>Column function in framework/configstore/migrations.go using the addColumnIfNotExists and dropColumnIfExists helpers, then register it at the end of the migrations slice. Never use a bare ALTER TABLE statement.

Should a new pricing field be added to Bifrost's public Pricing struct?▼

Usually no. The Pricing struct in core/schemas/models.go intentionally exposes only a small summary of fields. Only populate an existing slot via ApplyModelInfo if the field maps to one, and ask before widening the public API surface.

How do I regenerate Bifrost's OpenAPI bundle after editing the schema?▼

Edit the source YAML in docs/openapi/schemas, then run python3 bundle.py from the docs/openapi directory. Never hand-edit docs/openapi/openapi.json; verify the regenerated diff contains only the new field's lines.