complexity

A code scanner that measures how difficult functions are to follow using branching and nesting scores. Cyclomatic complexity counts independent paths, while cognitive complexity reflects how much nesting and mental effort the code requires.

In plain words
What is it for?
Use it to find overly complex functions, inspect their complexity scores, and plan refactoring such as extracting helpers, using early returns, or simplifying branches.
Why use it?
It highlights functions that may be hard to understand, test, or change, and explains which code patterns raise their scores.

Skill for Claude CodeCodex

Install

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.

agentmods
npx agentmods add skills/ysfaskri/archguardian/complexity
Any agent
npx skills add ysfAskri/archguardian --skill complexity
Clone the repo
git clone --depth 1 https://github.com/ysfAskri/archguardian

Made for: Claude Code, Codex.

Per session 11 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 221 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

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.

ModelPer sessionOnce invoked
Fable 5 $0.00011 $0.00221
Opus 5 $0.00005 $0.00111
Sonnet 5 $0.00002 $0.00044
Haiku 4.5 $0.00001 $0.00022

Measured 2d ago against content hash 23bb2e50ba3e, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

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.

.claude/skills/complexity/SKILL.md · 30 lines

What it actually says

archguardian complexity

Analyze function complexity metrics using archguardian.

Instructions

  1. Run the scan with complexity enabled:
    npx archguardian scan --format json $ARGUMENTS
    
    Ensure .archguard.yml has analyzers.complexity.enabled: true.
  2. Parse JSON output, filter for complexity/* rules.
  3. For each finding, explain:
    • The function name and its cyclomatic/cognitive score
    • What makes the function complex (nested conditionals, loops, logical operators)
    • How to refactor: extract helper functions, use early returns, simplify branching

Tips

  • Default thresholds: cyclomatic 15, cognitive 20. Configure in .archguard.yml.
  • Suggest breaking complex functions into smaller, focused functions.
  • Cognitive complexity weighs nesting depth, so deeply nested code scores higher.
Changes

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.

  1. 2d ago First seen · 30 lines · 11 tokens per session scan A 23bb2e50ba3e

Subscribe to this mod's changes

complexity is a skill published in the GitHub repository ysfAskri/archguardian (4 stars, last pushed 6mo ago), licensed MIT. It adds 11 tokens to every session and 221 once invoked, about $0.0001 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.