Code Stats

VerifiedSafe

Analyze codebase size and changes using tokei for line counts and difft for semantic diffs.

Sby Skills Guide Bot
DevelopmentBeginner
7/22/2026
Claude CodeCursorCodex
#code-metrics#semantic-diff#cli-tools#tokei#difftastic

Recommended for

Automated summary

This skill explains how to use tokei for per-language line counts and difft for AST-aware semantic diffs.

Strengths

  • Provides copy-paste commands for tokei (counting, sorting by code, language-type filters, excludes) and difft (inline mode, git integration)
  • Includes a quick-reference table mapping each task to its exact command
  • Shows how to emit JSON and pipe it through jq for scripting
  • Explains concretely why semantic diffs beat line-by-line diffs (moves recognized, formatting ignored)

Limitations

  • Assumes tokei and difftastic are already installed; the skill only repeats the install commands
  • Covers counting and file comparison only, not code quality or complexity analysis
  • Gives little guidance on interpreting the numbers or using them in CI, deferring to external reference files
When to use it

Use it when you want a fast overview of a repository's size and language mix, or to compare two versions of a file without formatting noise.

When not to use it

Skip it if tokei and difftastic cannot be installed in your environment, or if you need static quality analysis rather than statistics.

Security analysis

Safe
Quality score82/100

The skill only documents read-only code-analysis commands using tokei and difft. It does not instruct destructive actions, network exfiltration, credential access, obfuscated payloads, or safety-disabling behavior. Bash is allowed but used for legitimate local inspection commands.

No concerns found

How this analysis is made

Examples

Codebase overview
How big is this codebase and what languages does it use? Run tokei and give me a compact summary sorted by lines of code.
Semantic git diff
Show me the semantic diff of the last commit using difft, ignoring pure formatting changes.
Scriptable stats
Output tokei results as JSON and extract the total code line count with jq.

name: code-stats description: "Analyze codebase with tokei (fast line counts by language) and difft (semantic AST-aware diffs). Get quick project overview without manual counting. Triggers on: how big is codebase, count lines of code, what languages, show semantic diff, compare files, code statistics." license: MIT compatibility: "Requires tokei and difft CLI tools. Install: brew install tokei difft (macOS) or cargo install tokei difftastic (cross-platform)." allowed-tools: "Bash" metadata: author: claude-mods

Code Statistics

Quickly analyze codebase size, composition, and changes.

tokei - Line Counts

# Count all code
tokei

# Compact output sorted by code
tokei --compact --sort code

# Specific languages
tokei --type=TypeScript,JavaScript

# Exclude directories
tokei --exclude node_modules --exclude dist

# JSON output for scripting
tokei --output json | jq '.Total.code'

Sample Output

===============================================================================
 Language            Files        Lines         Code     Comments       Blanks
===============================================================================
 TypeScript             45        12847         9823         1456         1568
 JavaScript             12         2341         1876          234          231
-------------------------------------------------------------------------------
 Total                  57        15188        11699         1690         1799
===============================================================================

difft - Semantic Diffs

# Compare files
difft old.ts new.ts

# Inline mode
difft --display=inline old.ts new.ts

# With git
GIT_EXTERNAL_DIFF=difft git diff
GIT_EXTERNAL_DIFF=difft git show HEAD~1

Why Semantic?

| Traditional diff | difft | |-----------------|-------| | Line-by-line | AST-aware | | Shows moved as delete+add | Recognizes moves | | Whitespace sensitive | Ignores formatting |

Quick Reference

| Task | Command | |------|---------| | Count all code | tokei | | Compact output | tokei --compact | | Sort by code | tokei --sort code | | TypeScript only | tokei -t TypeScript | | JSON output | tokei --output json | | Exclude dir | tokei --exclude node_modules | | Semantic diff | difft file1 file2 | | Git diff | GIT_EXTERNAL_DIFF=difft git diff |

When to Use

  • Getting quick codebase overview
  • Comparing code changes semantically
  • Understanding project composition
  • Reviewing refactoring impact
  • Tracking codebase growth

Additional Resources

For detailed patterns, load:

  • ./references/tokei-advanced.md - Filtering, output formats, CI integration
  • ./references/difft-advanced.md - Display modes, git integration, language support

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/code-stats-mrwakb1u/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/code-stats-mrwakb1u' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/code-stats-mrwakb1u/download' --output '.skill-downloads/code-stats-mrwakb1u/SKILL.md.part' && mv '.skill-downloads/code-stats-mrwakb1u/SKILL.md.part' '.skill-downloads/code-stats-mrwakb1u/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

Environment declared by the author: Requires tokei and difft CLI tools. Install: brew install tokei difft (macOS) or cargo install tokei difftastic (cross-platform).

Tools declared by the author (check availability in your agent): Bash

Original excerpt: Quick Reference
TaskCommand
Count all codetokei
Compact outputtokei --compact
Sort by codetokei --sort code
TypeScript onlytokei -t TypeScript
JSON outputtokei --output json
Exclude dirtokei --exclude node_modules
Semantic diffdifft file1 file2
Git diffGIT_EXTERNAL_DIFF=difft git diff

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/code-stats-mrwakb1u/SKILL.md' && test -s '.skill-downloads/code-stats-mrwakb1u/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/code-stats' && cp -R '.skill-downloads/code-stats-mrwakb1u' '.claude/skills/code-stats'

Cursor
test -f '.skill-downloads/code-stats-mrwakb1u/SKILL.md' && test -s '.skill-downloads/code-stats-mrwakb1u/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/code-stats' && cp -R '.skill-downloads/code-stats-mrwakb1u' '.cursor/skills/code-stats'

Codex
test -f '.skill-downloads/code-stats-mrwakb1u/SKILL.md' && test -s '.skill-downloads/code-stats-mrwakb1u/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/code-stats' && cp -R '.skill-downloads/code-stats-mrwakb1u' '.agents/skills/code-stats'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/code-stats-mrwakb1u'

openskills read 'code-stats-mrwakb1u'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/code-stats-mrwakb1u/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills