cost-compact-context

Retrieves compacted ReasoningBank context and reports bridge-reported token savings for cost-analysis queries.

70.1k|8.4k|Updated Jun 2, 2025
One-click install
npx skills add https://github.com/ruvnet/claude-flow --skill cost-compact-context
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cost-compact-context
Source: https://github.com/ruvnet/claude-flow/tree/main/plugins/ruflo-cost-tracker/skills/cost-compact-context
Command: npx skills add https://github.com/ruvnet/claude-flow --skill cost-compact-context

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @claude-flow/integration, agentic-flow, and includes scripts (resource) components.

What problem does it solve?

When analyzing token costs in claude-flow, there is no MCP tool that wraps the token optimizer's compact-context API, so engineers cannot easily see how much context compaction saves for a given query. This Skill shells a Node one-liner to call getTokenOptimizer().getCompactContext() and reports the bridge-reported tokensSaved value.

Core Features & Use Cases

  • Compact context retrieval: Invokes getCompactContext(query) from @claude-flow/integration via a Node script and prints a markdown summary plus a JSON line.
  • Graceful fallback: When agentic-flow is not installed, the bridge returns inert results (tokensSaved: 0, empty memories) and the skill exits cleanly with a clear message.
  • Honest metrics reporting: Carries forward the disclaimer that tokensSaved is a heuristic (query tokens minus compact prompt tokens), not a baseline-measured saving.
  • Use Case: A cost engineer wants to check how many tokens ReasoningBank compaction saves for the query "authentication refactor" — run the skill with that query and read the markdown table of memories retrieved, tokens saved, and cache hit rate.

Quick Start

Ask the AI to run the cost compact context skill with your query, for example: get compact context token savings for the query "authentication refactor".

Frequently Asked Questions about cost-compact-context

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

FAQPage Schema
How do I check token savings from ReasoningBank context compaction?

Run the skill with your query as the single argument; it executes a Node script under v3/ that calls getTokenOptimizer().getCompactContext(query) and prints a markdown table with memories retrieved, tokens saved, and cache hit rate.

What happens if agentic-flow is not installed?

The bridge falls back gracefully: getCompactContext returns tokensSaved of 0 with an empty memories list, and the skill prints an "agentic-flow not installed" message and exits cleanly without errors.

Is the tokensSaved metric an actual measured token reduction?

No. tokensSaved is a heuristic computed as query tokens minus compact prompt tokens, not a measurement against a no-RAG baseline. The skill explicitly carries this disclaimer forward in its output.

Why does the skill use a Node script instead of an MCP tool?

No MCP tool currently wraps getTokenOptimizer, as noted in ADR-0002. The skill shells a Node one-liner that imports the canonical @claude-flow/integration/token-optimizer export to bridge that gap.

Can I check whether the agent-booster optimization path is active?

Booster availability is not exposed as a getter; it is only observable through optimizedEdit returning method 'agent-booster' or the [AGENT_BOOSTER_AVAILABLE] signal covered by the cost-booster-route skill.