home/ecommerce/add-llm-prompt-cost-gate-github-actions

Add Llm Prompt Cost Gate Github Actions

GPTClaudeGemini··238 copies·updated 2026-07-14
add-llm-prompt-cost-gate-github-actions.prompt
# Add an LLM Prompt Cost Gate to GitHub Actions in 10 Minutes

Prompt changes deserve the same review discipline as code changes. A longer
system prompt, a few extra examples, or a copied product description template
can silently increase the cost of every LLM call that uses it.

This tutorial shows how to add a Tokenometer GitHub Actions gate that measures
prompt-cost changes on pull requests, posts a sticky PR comment, and fails the
check when the cost delta crosses a USD budget.

Canonical demo repo:
[faraa2m/commerce-api-starter](https://github.com/faraa2m/commerce-api-starter)

Canonical Tokenometer Action:
[`faraa2m/tokenometer/packages/action@v1`](https://github.com/faraa2m/tokenometer/tree/main/packages/action#readme)

## What You Will Build

You will add:

- A `prompts/` directory containing LLM prompt files.
- A `.github/workflows/prompt-cost.yml` workflow.
- A pull-request budget gate using Tokenometer.
- A local command to reproduce the same measurement before pushing.

The example uses a commerce API prompt because it is easy to reason about:
product-copy prompts are often edited by engineers and product teams, and small
wording changes can affect every generated product description.

## Prerequisites

- A GitHub repository with GitHub Actions enabled.
- Prompt files committed under a predictable path such as `prompts/**/*.md`.
- Node.js only if you want to run the local `npx tokenometer` check.

The GitHub Action does not need provider API keys. It uses Tokenometer's offline
tokenizer path, which is designed for deterministic CI checks.

## Step 1: Add a Prompt File

Create `prompts/product-description.md`:

when to use it

Community prompt sourced from the open-source GitHub repo faraa2m/tokenometer (MIT). A "Add Llm Prompt Cost Gate Github Actions" style prompt — adapt the placeholders and specifics to your task. Imported as-is and not independently retested here, so check the output before relying on it.

tags

ecommercecommunitygeneral

source

faraa2m/tokenometer · MIT