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 skills add luabagg/agent-skills --skill cognitive-refactorgit clone --depth 1 https://github.com/luabagg/agent-skillsWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/luabagg/agent-skills/cognitive-refactor)<a href="https://agentmods.dev/skills/luabagg/agent-skills/cognitive-refactor"><img src="https://agentmods.dev/badge/skills/luabagg/agent-skills/cognitive-refactor/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/skills/luabagg/agent-skills/cognitive-refactor"><img src="https://agentmods.dev/badge/skills/luabagg/agent-skills/cognitive-refactor.svg" alt="Reviewed on agentmods" width="80" height="20"></a>What 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.1 | $0.00072 | $0.02889 |
| Opus 5.5 | $0.00029 | $0.01156 |
| Sonnet 5.5 | $0.00014 | $0.00578 |
| Haiku 4.5 | $0.00007 | $0.00289 |
Grade A, and why
cognitive-refactor 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 1mo 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 — 221 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Cognitive Refactor
A complexity score counts branches. A reader counts the places they must open to answer one question: functions, files, and conditions they must hold in mind. Refactor to reduce the places. A change that lowers the score and adds places is a regression.
Control flow
- Handle each special case first, and return or throw at once. The main path then runs without nesting.
- When a function picks one of several outcomes, each branch returns its outcome. Do not write
elseorelse ifafter a branch that returns. - When every branch tests one value, use a
switchon it. Give aswitchon a union adefaultthat assigns the value tonever, so a new member fails to compile. - Keep nesting to two levels. Deeper code needs a guard clause or an extracted function.
- Write the positive case:
if (isPosted), notif (!isUnposted). Put a long condition in a named boolean first.
// Wrong: the fee travels through three levels before it returns.
function shippingFeeCents(order: Order): number {
let fee = 0
if (order.items.length > 0) {
if (order.country === "BR") {
if (order.totalCents < FREE_SHIPPING_MINIMUM_CENTS) {
fee = DOMESTIC_FEE_CENTS
}
} else {
fee = INTERNATIONAL_FEE_CENTS
}
}
return fee
}
// Right: each case returns where it is decided.
function shippingFeeCents(order: Order): number {
if (order.items.length === 0) return 0
if (order.country !== "BR") return INTERNATIONAL_FEE_CENTS
if (order.totalCents >= FREE_SHIPPING_MINIMUM_CENTS) return 0
return DOMESTIC_FEE_CENTS
}
One unit, one job
A function, a task, or a module does one job. Two steps of one action are one job: signInAndSaveSession.
These are the signs of two jobs:
- The name hides one of the effects, or joins two unrelated effects with "and".
- One job has a risk or a cost the other does not have, such as an email sent, money charged, or an account changed.
- A parameter serves only one field of the result.
loadAvailityClaimStatusPollingCounts(name, since)returned{ openNow, cappedSince }, and onlycappedSinceusedsince. Split it into one count per question. - A decision and its writes sit in one function.
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.
- 1mo ago Changed · +94 lines · +17 tokens per session 266679097059
- 2mo ago Changed · -6 tokens per session ae27e2dca9cf
- 2mo ago Changed · +56 lines c6329841206f
- 2mo ago First seen · 71 lines · 61 tokens per session scan A 8de0e2a54904
cognitive-refactor is a skill published in the GitHub repository luabagg/agent-skills (3 stars, last pushed 4d ago), licensed MIT. It adds 72 tokens to every session and 2,889 once invoked, about $0.0003 per session on Opus 5.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-09-11.
cognitive-refactor compared with skills from other repositories
| Mod | Type | Stars | Last push | Licence | Scan | Tokens | Works with |
|---|---|---|---|---|---|---|---|
| cognitive-refactorluabagg/agent-skills | Skill | 3 | 4d ago | MIT | A | 72 | Claude Code, Codex |
| mmx.errors-cheatsheetjavimosch/supercli | Skill | 58 | 5d ago | MIT | A | 29 | Claude Code, Codex |
| gardenharness-mini/harness-mini | Skill | 7 | yesterday | MIT | A | 60 | Claude Code, Codex |
| generator-apply-fixesredker56/auto-harness | Skill | 15 | 7mo ago | MIT | A | 36 | Claude Code |
| gke-workload-scaling-troubleshootinggoogle/skills | Skill | 25k | today | Apache-2.0 | A | 170 | Claude Code, Codex |
| gke-ai-troubleshooting-jobset-interruptiongoogle/skills | Skill | 25k | today | Apache-2.0 | A | 83 | Claude Code, Codex |
| bigquery-troubleshootinggoogle/skills | Skill | 25k | today | Apache-2.0 | A | 140 | Claude Code, Codex |