Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add skills/rbraga01/builder-ai/context-optimizationnpx skills add RBraga01/builder-ai --skill context-optimizationgit clone --depth 1 https://github.com/RBraga01/builder-aiWhat it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00048 | $0.01282 |
| Opus 5 | $0.00024 | $0.00641 |
| Sonnet 5 | $0.00010 | $0.00256 |
| Haiku 4.5 | $0.00005 | $0.00128 |
Grade A, and why
context-optimization scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 138 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Context Optimization
The Law
PROMPT COST IS NOT OPTIMISED BY GUESSING.
"I already have a short prompt" is a guess about token count.
"Reducing context will hurt quality" is a guess about the quality/cost curve.
Measure first. Apply the hierarchy. Measure again. THEN claim improvement.
When to Use
Trigger when:
- Prompt + context exceeds 60% of the model's context window
- p95 latency is above target
- Cost per 1k calls exceeds budget
- RAG pipeline is stuffing too many chunks into each call
- Output quality is degrading on long inputs (long context dilution)
When NOT to Use
- The feature has < 100 calls/month and total monthly cost is < $20 — optimisation ROI is negative at this volume
- Quality is currently below threshold — fix quality first; optimising a broken pipeline only makes it cheaper to be wrong
- The system prompt changes every call — prompt caching (Level 5) has no effect; skip straight to Level 1–3
The Reduction Hierarchy
Apply in order. Stop when the target is met. Do not apply all steps preemptively.
Level 1 — Trim the System Prompt
Audit every sentence:
- Run the prompt without each instruction — does output quality change?
- Remove any instruction the model follows without it
- Remove few-shot examples that duplicate knowledge the model already has
- Replace verbose explanations with single directives
Target: system prompt under 500 tokens for most tasks. Measure token count precisely:
import tiktoken
enc = tiktoken.get_encoding("cl100k_base")
print(len(enc.encode(system_prompt)))
Level 2 — Reduce Retrieved Context
If using RAG, before any other change:
- Reduce
top_kby 1 and run eval-before-ship — recall often holds at lower top_k - Add or tighten a similarity threshold (filter chunks below 0.75 cosine similarity)
- Set a hard context budget:
MAX_CONTEXT_TOKENS = context_window × 0.4
Level 3 — Compress Retrieved Content
Before injecting:
- Strip document headers, footers, and repeated boilerplate
- Normalise whitespace and remove formatting artefacts
- Convert verbose JSON to compact tabular format
- For chunks over 600 tokens: LLM-summarise to 1/3 length with a fast model
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 2d ago First seen · 138 lines · 48 tokens per session scan A 139a70ad55ad
context-optimization is a skill published in the GitHub repository RBraga01/builder-ai (2 stars, last pushed 1mo ago), licensed MIT. It adds 48 tokens to every session and 1,282 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.
Other skills, from other repositories
metrics-instrumentation
Specification for instrumenting an opik-backend workflow with operational OpenTelemetry metrics — per-stage throughput/latency/error counters and native histograms, dimensioned per-customer (workspace). Use when a pipeline (scoring, ingestion, experiments, jobs) needs per-stage visibility. Covers metric emission only…
comet-verify
Comet Phase 4: Verify and Close. Invoke with /comet-verify. Verify implementation matches design, handle development branch.
comet-design
Comet Classic 阶段 2 —— 为 change 产出深度技术 Design Doc。.
happiness-skill
当用户问「怎么才能更幸福/为什么得到了还不满足/怎么减少焦虑」时调用。 核心理念: 幸福是缺憾感清空的默认状态, 是可训练的技能; 欲望是与自己的契约(得到前不快乐), 同时只留一个重大欲望; 活在当下。 不适用于: 临床抑郁等需要专业治疗的场景(本书方法不能替代医疗)。 Triggers: 幸福/不快乐/欲望/焦虑/知足/活在当下/happiness/desire/anxiety.
comet-github
将 Comet GitHub 维护请求路由到基于证据的 PR 审阅、Issue 分诊、本地想法收集、CI 诊断或 Issue 实施流程。用户提到 Comet GitHub Issue/PR 但未指定流程,或询问下一步如何处理时使用。.
superlint
This skill describes the mandatory standard operating procedure for using our internal SuperLint tool. Use this when tasks require fixing code quality issues according to corporate standards.