code-stats
Analyzes code files and reports statistics including line counts, file counts by extension, and total size. Use this skill whenever the user wants to understand the composition of a codebase - asking about "how many lines of code", "what file types exist", "code distribution", or
Install
npx skills add https://github.com/alibaba/skill-up/tree/main/examples/code-stats
claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install alibaba-skill-up@llmmart
git clone https://github.com/alibaba/skill-up.git
The skills CLI installs just this skill, for any of its supported agents. Claude Code installs the whole alibaba/skill-up collection as a plugin from our marketplace. Git is the plain clone.
README
Code Stats Skill
A real evaluable skill that analyzes code files and reports statistics. Works with both skill-creator and skill-up.
Structure
code-stats/
├── SKILL.md # Skill definition with instructions
└── evals/
├── eval.yaml # skill-up config (YAML format)
├── evals.json # skill-creator format
├── cases/
│ ├── analyze-directory.yaml # Test: analyze directory
│ ├── top-extensions.yaml # Test: find top extensions
│ ├── current-directory-format.yaml
│ └── exclude-dependencies.yaml
└── fixtures/
├── scripts/
│ └── check-stats.sh # Evaluation script
└── repos/
└── sample-project/ # Test repository
├── main.go
├── util.go
└── README.md
How to Evaluate
With skill-creator
# Run evaluation using skill-creator workflow
claude -p "$(cat <<'EOF'
Create a skill evaluation for ./examples/code-stats using skill-creator.
EOF
)"
With skill-up (Go framework)
The YAML suite uses OpenCode with dashscope/qwen3.8-max at
https://dashscope.aliyuncs.com/compatible-mode/v1. Install OpenCode and inject
DASHSCOPE_API_KEY through your environment or secret manager; keep it out of YAML.
The endpoint and model must be available to that key.
# From the repository root; DASHSCOPE_API_KEY must already be injected.
make build
./bin/skill-up validate ./examples/code-stats/evals/eval.yaml
./bin/skill-up run ./examples/code-stats/evals/eval.yaml \
--include-case-name analyze-directory --parallelism 1 \
--format json --format html --format junit
analyze-directory reuses check-stats.sh as the format script judge and adds
an independent relevance Agent judge. The other cases retain their singular
script judges. The evaluated agent runs once per configuration; semantic review
uses a separate Agent session over the same completed output. all_required
requires both judges to pass. Benchmark mode also runs a separate without_skill
configuration; that is a baseline evaluation, not a second execution for judging.
The relevance judge selects its own OpenCode model and endpoint through
judges[].engine, so runner engine/model CLI overrides do not change the reviewer.
Its credentials still resolve from the DashScope provider configuration. In the
none runtime, preinstall every selected runner and judge CLI. Multi-judge
Docker/OpenSandbox snapshot support is a separate runtime extension.
The prompt limits the project to main.go, util.go, and README.md, and gates
check 3 files and 20 lines. This excludes OpenCode's installed Skill and generated
configuration from project statistics. The reused script checks report formatting;
the semantic rubric checks that an actual, complete report answers the request.
Verified behavior
The selected case was exercised with real OpenCode 1.14.24 / Qwen3.8-Max calls on 2026-09-30: both judges passed with the Skill. A controlled failure in a scratch copy produced script FAIL, semantic PASS and aggregate FAIL; the semantic judge could not see a file written by the script judge. The baseline failed the exact output-format gates, so both judges were skipped.
See the verification report and reproduction steps for evidence boundaries and the negative-test procedure. This does not claim a live-model run of all four cases.
Dual Format Support
| Tool | Config File | Format |
|---|---|---|
| skill-creator | evals/evals.json |
JSON with skill_name, evals[] array |
| skill-up | evals/eval.yaml + cases/*.yaml |
YAML with schema v1alpha1 |
For skill-up, case file paths, repo_fixture, and script_path are relative to the Skill root (the directory containing SKILL.md). Use evals/cases/... and evals/fixtures/... as in this example.
Test Cases
- analyze-directory: Check the fixed project with script and semantic judges
- top-extensions: Find top file extensions by line count
- current-directory-format: Check the required report sections
- exclude-dependencies: Verify dependency-directory exclusions
Evaluation Script
check-stats.sh validates:
- Agent exit code is recorded as a warning if nonzero; script exit code determines its verdict
- Output contains "Files by Extension"
- Output contains "Total Files" and "Total Lines"
- Markdown table format with
|characters - No error indicators
Skill manifest
Code Stats Skill
Analyzes code files and generates statistics about a codebase.
Usage
When invoked, this skill will:
- Scan the specified directory (defaults to current directory)
- Exclude
node_modules/,.git/,dist/, andbuild/unless the user explicitly asks to count them. These are dependencies, repository metadata, or generated output rather than project source.
- Exclude
- Count total lines, files by extension
- Report the largest files
- Output results in a structured format
- Sort extension summaries by total line count in descending order
Output Format
Always use this exact format for the output:
# Code Statistics
## Summary
- Total Files: <count>
- Total Lines: <count>
- Total Size: <size_bytes> bytes
## Files by Extension
| Extension | Files | Lines |
|-----------|-------|-------|
| .go | 12 | 1500 |
| .md | 5 | 200 |
## Top 5 File Extensions by Line Count
1. .go — 1500 lines
2. .md — 200 lines
## Largest Files (top 5)
1. main.go (500 lines)
2. util.go (300 lines)
If a file has no extension, group it under (no ext) in both extension sections.
Process
- Use
Bashwithfindto locate project files, pruning the excluded directories - Use
Bashwithwc -lto count lines per file - Group files with no extension under
(no ext) - Sort both extension summaries by total line count in descending order
- Aggregate the results into the output format above
- If no directory is specified, analyze the current working directory
Examples
- "Analyze the current directory"
- "Run code-stats on ./src"
- "Show me file type distribution"
- "How many lines of Python do we have?"
Files (skill-up)
-
evals
-
cases
-
agent-judge-file.yaml 344 B
Loading… -
analyze-directory.yaml 1.5 KB
Loading… -
current-directory-format.yaml 841 B
Loading… -
exclude-dependencies.yaml 1 KB
Loading… -
top-extensions.yaml 687 B
Loading…
-
-
fixtures
-
repos
-
sample-project
-
main.go 143 B · in bundle
-
README.md 73 B
Loading… -
util.go 134 B · in bundle
-
-
-
scripts
-
check-stats.sh 1.9 KB
Loading…
-
-
-
eval-agent-judge-file.yaml 605 B
Loading… -
eval.yaml 821 B
Loading… -
evals.json 1.8 KB
Loading…
-
-
README.md 4.6 KB
# Code Stats Skill A real evaluable skill that analyzes code files and reports statistics. Works with both **skill-creator** and **skill-up**. ## Structure ``` code-stats/ ├── SKILL.md # Skill definition with instructions └── evals/ ├── eval.yaml # skill-up config (YAML format) ├── evals.json # skill-creator format ├── cases/ │ ├── analyze-directory.yaml # Test: analyze directory │ ├── top-extensions.yaml # Test: find top extensions │ ├── current-directory-format.yaml │ └── exclude-dependencies.yaml └── fixtures/ ├── scripts/ │ └── check-stats.sh # Evaluation script └── repos/ └── sample-project/ # Test repository ├── main.go ├── util.go └── README.md ``` ## How to Evaluate ### With skill-creator ```bash # Run evaluation using skill-creator workflow claude -p "$(cat <<'EOF' Create a skill evaluation for ./examples/code-stats using skill-creator. EOF )" ``` ### With skill-up (Go framework) The YAML suite uses OpenCode with `dashscope/qwen3.8-max` at `https://dashscope.aliyuncs.com/compatible-mode/v1`. Install OpenCode and inject `DASHSCOPE_API_KEY` through your environment or secret manager; keep it out of YAML. The endpoint and model must be available to that key. ```bash # From the repository root; DASHSCOPE_API_KEY must already be injected. make build ./bin/skill-up validate ./examples/code-stats/evals/eval.yaml ./bin/skill-up run ./examples/code-stats/evals/eval.yaml \ --include-case-name analyze-directory --parallelism 1 \ --format json --format html --format junit ``` `analyze-directory` reuses `check-stats.sh` as the `format` script judge and adds an independent `relevance` Agent judge. The other cases retain their singular script judges. The evaluated agent runs once per configuration; semantic review uses a separate Agent session over the same completed output. `all_required` requires both judges to pass. Benchmark mode also runs a separate `without_skill` configuration; that is a baseline evaluation, not a second execution for judging. The `relevance` judge selects its own OpenCode model and endpoint through `judges[].engine`, so runner engine/model CLI overrides do not change the reviewer. Its credentials still resolve from the DashScope provider configuration. In the `none` runtime, preinstall every selected runner and judge CLI. Multi-judge Docker/OpenSandbox snapshot support is a separate runtime extension. The prompt limits the project to `main.go`, `util.go`, and `README.md`, and gates check 3 files and 20 lines. This excludes OpenCode's installed Skill and generated configuration from project statistics. The reused script checks report formatting; the semantic rubric checks that an actual, complete report answers the request. ## Verified behavior The selected case was exercised with real OpenCode 1.14.24 / Qwen3.8-Max calls on 2026-09-30: both judges passed with the Skill. A controlled failure in a scratch copy produced script FAIL, semantic PASS and aggregate FAIL; the semantic judge could not see a file written by the script judge. The baseline failed the exact output-format gates, so both judges were skipped. See the [verification report and reproduction steps](../../docs/design/multi-judge.md#live-qwen-verification) for evidence boundaries and the negative-test procedure. This does not claim a live-model run of all four cases. ## Dual Format Support | Tool | Config File | Format | |------|-------------|--------| | skill-creator | `evals/evals.json` | JSON with `skill_name`, `evals[]` array | | skill-up | `evals/eval.yaml` + `cases/*.yaml` | YAML with schema v1alpha1 | For `skill-up`, case file paths, `repo_fixture`, and `script_path` are relative to the Skill root (the directory containing `SKILL.md`). Use `evals/cases/...` and `evals/fixtures/...` as in this example. ## Test Cases 1. **analyze-directory**: Check the fixed project with script and semantic judges 2. **top-extensions**: Find top file extensions by line count 3. **current-directory-format**: Check the required report sections 4. **exclude-dependencies**: Verify dependency-directory exclusions ## Evaluation Script `check-stats.sh` validates: - Agent exit code is recorded as a warning if nonzero; script exit code determines its verdict - Output contains "Files by Extension" - Output contains "Total Files" and "Total Lines" - Markdown table format with `|` characters - No error indicators -
SKILL.md 2.1 KB
--- name: code-stats description: Analyzes code files and reports statistics including line counts, file counts by extension, and total size. Use this skill whenever the user wants to understand the composition of a codebase - asking about "how many lines of code", "what file types exist", "code distribution", or needing a quick audit of project size and structure. Make sure to invoke this skill when users mention analyzing codebases, counting lines, checking file distributions, or auditing code. version: 1.0.0 --- # Code Stats Skill Analyzes code files and generates statistics about a codebase. ## Usage When invoked, this skill will: 1. Scan the specified directory (defaults to current directory) - Exclude `node_modules/`, `.git/`, `dist/`, and `build/` unless the user explicitly asks to count them. These are dependencies, repository metadata, or generated output rather than project source. 2. Count total lines, files by extension 3. Report the largest files 4. Output results in a structured format 5. Sort extension summaries by total line count in descending order ## Output Format Always use this exact format for the output: ``` # Code Statistics ## Summary - Total Files: <count> - Total Lines: <count> - Total Size: <size_bytes> bytes ## Files by Extension | Extension | Files | Lines | |-----------|-------|-------| | .go | 12 | 1500 | | .md | 5 | 200 | ## Top 5 File Extensions by Line Count 1. .go — 1500 lines 2. .md — 200 lines ## Largest Files (top 5) 1. main.go (500 lines) 2. util.go (300 lines) ``` If a file has no extension, group it under `(no ext)` in both extension sections. ## Process 1. Use `Bash` with `find` to locate project files, pruning the excluded directories 2. Use `Bash` with `wc -l` to count lines per file 3. Group files with no extension under `(no ext)` 4. Sort both extension summaries by total line count in descending order 5. Aggregate the results into the output format above 6. If no directory is specified, analyze the current working directory ## Examples - "Analyze the current directory" - "Run code-stats on ./src" - "Show me file type distribution" - "How many lines of Python do we have?"
Comments (0)
Sign in to join the conversation.
Reviews (0)
No reviews yet.
No comments yet.