Agent skill

Cost Optimize

by ruvnet in ruvnet/ruflo

Analyze token usage patterns and recommend cost optimizations with estimated savings

MITAuto-check: notesAI & LLM Engineering

Install Cost Optimize

skills CLI
$ npx skills add ruvnet/ruflo --skill cost-optimize -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install ruvnet/ruflo cost-optimize --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/ruvnet/ruflo.git skills-src && mkdir -p .claude/skills && cp -r skills-src/plugins/ruflo-cost-tracker/skills/cost-optimize .claude/skills/cost-optimize && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
cost-optimize
GitHub stars
74k
Token cost
~997 tokens
SKILL.md length
358 words
Files
1
Skills in repo
264
Repo updated
First seen
Licence
MIT

At a glance

Analyze token usage patterns and recommend cost optimizations with estimated savings

  • Works in 9 steps: Load usage data -- call… → Analyze model fit -- for each agent,… → Check cache rates -- compute cache hit… → …
  • Tasks that involve LLM cost and token optimization
  • SKILL.md covers When to use, Steps and CLI alternative
  • Calls npx and node

What it does

Cost Optimize is an agent skill from ruvnet/ruflo. Analyze token usage patterns and recommend cost optimizations with estimated savings

Its SKILL.md is about 1000 tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in AI & LLM Engineering, covering LLM cost and token optimization. It works with Model Context Protocol. The repository describes itself as: 🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory…. The licence is MIT.

When your agent uses it

  • Tasks that involve LLM cost and token optimization

Example prompts

  • “/cost-optimize”

Requirements

  • Node.js
  • Pre-approved tools (allowed-tools): mcp__plugin_ruflo-core_ruflo__memory_search, mcp__plugin_ruflo-core_ruflo__memory_list, mcp__plugin_ruflo-core_ruflo__memory_store, mcp__plugin_ruflo-core_ruflo__agentdb_pattern-search, mcp__plugin_ruflo-core_ruflo__agentdb_pattern-store, mcp__plugin_ruflo-core_ruflo__agentdb_semantic-route, mcp__plugin_ruflo-core_ruflo__hooks_model-outcome, Bash

Workflow steps

9 steps, taken from the first numbered list in SKILL.md.

  1. Load usage data -- call mcpplugin_ruflo-core_ruflomemory_search on the cost-tracking namespace (last 7 days). The memory_* tools route by…
  2. Analyze model fit -- for each agent, assess whether the model tier matches task complexity
  3. Check cache rates -- compute cache hit rate per agent; if below 60%, recommend enabling or improving prompt caching (90% cost reduction on…
  4. Detect redundancy -- look for multiple agents performing overlapping tasks, or agents being spawned for work that could be batched
  5. Estimate savings -- for each recommendation, calculate: current cost, projected cost after optimization, dollar savings, percentage…
  6. Search prior optimization patterns -- call mcpplugin_ruflo-core_rufloagentdb_pattern-search (ReasoningBank-routed; don't pass a namespace…
  7. Store the optimization pattern -- two paths
  8. Close the routing feedback loop — auto-emit hooks_model-outcome -- for each downgrade recommendation, format the outcome-emit command as…
  9. Report -- display: ranked recommendations with savings estimate, total potential savings, implementation priority (quick wins first), and…

What it can do on your machine

Read from SKILL.md and the folder at commit de590e1. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves these tools, so the agent can use them without asking each time:

    • mcp__plugin_ruflo-core_ruflo__memory_search
    • mcp__plugin_ruflo-core_ruflo__memory_list
    • mcp__plugin_ruflo-core_ruflo__memory_store
    • mcp__plugin_ruflo-core_ruflo__agentdb_pattern-search
    • mcp__plugin_ruflo-core_ruflo__agentdb_pattern-store
    • mcp__plugin_ruflo-core_ruflo__agentdb_semantic-route
    • mcp__plugin_ruflo-core_ruflo__hooks_model-outcome
    • Bash

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • npx
    • node

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use npx, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Cost Optimize loads about 997 tokens when it runs. Until then it costs about 25 tokens; SKILL.md has 358 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~25
When it runs · the whole SKILL.md, loaded when a task matches
~997

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check: notes

The automated check noted patterns worth knowing about, such as sudo or a known installer.

  • NotePre-approves every shell command (allowed-tools: Bash)SKILL.md
    allowed-tools: mcp__plugin_ruflo-core_ruflo__memory_search, mcp__plugin_ruflo-core_ruflo__memory_list, mcp__plugin_

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from ruvnet/ruflo at commit de590e1, republished under its MIT licence (© ruvnet). 358 words, ~997 tokens.

Download SKILL.mdSave it as .claude/skills/cost-optimize/SKILL.md (or your agent's skills folder).
name
cost-optimize
description
Analyze token usage patterns and recommend cost optimizations with estimated savings
allowed-tools
mcp__plugin_ruflo-core_ruflo__memory_search, mcp__plugin_ruflo-core_ruflo__memory_list, mcp__plugin_ruflo-core_ruflo__memory_store, mcp__plugin_ruflo-core_ruflo__agentdb_pattern-search, mcp__plugin_ruflo-core_ruflo__agentdb_pattern-store, mcp__plugin_ruflo-core_ruflo__agentdb_semantic-route, mcp__plugin_ruflo-core_ruflo__hooks_model-outcome, Bash

Cost Optimize

Analyze recent token usage across agents and models, identify waste, and recommend specific optimizations with estimated dollar savings.

When to use

When costs are higher than expected or you want to proactively reduce spending. Analyzes model selection efficiency, cache utilization, agent redundancy, and prompt efficiency.

Steps

  1. Load usage data -- call mcp__plugin_ruflo-core_ruflo__memory_search on the cost-tracking namespace (last 7 days). The memory_* tools route by namespace; use them — not agentdb_hierarchical-* (which routes by tier).

  2. Analyze model fit -- for each agent, assess whether the model tier matches task complexity:

    • Agents doing simple tasks (formatting, linting) on Sonnet/Opus → suggest Haiku or Agent Booster
    • Agents doing complex tasks (architecture, security) on Haiku → flag quality risk
  3. Check cache rates -- compute cache hit rate per agent; if below 60%, recommend enabling or improving prompt caching (90% cost reduction on cache reads)

  4. Detect redundancy -- look for multiple agents performing overlapping tasks, or agents being spawned for work that could be batched

  5. Estimate savings -- for each recommendation, calculate: current cost, projected cost after optimization, dollar savings, percentage reduction

  6. Search prior optimization patterns -- call mcp__plugin_ruflo-core_ruflo__agentdb_pattern-search (ReasoningBank-routed; don't pass a namespace argument — pattern-* tools ignore it).

  7. Store the optimization pattern -- two paths:

    • Pattern store (typed, recommended): mcp__plugin_ruflo-core_ruflo__agentdb_pattern-store with type: 'cost-optimization'. Don't pass a namespace arg — ReasoningBank routes it; on bridge unavailability the fallback writes to the reserved pattern namespace with controller: 'memory-store-fallback' (see ruflo-agentdb ADR-0001).
    • Plain store (namespace-routable): mcp__plugin_ruflo-core_ruflo__memory_store --namespace cost-patterns — this DOES respect the cost-patterns namespace because memory_* is namespace-routed.
  8. Close the routing feedback loop — auto-emit hooks_model-outcome -- for each downgrade recommendation, format the outcome-emit command as part of the recommendation table so it can be run directly:

    bash
    # success path (downgrade worked)
    node plugins/ruflo-cost-tracker/scripts/outcome.mjs "<task-description>" <model> success
    
    # escalated path (had to upgrade after downgrade attempt)
    node plugins/ruflo-cost-tracker/scripts/outcome.mjs "<task-description>" <model> escalated

    The script wraps npx @claude-flow/cli hooks model-outcome -t ... -m ... -o ... with explicit-argv spawnSync so quoting is safe. Without this signal the router does not learn from cost-tracker's recommendations and the booster bypass rate (see cost-booster-route skill) does not improve over time. This is the typed equivalent of the legacy routing-outcomes namespace (see ruflo-intelligence ADR-0001 §"Neutral").

  9. Report -- display: ranked recommendations with savings estimate, total potential savings, implementation priority (quick wins first), and any model-outcome events emitted in step 8

Show full SKILL.md (2 more words)Show less

CLI alternative

bash
npx @claude-flow/cli@latest memory search --query "cost optimization strategies" --namespace cost-patterns
npx @claude-flow/cli@latest memory store --key "opt-2026-05-04" --value '{...}' --namespace cost-patterns

© ruvnet, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in plugins/ruflo-cost-tracker/skills/cost-optimize of ruvnet/ruflo.

Open the folder on GitHubat commit de590e1

Compare with similar skills

Cost Optimize next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Cost Optimize compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Cost Optimize this skillruvnet/ruflo74k—~997Automated safety check: NotesMIT
Agents Best PracticesDenisSergeevitch/agents-best-practices2.4k—~7.4kAutomated safety check: PassMIT
Omnifajarhide/omni374—~1.1kAutomated safety check: PassApache-2.0
SupercompressSupercompress/Supercompress106—~519Automated safety check: PassMIT
Claude Code Daily Cost Reporttombelieber/claude-view110—~3kAutomated safety check: PassMIT
Amazon Bedrockaws/agent-toolkit-for-aws2.8k—~8.6kAutomated safety check: PassApache-2.0

Similar skills

  • Agents Best Practices

    DenisSergeevitch/agents-best-practices

    A skill your agent uses when designing, generating an MVP blueprint for, auditing, troubleshooting, refactoring, or explaining an agentic harness for any domain.

    2.4k GitHub stars~7.4k tokensUpdated 2 days ago
    AI & LLM EngineeringAuto-check passed
  • Omni

    fajarhide/omni

    A skill your agent uses when installing, verifying or configuring OMNI, when command output carries an [OMNI: ...] marker, or when output looks shorter than expected.

    374 GitHub stars~1.1k tokensUpdated today
    AI & LLM EngineeringAuto-check passed
  • Supercompress

    Supercompress/Supercompress

    Always-on context compression for Grok Build. An agent skill from Supercompress/Supercompress.

    106 GitHub stars~519 tokensUpdated 2 days ago
    Productivity & AutomationAuto-check passed
  • Claude Code Daily Cost Report

    tombelieber/claude-view

    Shows today's Claude Code spending through the claude-view MCP server, with total cost, running sessions and a per-session breakdown, and other date ranges on request.

    110 GitHub stars~3k tokensUpdated 6 days ago
    AI & LLM EngineeringAuto-check passed
  • Amazon Bedrock

    aws/agent-toolkit-for-aws

    Official

    Builds generative AI applications on Amazon Bedrock. An agent skill from aws/agent-toolkit-for-aws.

    2.8k GitHub stars~8.6k tokensUpdated today
    AI & LLM EngineeringAuto-check passed
  • AI Agent

    LanternOps/breeze

    Quick reference for the Breeze RMM AI Agent system architecture, MCP tools, streaming chat, cost tracking, guardrails, and MCP server.

    130 GitHub stars~3.7k tokensUpdated today
    Agent WorkflowsAuto-check passed

More from ruvnet/ruflo

All 264 skills in this repo
  • Stores, searches, and retrieves successful patterns with HNSW-indexed semantic search so agents can reuse past solutions instead of relearning them.

    74k GitHub starsUsed in 2 repos~830 tokens
    Auto-check passed
  • Runs claude-flow CLI security scans for input validation, path traversal, SQL injection, XSS, hardcoded secrets and known CVEs, and writes an audit report.

    74k GitHub starsUsed in 2 repos~823 tokens
    Auto-check passed
  • Applies the SPARC method (specification, pseudocode, architecture, refinement, completion) with 17 specialized modes and multi-agent orchestration, from research to deployment.

    74k GitHub starsUsed in 2 repos~829 tokens
    Auto-check passed
  • Coordinates a hierarchical swarm of specialized agents through the claude-flow CLI for work that spans several files or modules at once.

    74k GitHub starsUsed in 2 repos~779 tokens
    Auto-check passed
  • Sets up and drives Ruflo, an npm-installed orchestration layer for multi-agent swarms, persistent memory, routing, hooks and its MCP tool catalog.

    74k GitHub starsUsed in 1 repo~975 tokens
    Auto-check passed
  • Agent Coordination

    ruvnet/ruflo

    Reference for spawning, listing, monitoring and stopping agents with claude-flow commands, with agent type families, routing codes and coordination tips.

    74k GitHub starsUsed in 2 repos~519 tokens
    Auto-check passed

Questions about Cost Optimize

What does Cost Optimize do?

Analyze token usage patterns and recommend cost optimizations with estimated savings. Cost Optimize is an agent skill from ruvnet/ruflo.

When should I use Cost Optimize?

Cost Optimize fits situations like: tasks that involve LLM cost and token optimization.

How do I install Cost Optimize in Claude Code?

Run `npx skills add ruvnet/ruflo --skill cost-optimize -a claude-code`. Or copy the skill folder (plugins/ruflo-cost-tracker/skills/cost-optimize in ruvnet/ruflo) into .claude/skills/cost-optimize in your project. Claude Code loads it when a task matches its description.

How do I install Cost Optimize in Codex?

Run `npx skills add ruvnet/ruflo --skill cost-optimize -a codex`. Or copy the skill folder (plugins/ruflo-cost-tracker/skills/cost-optimize in ruvnet/ruflo) into .agents/skills/cost-optimize in your project. Codex loads it when a task matches its description.

Can I use Cost Optimize in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add ruvnet/ruflo --skill cost-optimize -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/cost-optimize, .gemini/skills/cost-optimize, .github/skills/cost-optimize and .opencode/skills/cost-optimize in your project.

What does Cost Optimize need to run?

Going by SKILL.md and its folder, Cost Optimize needs the command-line tools its instructions call (npx and node). Our summary lists: Node.js. Its frontmatter pre-approves these tools: mcp__plugin_ruflo-core_ruflo__memory_search, mcp__plugin_ruflo-core_ruflo__memory_list, mcp__plugin_ruflo-core_ruflo__memory_store, mcp__plugin_ruflo-core_ruflo__agentdb_pattern-search, mcp__plugin_ruflo-core_ruflo__agentdb_pattern-store, mcp__plugin_ruflo-core_ruflo__agentdb_semantic-route, mcp__plugin_ruflo-core_ruflo__hooks_model-outcome, Bash.

Does Cost Optimize access the network?

SKILL.md contains no URLs. Its commands use npx, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Cost Optimize safe to install?

Our automated static check of SKILL.md found notes only (pre-approves every shell command (allowed-tools: bash)), nothing it rates as a warning. It is not a guarantee. Review the folder before installing.

What licence does Cost Optimize use?

Cost Optimize is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Cost Optimize use?

About 997 tokens (SKILL.md is roughly 4k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Cost Optimize?

Skills that share tags, products or a category with Cost Optimize: Agents Best Practices (DenisSergeevitch/agents-best-practices, 2.4k stars), Omni (fajarhide/omni, 374 stars), Supercompress (Supercompress/Supercompress, 106 stars) and Claude Code Daily Cost Report (tombelieber/claude-view, 110 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Cost Optimize?

ruvnet (a GitHub user) maintains it in ruvnet/ruflo, which has 74,012 GitHub stars. The repository holds 264 skills in this directory. The repository was last updated on October 7, 2026.

Source: ruvnet/ruflo on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.