head-tail-log-clipping

head-tail-log-clipping is a skill for Claude Code from alivirgo/Major-AI-Skills. It costs 27 tokens per session (1,247 once invoked), scanned A, original, MIT.

A method for shortening very large command and build logs by keeping their beginning and end while removing the middle.

In plain words
What is it for?
Use it when processing output from tests, Docker builds, package installs, or other commands that produce thousands of lines.
Why use it?
It keeps command details and final error messages visible without filling an agent's context with repetitive progress output.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin. Also seen: mentions Codex.

Part of the major-ai-skills plugin — 147 skills, 8 plugins shipped together

Good fit Use it when processing output from tests, Docker builds, package installs, or other commands that produce thousands of lines.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/alivirgo/major-ai-skills/head-tail-log-clipping
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add alivirgo/Major-AI-Skills --skill head-tail-log-clipping
Clone the repo
git clone --depth 1 https://github.com/alivirgo/Major-AI-Skills

Made for: Claude Code.

Or install major-ai-skills, the plugin that ships this one along with the rest of its 147 skills, 8 plugins.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for head-tail-log-clipping

README.md
[![agentmods](https://agentmods.dev/badge/skills/alivirgo/major-ai-skills/head-tail-log-clipping/github.svg)](https://agentmods.dev/skills/alivirgo/major-ai-skills/head-tail-log-clipping)
Your own site
<a href="https://agentmods.dev/skills/alivirgo/major-ai-skills/head-tail-log-clipping"><img src="https://agentmods.dev/badge/skills/alivirgo/major-ai-skills/head-tail-log-clipping/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for head-tail-log-clipping

Your own site · 80×15
<a href="https://agentmods.dev/skills/alivirgo/major-ai-skills/head-tail-log-clipping"><img src="https://agentmods.dev/badge/skills/alivirgo/major-ai-skills/head-tail-log-clipping.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 27 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,247 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00027 $0.01247
Opus 5 $0.00014 $0.00624
Sonnet 5 $0.00005 $0.00249
Haiku 4.5 $0.00003 $0.00125

Measured yesterday against content hash 05c320faabaa, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-12, from the pricing page.

Security

Grade A, and why

head-tail-log-clipping scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/head-tail-log-clipping/SKILL.md · 123 lines

How it starts

The opening of the file, as written. The whole thing — 123 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Head/Tail Log Clipping (Sandwich Truncation Protocol)

Overview

When running large test suites, Docker image builds, or package installations (npm test, cargo test, docker build), terminal commands frequently generate 500 to 5,000 lines of output.

In 99% of software failures, the critical diagnostic information is distributed in two places:

  1. The Head (First 15-25 lines): Command invocation arguments, environment variables, compiler flags, and target module names.
  2. The Tail (Last 30-50 lines): The fatal assertion failure, exact line number, exception stack trace, and final exit code summary.

The middle 90% of the log consists of redundant progress meters ("Passing test 1..140", "Downloading layer 4a3f..."). Ingesting unclipped logs burns 10,000+ tokens per failure turn.

The Head/Tail Log Clipping Protocol (also known as the Sandwich Truncation Protocol) extracts the Head and Tail while replacing the middle with a compact tombstone count.


3,000-Line Raw Log vs. Sandwich Truncation

┌─────────────────────────────────────────────────────────────┐
│                 Log Stream Ingestion Impact                 │
│                                                             │
│  Unclipped Terminal Log (3,000 Lines / 18,500 Tokens):      │
│  • Lines 1-20: `pytest tests/` (Environment info)           │
│  • Lines 21-2950: 2,930 lines of passing green dots / tests │
│  • Lines 2951-3000: AssertionError on line 42               │
│  ↳ 18,500 tokens billed, agent loses attention in middle    │
│                                                             │
│  Sandwich Truncated Log (60 Lines / 420 Tokens - 97.7% Cut):│
│  === HEAD (Lines 1-20) ===                                  │
│  pytest tests/auth/ -v --color=no                           │
│  [... 2,930 passing test lines truncated for efficiency ...]│
│  === TAIL (Lines 2960-3000) ===                             │
│  FAILED tests/auth/test_jwt.py::test_expiry - AssertionError │
│  ↳ 420 tokens billed, instant pinpoint fix on test_jwt.py   │
└─────────────────────────────────────────────────────────────┘

Read the full file on GitHub · 123 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday Changed · -22 tokens per session 05c320faabaa
  2. 7d ago First seen · 123 lines · 49 tokens per session scan A 2e92284282f2

Subscribe to this mod's changes

head-tail-log-clipping is a skill published in the GitHub repository alivirgo/Major-AI-Skills (1 stars, last pushed today), licensed MIT. It adds 27 tokens to every session and 1,247 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-05.

Related

Other skills, from other repositories

agenttrace-session-audit

Audit local AI coding-agent sessions with agenttrace for cost, tool failures, latency, anomalies, health, diffs, and CI gates.

sickn33/agentic-awesome-skills · 34 tokens

error-experience-library

An error knowledge base that stores recurring error patterns, their causes, and the fixes that worked. It can search past entries and track whether each suggested fix succeeded.

hashgraph-online/awesome-codex-plugins · 46 tokens

agent-memory-mcp-v2

Agent Memory Skill workflow skill. Use this skill when the user needs A hybrid memory system that provides persistent, searchable knowledge management for AI agents (Architecture, Patterns, Decisions) and the operator should preserve the upstream workflow, copied support files, and provenance before merging or handing…

diegosouzapw/awesome-omni-skills · 62 tokens

azure-network-watcher

Expert knowledge for Azure Network Watcher development including troubleshooting, decision making, limits & quotas, security, configuration, and integrations & coding patterns. Use when configuring flow logs, Traffic Analytics, packet capture, VPN monitoring, or KQL/Terraform integrations, and other Azure Network…

MicrosoftDocs/Agent-Skills · 101 tokens

aio-golang-mastery

Write, review, and lint Go code. Lint mode runs go build, go vet, golangci-lint, govulncheck, nilaway, deadcode, and race detection (race detector), then applies idiomatic fixes. Reference mode covers concurrency, error handling, generics, testing, gRPC, and production hardening. Use when asked to lint golang, run a…

aiocean/claude-plugins · 111 tokens

aio-gitnexus

Install, configure, and manage the GitNexus code intelligence engine — index codebase, setup MCP, check status, troubleshoot, and document local git-hook auto-refresh for master-only workflows.

aiocean/claude-plugins · 44 tokens