본문으로 건너뛰기
Skillpedia
일반 코딩7.8k · #13040

combined-head-linecount-check

하는 일

이 스킬은 AI 에이전트가 파일의 맨 위를 보고 줄 수를 세는 일을 한 명령으로 처리하는 방법을 보여 줍니다. 코드나 설정 파일을 빠르게 확인하려는 사람을 위한 스킬입니다.

사용하는 경우

  • ✓파일의 첫 몇 줄과 전체 길이를 한 단계에서 보고 싶을 때.
  • ✓여러 파일을 점검하면서 셸 호출 횟수를 줄이고 싶을 때.
  • ✓파일을 고치기 전에 머리글 내용이나 길이가 중요한 경우.

스킬 링크

https://github.com/HKUDS/AgentPilot/blob/main/openspace/legacy/v1/showcase/skills/combined-head-linecount-check/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/HKUDS/AgentPilot/blob/main/openspace/legacy/v1/showcase/skills/combined-head-linecount-check/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“main.ts의 처음 10줄과 전체 줄 수를 한 번의 확인으로 보여 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

에이전트는 head로 맨 위 줄을 보여 준 다음, 구분선을 출력하고 wc -l로 줄 수를 셉니다. 출력에서는 내용이 먼저 나오고, 대시 구분선 아래에 줄 수가 나옵니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 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 (head then wc -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:

  1. Read file contents with cat or head for multiple files.
  2. Simultaneously verify line counts with wc -l.
  3. 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 the echo label above it.

Key Takeaway

Never use two shell calls where one will do. Combining head -N and wc -l in a single command is the minimal-overhead way to answer both "what does this file contain?" and "is it the right size?" simultaneously.

자주 묻는 질문

두 확인을 왜 합치나요?

셸 호출마다 왕복 시간이 걸리므로, 한 명령으로 묶으면 단계가 줄어듭니다.

여러 파일을 한 번에 확인할 수 있나요?

네, 스킬은 여러 파일의 확인을 한 번의 셸 호출로 이어서 실행하는 방법을 보여 줍니다.

구분선은 무엇을 하나요?

파일 내용과 줄 수를 나눠 주어 출력이 읽기 쉽게 합니다.

상세 정보

작성자의 원본 설명

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

인기도

GitHub 스타
7.8k
순위
#13040
라이선스
MIT
업데이트
2026. 11. 1.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬