selamy-labs/agent-skills/complexity-budgets
Claude Code and agent skill by selamy-labs/agent-skills
- community
Checking that the SKILL.md file is still in the repository.
Use when code review or implementation needs enforceable limits on branching, nesting, cognitive complexity, function size, or parameter count. Compose language-specific complexity analyzers with repo-native lint gates.
Install
npx vskill@latest install selamy-labs/agent-skills/complexity-budgetsSKILL.md
The same SKILL.md was published earlier as selamy-labs/agent-skills/complexity-budgets.
Complexity Budgets
Use this skill when functions are hard to understand because they branch too much, nest too deeply, take too many parameters, or own too many responsibilities.
Workflow
- Run the repository's existing formatter and linter first.
- If a repository is indexed by CodeGraph, use
codegraph-worktree-startup
for navigation and blast radius before selecting files to measure. CodeGraph finds the code; complexity analyzers score it.
- Run the appropriate language analyzer to find hotspots before choosing a
threshold:
```bash # Python complexipy . --top 20 --sort desc complexipy . --max-complexity-allowed 10 --failed --suggest-refactors
# TypeScript / JavaScript, when @genese/complexity is installed complexity src genese cpx src --language ts --console ```
For changed-code checks, prefer the repository's base reference or staged diff when the tool supports it:
``bash complexipy . --diff main complexipy . --staged=true ``
- Add the smallest rule that catches the problem — cyclomatic complexity,
cognitive complexity, max nesting depth, max function length, or max parameter count — not all of them.
- Set the first threshold to the current worst offender, so it stops new
outliers without forcing a cleanup PR. For cyclomatic complexity, a starting threshold of 10 is the conventional default across the linters below; raise it to fit existing debt, then ratchet down.
- Add focused tests around a complex function before reducing its complexity.
- Lower a threshold only after the code is already below the new value.
Tool Bindings
Each tool's cyclomatic-complexity check defaults to a limit near 10 — a sound starting point before ratcheting:
- Python: Ruff with McCabe (
C901) for cyclomatic complexity;complexipyfor
cognitive complexity, diff reports, and refactor suggestions.
- TypeScript and JavaScript: ESLint
complexityandmax-depth; use
typescript-eslint where type information matters. When the complexity CLI from @genese/complexity is available, use it for cognitive and cyclomatic reports over ts, js, tsx, and jsx code.
- TypeScript hotspot scans:
fta-cliis a good fast file-level triage tool
when the repository already uses it, but do not substitute a file-level score for function-level thresholds when a function budget is needed.
- Go: golangci-lint with
gocycloorgocognit. - Java: Checkstyle complexity checks plus SpotBugs for bug patterns.
- Kotlin: detekt complexity rules.
- Shell: ShellCheck plus shfmt; extract shell functions once branches grow.
Review Checks
- The rule runs in CI and blocks only changed or newly violating code when the
repository has existing debt.
- CI should invoke the same language analyzer used during review. Python CI may
use complexipy JSON, GitLab, or SARIF output; TypeScript/JavaScript CI may use complexity/genese cpx reports or ESLint complexity rules, depending on whether the budget is cognitive, cyclomatic, or both.
- Suppressions are rare, local, and include a reason.
- Complexity reduction does not remove behavior coverage.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/complexity-budgets/SKILL.md
Popularity
- 7-day trend score
- 5
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/selamy-labs/agent-skills/complexity-budgets)