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/gaasher/agent-loop-skills/optimize-loopnpx skills add gaasher/Agent-Loop-Skills --skill optimize-loopgit clone --depth 1 https://github.com/gaasher/Agent-Loop-SkillsWhat 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.00116 | $0.02488 |
| Opus 5 | $0.00058 | $0.01244 |
| Sonnet 5 | $0.00023 | $0.00498 |
| Haiku 4.5 | $0.00012 | $0.00249 |
Grade A, and why
optimize-loop 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 — 141 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Optimize Loop
An evaluator-optimizer loop with a pluggable correctness gate + minimized metric. The artifact is some editable thing (a code module or a SQL query); the feedback signal is two-part: a bound gate that must pass (behaviour/results unchanged) and a bound metric that must drop (the cost you minimize). You apply one change, check the gate, measure the metric, and keep the change only if the gate passes AND the metric improves — otherwise you revert. Repeat until the metric stops improving or the budget runs out. Once the loop starts, do not pause for permission.
Two ready bindings ship in tools/ (both vendored, stdlib-only):
- code mode — gate:
<gate_cmd>(the test suite) exits 0; metric:tools/metrics.pyprintscomplexity(primary),max_nesting,loc(lexicographic tie-breakers). Lower is better. - sql mode — gate: the result-set
hashfromtools/bench.pymatches the baseline; metric: the same tool'smedian_ms. Lower is better.
The gate is non-negotiable in both modes: a change that fails it is a regression, not an improvement.
Never edit the ground truth (the tests / tools/metrics.py in code mode, the database / tools/bench.py
in sql mode) — editing what measures you to move the number defeats the loop.
When to use
Use when there is a clear correctness bound to hold and a number to minimize: refactoring code that
has a passing test suite (cut complexity), or tuning a SQL query that has a fixed result-set (cut
latency). The default is the matching shipped tool; the escape hatch is to bind any <gate_cmd> that
exits 0 on pass and any <metric_cmd> that prints a single number to minimize (e.g. a linter's issue
count, or a non-SQLite engine's timing + result fingerprint). Not for adding features or fixing
bugs — those intend to change behaviour, which this loop is built to forbid.
Setup
Resolve bindings interactively. If loop.run.yaml exists in the working dir, load it, confirm the
values back in one line, and skip to the loop. Otherwise pick <mode> first (it selects the gate +
metric), then on Claude Code (the AskUserQuestion tool is available) infer a likely value for each
binding and present it as the recommended option; on other hosts ask each as a quoted plain-text
prompt. Then write loop.run.yaml and confirm the values before creating any other files.
What ships with it
4 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.
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 · 141 lines · 116 tokens per session scan A 9345aa875395
optimize-loop is a skill published in the GitHub repository gaasher/Agent-Loop-Skills (158 stars, last pushed 2mo ago), licensed MIT. It adds 116 tokens to every session and 2,488 once invoked, about $0.0006 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-30.
Other skills, from other repositories
fixing-flaky-e2e-tests
Diagnose and fix flaky Playwright e2e tests. Use when tests fail intermittently, show timeout errors, have snapshot mismatches, or exhibit browser-specific failures.
fixing-streamlit-ci
Analyze and fix failed GitHub Actions CI jobs for the current branch/PR. Use when CI checks fail, PR checks show failures, or you need to diagnose lint/type/test errors and verify fixes locally.
updating-internal-docs
Review internal documentation (.md files) against the current codebase state and propose updates for outdated or incorrect information.
reviewing-readability
Evaluates comments, docstrings, and naming in code for readability by a developer new to the codebase — is the documentation clear and concise, and is non-obvious logic documented? Produces findings with concrete proposed rewrites (or additions where documentation is missing); the caller decides whether to apply them…
reviewing-pr-description
Evaluates a PR's title and description for readability — do they clearly and concisely convey what changed and why to a reviewer? Produces findings with concrete proposed rewrites; the caller decides whether to apply them or present them as feedback. Use when finalizing a PR or reviewing PR metadata. For code…
ppt-analysis
PPT (.pptx/.ppt) 全量解析。覆盖:所有 slide 文本/表格/图表提取、嵌入图片 caption、纯图片 slide 渲染识别、数据标签提取。.