/claude-crap:analyzefrom claude-crap
Analyzes source file complexity using tree-sitter AST, reporting per-function cyclomatic complexity and LOC metrics. Supports TypeScript, JavaScript, Python, Java, and C#.
Ships in claude-crap. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Run the analyze_file_ast MCP tool from the claude-crap server against a user-supplied file and report deterministic AST metrics.
The user supplies a file path as the argument, typed after the skill name:
/claude-crap:analyze src/index.ts
/claude-crap:analyze app/main.py
/claude-crap:analyze lib/foo.cs
Parse the file path. Take $ARGUMENTS as the path. Reject it with a friendly one-liner if it contains ../ — the server's workspace guard will reject path traversal attempts regardless, but failing fast in the skill is cleaner than surfacing a stack trace from the MCP layer.
Detect the language from the extension. Use this table:
| Extension | language argument |
|---|---|
.ts / .tsx / .mts / .cts | typescript |
.js / .jsx / .mjs / .cjs | javascript |
.py | python |
.java | java |
.cs | csharp |
If the extension does not map to one of those five, tell the user which languages are supported and do not invoke the tool. Claude-sonar's tree-sitter engine is language-scoped; there is no "auto-detect from content" mode.
Invoke the MCP tool analyze_file_ast with filePath: "$ARGUMENTS" and the detected language.
Display file-level metrics first: physical LOC (every newline-terminated line including blanks and comments) and logical LOC (lines with at least one non-whitespace character). The delta between the two is an informal "comment density" signal.
Display a ranked function list, sorted by cyclomatic complexity descending. For each function, show:
<anonymous> if the tree-sitter grammar could not resolve a name)endLine - startLine + 1)Flag refactoring candidates. Any function whose cyclomatic complexity exceeds 15 (the plugin's default cyclomaticMax) is a Stop-gate warning candidate — call those out explicitly as "above the cyclomatic ceiling; refactor candidate". A function above 30 will fail the CRAP quality gate regardless of coverage and MUST be decomposed; those are the highest-priority targets.
Handle errors gracefully. If the tool returns status: "error", the most likely cause is a tree-sitter grammar that failed to load (Could not load wasm grammar for language X). Tell the user they may need to reinstall the plugin via /plugin install claude-crap@herz so the bundled WASM grammars are re-extracted into the plugin cache.
A compact report along the lines of:
src/index.ts — 658 LOC (512 logical)
Functions ranked by cyclomatic complexity:
1. handleRequest lines 120–245 CC=22 (126 lines) ⚠ above cyclomatic ceiling (15)
2. parseBody lines 48–102 CC=14 ( 55 lines)
3. sendResponse lines 300–340 CC= 9 ( 41 lines)
4. init lines 10–30 CC= 3 ( 21 lines)
⚠ `handleRequest` has CC=22 (ceiling is 15). Refactor candidate.
Exact formatting can vary — the important thing is that the function list is ranked and the refactoring candidates are called out explicitly.
The analyze_file_ast MCP tool is the deterministic alternative to "Claude reads the file and estimates complexity." Manual complexity estimation is a known failure mode for LLMs — we overcount branches, we undercount nested constructs, and we are not self-consistent across runs. The tree-sitter engine gives exact, reproducible per-function metrics that the user can trust for refactoring decisions, and the numbers match what the Stop quality gate will eventually grade against, so using this tool up-front closes the loop between exploration and enforcement.
.gitignore, not in the analyzer.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub ahernandez-developer/claude-crap --plugin claude-crap4 skills in this plugin
/adoptInteractive onboarding walkthrough for teams introducing claude-crap on an existing codebase. Use this skill whenever the user asks "how do I install claude-crap on my project", "we're adopting claude-crap for our team", "how should I roll claude-crap out", "what strictness mode should I pick", "we have a lot of legacy code, can we ease into this gradually", "our project has a bunch of existing errors, how do I avoid getting blocked", or is otherwise looking for guidance on gradual rollout strategy instead of just dropping a strict quality gate on a messy codebase. The skill asks a short three-question assessment about test coverage, existing findings, and appetite for hard enforcement, recommends one of three strictness modes (advisory / warn / strict), and emits a copy-pasteable .claude-crap.json snippet for the workspace root so the team can commit the policy in a single step./check-testCheck whether a production source file has an accompanying characterization test using claude-crap's deterministic test-harness resolver. Use this skill whenever the user asks "is this file tested", "does foo.ts have a test", "where's the test for bar.py", "check test coverage for this file", "do I have a test harness for src/baz.java", or is about to modify a source file and wants to know if the CLAUDE.md Golden Rule test prerequisite is already satisfied. Use it proactively at the start of any work on a .ts / .tsx / .js / .jsx / .mjs / .cjs / .py / .java / .cs file to verify a characterization test exists — this is required by CLAUDE.md and claude-crap's PostToolUse hook will flag the violation later if you skip the check. The skill takes a single file-path argument after the skill name.Other plugins' skills for the same job