dancing-bear: Skill for Claude Code

.claude/skills/optimize-code-complexity/SKILL.md

optimize-code-complexity is a skill for Claude Code from dancing-bear-show/dancing-bear. It costs 43 tokens per session (855 once invoked), scanned A, original, MIT.

A code-refactoring workflow that finds functions with too many branches or decisions and helps simplify them. Refactoring means changing code structure without changing its intended behavior.

In plain words
What is it for?
Use it after implementing complicated logic, when a function has a high complexity score, or when code needs to be easier to understand. It can apply patterns such as early returns, helper extraction, and dispatch tables.
Why use it?
Complex functions are harder to read, test, and modify safely. This helps reduce deeply nested logic and makes the main paths easier to follow.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter.

This is dancing-bear-show/dancing-bear's own configuration. It tells Claude Code how to work on dancing-bear itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything dancing-bear configures →

Reuse

Borrowing it

Nothing to install: this file belongs to dancing-bear-show/dancing-bear. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/dancing-bear-show/dancing-bear/main/.claude/skills/optimize-code-complexity/SKILL.md
Clone the repo
git clone --depth 1 https://github.com/dancing-bear-show/dancing-bear

Made for: Claude Code.

Wrote 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.

agentmods badge for optimize-code-complexity

README.md
[![agentmods](https://agentmods.dev/badge/skills/dancing-bear-show/dancing-bear/optimize-code-complexity/github.svg)](https://agentmods.dev/skills/dancing-bear-show/dancing-bear/optimize-code-complexity)
Your own site
<a href="https://agentmods.dev/skills/dancing-bear-show/dancing-bear/optimize-code-complexity"><img src="https://agentmods.dev/badge/skills/dancing-bear-show/dancing-bear/optimize-code-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.

agentmods 80×15 button for optimize-code-complexity

Your own site · 80×15
<a href="https://agentmods.dev/skills/dancing-bear-show/dancing-bear/optimize-code-complexity"><img src="https://agentmods.dev/badge/skills/dancing-bear-show/dancing-bear/optimize-code-complexity.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 43 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 855 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00043 $0.00855
Opus 5.5 $0.00017 $0.00342
Sonnet 5.5 $0.00009 $0.00171
Haiku 4.5 $0.00004 $0.00085

Measured yesterday against content hash 4ae38063da50, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

optimize-code-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 yesterday.

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/optimize-code-complexity/SKILL.md · 64 lines

How it starts

The opening of the file, as written. The whole thing — 64 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Optimize Code — Complexity Pass

Delegates to workflows/code/optimize-code.yaml with skip_checks=reuse,coverage,security,arch, running only the complexity scan dimension. Findings are applied and rechecked automatically.

When to Use

  • After implementing complex logic
  • When functions exceed complexity grade C (complexity > 10)
  • Pre-PR simplification check
  • User says "simplify", "reduce complexity", or "improve readability"

How to Run

Bootstrap source_root, test_path and domain_slug from context:

  • source_root: the src/<domain>/ directory of the files you just wrote or changed
  • test_path: the corresponding tests/<domain>_tests/ directory
  • domain_slug: source_root with / replaced by - (e.g. src-mail); keeps each domain's workspace separate
  • pr_number: optional — if you have an open PR, pass it to scope file detection to that PR's diff

IMPORTANT: Use the /workflow skill — do NOT call ./bin/workflow run --execute directly. It only writes dispatch files and exits (status=pending). The /workflow skill is what actually spawns agents, waits for results, and handles human gates.

Skill(skill="workflow", args="--workflow workflows/code/optimize-code.yaml --params source_root=src/<domain>/ --params test_path=tests/<domain>_tests/ --params domain_slug=src-<domain> --params skip_checks=reuse,coverage,security,arch")

With a PR number:

Skill(skill="workflow", args="--workflow workflows/code/optimize-code.yaml --params pr_number=314 --params source_root=src/<domain>/ --params test_path=tests/<domain>_tests/ --params domain_slug=src-<domain> --params skip_checks=reuse,coverage,security,arch")

What Runs

Focuses on the complexity scan dimension — other dimensions can be added via skip_checks. The workflow runs the full correction and recheck cycle:

  1. pre-check-auth — verify GitHub and qlty connections
  2. scan-changed-files — identify .py files changed vs main (or PR diff)
  3. mps-scan-complexity — cognitive complexity audit (target < 15), print-vs-logging check
  4. mps-collate-findings — collate complexity findings into unified report
  5. apply-corrections — fix all critical + auto-fixable minor complexity findings
  6. recheck-lint — bin/ruff-resolve.sh check + tests to confirm fixes
  7. human-gate — present complexity summary, ask to commit/open PR

Read the full file on GitHub · 64 lines

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. yesterday First seen · 64 lines · 43 tokens per session scan A 4ae38063da50

Subscribe to this mod's changes

optimize-code-complexity is a skill published in the GitHub repository dancing-bear-show/dancing-bear (7 stars, last pushed yesterday), licensed MIT. It adds 43 tokens to every session and 855 once invoked, about $0.0002 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-11-07.

Related

optimize-code-complexity compared with skills from other repositories

optimize-code-complexity next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
optimize-code-complexitydancing-bear-show/dancing-bearSkill7yesterdayMITA43Claude Code
gogolafkfreund/nixos_configSkill32yesterdayGPL-3.0A125Claude Code, Codex
google-workspace-authbobmatnyc/claude-mpmSkill1582mo agononeA22Claude Code
find-simplificationsQwenLM/qwen-codeSkill29ktodayApache-2.0C103Claude Code, Codex
swarm-pr-reviewZaxbyHub/opencode-swarmSkill518todayMITA91Claude Code
code-reviewjrswab/axeSkill90917d agoApache-2.0A0Claude Code, Codex
agent-debug-ciNVIDIA/elementsSkill115yesterdayApache-2.0A80Claude Code, Codex