
Cost Compact Context
FreeOptimize token usage for cost-analysis queries.
Free · Opens the source repo
What Cost Compact Context does
Cost Compact Context is a skill designed to enhance the efficiency of cost-analysis queries by utilizing the getTokenOptimizer().getCompactContext() function from the @claude-flow/integration package. This skill allows developers and designers to retrieve a compacted version of the ReasoningBank context, which can lead to significant savings in token usage during queries. By wrapping the getCompactContext() function, this skill provides a straightforward method to analyze how many tokens can be saved, making it particularly useful for those working with AI agents that are sensitive to token costs.
When you invoke this skill, it dynamically imports the necessary components and runs a script that processes your query. The output includes a markdown summary along with a JSON line that details the tokens saved, the number of memories retrieved, and the availability of the agentic-flow. This ensures that users receive a clear and concise report of the efficiency of their queries. The skill is designed to exit cleanly if the agentic-flow package is not installed, providing a graceful fallback that does not disrupt your workflow.
This skill is particularly beneficial for developers who frequently work with AI-driven applications and need to optimize their token usage for cost efficiency. By understanding the potential savings in token consumption, users can make informed decisions about their queries and improve the overall performance of their applications. However, it is important to note that the reported savings are heuristic in nature and not derived from a baseline measurement, which users should keep in mind when interpreting the results.
When to use it
Use this skill when you need to analyze the efficiency of token usage in your AI queries and want to optimize costs.
When not to use it
This skill may not be suitable if you do not use the `@claude-flow/integration` package or if you require guaranteed baseline measurements for token savings.
What you can build with it
Cost Analysis for AI Queries
Utilize the skill to analyze the token usage of your AI queries, helping to identify potential savings.
Integrating with AI Workflows
Incorporate this skill into your existing AI workflows to enhance efficiency and reduce operational costs.
Reporting Token Efficiency
Generate reports on token savings and memory retrieval to better understand the performance of your AI applications.
How to install Cost Compact Context
View source1. Install with the skills CLI
npx skills add ruvnet/ruflo/cost-compact-context --agent claude-code2. Or install it manually
Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.
Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs
Inside SKILL.md
Written by ruvnetCost Compact Context
Wraps getTokenOptimizer().getCompactContext() from @claude-flow/integration for cost-analysis queries. The bridge dynamically imports agentic-flow with graceful fallback: when the package isn't installed, tokensSaved is 0 and the skill exits cleanly. No MCP tool wraps getTokenOptimizer today (ADR-0002 §"Riskiest assumption"); we shell a Node one-liner instead.
Steps
-
Take the query — the single argument.
-
Invoke — run from anywhere under
v3/so@claude-flow/integrationresolves:( cd v3 && node ../plugins/ruflo-cost-tracker/scripts/compact.mjs "<QUERY>" )The script imports
@claude-flow/integration/token-optimizer(canonical export — notdist/token-optimizer.js, which would double the.jsextension via Node's./*exports rule), callsgetCompactContext(query), and prints a markdown summary plus a JSON line viaCOMPACT_QUIET=1. -
Report — markdown table with: memories retrieved, tokens saved (bridge-reported), agentic-flow availability, cache hit rate. The script also emits a "bridge-reported, not measured against a no-RAG baseline" disclaimer. On bridge-unavailable: prints "agentic-flow not installed — bridge returns inert results." and exits cleanly.
Caveats — claimed upstream, not yet verified
CLAUDE.md root claims ReasoningBank retrieval: -32% tokens. The bridge's tokensSaved is query_tokens − compact_prompt_tokens (token-optimizer.ts:141–143) — a heuristic, not a baseline-measured saving. token-optimizer.ts:9–10 itself says: "No fabricated metrics are reported — all stats reflect real measurements". This skill carries that disclaimer forward.
Booster-specific availability is not exposed as a getter — observable only through optimizedEdit() returning method: 'agent-booster'. The canonical Tier 1 signal is [AGENT_BOOSTER_AVAILABLE] (see cost-booster-route).
Fallback
agentic-flow not installed → getCompactContext returns {tokensSaved: 0, memories: []} (line 116–124), optimizedEdit returns {method: 'traditional'}, getOptimalConfig falls back to anti-drift defaults. Skill exits cleanly with the "not available" message.
Cross-references
ADR-0002 Decision #2 + §"Riskiest assumption" · token-optimizer.ts:308 (singleton export) · docs/benchmarks/0002-baseline.md (verification findings).
Frequently asked questions about Cost Compact Context
Similar skills
Mini Context Graph
Build a persistent knowledge base with structured retrieval.
Pinecone RAG
Build RAG pipelines with Pinecone as your vector database.
Amazon Bedrock
Build generative AI applications on AWS Bedrock.
Supermemory
Enhance AI agents with persistent memory and context.
RAG Implementation
Build knowledge-grounded AI systems with RAG.
Memory Management
Enhance learning and knowledge sharing with persistent memory.
