head-tail

GitHub

针对日志、构建输出等中间内容重复的大文件,通过采样首尾片段并报告缺失区间来高效分析,避免全量读取。适用于排查错误和检查配置,不适用于源码或配置文件。

.agents/skills/head-tail/SKILL.md mtarcure/claude-vibe-squad

Trigger Scenarios

日志文件过大无法直接阅读 CI/构建输出过长需快速定位结果

Install

npx skills add mtarcure/claude-vibe-squad --skill head-tail -g -y
More Options

Non-standard path

npx skills add https://github.com/mtarcure/claude-vibe-squad/tree/main/.agents/skills/head-tail -g -y

Use without installing

npx skills use mtarcure/claude-vibe-squad@head-tail

指定 Agent (Claude Code)

npx skills add mtarcure/claude-vibe-squad --skill head-tail -a claude-code -g -y

安装 repo 全部 skill

npx skills add mtarcure/claude-vibe-squad --all -g -y

预览 repo 内 skill

npx skills add mtarcure/claude-vibe-squad --list

SKILL.md

Frontmatter
{
    "name": "head-tail",
    "audience": "specialist",
    "description": "Use when a log, build transcript, generated artifact, or dump is too large to read whole and its middle is repetitive—sample bounded first\/last slices, report the unread gap, and capture producer status separately. Not for source, briefs, packets, or configuration; their whole-file rule comes from the injected task contract."
}

Head-Tail

Sample a file that is too large to read whole by taking a bounded slice from each end. Logs and build output are usually structured this way on purpose: the beginning carries the invocation, configuration, and version banner, and the end carries the outcome, the error, and the exit status.

Canonical efficiency contract

The task packet's injected Execution efficiency — the cost unit is ROUND-TRIPS section is the sole source for whole-file reads, batching independent operations, avoiding re-reads, and excluding generated content with tool-level globs. This skill does not redefine those rules. It adds only the log-specific decision test, bounded-sample evidence contract, long-line defense, middle-search rule, and producer-status trap that the packet section does not specify.

When this is the right tool — and when it is the wrong one

This technique is narrow, and applying it to the wrong file is a measured, expensive mistake.

  • Right: log files, CI/build output, test-runner transcripts, generated artifacts, data dumps, and anything whose middle is repetitive by construction.
  • Wrong: source files, briefs, packets, and configuration. Follow the injected whole-file contract; do not use this skill as an exception to it. A large dense file is not a sampling candidate merely because its full read is inconvenient.

The deciding question is not "is this file long?" but "is this file's middle repetitive?" A 3,000-line source file is long and dense; a 3,000-line test log is long and repetitive. Only the second is a head-tail candidate.

Steps

  1. Size it first. Check the byte size and line count before reading anything. This is one cheap call and it decides the entire approach — a file you assumed was huge is often small enough to read whole.
  2. Choose the slice deliberately. Twenty lines from each end is a reasonable default for a log. Take more from the tail when you are chasing a failure, more from the head when you are checking how a run was invoked or configured.
  3. Label both slices. Follow the packet's batching rule, and make the output itself distinguish the head from the tail so lines from opposite ends cannot be mistaken for contiguous evidence.
  4. Bound the line length. A single line in a log can be megabytes — a serialized payload, a base64 blob, a minified bundle. Truncate over-long lines and mark them truncated, so one pathological line cannot displace everything else you read.
  5. State the gap explicitly. Report the sampled range and what was skipped: "lines 1–20 and 14,981–15,000 of 15,000; the middle 14,960 lines were not read." A reader who does not know a gap exists will treat your sample as the whole file.
  6. Search the middle rather than paging it. When the ends do not answer the question, do not walk the file in windows. Search it — grep for the error, the failing test name, the exception class — and read the matches with a little surrounding context. One targeted search beats twenty sequential pages.
  7. Capture producer status separately. Save the build/test process's direct exit status before any sampling pipeline. A successful head, tail, formatter, or filter says only that the sampler ran; it cannot establish that the producer succeeded.

Failure modes

  • Sampling a source file. The middle of a source file is the part that matters. Read it whole.
  • The truncated conclusion. Reading the tail of a log, finding no error, and reporting success — when the failure was logged mid-run and execution continued. Absence of an error in a sample is not evidence of absence in the file.
  • The masked exit status. A piped command returns the status of its last stage, so some-build | tail reports the status of tail, not of the build. Reading the tail of a build log is not the same as reading the build's exit code — capture the status separately.
  • Unreported gaps. Presenting a sample as though it were the file.
  • Paging the middle. Substituting many sequential window reads for one search.

Acceptance

  • The file was sized before it was read, and the whole-file read was ruled out on evidence, not assumption.
  • The sample's range and its unread gap are stated wherever the content is used or quoted.
  • Over-long lines are bounded and marked, so one line cannot swamp the sample.
  • No conclusion about the file as a whole rests on the sample alone; questions about the middle were answered by searching, not by paging.
  • Where an exit status matters, it was captured directly rather than inferred from tail output.

Version History

  • d5262e2 Current 2026-09-11 11:16

Same Skill Collection

.agents/skills/accessible-media-authoring/SKILL.md
.agents/skills/agent-prompt-engineering/SKILL.md
.agents/skills/agentic-safety-audit/SKILL.md
.agents/skills/audio-event-map-authoring/SKILL.md
.agents/skills/auto-scaffold/SKILL.md
.agents/skills/claim-verification/SKILL.md
.agents/skills/code-reachability-audit/SKILL.md
.agents/skills/code-review-loop/SKILL.md
.agents/skills/color-theory/SKILL.md
.agents/skills/conversation-design/SKILL.md
.agents/skills/copy-refinement/SKILL.md
.agents/skills/cross-file-relationship-synthesis/SKILL.md
.agents/skills/dependency-cycle-audit/SKILL.md
.agents/skills/dependency-health-triage/SKILL.md
.agents/skills/detection-as-code/SKILL.md
.agents/skills/diff-aware-semgrep-scan/SKILL.md
.agents/skills/differential-review/SKILL.md
.agents/skills/dimensional-analysis-check/SKILL.md
.agents/skills/dual-level-retrieval/SKILL.md
.agents/skills/figma-implement-design/SKILL.md
.agents/skills/forensic-timeline-authoring/SKILL.md
.agents/skills/game-design-fundamentals/SKILL.md
.agents/skills/game-mechanics-balancing/SKILL.md
.agents/skills/incident-response-runbook/SKILL.md
.agents/skills/interactive-audio-design/SKILL.md
.agents/skills/interface-ambiguity-check/SKILL.md
.agents/skills/keyword-clustering/SKILL.md
.agents/skills/knowledge-base-integration/SKILL.md
.agents/skills/layered-analysis-loop/SKILL.md
.agents/skills/level-design-patterns/SKILL.md
.agents/skills/locale-adaptation/SKILL.md
.agents/skills/narrative-structure/SKILL.md
.agents/skills/platform-compliance/SKILL.md
.agents/skills/player-engagement-psychology/SKILL.md
.agents/skills/requirements-elicitation/SKILL.md
.agents/skills/rule6-rights-gate/SKILL.md
.agents/skills/rule8-truth-gate/SKILL.md
.agents/skills/sandbox-provision-discipline/SKILL.md
.agents/skills/scope-decomposition/SKILL.md
.agents/skills/scope-estimation/SKILL.md
.agents/skills/security-ownership-map/SKILL.md
.agents/skills/security-threat-model/SKILL.md
.agents/skills/semgrep-rule-author/SKILL.md
.agents/skills/skill-description-trigger-authoring/SKILL.md
.agents/skills/sound-design-principles/SKILL.md
.agents/skills/structured-data-authoring/SKILL.md
.agents/skills/supply-chain-audit/SKILL.md
.agents/skills/take-over-resume/SKILL.md
.agents/skills/technical-seo-audit/SKILL.md

Metadata

Files
0
Version
d5262e2
Hash
385b463d
Indexed
2026-09-11 11:16

Home - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-09-13 05:02
浙ICP备14020137号-1 $Map of visitor$