/major-ai-skills:exit-code-fast-checkingfrom major-ai-skills
Check command exit codes and retain relevant errors when summarizing build or test results.
Ships in major-ai-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
When an agent runs a build tool, type-checker, or test suite (tsc --noEmit, cargo build, npm run lint), successful runs generate 100 to 800 lines of informational progress logs ("Compiling 140 modules...", "Emitting chunks...", "Done in 2.4s").
Ingesting hundreds of lines of successful build output burns 1,000+ context tokens without providing any new actionable information to the model.
The Zero-Stdout Exit Code Protocol intercepts subprocess execution: if the Exit Code is 0 (Success), stdout is suppressed and replaced with a compact 1-line confirmation token ([OK: exit 0]). Full output is streamed only when the exit code is non-zero (Failure).
┌─────────────────────────────────────────────────────────────┐
│ CLI Success Output Comparison │
│ │
│ Unfiltered Successful Build (650 Tokens): │
│ [webpack] Compiling 248 modules... │
│ [webpack] 10% building 24/248 modules... │
│ [webpack] 50% building 124/248 modules... │
│ [webpack] 100% compiled successfully in 2,420ms! │
│ [webpack] asset main.js 420 KiB [emitted] │
│ ↳ 650 tokens billed on meaningless progress text │
│ │
│ Exit Code Fast Check (8 Tokens - 98.7% Reduction): │
│ [COMMAND SUCCESS: exit 0 (tsc & webpack build clean)] │
│ ↳ 8 tokens billed, zero context pollution │
└─────────────────────────────────────────────────────────────┘
┌───────────────────────────────────────────────────────────────────────────┐
│ IF EXIT CODE == 0 (SUCCESS): │
│ • Suppress full stdout stream │
│ • Return compact confirmation: `[EXECUTION_SUCCESS: exit 0]` │
│ │
│ IF EXIT CODE != 0 (FAILURE): │
│ • Suppress successful info logs │
│ • Extract and stream ONLY the first 20 lines of `stderr` / error trace │
└───────────────────────────────────────────────────────────────────────────┘
import subprocess
from pathlib import Path
from typing import Tuple
def execute_command_with_exit_guard(cmd: list, cwd: Path = Path(".")) -> str:
"""Executes CLI command, suppressing stdout on success and emitting stderr on error."""
result = subprocess.run(
cmd,
cwd=cwd,
capture_output=True,
text=True
)
# Fast Success Path (Exit Code 0)
if result.returncode == 0:
return f"[SUCCESS: {' '.join(cmd)} (exit code 0)]"
# Failure Path (Exit Code != 0): Stream clean error lines only
error_output = result.stderr.strip() or result.stdout.strip()
error_lines = error_output.splitlines()
truncated_errors = "\n".join(error_lines[:25])
return (
f"[FAILED: {' '.join(cmd)} (exit code {result.returncode})]\n"
f"--- Error Output (First 25 lines) ---\n"
f"{truncated_errors}"
)
When constructing terminal execution strings:
# Type check silently; echo only on success or fail
tsc --noEmit --pretty false > /dev/null 2>&1 && echo "[TSC: CLEAN (exit 0)]" || tsc --noEmit
# Python lint check silently
flake8 src/ > /dev/null 2>&1 && echo "[LINT: CLEAN (exit 0)]" || flake8 src/
Evaluating 50 compiler / linter verification checks:
| Strategy | Total Ingested Tokens | Latency | Context Window Impact |
|---|---|---|---|
| Raw Stdout Stream (Every Run) | 32,500 tokens | 1.8s | 32.5% of context window consumed |
| Exit Code Fast Check Protocol | 400 tokens | 0.05s | 0.4% of context window (98.7% Savings!) |
MANDATORY: When executing verification tools, linters, and compilers where the only question is whether the operation passed or failed, suppress stdout on exit code
0. Stream error diagnostics only when the command exits with non-zero status.
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub alivirgo/major-ai-skills --plugin major-ai-skills412 skills in this plugin
/3d-slicerAutomate 3D Slicer research workflows with MRML, VTK/ITK, DICOM data, and Segment Editor. Use for software workflows, not clinical interpretation./abbreviated-git-statusInspect Git branch, staging, and working-tree changes with short or porcelain status output when a compact repository check is needed./ableton-liveAutomate Ableton Live sessions with Python MIDI Remote Scripts, Max for Live, AbletonOSC, and Link synchronization./act-as-a-personal-tutorExplain a subject step by step, assess prior knowledge, and use short exercises to check understanding before advancing.Other plugins' skills for the same job