befund-complexity-score
Computes a relative complexity/attention-priority index per stage using the fixed formula 2.94 x (KSLOC)^1.10, and lists unmeasured stages plainly rather than inventing numbers. Use when the user asks "which module needs attention first", "score complexity per stage", "what's our tech debt hotspot", or as part of befund-autopilot's CHECK phase.
- License 许可
- MIT
- 最近更新
- 2026-11-02
- Stars
- ★ 1
- Forks
- 0
01 前言 Front Matter
- name
- befund-complexity-score
- description
- Computes a relative complexity/attention-priority index per stage using the fixed formula 2.94 x (KSLOC)^1.10, and lists unmeasured stages plainly rather than inventing numbers. Use when the user asks "which module needs attention first", "score complexity per stage", "what's our tech debt hotspot", or as part of befund-autopilot's CHECK phase.
03 SKILL.md 正文
befund-complexity-score
Compute a relative complexity/attention-priority index per stage or module.
Step 0: Settings gate
python3 -B "${CLAUDE_PLUGIN_ROOT}/scripts/befund_cli.py" check-enabled --repo <repo_root> --skill befund-complexity-score
This skill has no Verify phase -- do not gate anything here on skip_verification; that
setting simply does not apply to a pure measurement.
Step 1: Determine the stage list
Prefer <output_dir>/stage_map.json if it exists (reuse befund-stage-map's stages).
Otherwise fall back to the detected-languages list from detect-languages, treating each
language's file set as one pseudo-stage.
Step 2: Measure each stage
Dispatch complexity-surveyor per stage to measure SLOC, file count, and cyclomatic complexity
(via whatever tool is available for that language -- radon, lizard, gocyclo, etc.). If no
tool is available for a stage's language, the surveyor reports -1/0 per its own refusal
list rather than fabricating a plausible-looking number -- when that happens, mark the stage
unmeasured: true in the output and list it plainly in COMPLEXITY_SCORE.md instead of
computing an index for it.
Step 3: Apply the exact formula -- no substitutes
Rule complexity-score-formula: the index MUST be 2.94 x (KSLOC)^1.10 and nothing else.
python3 -B "${CLAUDE_PLUGIN_ROOT}/scripts/befund_cli.py" complexity-index --ksloc <stage_sloc / 1000>
Use this for every measured stage rather than restating the constants inline -- the formula
lives in one place (scripts/lib/formulas.py) so no per-skill copy can drift from it.
Step 4: Validate and write
python3 -B "${CLAUDE_PLUGIN_ROOT}/scripts/befund_cli.py" validate-artifact --kind complexity_score_summary --file <path-or-inline-json>
The validator recomputes 2.94 x (KSLOC)^1.10 for every non-unmeasured stage and rejects the
artifact if the persisted complexity_index does not match to within floating-point tolerance
-- a hand-typed or LLM-guessed number cannot pass.
A complexity_score_summary.json stage entry looks like this -- one measured, one not:
{
"stages": [
{"stage": "api", "sloc": 4200, "complexity_index": 187.3, "unmeasured": false},
{"stage": "legacy-perl", "sloc": 0, "complexity_index": null, "unmeasured": true}
]
}
python3 -B "${CLAUDE_PLUGIN_ROOT}/scripts/befund_cli.py" resolve-output-path --repo <repo_root> --filename COMPLEXITY_SCORE.md
python3 -B "${CLAUDE_PLUGIN_ROOT}/scripts/befund_cli.py" resolve-output-path --repo <repo_root> --filename complexity_score_summary.json
Read-only constraint
Never use Write/Edit outside the resolved output paths.
04 同仓库更多 Skills
toy-check
A skill that checks things in the repository and reports what it finds.
demo-check
Reports which generated files changed since the last generation run. Use when the user asks what drifted. Read-only; never edits a file.
demo-check
Reports which generated files changed since the last generation run. Use when the user asks what drifted. Read-only; never edits a file.
demo-check
Reports which generated files changed since the last generation run. Use when the user asks what drifted. Read-only; never edits a file.
demo-check
Reports which generated files changed since the last generation run. Use when the user asks what drifted. Read-only; never edits a file.
zirkel-verify-assumptions
Checks exactly ONE named assumption against real evidence in at most 3 steps and reports one outcome: confidence raised (>=90), reading changed, or still unresolved. Use to resolve a single load-bearing uncertainty — typically a blocking entry surfaced by zirkel-clarify-scope: "verify this one assumption", "is it actually true that X", "check this before we rely on it". For multiple uncertainties, invoke once per uncertainty — the step budget is never shared.