Skip to content
Back to skills

Pinned Debt

BSecurity

Measure technical debt and cognitive load in any JS/TS or Python git repo with a pinned tool set (ESLint 9 + sonarjs cognitive complexity, complexipy, jscpd, git history) running inside a bubblewrap sandbox with no network and the repo mounted read-only. Reports cognitive complexity per function, duplication, oversized files, change amplification and churn x complexity hotspots, per repo plus a cross-repo summary. Use when asked to "analyse tech debt", "measure cognitive load", "find hotspots...

  • 6 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added November 15, 2026
code-qualitypythongobashnodegit

Security analysis

B84/100
  • mediumInstalls packages at runtime which could introduce malicious dependencies
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro scans all 5 files and shows the line behind each finding

Scanned November 15, 2026

npx -y skills add gbencke/dotfiles --skill pinned-debt --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Pinned Debt?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Pinned Debt
[![Security: B — Skills Directory](https://www.skillsdirectory.com/api/skills/gbencke-pinned-debt/badge)](https://www.skillsdirectory.com/skills/gbencke-pinned-debt)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: pinned-debt
description: Measure technical debt and cognitive load in any JS/TS or Python git repo with a pinned tool set (ESLint 9 + sonarjs cognitive complexity, complexipy, jscpd, git history) running inside a bubblewrap sandbox with no network and the repo mounted read-only. Reports cognitive complexity per function, duplication, oversized files, change amplification and churn x complexity hotspots, per repo plus a cross-repo summary. Use when asked to "analyse tech debt", "measure cognitive load", "find hotspots", "debt analysis", "how hard is this code to understand", "compare repos for debt", "review AI-generated code for complexity", or invokes /pinned-debt.
---

# Pinned debt analysis (bubblewrap)

`pinned-debt` in this skill's directory (call it by its absolute path, written `<skill-dir>/pinned-debt` below) installs pinned tools into `~/.cache/pinned-debt/<hash>` and runs the analysis under `bwrap`: network off, filesystem read-only, every repo read-only, only the report dir writable.

## macOS: Linux VM with shared folders

The runner uses the same `pinned-skills` Lima VM as `pinned-eslint`. Follow the one-time setup in `../pinned-eslint/SKILL.md`; its `lima.yaml` installs the prerequisites for both skills.

Run the normal commands below from macOS. Repos stay on the Mac disk and are shared at the same absolute paths, including the real target of a `~/git` symlink. No clone or sync is needed. The runner starts the existing VM, normalizes repo and output paths, and forwards `--since`, `--print-store`, `PINNED_DEBT_PLUGINS`, and `PINNED_DEBT_PY`.

Bubblewrap keeps every repo read-only and disables network access during analysis. Tool caches stay in Linux; reports under Mac `/tmp` use shared `/private/tmp` and can be opened on the Mac. Unlike pinned-eslint's editor cache, `--print-store` returns a **Linux-only** cache path.

Mount other repo roots and output directories explicitly before using them. Stop the VM with `limactl stop pinned-skills` to release RAM. Do not bypass the sandbox if VM setup fails.

## Run

```bash
<skill-dir>/pinned-debt <repo>                                 # one repo, report in /tmp/pinned-debt-<date>/
<skill-dir>/pinned-debt <repo> <repo> ...                      # many repos plus a cross-repo summary.md
<skill-dir>/pinned-debt <repo> --out /tmp/debt                 # choose the report dir
<skill-dir>/pinned-debt <repo> --since '6 months ago'          # history window (git date, default 12 months)
<skill-dir>/pinned-debt --print-store                          # install if needed, print the pinned install dir, exit
```

- Each `<repo>` must be a git work tree.
- The first run per tool set runs `npm install` and `pip install` (network, ~1 min). Later runs use the cache.
- Override versions with `PINNED_DEBT_PLUGINS='pkg@ver ...'` (npm) or `PINNED_DEBT_PY='pkg==ver ...'` (pip). Each override creates a new cache entry.

Run it in the background with a timeout. Large repos take minutes:

```bash
nohup <skill-dir>/pinned-debt <repos...> --out /tmp/debt > /tmp/debt.log 2>&1 &
timeout 900 tail -f /tmp/debt.log
```

## What it measures

Production code only: `git ls-files` filtered to `.ts .tsx .js .jsx .mjs .cjs .mts .cts .py`. Tests (`__tests__/`, `test(s)/`, `cypress/`, `e2e/`, `mocks/`, `*.test.*`, `*.spec.*`, `*.stories.*`, `test_*.py`, `conftest.py`) and generated output (`dist/`, `build/`, `coverage/`, `cdk.out/`, `node_modules/`, `*.d.ts`, `*.min.js`, and any file whose first 400 bytes say "automatically generated", "auto-generated", "@generated", "Code generated by" or "do not edit") are excluded and counted separately. Test LOC is reported separately.

| Signal | Tool | Threshold | Why it matters |
|---|---|---|---|
| Cognitive complexity per function | `sonarjs/cognitive-complexity` (JS/TS), `complexipy` (Python) | 15 (Sonar default) | Nesting and breaks in linear flow: what a reader must hold in mind |
| Cognitive complexity per 100 LOC | derived | compare repos | Density, independent of repo size |
| File size | non-blank lines | 300 | Long files hide many concepts |
| Duplication | `jscpd`, 50 tokens min | ~3% (Sonar gate) | Copy-paste means one change must be made in many places |
| Change amplification | `git log --no-merges` | 10+ code files per commit | Wide commits mean no module owns the decision |
| Hotspots | commits x file cognitive complexity | top 15 | Complex code that changes often costs the most |
| Suppressions | `eslint-disable`, `@ts-ignore`, `@ts-expect-error`, `@ts-nocheck`, `# noqa`, `# type: ignore`, `pylint: disable` | compare repos | Silenced checks hide the debt the other metrics would show |

## Output

In `--out`:

- `summary.md`: one row per repo, sorted by cognitive complexity per 100 LOC, worst first. Failed repos are listed at the end.
- `<repo>.md`: summary table, hotspots, the 15 most complex functions, largest files, largest clones.
- `<repo>.json`: the same data for scripts.

Exit code 1 means at least one repo failed; the other reports are still written.

## Then read the code

The numbers find where to look. They do not judge design. For each repo, open the top 3 hotspots and the worst function, then write a short verdict:

1. **Concept count.** How many names, types and layers must a reader hold to follow one feature?
2. **Shallow modules** (Ousterhout). Wrappers, single-implementation interfaces and pass-through layers that add a concept and hide nothing.
3. **Two-minute test.** Can you say what the file does and why it is shaped this way in two minutes? If not, say what blocks you.
4. **AI-generation smells.** Repeated near-identical blocks, defensive checks for impossible states, unused options, comments that restate code.
5. **Capped functions, huge files.** When a repo lints cognitive complexity at 15, "Max fn" sits at 15 and the load moves into files: dozens of small callbacks sharing state through refs or class fields. Judge those by the file's total cognitive score in the hotspot table, not by the per-function maximum.

Finish with a ranked list of fixes: split which function, merge which clones, delete which layer. Point to `file:line`.

## Caveats

- The repo is never written. Any tool that tries to write into it fails, by design.
- Squash-merge history makes one commit equal one PR. Merge-commit history counts each commit. Compare change amplification only between repos with the same style.
- ESLint runs without type information, so it is fast and needs no `node_modules`. Files it cannot parse are counted as "Files ESLint could not parse"; report a high count.
- jscpd compares production files only. Duplicates inside tests are not counted.
- Not measured: dead code, coupling (fan-in, fan-out). Use `knip` or `madge` by hand if needed.
- Errors such as `install bubblewrap` are fatal. Report them as-is.

Files in this skill

  • README.md1.3 KB
  • SKILL.md6.7 KB
  • debt_analysis.py14.3 KB
  • eslint.debt.config.mjs630 B
  • pinned-debt3.3 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in code-quality →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.