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 gspencergoog/skills --skill cognitive-complexitygit clone --depth 1 https://github.com/gspencergoog/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/gspencergoog/skills/cognitive-complexity)<a href="https://agentmods.dev/skills/gspencergoog/skills/cognitive-complexity"><img src="https://agentmods.dev/badge/skills/gspencergoog/skills/cognitive-complexity/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/gspencergoog/skills/cognitive-complexity"><img src="https://agentmods.dev/badge/skills/gspencergoog/skills/cognitive-complexity.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.00106 | $0.01484 |
| Opus 5.5 | $0.00042 | $0.00594 |
| Sonnet 5.5 | $0.00021 | $0.00297 |
| Haiku 4.5 | $0.00011 | $0.00148 |
Grade A, and why
cognitive-complexity 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 — 132 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Cognitive Complexity Skill
This skill provides instructions and standalone CLI tools to calculate and audit the Cognitive Complexity of source code across Python, TypeScript/JavaScript, Dart, Swift, Kotlin, and C/C++ according to the official SonarSource standard.
1. Overview
While Cyclomatic Complexity measures the number of linearly independent paths required to test code, Cognitive Complexity measures how difficult the code is for a human developer to understand and maintain.
The metric evaluates code based on three core rules:
- Increments: Adds +1 for control flow breaks (
if, ternary? :,switch/when/match,for,while,catch, recursion, boolean sequence changes). - Nesting Penalties: Adds
+1 + nesting_levelwhen control flow structures are nested inside others. - Idiom Shorthands: No penalty for
else if/elif, method chaining, or safe navigation (?.).
For a detailed theoretical explanation of the rules, see SonarSource Rules Reference and Language AST Mapping Reference.
2. Thresholds & Score Interpretation
| Complexity Score | Classification | Risk Level | Recommended Action |
|---|---|---|---|
| 0 – 5 | Simple | Low | Ideal maintainability. No changes needed. |
| 6 – 10 | Moderate | Low | Normal function logic. Keep clear comments. |
| 11 – 15 | Elevated | Medium | Approaching threshold. Look for simplification opportunities. |
| 16 – 24 | High | High | Exceeds standard threshold (15). Refactor via Extract Method or Guard Clauses. |
| 25+ | Critical Hotspot | Extreme | High risk of bugs during maintenance. Immediate refactoring required. |
What ships with it
44 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.
- references/cli_reference.md 5.2 KB
- references/language_rules.md 16 KB
- references/sonar_rules.md 4.2 KB
- scripts/cognitive_complexity.py 18 KB runs code
- scripts/cpp/cognitive_complexity.py 31 KB runs code
- scripts/cpp/test_cognitive_complexity.py 11 KB runs code
- scripts/dart/bin/cognitive_complexity.dart 7.4 KB
- scripts/dart/lib/cognitive_complexity.dart 84 B
- scripts/dart/lib/src/models.dart 2.5 KB
- scripts/dart/lib/src/visitor.dart 11 KB
- scripts/dart/pubspec.lock 11 KB
- scripts/dart/pubspec.yaml 283 B
- scripts/dart/test/visitor_test.dart 5.8 KB
- scripts/kotlin/build.gradle.kts 955 B
- scripts/kotlin/cognitive-complexity-kt.jar 2078 KB
- scripts/kotlin/gradle.properties 167 B
- scripts/kotlin/gradle/wrapper/gradle-wrapper.jar 46 KB
- scripts/kotlin/gradle/wrapper/gradle-wrapper.properties 251 B
- scripts/kotlin/gradlew 2.2 KB
- scripts/kotlin/settings.gradle.kts 45 B
- scripts/kotlin/src/main/kotlin/com/complexity/CognitiveComplexityVisitor.kt 7.5 KB
- scripts/kotlin/src/main/kotlin/com/complexity/Main.kt 6.8 KB
- scripts/kotlin/src/main/kotlin/com/complexity/Models.kt 1.5 KB
- scripts/kotlin/src/test/kotlin/com/complexity/CognitiveComplexityTest.kt 6.6 KB
- scripts/python/cognitive_complexity.py 20 KB runs code
- scripts/python/test_cognitive_complexity.py 12 KB runs code
- scripts/swift/CognitiveComplexity 1.0 KB
- scripts/swift/CognitiveComplexity-darwin 6023 KB
- scripts/swift/CognitiveComplexity-linux 8090 KB
- scripts/swift/Package.resolved 393 B
- scripts/swift/Package.swift 1000 B
- scripts/swift/Sources/CognitiveComplexity/ComplexityVisitor.swift 13 KB
- scripts/swift/Sources/CognitiveComplexity/main.swift 9.2 KB
- scripts/swift/Sources/CognitiveComplexity/Models.swift 3.5 KB
- scripts/swift/Tests/CognitiveComplexityTests/ComplexityTests.swift 8.5 KB
- scripts/test_orchestrator.py 8.4 KB runs code
- scripts/typescript/dist/cli.js 9725 KB runs code
- scripts/typescript/package.json 533 B
- scripts/typescript/src/cli.ts 8.3 KB runs code
- scripts/typescript/src/types.ts 924 B runs code
- scripts/typescript/src/visitor.ts 8.9 KB runs code
- scripts/typescript/test/visitor.test.ts 6.5 KB runs code
- scripts/typescript/tsconfig.json 318 B
- scripts/typescript/yarn.lock 9.5 KB
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 Changed · +1 lines 0dae5a47932d
- 10d ago Changed · +2 lines · -5 tokens per session b345ad45c280
- 20d ago Changed · +3 lines · +3 tokens per session 43d63f180b56
- 1mo ago Changed · +8 lines 3c5ae754df54
- 1mo ago First seen · 118 lines · 108 tokens per session scan A f204aa436af3
cognitive-complexity is a skill published in the GitHub repository gspencergoog/skills (2 stars, last pushed today), licensed Apache-2.0. It adds 106 tokens to every session and 1,484 once invoked, about $0.0004 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-04.
Other skills, from other repositories
local-ai-agents
Build local-first AI agents that run entirely on a developer workstation with Microsoft Foundry Local and Qwen function-calling models. Covers Small Language Models (SLMs), the OpenAI-compatible local endpoint, sandboxed local tools, local RAG with Chroma, local MCP servers, hybrid cloud/local routing, and the…
systematic-debugging
Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes.
next-cache-components-adoption
Turn on Cache Components in a Next.js app and resolve the blocking routes it surfaces. Use when the user wants to enable, adopt, or migrate to Cache Components, flip the cacheComponents flag, work through a flood of blocking-prerender / instant validation errors, run the cache-components-instant-false codemod, or…
chat-pet-sprite-creation
Use when creating or changing VS Code chat pet sprite art, sprite sheets, state animations, eye treatments, Stable/Insiders variants, or pet transitions under src/vs/workbench/contrib/chat/browser/widget/media/chatPet.
cpu-profile-analysis
Analyze V8/Chrome CPU profiles (.cpuprofile) and DevTools trace files (Trace-.json). Use when: profiling performance, investigating slow functions, comparing code paths, finding bottlenecks, analyzing timeToRequest, understanding call trees from sampling profiler data, analyzing layout/paint/rendering, investigating…
insight-error-page
Write or audit an insight-kind error page for the Next.js dev overlay. Use when creating a new errors/ .mdx page, auditing an existing one, or checking that a page matches the framework fix cards. Covers page structure, title alignment, FixCard cards with Copy prompt button, code snippets, terminology verification…