inceptyon-labs/tenet-skills/tenet-complexity
Claude Code and agent skill by inceptyon-labs/tenet-skills
- community
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-complexitySKILL.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:
- Cyclomatic complexity — number of linearly independent paths through a function
- Cognitive complexity — how hard a function is for a human to understand (weighted nesting, recursion, breaks in linear flow)
- Max nesting depth — deepest level of nested control structures within a function
- File length — total lines of code per file
- 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
Toolchain Inputs
This skill consumes pre-computed output from the deterministic toolchain layer:
| File | When Available | What It Provides | |
|---|---|---|---|
.healthcheck/toolchain/eslint.json | JS/TS projects with eslint configured | Per-function cyclomatic complexity via complexity rule | |
.healthcheck/toolchain/radon.json | Python projects with radon installed | Per-function cyclomatic complexity grades (A-F) and raw scores | |
.healthcheck/toolchain/gocyclo.json | Go projects with gocyclo installed | Per-function cyclomatic complexity scores | |
.healthcheck/toolchain/language-census.json | Always | Language 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
| Threshold | Severity | Rationale | |
|---|---|---|---|
| 10-14 | minor | Approaching the maintainability limit; consider refactoring when touching this function | |
| 15-19 | major | Difficult to test exhaustively; should be decomposed this sprint | |
| >= 20 | critical | Untestable; high defect probability; refactor immediately |
Cognitive Complexity per Function
| Threshold | Severity | Rationale | |
|---|---|---|---|
| 15-24 | minor | Harder than necessary to reason about | |
| 25-39 | major | Significant mental overhead; decompose into named helpers | |
| >= 40 | critical | Nearly impossible to hold in working memory |
Max Nesting Depth per Function
| Threshold | Severity | Rationale | |
|---|---|---|---|
| 4 | minor | Consider early returns or guard clauses | |
| 5 | major | Refactor: extract nested logic into helper functions | |
| >= 6 | critical | Deeply nested code is a reliability risk; flatten immediately |
File Length
| Threshold | Severity | Rationale | |
|---|---|---|---|
| 500-999 lines | minor | File is growing large; consider splitting by responsibility | |
| >= 1000 lines | major | File is a maintenance burden; split into focused modules |
Function Length
| Threshold | Severity | Rationale | |
|---|---|---|---|
| 50-99 lines | minor | Function is doing too much; extract sub-steps | |
| >= 100 lines | major | Function 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
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:
functionorname()
Track opening/closing braces (or indentation for Python/Ruby) to determine function boundaries.
3b. Count cyclomatic complexity by counting branching keywords:
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:
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 abovetitle: e.g., "Cyclomatic complexity 23 in processOrder()"description: 2-4 sentences explaining the riskfile: repo-relative pathline: line number of function definitionsnippet: first 500 chars of the function (or the function signature + first few lines)fix_prompt: self-contained prompt following the template inshared/fix_prompt_template.mdconfidence: one ofdeterministic,native,tree_sitter,heuristic
Step 6: Compute Score
Apply the standard scoring formula:
Info findings do NOT affect the score.
Step 7: Compute Dimension Metrics
Collect aggregate metrics for the dimension summary:
Step 8: Write Report
Write the dimension report to .healthcheck/reports/complexity.json:
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
confidencefield 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
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
- SKILL.md in the repositoryCheckingskills/tenet-complexity/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/inceptyon-labs/tenet-skills/tenet-complexity)