# code-stats

Adopt this skill: https://proskills.md/skills/other/alibaba-skill-up-examples-code-stats

Page: https://proskills.md/skills/other/alibaba-skill-up-examples-code-stats
This document is the public skill bundle for that page. It contains SKILL.md and every helper file the catalog carries. No login is required.

## File: examples/code-stats/SKILL.md
size: 1945
upstream: https://github.com/alibaba/skill-up/blob/main/examples/code-stats/SKILL.md

````text
---
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)
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 all code files
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?"
````

## File: README.md
upstream: https://github.com/alibaba/skill-up/blob/main/README.md

````text
# 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
````
