inceptyon-labs/tenet-skills/tenet-complexity

Claude Code and agent skill by inceptyon-labs/tenet-skills

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Measures function/file complexity, nesting, length, and maintainability thresholds.

Install

npx vskill@latest install inceptyon-labs/tenet-skills/tenet-complexity

SKILL.md

The same SKILL.md was published earlier as inceptyon-labs/tenet-skills/tenet-complexity.

Tenet Complexity — Code Complexity Audit

Measures structural complexity across all code in the repository. Functions that are too complex, too deeply nested, or too long are flagged with severity proportional to the violation.

Purpose

This skill evaluates the structural complexity of the codebase by measuring five metrics per function and per file:

  1. Cyclomatic complexity — number of linearly independent paths through a function
  2. Cognitive complexity — how hard a function is for a human to understand (weighted nesting, recursion, breaks in linear flow)
  3. Max nesting depth — deepest level of nested control structures within a function
  4. File length — total lines of code per file
  5. Function length — total lines per function or method

High complexity correlates with bugs, difficulty onboarding new developers, and resistance to safe refactoring. This dimension provides the quantitative foundation for technical debt decisions.

Calibration — read first

Follow shared/scan-discipline.md (complete every step, enumerate rather than sample, and §2a: report only issues that actually exist), shared/verification.md (every finding is confirmed against the code before it ships; unconfirmed candidates are dropped, not demoted), and shared/severity.md (severity is confirmed impact, never a hedge for doubt).

A finding must exist in this codebase on a path that can run. Do not report hypotheticals, dead code, style preferences, or anything an upstream check already prevents. Zero findings for a step is the normal result on healthy code; do not fill a step to show you looked. Do not overthink it: read the code and its context, decide, move on.

Language Support Matrix

yaml
support:
native: [typescript, javascript, python]
tree_sitter: [go, rust, java, kotlin, swift, c, cpp]
heuristic: [ruby, php, shell, lua, elixir, scala, dart, all others]
note: >
Native support uses toolchain output (eslint, radon, gocyclo) for
deterministic metrics. Tree-sitter support parses AST for accurate
function boundary detection. Heuristic support counts branching
keywords and uses indentation to estimate nesting depth.

Toolchain Inputs

This skill consumes pre-computed output from the deterministic toolchain layer:

FileWhen AvailableWhat It Provides
.healthcheck/toolchain/eslint.jsonJS/TS projects with eslint configuredPer-function cyclomatic complexity via complexity rule
.healthcheck/toolchain/radon.jsonPython projects with radon installedPer-function cyclomatic complexity grades (A-F) and raw scores
.healthcheck/toolchain/gocyclo.jsonGo projects with gocyclo installedPer-function cyclomatic complexity scores
.healthcheck/toolchain/language-census.jsonAlwaysLanguage breakdown for routing analysis strategy

If a toolchain file is missing for a given language, the skill falls back to heuristic analysis for that language.

Rubric

Cyclomatic Complexity per Function
ThresholdSeverityRationale
10-14minorApproaching the maintainability limit; consider refactoring when touching this function
15-19majorDifficult to test exhaustively; should be decomposed this sprint
>= 20criticalUntestable; high defect probability; refactor immediately
Cognitive Complexity per Function
ThresholdSeverityRationale
15-24minorHarder than necessary to reason about
25-39majorSignificant mental overhead; decompose into named helpers
>= 40criticalNearly impossible to hold in working memory
Max Nesting Depth per Function
ThresholdSeverityRationale
4minorConsider early returns or guard clauses
5majorRefactor: extract nested logic into helper functions
>= 6criticalDeeply nested code is a reliability risk; flatten immediately
File Length
ThresholdSeverityRationale
500-999 linesminorFile is growing large; consider splitting by responsibility
>= 1000 linesmajorFile is a maintenance burden; split into focused modules
Function Length
ThresholdSeverityRationale
50-99 linesminorFunction is doing too much; extract sub-steps
>= 100 linesmajorFunction is a mini-program; decompose into composable units
Info-Level Observations

The following do NOT affect the score but are reported as info:

  • Functions with complexity 8-9 (approaching threshold)
  • Files with 400-499 lines (approaching threshold)
  • Functions with 40-49 lines (approaching threshold)
  • Opportunities to replace complex conditionals with lookup tables or polymorphism

Procedure

Step 1: Read Toolchain Data and Language Census
Read .healthcheck/toolchain/language-census.json
Read .healthcheck/toolchain/eslint.json (if exists)
Read .healthcheck/toolchain/radon.json (if exists)
Read .healthcheck/toolchain/gocyclo.json (if exists)

Determine which languages are present and which toolchain outputs are available.

Step 2: Consume Toolchain Metrics (Deterministic Path)

For each available toolchain file, extract per-function complexity data:

eslint.json (JS/TS):

  • Look for findings with rule complexity — the message contains the cyclomatic complexity value
  • Look for findings with rule max-depth — nesting depth violations
  • Look for findings with rule max-lines-per-function — function length violations
  • Confidence: deterministic

radon.json (Python):

  • Each entry contains complexity (integer), name (function/method), lineno, col_offset, type (function/method/class)
  • Map radon grades: A(1-5), B(6-10), C(11-15), D(16-20), E(21-25), F(26+)
  • Confidence: deterministic

gocyclo.json (Go):

  • Each entry contains Complexity (integer), Function, File, Line
  • Confidence: deterministic
Step 3: Heuristic Analysis (Fallback Path)

For languages without toolchain output, perform heuristic complexity analysis:

3a. Identify functions and their boundaries:

Use language-appropriate patterns to find function definitions:

  • JS/TS: function, =>, method definitions in classes
  • Python: def
  • Go: func
  • Rust: fn
  • Java/Kotlin: method declarations within class bodies
  • Ruby: def/end
  • PHP: function
  • Shell: function or name()

Track opening/closing braces (or indentation for Python/Ruby) to determine function boundaries.

3b. Count cyclomatic complexity by counting branching keywords:

Branching keywords per language:
JS/TS/Java/Go/Rust/C/C++:
if, else if, else, case, for, while, do, catch, &&, ||, ?:, ??
Python:
if, elif, else, for, while, except, and, or, assert, with
Ruby:
if, elsif, else, unless, case, when, for, while, until, rescue, &&, ||
Shell:
if, elif, else, case, for, while, until, ||, &&

Formula: cyclomatic = 1 + count(branching_keywords_within_function_body)

Confidence: heuristic

3c. Measure nesting depth:

Track indentation levels or brace depth within each function. Record the maximum depth reached.

3d. Measure function and file length:

Count lines between function boundaries (excluding blank lines and comment-only lines for function length). Count total file lines for file length.

Step 4: Compute Cognitive Complexity

Cognitive complexity adds weight for nested control flow:

For each control structure (if/for/while/switch/try):
+1 base
+1 per nesting level it appears at
For each break in linear flow:
+1 for else, elif, catch, finally
+1 for each boolean operator sequence (a && b || c = +2)
For each recursion:
+1 per recursive call detected

This is computed for all languages regardless of toolchain availability, since no standard tool emits cognitive complexity for most languages.

Step 5: Classify Findings

For each function and file, apply the rubric thresholds and emit findings.

Each finding MUST include:

  • dimension: "complexity"
  • severity: per rubric above
  • title: e.g., "Cyclomatic complexity 23 in processOrder()"
  • description: 2-4 sentences explaining the risk
  • file: repo-relative path
  • line: line number of function definition
  • snippet: first 500 chars of the function (or the function signature + first few lines)
  • fix_prompt: self-contained prompt following the template in shared/fix_prompt_template.md
  • confidence: one of deterministic, native, tree_sitter, heuristic
Step 6: Compute Score

Apply the standard scoring formula:

score = 100 - (5 × critical_count + 2 × major_count + 0.5 × minor_count)
score = max(0, min(100, int(score + 0.5))) # Arithmetic rounding, not banker's rounding

Info findings do NOT affect the score.

Step 7: Compute Dimension Metrics

Collect aggregate metrics for the dimension summary:

json
{
"total_functions_analyzed": 342,
"functions_exceeding_cyclomatic_10": 18,
"functions_exceeding_cyclomatic_15": 5,
"functions_exceeding_cyclomatic_20": 1,
"avg_cyclomatic_complexity": 4.2,
"max_cyclomatic_complexity": 23,
"max_cyclomatic_function": "processOrder",
"max_cyclomatic_file": "src/orders/processor.ts",
"avg_cognitive_complexity": 6.8,
"max_cognitive_complexity": 47,
"max_nesting_depth": 7,
"files_over_500_lines": 3,
"files_over_1000_lines": 1,
"functions_over_50_lines": 12,
"functions_over_100_lines": 2,
"confidence_breakdown": {
"deterministic": 280,
"heuristic": 62
}
}
Step 8: Write Report

Write the dimension report to .healthcheck/reports/complexity.json:

json
{
"key": "complexity",
"score": 72,
"weight": 1.1,
"skill_version": "1.0.0",
"applicable": true,
"notes": "Analyzed 342 functions across 47 files. 1 critical finding (processOrder has cyclomatic complexity 23), 5 major findings. Hotspot: src/orders/processor.ts.",
"metrics": { ... },
"findings": [ ... ]
}

Output

  • .healthcheck/reports/complexity.json — the dimension report with all findings, score, and metrics

Constraints

  • Toolchain-first: ALWAYS prefer toolchain data over heuristic analysis. Only fall back to heuristics when no toolchain output exists for a language.
  • No double-counting: If eslint reports cyclomatic complexity for a function AND the heuristic also finds it, use only the deterministic result.
  • Confidence tagging: Every finding MUST include a confidence field reflecting how it was detected.
  • Scoring math is pure: The score formula is arithmetic only — no LLM judgment in the number.
  • Respect .gitignore: Only analyze files tracked by git (git ls-files).
  • Exclude generated code: Skip files matching common generated patterns: *.generated.*, *.min.js, *.bundle.js, dist/, build/, vendor/, node_modules/, __pycache__/.
  • Exclude test files from file-length checks: Test files (*.test.*, *.spec.*, *_test.*, test_*.*) are still checked for function complexity but are exempt from file-length findings (test files are naturally longer).
  • Max findings cap: Emit at most 50 findings. If more exist, keep all critical, then major, then minor, then info, sorted by severity descending then complexity value descending. Add an info finding noting how many were omitted.

fix_prompt Examples

Example 1: High Cyclomatic Complexity
# Fix: Reduce cyclomatic complexity in processOrder()
## Context
The function `processOrder` in `src/orders/processor.ts` has cyclomatic complexity 23 (critical threshold is 20). It contains deeply interleaved conditionals for order validation, payment processing, inventory checks, and notification dispatch.
## Location
- File: src/orders/processor.ts
- Line: 45
- Dimension: complexity / critical

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 95 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

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
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/inceptyon-labs/tenet-skills/tenet-complexity/badge)](https://verified-skill.com/skills/inceptyon-labs/tenet-skills/tenet-complexity)

Something wrong with this skill or its page? Tell us.