combined-head-linecount-check
What it does
This skill shows the AI agent how to look at the top of a file and count its lines in a single command. It is for people who want quick checks on code or config files.
When to use it
- ✓When you want to see the first lines of a file and how long the file is in one step.
- ✓When you are auditing several files and want fewer shell calls.
- ✓When a file's header content or length matters before you edit it.
Skill link
https://github.com/HKUDS/AgentPilot/blob/main/openspace/legacy/v1/showcase/skills/combined-head-linecount-check/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agent’s skills folder.
Example of what to ask your AI
“Show me the first 10 lines of main.ts and how many lines it has, in one check.”
5 new skills a week. 1 minute to read.
How it works
The agent runs head to show the top lines, prints a separator, then runs wc -l to count the lines. The output shows the content first and the line count below the dashes.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
Combined Head + Line Count Check
When you need to both inspect the top of a file and confirm its total line count, collapse the two checks into a single run_shell call instead of issuing two separate commands.
Why
- Each shell call is a round-trip. Two separate calls (
headthenwc -l) cost two iterations. - A combined call costs one iteration and returns both pieces of information atomically.
- When checking multiple files at once, each file still only needs one call (or all files can be parallelized in a single compound command).
Pattern
head -N <file> && echo "---" && wc -l <file>
The echo "---" separator makes the output easy to parse visually: everything above the dashes is content, everything below is the line count.
Examples
Single file — inspect first 10 lines and total count
head -10 src/main.ts && echo "---" && wc -l src/main.ts
Sample output:
import { createApp } from 'vue'
import App from './App.vue'
...
---
142 src/main.ts
Multiple files — fully parallelized
When you need to check several files simultaneously, run them all in one shell call using && chains or newline-separated subshells:
(head -10 src/main.ts && echo "---" && wc -l src/main.ts) && echo "===" && \
(head -10 vite.config.ts && echo "---" && wc -l vite.config.ts) && echo "===" && \
(head -5 package.json && echo "---" && wc -l package.json)
Or, if order independence is acceptable, run them in parallel background jobs and wait:
{
head -10 src/main.ts && echo "---" && wc -l src/main.ts
} &
{
head -10 vite.config.ts && echo "---" && wc -l vite.config.ts
} &
wait
When to Apply
| Situation | Recommendation |
|---|---|
| Verifying a generated/modified file was written correctly | ✅ Use combined call |
| Checking multiple output files after a build step | ✅ Parallelize all in one shell call |
| Only need line count (no content preview required) | Use plain wc -l |
| Only need content (no line count required) | Use plain head -N |
| File is extremely large and you want a middle section | Use sed -n or awk instead |
Integration with Parallel Reads
This pattern compounds well with parallel file reads. In a single iteration you can:
- Read file contents with
catorheadfor multiple files. - Simultaneously verify line counts with
wc -l. - Check for specific patterns with
grep -c.
Example of a 5-file parallel verification in one shell call:
echo "=== main.ts ===" && head -10 src/main.ts && echo "lines:" && wc -l < src/main.ts && \
echo "=== config ===" && head -5 vite.config.ts && echo "lines:" && wc -l < vite.config.ts && \
echo "=== package ===" && head -5 package.json && echo "lines:" && wc -l < package.json && \
echo "=== index ===" && head -8 index.html && echo "lines:" && wc -l < index.html && \
echo "=== readme ===" && head -5 README.md && echo "lines:" && wc -l < README.md
Tip: Using
wc -l < file(with input redirect) prints only the number, without the filename — cleaner output when the filename is already shown by theecholabel above it.
Key Takeaway
Never use two shell calls where one will do. Combining
head -Nandwc -lin a single command is the minimal-overhead way to answer both "what does this file contain?" and "is it the right size?" simultaneously.
FAQ
Why combine the two checks?
Each shell call takes a round trip, so one combined command finishes the job in fewer steps.
Can it check several files at once?
Yes, the skill shows chaining the checks for multiple files in a single shell call.
What does the dashed line do?
It separates the file content from the line count, so the output is easy to read.
Details
Original description by the author
Verify a file's first N lines and total line count in one shell call using head and wc -l with an echo separator, minimizing read operations and shell iterations.
repo: HKUDS/AgentPilot
Popularity
- GitHub stars
- 7.8k
- Ranking position
- #13040
- License
- MIT
- Updated
- 11/1/2026
Comments
- …
More skills from this repository
agentpilot
7.8kHelps your agent improve a project step by step by preparing a task and running the AgentPilot loop that proposes, tests and scores changes.
openspace
7.8kHelps your agent set up OpenSpace, a tool that stores and fetches agent skills, and connect it to your AI app through MCP.
rsi-arena
7.8kHelps your agent set up and run standard AI benchmark tests, such as AIME and Terminal-Bench, to compare different improvement methods.
experiment-guide
7.8kHelps your agent plan small experiments, read their results and record findings while it investigates how to improve a program.
Similar skills
diffs
394kLets your agent produce a real, shareable diff of edits as a viewer link or image file, instead of a hand-written summary.
coding-agent
394kHelps your agent hand a larger coding job to Codex, Claude Code, or OpenCode as a background worker, then check on its progress.
gh-issues
394kHelps your agent find GitHub issues, pick the ones to work on, and open pull requests with fixes, including follow-up on review comments.