How to Use CMS drug spending rankings in opencode
Returns drugs ranked by spending, claims, Medicare beneficiary measures, or changes in average spending per unit. Use it to find the largest spenders or fastest changes before investigating individual drugs.
Prompts to try with CMS drug spending rankings in opencode
Copy an example into opencode, or ask in your own words.
Use CMS drug spending rankings to find the 20 highest-spending Medicaid drugs for 2024 and add a ranked table to this project's report.
Use CMS drug spending rankings to look this up and give me the result as a table. Save the result in ./assets.
Pull the latest numbers from CMS drug spending rankings and tell me what changed since last week.
Check CMS drug spending rankings and summarize what you find in three bullet points.
Pull the newest data from CMS drug spending rankings and give me the result as a table.
How to set up CMS drug spending rankings in opencode
Pick the way that suits you. Each takes about two minutes.
Use Spiral's MCP server
- Add the server
Leave out --global to add Spiral to the current project only. No header and no client ID or secret: opencode registers itself with Spiral.
opencode mcp add spiral --global --url https://api.spiral.ai/mcp
- Sign in
Your browser opens. Sign in to Spiral, pick the organization and click Authorize, then return to the terminal. No API key. Inside opencode, /mcps starts the same sign-in.
opencode mcp auth spiral
- Check it
Spiral shows as connected.
opencode mcp list
Use the Spiral skill
- Send opencode this message
Your agent reads Spiral's skill and sets itself up.
set up https://spiral.ai/SKILL.md
- Sign in or paste a key
Approve Spiral in the browser, or give the agent a key from the console.
Use the Spiral CLI
- Install and sign in
Installs the Spiral CLI, signs you in and adds its skill to your coding agents.
npx -y spiral-cli@latest init
Call the Spiral API
- Create an API key
In the console, under API keys.
- Run CMS drug spending rankings
One request; the result comes back by polling or a webhook.
curl https://api.spiral.ai/v1/runs \ -H "Authorization: Bearer $SPIRAL_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: $(uuidgen)" \ -d '{ "provider": "alexandria", "model": "data-cms-gov/drug-spending/top", "input": { "program": "part_d" } }'
Then paste one of the prompts above: opencode finds CMS drug spending rankings on Spiral, shows the price and runs it.
CMS drug spending rankings providers and prices
Spiral runs CMS drug spending rankings through Alexandria. Open a card for today's price, with every fee included.
Settings you can ask for
Ask opencode for any of these in your prompt.
| Setting | Allowed values | Default | Description |
|---|---|---|---|
| Program | part_d, part_b, or medicaid | The dataset to rank. | |
| Year | 2000 to 2100 | Calendar year to rank; defaults to the latest year in the current release (2024). Years outside the release are invalid_input. | |
| Limit | 1 to 100 | 10 | limit |
| Order | desc or asc | desc |
|
| Sort by | total_spending, total_claims, total_beneficiaries, avg_spending_per_beneficiary, or avg_spending_per_unit_change | total_spending |
|
| Min total spending | a number from 0 | Only drugs with at least this total spending in USD in |
Every API field of CMS data.cms.gov · Top is on its tool page: open its card above.
What can you do with CMS drug spending rankings in opencode?
Build a CMS drug spending report that compares prescription fills with reported spending for named drugs. A coding agent can turn the records into project tables and charts while keeping Medicare and Medicaid measures distinct.
Annual drug spending report
Identify the annual datasets and publication versions, collect the records, rank spending, and investigate named drugs. Recheck the exact records supporting the report's main findings.
Medicare Part B oncology spending review
Find the relevant Part B publication, rank spending, and examine Keytruda alongside other reported drugs. Collect the underlying records and verify selected results before preparing a fee-for-service spending brief.
Prescription volume and spending comparison
Use a consistent annual publication to find high-spending drugs and compare their spending changes with prescription-fill changes. Retrieve and verify the records needed to distinguish changes in reported utilization from changes in average spending.
Medicaid spending concentration analysis
Rank drugs by reported Medicaid spending and use the full dataset to calculate how much the largest drugs contribute to the total. Keep the analysis at the drug and prescription level because beneficiary counts are unavailable.
Select drugs for a policy brief
Find the highest-spending drugs or largest changes in average spending per unit, then examine named results and their underlying records. Use the findings to choose which drugs warrant a closer explanation.
More on CMS drug spending rankings and opencode
Overview
CMS drug spending rankings in other agents
Questions about CMS drug spending rankings in opencode
Can opencode use CMS drug spending rankings?
Yes. Add Spiral to opencode as an MCP server, and opencode can find and run CMS drug spending rankings like any built-in tool.
How much does CMS drug spending rankings cost in opencode?
$0.00873 per call. You pay from your Spiral balance as you go, with no subscription, and a failed run is not charged. Your opencode plan is separate.
Do I need an Alexandria account to use CMS drug spending rankings in opencode?
No. Spiral runs CMS drug spending rankings on its own Alexandria account. You sign in to Spiral once and never paste a key.
How long does it take to set up CMS drug spending rankings in opencode?
About two minutes: add the server, then sign in, then check it.
Does opencode wait while CMS drug spending rankings runs?
CMS drug spending rankings runs in the background. opencode starts the run, checks on it and gives you the json when it's ready.
Does CMS drug spending cover the entire US drug market?
No. Annual Part D data summarizes final-action claims for Part D enrollees, Part B spending excludes Medicare Advantage beneficiaries, and Medicaid spending covers outpatient drugs paid for by state Medicaid agencies.
How often does CMS update annual drug spending data?
CMS typically updates the annual Medicare Part D spending dataset once every 12 months. That publication schedule describes the annual dataset, rather than current prescribing activity.
Do the spending totals include rebates?
Part D totals exclude manufacturer rebates and other price concessions. Medicaid totals likewise are not reduced by rebates paid to states, so these figures do not establish spending after rebates.
Can I compare spending per beneficiary across Medicare and Medicaid?
The Medicaid spending dataset does not provide individual beneficiary counts. CMS explicitly says that per-beneficiary calculations are therefore not possible for that dataset.
Does a Part D drug total describe one strength or dosage form?
Annual Part D summaries combine strengths, dosage forms, and routes of administration under brand and generic names. A drug-level result therefore does not isolate a particular tablet strength or injection formulation.
Start using CMS drug spending rankings in opencode
One Spiral account for every tool your agent needs. No subscription; you pay per run.
Paste this into opencode:
set up https://spiral.ai/SKILL.md


