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
└── 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)
# Build and run (from repo root)
make build
./bin/skill-up run ./examples/code-stats/evals/eval.yaml
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 files in evals/eval.yaml stay relative to eval.yaml, while fixture-style references such as repo_fixture and script_path are relative to the directory containing SKILL.md, so they should be written as evals/fixtures/....
Test Cases
- analyze-directory: Analyze the evals directory and report statistics
- top-extensions: Find top file extensions by line count
Evaluation Script
check-stats.sh validates:
- Exit code is 0
- 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)
- 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 all code files - 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
-
analyze-directory.yaml 735 B
id: analyze-directory title: Analyze code stats for evals directory description: Run code-stats on the current workspace and verify output format input: prompt: | Analyze the current directory using the code-stats requirements. Report the statistics in the full Code Statistics format with Summary, Files by Extension, Top File Extensions, and Largest Files sections. context: repo_fixture: evals/fixtures/repos/sample-project constraints: timeout_seconds: 900 max_turns: 5 expect: must_contain: - "Files by Extension" - "Total Files" - "Total Lines" must_not_contain: - "error" - "Error" judge: type: script script_path: evals/fixtures/scripts/check-stats.sh timeout_seconds: 30 -
current-directory-format.yaml 841 B
id: current-directory-format title: Verify code-stats report format for current directory description: Verify that code-stats produces the full report format for the current workspace input: prompt: | Use the code-stats requirements to analyze the current directory. Run the needed local read-only commands directly; do not ask for interactive permission or human approval. Include Summary, Files by Extension, Top 5 File Extensions by Line Count, and Largest Files sections. context: repo_fixture: evals/fixtures/repos/sample-project constraints: timeout_seconds: 900 max_turns: 5 expect: must_contain: - "Summary" - "Files by Extension" - "Total" must_not_contain: - "error" - "Error" judge: type: script script_path: evals/fixtures/scripts/check-stats.sh timeout_seconds: 30 -
top-extensions.yaml 687 B
id: top-extensions title: Find top file extensions by line count description: Identify the most common file types in a codebase input: prompt: | Use the code-stats skill to analyze the current directory. Report the full Code Statistics output format, including the top file extensions by total line count. context: repo_fixture: evals/fixtures/repos/sample-project constraints: timeout_seconds: 900 max_turns: 5 expect: must_contain: - "Files by Extension" - "Total Files" - "Total Lines" - "Total" must_not_contain: - "error" - "Error" judge: type: script script_path: evals/fixtures/scripts/check-stats.sh timeout_seconds: 30
-
-
fixtures
-
repos
-
sample-project
-
main.go 143 B · in bundle
-
README.md 73 B
# Sample Project This is a sample project for testing code-stats skill. -
util.go 134 B · in bundle
-
-
-
scripts
-
check-stats.sh 1.9 KB
#!/bin/bash # check-stats.sh - Evaluation script for code-stats skill # Exit code 0 = pass, non-zero = fail set -e # Environment variables provided by skill-up: # EVAL_TRANSCRIPT_PATH - path to transcript.json # EVAL_FINAL_MESSAGE - final message from agent # EVAL_EXIT_CODE - exit code from agent execution TRANSCRIPT_PATH="${EVAL_TRANSCRIPT_PATH:-}" FINAL_MESSAGE="${EVAL_FINAL_MESSAGE:-}" EXIT_CODE="${EVAL_EXIT_CODE:-0}" echo "=== Code Stats Skill Evaluation ===" echo "Exit code: $EXIT_CODE" echo "Final message preview: ${FINAL_MESSAGE:0:200}..." # qodercli may occasionally time out after producing a complete final message. # This case evaluates report content, so keep exit-code checks in expect rules # for cases that specifically need process-status validation. if [ "$EXIT_CODE" != "0" ]; then echo "WARN: Agent exited with non-zero code: $EXIT_CODE" fi # Check that final message is not empty if [ -z "$FINAL_MESSAGE" ]; then echo "FAIL: Final message is empty" exit 1 fi # Check for required sections in output MISSING="" if ! echo "$FINAL_MESSAGE" | grep -qi "Files by Extension"; then MISSING="$MISSING 'Files by Extension'" fi if ! echo "$FINAL_MESSAGE" | grep -qi "Total Files"; then MISSING="$MISSING 'Total Files'" fi if ! echo "$FINAL_MESSAGE" | grep -qi "Total Lines"; then MISSING="$MISSING 'Total Lines'" fi # Check for markdown table structure (has | and ---) if ! echo "$FINAL_MESSAGE" | grep -q "|"; then MISSING="$MISSING 'markdown table (|)'" fi # Check for error indicators if echo "$FINAL_MESSAGE" | grep -qi "error\|fail"; then echo "FAIL: Output contains error indicators" exit 1 fi if [ -n "$MISSING" ]; then echo "FAIL: Missing required sections:$MISSING" exit 1 fi echo "PASS: All checks passed" echo "Evaluation reason: Agent produced valid code stats output with required sections" exit 0
-
-
-
eval.yaml 682 B
schema_version: v1alpha1 environment: type: none workspace_mount: /workspace env: TZ: UTC mcp: servers: [] skills: - source: local_path path: . engine: name: qodercli model: name: auto cases: files: - evals/cases/analyze-directory.yaml - evals/cases/top-extensions.yaml - evals/cases/current-directory-format.yaml defaults: timeout_seconds: 900 max_turns: 5 parallelism: 2 retry_policy: max_retries: 2 retry_on: - error benchmark: enabled: true judge: type: script script_path: evals/fixtures/scripts/check-stats.sh timeout_seconds: 30 report: formats: [json, html] artifacts: - transcript -
evals.json 1.8 KB
{ "skill_name": "code-stats", "evals": [ { "id": 1, "prompt": "Analyze the current directory using the code-stats requirements. Report the statistics in the full Code Statistics format with Summary, Files by Extension, Top File Extensions, and Largest Files sections.", "expected_output": "A markdown table showing files by extension with line counts, and summary totals", "files": [], "expectations": [ "Output contains 'Files by Extension' section", "Output contains a markdown table with extension counts", "Output contains 'Total Files' count greater than 0", "Output contains 'Total Lines' count greater than 0" ] }, { "id": 2, "prompt": "Use the code-stats skill to analyze the current directory. Report the full Code Statistics output format, including the top file extensions by total line count.", "expected_output": "A code statistics report for the current workspace with top file extensions by total line count", "files": [], "expectations": [ "Output contains the full Code Statistics format with Summary and Files by Extension sections", "Output shows line counts for each extension", "Output identifies the top file extensions by total line count" ] }, { "id": 3, "prompt": "Run code-stats to analyze the current directory. Include Summary, Files by Extension, Top 5 File Extensions by Line Count, and Largest Files sections.", "expected_output": "Code statistics for the current workspace with extension breakdown", "files": [], "expectations": [ "Output follows the exact format with Summary and Files by Extension sections", "Contains file extension counts", "Markdown table format is used" ] } ] }
-
-
README.md 2.1 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 └── 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) ```bash # Build and run (from repo root) make build ./bin/skill-up run ./examples/code-stats/evals/eval.yaml ``` ## 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 files in `evals/eval.yaml` stay relative to `eval.yaml`, while fixture-style references such as `repo_fixture` and `script_path` are relative to the directory containing `SKILL.md`, so they should be written as `evals/fixtures/...`. ## Test Cases 1. **analyze-directory**: Analyze the evals directory and report statistics 2. **top-extensions**: Find top file extensions by line count ## Evaluation Script `check-stats.sh` validates: - Exit code is 0 - Output contains "Files by Extension" - Output contains "Total Files" and "Total Lines" - Markdown table format with `|` characters - No error indicators -
SKILL.md 1.9 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) 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?"
Comments (0)
Sign in to join the conversation.
Reviews (0)
No reviews yet.
No comments yet.