
printing-press-amend
熱門從以下兩種輸入來源之一修訂(Amend)已發布的 CLI:(1) Dogfood 模式:探勘當前 Claude Code 對話紀錄(transcript)中的使用摩擦點(如缺少的 Flag、手動構建的 API Payload、靜默返回 null 等);(2) 直接輸入模式:接受使用者提出的具體需求(如重新命名指令、新增指令或 Feed、修復指定 Bug、選擇性探測源站點以尋找新端點)。與使用者確認改動範圍後,自主規劃並執行修復,清理個人敏感資訊(PII),並對 mvanhorn/printing-press-library 建立 PR。包含兩個人工確認點(User-in-loop):擷取需求後的範圍確認,以及建立前的 PR 草稿確認。觸發短語:"amend the CLI", "submit a patch", "fix what I just dogfooded", "open a PR for this CLI", "patch this CLI", "add features to my CLI", "rename this command", "add these feeds to <cli>", "sniff for new APIs in <cli>", "amend with these ideas", "use printing-press-amend", "run printing-press-amend"。
從以下兩種輸入來源之一修訂(Amend)已發布的 CLI:(1) Dogfood 模式:探勘當前 Claude Code 對話紀錄(transcript)中的使用摩擦點(如缺少的 Flag、手動構建的 API Payload、靜默返回 null 等);(2) 直接輸入模式:接受使用者提出的具體需求(如重新命名指令、新增指令或 Feed、修復指定 Bug、選擇性探測源站點以尋找新端點)。與使用者確認改動範圍後,自主規劃並執行修復,清理個人敏感資訊(PII),並對 mvanhorn/printing-press-library 建立 PR。包含兩個人工確認點(User-in-loop):擷取需求後的範圍確認,以及建立前的 PR 草稿確認。觸發短語:"amend the CLI", "submit a patch", "fix what I just dogfooded", "open a PR for this CLI", "patch this CLI", "add features to my CLI", "rename this command", "add these feeds to <cli>", "sniff for new APIs in <cli>", "amend with these ideas", "use printing-press-amend", "run printing-press-amend"。
/printing-press-amend
將 Dogfood 測試過程轉化為對公共程式庫(Public Library)中已印製 CLI 的 PR。
/printing-press-amend # 從對話紀錄中自動偵測目標 CLI
/printing-press-amend superhuman # 明確指定簡短名稱
/printing-press-amend superhuman-pp-cli
/printing-press-amend "$PRESS_LIBRARY/superhuman"
此 Skill 位於本儲存庫(即印刷機 / Machine)中,並對公共程式庫中的已印製 CLI 進行操作。它與 /printing-press-publish(新增 CLI)、/printing-press-polish(發布前優化 CLI)以及 /printing-press-retro(對印刷機本身進行反思回顧)為兄弟指令。上述 Skill 皆未涵蓋由真實對話過程中的摩擦點所驅動的「發布後 CLI 修訂」。
此 Skill 產生的產物語意上屬於「Patch」(Git/PR 概念中的補丁),由公共程式庫的 .printing-press-patches/ 目錄追蹤(每個 Patch 對應一個檔案)。行內的 // PATCH(...) 原始碼註解為選填的導覽輔助工具,便於對自訂站點進行 Grep 搜尋。Slash-Skill 的名稱取為 amend,是為了與現有的 cli-printing-press patch 二進位子指令做出區隔(後者是透過 AST 注入預先定義的功能,機制與意圖皆不相同)。
Setup
在執行任何操作之前:
<!-- PRESS_SETUP_CONTRACT_START -->
# min-binary-version: 4.0.0
# Derive scope first — needed for local build detection
_scope_dir="$(git rev-parse --show-toplevel 2>/dev/null || echo "$PWD")"
_scope_dir="$(cd "$_scope_dir" && pwd -P)"
# Prefer local build when running from inside the printing-press repo.
_press_repo=false
if [ -x "$_scope_dir/cli-printing-press" ] && [ -d "$_scope_dir/cmd/cli-printing-press" ]; then
_press_repo=true
export PATH="$_scope_dir:$PATH"
echo "Using local build: $_scope_dir/cli-printing-press"
elif ! command -v cli-printing-press >/dev/null 2>&1; then
if [ -x "$HOME/go/bin/cli-printing-press" ]; then
echo "cli-printing-press found at ~/go/bin/cli-printing-press but not on PATH."
echo "Add GOPATH/bin to your PATH: export PATH=\"\$HOME/go/bin:\$PATH\""
else
echo "cli-printing-press binary not found."
echo "Install with: go install github.com/mvanhorn/cli-printing-press/v4/cmd/cli-printing-press@latest"
fi
return 1 2>/dev/null || exit 1
fi
# Resolve and emit the absolute path the agent must use for every later
# `cli-printing-press` invocation. `export PATH` above only affects this one
# Bash tool call; subsequent calls open a fresh shell and resolve bare
# `cli-printing-press` against the user's default PATH, where a stale global
# can silently shadow the local build. The agent captures this marker and
# substitutes the absolute path into every later invocation.
if [ "$_press_repo" = "true" ]; then
PRINTING_PRESS_BIN="$_scope_dir/cli-printing-press"
else
PRINTING_PRESS_BIN="$(command -v cli-printing-press 2>/dev/null || true)"
fi
if ! command -v go >/dev/null 2>&1; then
echo ""
echo "[setup-error] Go toolchain not found."
echo ""
echo "This Printing Press flow runs Go-based build or validation commands."
echo "Install Go 1.26.5 or newer from https://go.dev/dl/, then verify with:"
echo " go version"
echo "Then re-run this skill."
echo ""
return 1 2>/dev/null || exit 1
fi
echo "PRINTING_PRESS_BIN=$PRINTING_PRESS_BIN"
_pp_semver_lt() {
awk -v a="$1" -v b="$2" 'BEGIN {
split(a, x, "."); split(b, y, ".")
for (i = 1; i <= 3; i++) {
if ((x[i] + 0) < (y[i] + 0)) exit 0
if ((x[i] + 0) > (y[i] + 0)) exit 1
}
exit 1
}'
}
_pp_go_version_norm() {
printf '%s\n' "$1" | sed -nE 's/.*go([0-9]+)\.([0-9]+)(\.([0-9]+))?.*/\1.\2.\4/p' | awk -F. 'NF >= 2 { printf "%d.%d.%d\n", $1, $2, ($3 == "" ? 0 : $3) }'
}
_pp_check_go_currency() {
_pp_go_installed="$(_pp_go_version_norm "$(go env GOVERSION 2>/dev/null)")"
_pp_go_required="$(_pp_go_version_norm "$(go version "$PRINTING_PRESS_BIN" 2>/dev/null)")"
if [ -z "$_pp_go_installed" ] || [ -z "$_pp_go_required" ] || ! _pp_semver_lt "$_pp_go_installed" "$_pp_go_required"; then
return 0
fi
echo ""
if [ "${GOTOOLCHAIN:-auto}" = "local" ]; then
echo "[setup-error] Go $_pp_go_required or newer is required by this cli-printing-press binary (installed: $_pp_go_installed)."
echo "GOTOOLCHAIN=local disables automatic toolchain downloads, so later Go quality gates would fail."
echo "Install Go $_pp_go_required or newer from https://go.dev/dl/, or unset GOTOOLCHAIN."
echo ""
return 1
fi
echo "[go-toolchain-old] Go $_pp_go_required or newer is required by this cli-printing-press binary (installed: $_pp_go_installed)."
echo "PRESS_GO_INSTALLED=$_pp_go_installed"
echo "PRESS_GO_REQUIRED=$_pp_go_required"
echo "Default GOTOOLCHAIN behavior may download the required toolchain during Go commands."
echo ""
return 0
}
_pp_check_go_currency || { return 1 2>/dev/null || exit 1; }
PRESS_BASE="$(basename "$_scope_dir" | tr '[:upper:]' '[:lower:]' | sed -E 's/[^a-z0-9_-]/-/g; s/^-+//; s/-+$//')"
if [ -z "$PRESS_BASE" ]; then
PRESS_BASE="workspace"
fi
PRESS_SCOPE="$PRESS_BASE-$(printf '%s' "$_scope_dir" | shasum -a 256 | cut -c1-8)"
PRESS_HOME="${PRINTING_PRESS_HOME:-$HOME/printing-press}"
PRESS_RUNSTATE="$PRESS_HOME/.runstate/$PRESS_SCOPE"
PRESS_LIBRARY="$PRESS_HOME/library"
PRESS_MANUSCRIPTS="$PRESS_HOME/manuscripts"
PRESS_CURRENT="$PRESS_RUNSTATE/current"
_pp_check_disk_space() {
_pp_disk_warn_kb="${PRINTING_PRESS_DISK_WARN_KB:-3145728}"
_pp_disk_fail_kb="${PRINTING_PRESS_DISK_FAIL_KB:-524288}"
case "$_pp_disk_warn_kb$_pp_disk_fail_kb" in
""|*[!0-9]*) return 0 ;;
esac
_pp_disk_path="$PRESS_HOME"
while [ ! -e "$_pp_disk_path" ] && [ "$_pp_disk_path" != "/" ]; do
_pp_disk_path="$(dirname "$_pp_disk_path")"
done
_pp_disk_avail_kb="$(df -Pk "$_pp_disk_path" 2>/dev/null | awk 'NR == 2 { print $4; exit }')"
case "$_pp_disk_avail_kb" in
""|*[!0-9]*) return 0 ;;
esac
if [ "$_pp_disk_avail_kb" -lt "$_pp_disk_fail_kb" ]; then
echo ""
echo "[setup-error] Critically low disk space on the Printing Press workspace volume."
echo "PRESS_DISK_PATH=$_pp_disk_path"
echo "PRESS_DISK_AVAIL_KB=$_pp_disk_avail_kb"
echo "PRESS_DISK_FAIL_KB=$_pp_disk_fail_kb"
echo "Free disk space or set PRINTING_PRESS_HOME to a volume with more room, then re-run this skill."
echo ""
return 1
fi
if [ "$_pp_disk_avail_kb" -lt "$_pp_disk_warn_kb" ]; then
echo ""
echo "[low-disk] Printing Press workspace volume is low on free space."
echo "PRESS_DISK_PATH=$_pp_disk_path"
echo "PRESS_DISK_AVAIL_KB=$_pp_disk_avail_kb"
echo "PRESS_DISK_WARN_KB=$_pp_disk_warn_kb"
echo "This flow may need several GiB for generated files, Go build cache, module downloads, or repository clones."
echo ""
fi
}
_pp_check_disk_space || { return 1 2>/dev/null || exit 1; }
mkdir -p "$PRESS_RUNSTATE" "$PRESS_LIBRARY" "$PRESS_MANUSCRIPTS" "$PRESS_CURRENT"
# --- Currency-floor check (standalone, fail-open) ---
# Hard-stop on binaries below the published supported floor so amend does not
# regenerate CLIs with since-fixed bugs. Repo checkouts build from source and
# are exempt. The floor is clamped to <= latest so a bad value cannot brick
# every install. Fetched fresh each run rather than reusing the printing-press
# preflight's TTL cache: amend is low-frequency, so the bounded curl + go-list
# cost is not worth its own cache here.
if [ "$_press_repo" != "true" ] && command -v curl >/dev/null 2>&1; then
_semver_lt() {
awk -v a="$1" -v b="$2" 'BEGIN {
split(a, x, "."); split(b, y, ".")
for (i = 1; i <= 3; i++) {
if ((x[i] + 0) < (y[i] + 0)) exit 0
if ((x[i] + 0) > (y[i] + 0)) exit 1
}
exit 1
}'
}
_floor_installed=$("$PRINTING_PRESS_BIN" version --json 2>/dev/null | sed -nE 's/.*"version"[[:space:]]*:[[:space:]]*"([^"]+)".*/\1/p')
_floor_doc=$(curl -fsSL --max-time 5 \
https://raw.githubusercontent.com/mvanhorn/cli-printing-press/main/supported-versions.txt 2>/dev/null || true)
_floor_min=$(printf '%s\n' "$_floor_doc" | awk -F= '/^min_supported=/{print $2; exit}')
_floor_reason=$(printf '%s\n' "$_floor_doc" | sed -nE 's/^reason=//p' | head -n 1)
_floor_latest=""
if command -v go >/dev/null 2>&1; then
_floor_latest=$(go list -m -json github.com/mvanhorn/cli-printing-press/v4@latest 2>/dev/null | awk '/"Version":/{v=$2; gsub(/[",]/,"",v); sub(/^v/,"",v); print v; exit}')
fi
if [ -n "$_floor_min" ] && [ -n "$_floor_installed" ] && [ -n "$_floor_latest" ] &&
_semver_lt "$_floor_installed" "$_floor_min" &&
! _semver_lt "$_floor_latest" "$_floor_min"; then
echo ""
echo "[upgrade-required] printing-press v$_floor_min is the minimum supported version (you have v$_floor_installed)"
echo "PRESS_REQUIRED_MIN=$_floor_min"
echo "PRESS_REQUIRED_INSTALLED=$_floor_installed"
echo "PRESS_REQUIRED_REASON=$_floor_reason"
echo ""
fi
fi
<!-- PRESS_SETUP_CONTRACT_END -->
執行完初始化設定合約(Setup Contract)後,請從標準輸出(stdout)中擷取 PRINTING_PRESS_BIN=<abs-path> 這一行。在此 Skill 中,後續每次調用 cli-printing-press ... 時,都必須使用該絕對路徑(替換為具體數值,而非直接使用 $PRINTING_PRESS_BIN 字串)——上述的 export PATH 僅對當前執行的單一 Bash 工具 call 生效,後續調用會開啟新的 Shell,此時直接輸入 cli-printing-press 會依使用者的預設 PATH 解析,導致舊版的全域安裝版本默默覆蓋本地建置版本。
若 Setup 輸出了 [go-toolchain-old] 或 [low-disk],請將此提醒提示給使用者並繼續執行,除非 Setup 同時輸出了 [setup-error]。[go-toolchain-old] 表示後續的 Go 指令可能會下載所需的 Toolchain,或在網路下載受阻時失敗;[low-disk] 則表示本次執行可能需要數 GiB 的可用空間來儲存產生的檔案、Go 編譯快取、模組下載或儲存庫 Clone。
擷取二進位檔路徑後,請檢查二進位檔版本的相容性。讀取此 Skill 的 YAML Frontmatter 中的 min-binary-version 欄位。執行 <PRINTING_PRESS_BIN> version --json 並從輸出中解析版本號。依據 SemVer 語意化版本規則將其與 min-binary-version 進行比較。若已安裝的二進位檔版本低於最低要求,請立即停止並告知使用者:「cli-printing-press 二進位檔 vX.Y.Z 低於所需的最低版本 vA.B.C。請執行 go install github.com/mvanhorn/cli-printing-press/v4/cmd/cli-printing-press@latest 以進行升級。」
若 Setup 合約輸出了 [upgrade-required] 區塊,代表已安裝的二進位檔低於已發布的最低支援版本下限(Currency Floor, PRESS_REQUIRED_MIN)——使用較舊的版本重新產生 CLI 可能會帶入已被修復的 Bug(PRESS_REQUIRED_REASON)。這是獨立於 min-binary-version 的硬性限制(Hard Gate):切勿使用該二進位檔進行修訂或重新產生。請透過 AskUserQuestion 提供一鍵升級選項——是 — 立即升級(執行 go install github.com/mvanhorn/cli-printing-press/v4/cmd/cli-printing-press@latest,重新擷取 `PRINTING_PRE...



