Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

skill-shortener

БесплатноЗапускает вложенные скриптыНе проверен

Refactor a too-long SKILL.md by progressive disclosure: measure token cost, classify every section KEEP/CUT/MOVE, shorten the body into references/ and…

luongnv89от luongnv89★ 976 звёзд на GitHub

Об этом скилле

Skill Shortener

Shrink an over-long SKILL.md by progressive disclosure: what the agent needs on every activation stays in the body, everything else moves behind a pointer that says when to load it — or is cut outright.

Three load layers decide where a piece of content belongs:

Layer Holds Costs
always-loaded frontmatter name + description every turn
on-trigger the SKILL.md body every activation
on-demand references/, scripts/, assets/ only when read

The bar is behavior-preserving: the shortened skill drives the same process as the long one. Line count is the score, not the goal — a run that reaches 400 lines by deleting a loop's stop condition has failed, however good the number looks.

Two modes

Pick one before Phase 0; they diverge at Phase 2.

  • Mode 1 — shorten (default). Phases 0–4: measure, classify, plan, apply on approval, verify. Every "shorten this", "this SKILL.md is too long", "cut its token cost", "apply progressive disclosure" request is Mode 1.
  • Mode 2 — audit only. Phases 0–2, then stop and hand over the plan. Nothing outside the workdir is written, so the repo sync and snapshot in Phase 0 are skipped. Use when the user wants to know what would move, or will apply the split themselves.

Run variables

Every snippet below uses these four. Bash tool calls do not share shell state, so re-declare them at the top of each call that needs them — an empty $SKILL_PATH turns cp -R "$SKILL_PATH/." into a copy of the filesystem root. Capture RUN_EPOCH once and reuse the number; never re-stamp it.

SS="<this-skill-dir>"                                                # this skill: absolute path of the dir holding this SKILL.md
SKILL_PATH="$HOME/.claude/skills/<target>"                           # the target: the dir holding SKILL.md
QV="<SKILL_CREATOR_DIR>/scripts/quick_validate.py"                   # the Phase 4 gate: literal path from the acquire
# RUN_EPOCH: reuse the number the preflight printed, e.g. RUN_EPOCH=1787948450

Dependency Preflight (mandatory)

This skill invokes skill-creator, declared in frontmatter dependencies: it runs that skill's quick_validate.py as the Phase 4 frontmatter gate. Run this first, in both modes:

RUN_EPOCH="$(date +%s)"; echo "run_started_epoch=$RUN_EPOCH" >&2   # anchors Run stats
command -v asm >/dev/null || {
  echo "Missing installer: npm install -g agent-skill-manager" >&2
  exit 1
}
asm deps discover skill-shortener --json

Mode 1 only, before the snapshot below — the first step that changes anything — the main agent acquires the dependency. Phase 4 always needs it, and a miss found after Phase 3 would strand a half-applied split:

asm deps acquire skill-creator --session "skill-shortener-$RUN_EPOCH" --json

Set QV to scripts/quick_validate.py under the directory holding the returned skillMdPath, and reuse that literal path. If the acquire fails, stop before the snapshot and report its error — never continue with a partial run. Mode 2 never acquires.

The main agent releases the lease from its own finally/shutdown handling — after Phase 4, or at any earlier stop:

asm deps release --session "skill-shortener-$RUN_EPOCH" --json

Snapshot and Repo Sync Before Edits (mandatory)

Always snapshot first. The most common target — ~/.claude/skills/<name>/ — is not a git repository, so git is not a guaranteed undo path, and this skill rewrites a whole directory rather than one file:

: "${SKILL_PATH:?set SKILL_PATH to the target skill directory}"
: "${RUN_EPOCH:?reuse the epoch captured in the preflight}"
case "$PWD/" in "$SKILL_PATH"/*) echo "cwd is inside $SKILL_PATH — run from outside it, or the workdir is copied into itself" >&2; exit 1;; esac
SNAP=".skill-shortener/snapshot-$RUN_EPOCH"
mkdir -p "$SNAP" && cp -R "$SKILL_PATH/." "$SNAP/"

Then sync only if the target directory itself is a git work tree root — rev-parse --git-dir succeeds for any nested path inside a larger repo, and must not trigger fetch/pull of that tree:

toplevel="$(git -C "$SKILL_PATH" rev-parse --show-toplevel 2>/dev/null || true)"
if [ -n "$toplevel" ] && [ "$(cd "$SKILL_PATH" && pwd -P)" = "$toplevel" ]; then
  branch="$(git -C "$SKILL_PATH" rev-parse --abbrev-ref HEAD)"
  git -C "$SKILL_PATH" fetch origin && git -C "$SKILL_PATH" pull --rebase origin "$branch"
else
  echo "note: $SKILL_PATH is not a git work tree root — $SNAP is the only undo path; skip fetch/pull"
fi

If tracked files are modified (git -C "$SKILL_PATH" status --porcelain --untracked-files=no prints anything): git -C "$SKILL_PATH" stash push without -u, sync, then git -C "$SKILL_PATH" stash pop. Untracked files stay in place; other sessions may

Полный SKILL.md на GitHub

Установить skill-shortener в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Bash
Read
Write
Edit
Grep
Glob

Вложенные файлы

LICENSE.txtdocs/README.mdevals/evals.jsonreferences/behavior-preservation.mdreferences/cut-list.mdreferences/split-patterns.mdscripts/measure_skill.pyscripts/test_condition_cues.pyscripts/verify_shorten.py

FAQ

Что делает скилл skill-shortener?

Refactor a too-long SKILL.md by progressive disclosure: measure token cost, classify every section KEEP/CUT/MOVE, shorten the body into references/ and scripts/, verify nothing was lost. Don't use for authoring new skills, eval retrofits, or prose.

Как установить скилл skill-shortener?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл skill-shortener запускает скрипты?

Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.

Похожие скиллы

Сравнить skill-shortener с