Text Counter
A small command line helper for counting words, lines and characters in plain text files. Useful when you need a quick size estimate before committing notes or documentation, and you do not want to open an editor just to check length.
When to use it
Use this skill when you need to:
- Compare the length of two drafts before picking one.
- Check that a README stays below a documentation length limit.
- Count how many lines a log excerpt contains before pasting it into a ticket.
- Produce a quick word count for a chapter or a blog post draft.
How it works
The helper reads every path you pass, encodes the file as UTF-8, and reports three numbers: lines, words and characters. Lines are counted by newline characters, words by whitespace separated runs, and characters by Unicode code points so that emoji and accented letters are counted once rather than as multiple bytes.
Run it with one or more file paths:
text-counter notes.md draft.md
The output is one line per file followed by a total line:
notes.md lines=42 words=310 chars=2140
draft.md lines=58 words=405 chars=2870
total lines=100 words=715 chars=5010
Options
--linesprints only the line count.--wordsprints only the word count.--charsprints only the character count.--totalprints only the aggregate line for all inputs.--jsonprints a machine readable object with the same numbers.
When no option is given all three counters are shown. Options can be combined,
for example --lines --words reports just those two values.
Notes and limitations
Binary files are detected by a NUL byte in the first block and skipped with a warning so that accidentally passing an image does not produce meaningless counts. Very large files are streamed in chunks, so memory use stays flat even when the input is a few hundred megabytes.
The tool does not modify any input file. It only reads, counts and exits with status zero on success and status two when a path cannot be read.
Examples
Count a single draft:
text-counter draft.md
Count all markdown files and print only totals:
text-counter --total docs/*.md
Emit JSON for a script:
text-counter --json notes.md | jq .total.words
This skill is intentionally dependency free and works on Linux, macOS and Windows with a standard shell. It ships a single entry point plus this documentation, so installing it does not pull in extra packages.
