Who it is forA team lead estimating the token cost of a text-to-SQL agent before rolling it out on a large schema.
The problemPasting the whole schema into every prompt costs more as the schema grows, and the cost is hard to estimate without seeing the actual prompt.
The outcomeYou see the reduced DDL for one question, with a token count compared against the full schema.
What you need first
- Python and pip installed
- For your own database: a reachable Postgres, Oracle, MySQL or SQL Server URL, and the matching schemagate extra
- Optional: a model key only if you want generated answers or AI descriptions
Steps
- Run
pip install schemagateto install the library. - Run
schemagate demo "late shipments by carrier" --promptto print the DDL the model would receive. - Run
schemagate demo "which customers owe us money"and note the objects count and approximate token figure shown. - Repeat with your own questions and compare against the full schema size.
Prompt for your agent
Install schemagate, then run `schemagate demo "late shipments by carrier" --prompt` and `schemagate demo "which customers owe us money"`. Report the number of selected objects and the approximate prompt token count for each, and state the total object count of the bundled schema.
Caveat. The savings figures in the README come from the test schemas and a built-in estimator, so your own schema and tokenizer will give different numbers.
Use this in your AI agent
Ask your agent
Using the Deduped MCP, get the setup steps for ashishsinha1602/schemagate and "Measure how many prompt tokens selection saves"
Add Deduped to Claude Code once
claude mcp add --transport http deduped https://dedupedai.com/mcp
Every Monday: the 5 hottest repos and exactly how to use them. Free, one email a week, unsubscribe anytime.
Get them freeShare: X LinkedIn Hacker News Email Copy link
Third-party repos we don't own. AI-written use cases can be wrong. Disclaimer