[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7AWMP6Z0GV93GAW6MY8EYSP":3,"skill-same:01M7AWMP6Z0GV93GAW6MY8EYSP":57},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":34,"commitSha":35,"skillDirectory":36,"forksCount":37,"repositoryHtmlUrl":38,"repositoryHomepageUrl":6,"ownerHtmlUrl":39,"ownerBlogUrl":40,"ownerDescription":41,"updatedAt":42,"install":43,"resources":56},"01M7AWMP6Z0GV93GAW6MY8EYSP","printing-press-publish",null,"Publish a generated CLI to the printing-press-library repo","barkleesanders\u002Fclaude-code-starter","barkleesanders","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F30680901?v=4","01M7AW019CGBYWDA8MFJEN1JXC","Barklee Sanders","01M7AW01A5H994ASJ2QZPW67AV",4,"MIT","https:\u002F\u002Fgithub.com\u002Fbarkleesanders\u002Fclaude-code-starter\u002Fblob\u002Fmain\u002Fskills\u002Fprinting-press-publish\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: printing-press-publish\ndescription: Publish a generated CLI to the printing-press-library repo\nversion: 0.1.0\nmin-binary-version: \"4.0.0\"\nallowed-tools:\n  - Bash\n  - Read\n  - Write\n  - Edit\n  - Glob\n  - Grep\n  - AskUserQuestion\n---\n\n# \u002Fprinting-press publish\n\nPublish a generated CLI from your local library to the [printing-press-library](https:\u002F\u002Fgithub.com\u002Fmvanhorn\u002Fprinting-press-library) repo as a pull request.\n\n```bash\n\u002Fprinting-press publish notion-pp-cli\n\u002Fprinting-press publish notion\n\u002Fprinting-press publish notion --from-polish\n\u002Fprinting-press publish notion --skip-live-test=auth-unavailable\n\u002Fprinting-press publish notion --blocked-api-journal notion\n\u002Fprinting-press publish\n```\n\n## Direct User Invocation Required\n\nPublishing can fork `mvanhorn\u002Fprinting-press-library`, push a branch, and open or\nupdate a PR. Before setup or validation, check the invocation context. If this\nskill was invoked as a chained continuation from `printing-press-polish`'s\nPublish Offer, including an `AskUserQuestion` answer or auto-resolved polish\nrecommendation, stop immediately and tell the user to send\n`\u002Fprinting-press-publish \u003Ccli-name> --from-polish` in a fresh message. A fresh\nuser-authored request that explicitly asks to publish is sufficient; do not add\nanother confirmation prompt on top of a direct publish request.\n\nIf the fresh user-authored request includes `--from-polish`, record\n`POLISH_HANDOFF=true` for the terminal-state step and ignore that marker when\nresolving the CLI name. The marker is not a second confirmation and is not\npassed to `cli-printing-press`; it only preserves standalone polish's old\npost-publish retro offer after the fresh-turn publish completes.\n\nIf the request includes `--blocked-api-journal`, enter **Blocked API Journal\nMode** below instead of the normal printed-CLI publish flow. This mode may be\ninvoked from `\u002Fprinting-press`'s hold-path menu after the user explicitly chose\n\"Add to blocked-API journal\"; that parent menu choice is sufficient user\nauthorization for the public-library journal write. Do not require a second\nfresh-turn invocation for this journal-only mode.\n\nIf the fresh user-authored request includes `--skip-live-test=\u003Creason>`, record\nthe exact non-empty reason as `SKIP_LIVE_TEST_REASON` and remove the flag before\nresolving the CLI name. This is the only supported escape valve for the\npublish-time live test gate. Use it only for auth-unavailable, known upstream\noutage, LAN-unreachable hardware APIs, or similarly concrete operator-approved\ncases; never infer a skip from ordinary latency or from the presence of an\nolder Phase 5 marker.\n\nThe public library treats `library\u002F\u003Ccategory>\u002F\u003Capi-slug>\u002F.printing-press.json`\nand `manifest.json` as the source of truth for registry-display fields. Do not\nedit `registry.json`, README catalog cells, or `cli-skills\u002Fpp-\u003Capi-slug>\u002FSKILL.md`\nin publish PRs; all three are bot-regenerated post-merge by the library's own\nworkflows. The library's `Fail on changes to generated artifacts` check in\n`verify-library-conventions.yml` hard-fails any PR — fork or same-repo — whose\ndiff against base touches `registry.json` or `cli-skills\u002Fpp-*\u002FSKILL.md`, so a\npublish that includes either is pre-rejected before review.\n\nThe public library also owns per-CLI release accounting. Do not manually bump\n`CHANGELOG.md`, `.printing-press-release.json`, or runtime `var version = ...`\nfor a publish PR. Fresh printed CLIs may include blank release-ledger skeletons;\nthe library's post-merge workflow assigns the final `YYYY.M.N` release and\nstamps the runtime version after merge. When replacing an existing public\nlibrary CLI, preserve its existing release-ledger files so changelog history is\nnot lost in the reprint PR.\n\n`blocked-apis.json` is different: it is a hand-maintained public-library journal,\nnot a generated registry surface. Journal-only PRs may edit `blocked-apis.json`\nand must not stage `library\u002F`, `registry.json`, README catalog cells, or\n`cli-skills\u002F`.\n\n## Blocked API Journal Mode\n\nUse this mode only when the invocation includes `--blocked-api-journal`. It\nrecords a held `\u002Fprinting-press` attempt whose blocker is likely to repeat for\nother users until a machine or upstream issue changes.\n\nRequired fields from the caller:\n\n- `slug`: canonical API slug, not the CLI binary name.\n- `attempted_at`: `YYYY-MM-DD`.\n- `verdict`: `hold`.\n- `reason`: concise blocker reason, with no secrets, local paths, cookies,\n  tokens, or account-specific details.\n- `blocking_issue`: Printing Press issue number if known, otherwise `null`.\n- `permanent`: boolean.\n\nIf the caller did not provide one of these fields, infer only safe values from\nthe current run context. If `reason` is missing or vague, stop and ask for one\nspecific blocker sentence; do not write an unhelpful journal entry.\n\nRun the normal Setup, Configuration, scoped clone cleanup, and GitHub auth\nchecks, then prepare the public-library clone exactly as the normal publish\nflow does: fork if needed, ensure `upstream` points to\n`mvanhorn\u002Fprinting-press-library`, fetch `upstream`, and reset the clone to\n`upstream\u002Fmain` before editing.\n\nThen update only `$PUBLISH_REPO_DIR\u002Fblocked-apis.json`:\n\n```bash\ncd \"$PUBLISH_REPO_DIR\"\nif [ ! -f blocked-apis.json ]; then\n  printf '[]\\n' > blocked-apis.json\nfi\njq --arg slug \"\u003Capi-slug>\" \\\n   --arg attempted_at \"\u003CYYYY-MM-DD>\" \\\n   --arg verdict \"hold\" \\\n   --arg reason \"\u003Creason>\" \\\n   --argjson blocking_issue '\u003Cnumber-or-null>' \\\n   --argjson permanent '\u003Ctrue-or-false>' '\n  (if type == \"array\" then . else [] end)\n  | map(select(.slug != $slug))\n  + [{\n      slug: $slug,\n      attempted_at: $attempted_at,\n      verdict: $verdict,\n      reason: $reason,\n      blocking_issue: $blocking_issue,\n      permanent: $permanent\n    }]\n  | sort_by(.slug)\n' blocked-apis.json > blocked-apis.json.tmp || {\n  rm -f blocked-apis.json.tmp\n  echo \"Error: jq failed to update blocked-apis.json\"\n  exit 1\n}\nif ! jq empty blocked-apis.json.tmp; then\n  rm -f blocked-apis.json.tmp\n  echo \"Error: blocked-apis.json update produced invalid JSON\"\n  exit 1\nfi\nmv blocked-apis.json.tmp blocked-apis.json\n```\n\nCreate a journal branch and PR:\n\n```bash\ngit checkout -B chore\u002Fblocked-api-\u003Capi-slug>\ngit add blocked-apis.json\ngit commit -m \"chore(\u003Capi-slug>): journal blocked API\"\ngit push --force-with-lease -u origin chore\u002Fblocked-api-\u003Capi-slug>\n```\n\nOpen the PR against `mvanhorn\u002Fprinting-press-library` with a body that includes:\n\n- the held API slug and reason\n- whether the block is permanent or tied to `blocking_issue`\n- the expected Phase 0 behavior: future `\u002Fprinting-press \u003Capi-slug>` runs warn\n  before repeating the attempt\n\nAfter the PR is open, report the URL and stop. Do not continue into normal\nprinted-CLI package, live-test, registry, or skill-mirror steps.\n\n## Setup\n\nBefore doing anything else:\n\n\u003C!-- PRESS_SETUP_CONTRACT_START -->\n```bash\n# min-binary-version: 4.0.0\n\n# Derive scope first — needed for local build detection\n_scope_dir=\"$(git rev-parse --show-toplevel 2>\u002Fdev\u002Fnull || echo \"$PWD\")\"\n_scope_dir=\"$(cd \"$_scope_dir\" && pwd -P)\"\n\n# Prefer local build when running from inside the printing-press repo.\n_press_repo=false\nif [ -x \"$_scope_dir\u002Fcli-printing-press\" ] && [ -d \"$_scope_dir\u002Fcmd\u002Fcli-printing-press\" ]; then\n  _press_repo=true\n  export PATH=\"$_scope_dir:$PATH\"\n  echo \"Using local build: $_scope_dir\u002Fcli-printing-press\"\nelif ! command -v cli-printing-press >\u002Fdev\u002Fnull 2>&1; then\n  if [ -x \"$HOME\u002Fgo\u002Fbin\u002Fcli-printing-press\" ]; then\n    echo \"cli-printing-press found at ~\u002Fgo\u002Fbin\u002Fcli-printing-press but not on PATH.\"\n    echo \"Add GOPATH\u002Fbin to your PATH:  export PATH=\\\"\\$HOME\u002Fgo\u002Fbin:\\$PATH\\\"\"\n  else\n    echo \"cli-printing-press binary not found.\"\n    echo \"Install with:  go install github.com\u002Fmvanhorn\u002Fcli-printing-press\u002Fv4\u002Fcmd\u002Fcli-printing-press@latest\"\n  fi\n  return 1 2>\u002Fdev\u002Fnull || exit 1\nfi\n\n# Resolve and emit the absolute path the agent must use for every later\n# `cli-printing-press` invocation. `export PATH` above only affects this one\n# Bash tool call; subsequent calls open a fresh shell and resolve bare\n# `cli-printing-press` against the user's default PATH, where a stale global\n# can silently shadow the local build. The agent captures this marker and\n# substitutes the absolute path into every later invocation.\nif [ \"$_press_repo\" = \"true\" ]; then\n  PRINTING_PRESS_BIN=\"$_scope_dir\u002Fcli-printing-press\"\nelse\n  PRINTING_PRESS_BIN=\"$(command -v cli-printing-press 2>\u002Fdev\u002Fnull || true)\"\nfi\necho \"PRINTING_PRESS_BIN=$PRINTING_PRESS_BIN\"\n\nPRESS_BASE=\"$(basename \"$_scope_dir\" | tr '[:upper:]' '[:lower:]' | sed -E 's\u002F[^a-z0-9_-]\u002F-\u002Fg; s\u002F^-+\u002F\u002F; s\u002F-+$\u002F\u002F')\"\nif [ -z \"$PRESS_BASE\" ]; then\n  PRESS_BASE=\"workspace\"\nfi\n\nPRESS_SCOPE=\"$PRESS_BASE-$(printf '%s' \"$_scope_dir\" | shasum -a 256 | cut -c1-8)\"\nPRESS_HOME=\"${PRINTING_PRESS_HOME:-$HOME\u002Fprinting-press}\"\nPRESS_RUNSTATE=\"$PRESS_HOME\u002F.runstate\u002F$PRESS_SCOPE\"\nPRESS_LIBRARY=\"$PRESS_HOME\u002Flibrary\"\nPRESS_MANUSCRIPTS=\"$PRESS_HOME\u002Fmanuscripts\"\nPRESS_CURRENT=\"$PRESS_RUNSTATE\u002Fcurrent\"\n\nmkdir -p \"$PRESS_RUNSTATE\" \"$PRESS_LIBRARY\" \"$PRESS_MANUSCRIPTS\" \"$PRESS_CURRENT\"\n```\n\u003C!-- PRESS_SETUP_CONTRACT_END -->\n\nAfter running the setup contract, capture the `PRINTING_PRESS_BIN=\u003Cabs-path>` line from stdout. **Every subsequent `cli-printing-press ...` invocation in this skill must use that absolute path** (substitute the value, not the literal `$PRINTING_PRESS_BIN` token) — `export PATH` above only affects the single Bash tool call it runs in, so later calls open a fresh shell where bare `cli-printing-press` resolves against the user's default `PATH` and a stale global can shadow the local build.\n\nAfter capturing the binary path, check binary version compatibility. Read the `min-binary-version` field from this skill's YAML frontmatter. Run `\u003CPRINTING_PRESS_BIN> version --json` and parse the version from the output. Compare it to `min-binary-version` using semver rules. If the installed binary is older than the minimum, stop immediately and tell the user: \"cli-printing-press binary vX.Y.Z is older than the minimum required vA.B.C. Run `go install github.com\u002Fmvanhorn\u002Fcli-printing-press\u002Fv4\u002Fcmd\u002Fcli-printing-press@latest` to update.\"\n\n## Configuration\n\n```\nPUBLISH_REPO_URL=\"https:\u002F\u002Fgithub.com\u002Fmvanhorn\u002Fprinting-press-library\"\nPUBLISH_REPO_DIR=\"$PRESS_HOME\u002F.publish-repo-$PRESS_SCOPE\"\nPUBLISH_CONFIG=\"$PRESS_HOME\u002F.publish-config-$PRESS_SCOPE.json\"\n```\n\n### Publish config\n\n`$PUBLISH_CONFIG` stores persistent publish settings as JSON. On first publish, create it with defaults. The user can edit it to change the library repo or module path base.\n\n```json\n{\n  \"managed_by\": \"printing-press-publish\",\n  \"repo_url\": \"https:\u002F\u002Fgithub.com\u002Fmvanhorn\u002Fprinting-press-library\",\n  \"access\": \"push\",\n  \"protocol\": \"ssh\",\n  \"clone_path\": \"\u003Chome>\u002Fprinting-press\u002F.publish-repo-\u003Cscope>\",\n  \"scope_dir\": \"\u002Fabsolute\u002Fpath\u002Fto\u002Fsource\u002Fworktree\",\n  \"module_path_base\": \"github.com\u002Fmvanhorn\u002Fprinting-press-library\u002Flibrary\"\n}\n```\n\nThe `module_path_base` field sets the Go module path prefix for published CLIs. During packaging, the full module path is constructed as `\u003Cmodule_path_base>\u002F\u003Ccategory>\u002F\u003Capi-slug>`. If the user wants CLIs published to a different repo or path, they edit this field.\nStore expanded absolute paths for `clone_path` and `scope_dir` so cleanup can\ncheck them without relying on shell-specific `~` expansion. The `managed_by`\nfield is required before cleanup may delete anything.\n\n### Scoped clone cleanup\n\nBefore creating or reusing `$PUBLISH_REPO_DIR`, prune scoped publish clones whose\nsource worktree no longer exists. This keeps concurrent worktrees isolated\nwithout accumulating one library clone forever per short-lived worktree.\n\n```bash\nfind \"$PRESS_HOME\" -maxdepth 1 -name '.publish-config-*.json' -type f | while read -r cfg; do\n  [ \"$cfg\" = \"$PUBLISH_CONFIG\" ] && continue\n  managed_by=$(jq -r '.managed_by \u002F\u002F empty' \"$cfg\" 2>\u002Fdev\u002Fnull || true)\n  scope_dir=$(jq -r '.scope_dir \u002F\u002F empty' \"$cfg\" 2>\u002Fdev\u002Fnull || true)\n  clone_path=$(jq -r '.clone_path \u002F\u002F empty' \"$cfg\" 2>\u002Fdev\u002Fnull || true)\n  [ \"$managed_by\" = \"printing-press-publish\" ] || continue\n  [ -z \"$scope_dir\" ] && continue\n  [ -e \"$scope_dir\" ] && continue\n  [ -d \"$clone_path\u002F.git\" ] || continue\n  case \"$clone_path\" in \"$PRESS_HOME\"\u002F.publish-repo-*) ;; *) continue ;; esac\n  origin=$(git -C \"$clone_path\" remote get-url origin 2>\u002Fdev\u002Fnull || true)\n  case \"$origin\" in *mvanhorn\u002Fprinting-press-library*|*\u002F*\u002Fprinting-press-library*) ;; *) continue ;; esac\n  [ -z \"$(git -C \"$clone_path\" status --porcelain)\" ] || continue\n  [ \"$(git -C \"$clone_path\" rev-parse --abbrev-ref HEAD 2>\u002Fdev\u002Fnull || true)\" = \"main\" ] || continue\n  rm -rf \"$clone_path\" \"$cfg\"\ndone\n```\n\n## Step 1: Prerequisites\n\nVerify `gh` is authenticated:\n\n```bash\ngh auth status\n```\n\nIf this fails, stop and tell the user: \"GitHub CLI is not authenticated. Run `gh auth login` first.\"\n\n## Step 2: Resolve API Slug\n\nRun:\n\n```bash\ncli-printing-press library list --json\n```\n\nParse the JSON output into a list of CLIs. The library is now keyed by API slug (the directory name), not CLI name.\n\n**Name resolution order** (matches the score skill for consistency):\n\n1. **Exact match:** If the argument matches a directory name (API slug) exactly, use it\n2. **CLI name match:** If no exact match, try matching against `cli_name` fields, then derive the API slug from the manifest's `api_name` field\n3. **Suffix match:** If no match yet, try `\u003Cargument>-pp-cli` against `cli_name` fields\n4. **Glob match:** If no suffix match, search for entries where `cli_name` or `api_name` contains the argument as a substring. Cap at 5 most-recent matches. If multiple matches, present them via AskUserQuestion and let the user pick\n5. **No match:** List all available CLIs and ask the user to pick or re-enter\n6. **No argument:** If invoked with no name, list all CLIs sorted by modification time and let the user pick\n\nOnce resolved, read the manifest's `api_name` field to get the API slug. Use this slug for all downstream operations (branch names, registry entries, collision detection, path construction). The `cli_name` from the manifest is only used for binary-level operations.\n\nWhen presenting matches, show the API slug and modification time in a human-friendly format (e.g., \"2 hours ago\", \"3 days ago\").\n\n## Step 3: Determine Category\n\nRead `.printing-press.json` from the resolved CLI directory.\n\n**Category resolution order:**\n\n1. If the manifest has a `category` field, present it for confirmation:\n   > \"Publishing as **\u003Ccategory>**. OK?\"\n   Give the user the option to change it\n\n2. If no `category` but `catalog_entry` is present, look it up:\n   ```bash\n   cli-printing-press catalog show \u003Ccatalog_entry> --json\n   ```\n   Extract the category from the result. Present for confirmation\n\n3. If neither provides a category, present the full list via AskUserQuestion:\n   - developer-tools, monitoring, cloud, project-management\n   - productivity, social-and-messaging, sales-and-crm, marketing\n   - payments, auth, commerce, ai, food-and-dining, health, maps, media-and-entertainment, devices, other\n   - travel\n\n## Step 4: Validate\n\nRun:\n\n```bash\ncli-printing-press publish validate --dir \u003Ccli-dir> --json\n```\n\n`govulncheck` in this step is intentionally scoped to `\u003Ccli-dir>` only. It\nuses the default `govulncheck .\u002F...` mode so reachable symbol findings block\npublish, while merely-required vulnerable modules without a call path do not\nbecome release blockers. Do not replace this with a full public-library scan or\n`govulncheck -show verbose`.\n\nParse the JSON result. Display each check result to the user:\n\n```\nValidating \u003Capi-slug>...\n  manifest        PASS\n  phase5          PASS\n  go mod tidy     PASS\n  govulncheck     PASS\n  go vet          PASS\n  go build        PASS\n  --help          PASS\n  --version       PASS\n  manuscripts     WARN (no manuscripts found)\n```\n\nIf `\"passed\": false`, report the failing checks and **stop**. Do not create a partial PR.\nThe `manifest` check is authoritative for the public-library provenance\ncontract: current `schema_version`, `run_id`, `printing_press_version`,\n`printer`, `printer_name`, and MCP metadata files when MCP is advertised. If it\nfails, tell the user to re-print or re-package with current Printing Press\nmetadata before opening the library PR.\n\nSave the `help_output` field from the result — it's used in the PR description.\n\n## Step 4.5: Live End-to-End Gate\n\nBefore touching the managed publish clone, rerun the live behavioral gate\nagainst the CLI that is about to be published. Step 4 proves the source builds\nand validates structurally; this step proves the current post-edit tree still\nworks against the real upstream API. Do not rely on an older\n`phase5-acceptance.json` from generation or polish because the CLI may have\nbeen hand-edited since that marker was written.\n\nResolve the Phase 5 proofs directory from the CLI manifest:\n\n```bash\nMANIFEST=\"$CLI_DIR\u002F.printing-press.json\"\nAPI_SLUG=$(jq -r '.api_name \u002F\u002F empty' \"$MANIFEST\")\nCLI_NAME=$(jq -r '.cli_name \u002F\u002F empty' \"$MANIFEST\")\nRUN_ID=$(jq -r '.run_id \u002F\u002F empty' \"$MANIFEST\")\nAUTH_TYPE=$(jq -r '.auth_type \u002F\u002F \"none\"' \"$MANIFEST\")\nAUTH_ENV=$(jq -r '.auth_env_vars[0] \u002F\u002F empty' \"$MANIFEST\")\n\nif [ -z \"$API_SLUG\" ] || [ -z \"$RUN_ID\" ]; then\n  echo \"ERROR: manifest is missing api_name or run_id; cannot run publish live gate.\"\n  exit 1\nfi\n\nPROOFS_DIR=\"$CLI_DIR\u002F.manuscripts\u002F$RUN_ID\u002Fproofs\"\nif [ ! -d \"$PROOFS_DIR\" ] && [ -n \"$API_SLUG\" ] && [ -d \"$PRESS_MANUSCRIPTS\u002F$API_SLUG\u002F$RUN_ID\u002Fproofs\" ]; then\n  PROOFS_DIR=\"$PRESS_MANUSCRIPTS\u002F$API_SLUG\u002F$RUN_ID\u002Fproofs\"\nelif [ ! -d \"$PROOFS_DIR\" ] && [ -n \"$CLI_NAME\" ] && [ -d \"$PRESS_MANUSCRIPTS\u002F$CLI_NAME\u002F$RUN_ID\u002Fproofs\" ]; then\n  PROOFS_DIR=\"$PRESS_MANUSCRIPTS\u002F$CLI_NAME\u002F$RUN_ID\u002Fproofs\"\nfi\nmkdir -p \"$PROOFS_DIR\"\n```\n\nIf `SKIP_LIVE_TEST_REASON` is unset, run full live dogfood and write a fresh\nacceptance marker into that proofs directory:\n\n```bash\nLIVE_GATE_JSON=\"$PROOFS_DIR\u002Fpublish-live-gate.json\"\nLIVE_GATE_ARGS=(\n  dogfood\n  --dir \"$CLI_DIR\"\n  --live\n  --level full\n  --timeout 120s\n  --write-acceptance \"$PROOFS_DIR\u002Fphase5-acceptance.json\"\n  --json\n)\nif [ -n \"$AUTH_ENV\" ]; then\n  LIVE_GATE_ARGS+=(--auth-env \"$AUTH_ENV\")\nfi\n\nrm -f \"$PROOFS_DIR\u002Fphase5-skip.json\"\nif ! \"$PRINTING_PRESS_BIN\" \"${LIVE_GATE_ARGS[@]}\" >\"$LIVE_GATE_JSON\"; then\n  echo \"Publish live gate failed. See $LIVE_GATE_JSON and $PROOFS_DIR\u002Fphase5-acceptance.json.\"\n  jq -r '.tests[]? | select(.status == \"fail\") | \"- \\(.command) [\\(.kind)]: \\(.reason \u002F\u002F \"failed\")\"' \"$LIVE_GATE_JSON\" 2>\u002Fdev\u002Fnull || true\n  exit 1\nfi\n```\n\nOn failure, stop exactly like Step 4's `passed: false`: no managed clone, no\nbranch, no package, no PR. Report the failed command, exit code when present,\nstderr or reason snippet, and the path to the fresh proof files so the operator\ncan re-run dogfood and fix the CLI.\n\nIf `SKIP_LIVE_TEST_REASON` is set from `--skip-live-test=\u003Creason>`, write a\nfresh skip marker instead of running dogfood:\n\n```bash\nSKIP_REASON_LOWER=$(printf '%s' \"$SKIP_LIVE_TEST_REASON\" | tr '[:upper:]' '[:lower:]')\ncase \"$AUTH_TYPE\" in\n  api_key|bearer_token|oauth2)\n    ;;\n  none)\n    case \"$SKIP_REASON_LOWER\" in\n      *upstream*outage*|lan-unreachable-from-generation-host)\n        ;;\n      *)\n        echo \"ERROR: --skip-live-test is only valid for auth_type=none during a known upstream outage or LAN-unreachable hardware case.\"\n        exit 1\n        ;;\n    esac\n    ;;\n  *)\n    echo \"ERROR: --skip-live-test is not valid for auth_type=$AUTH_TYPE. Run the live gate instead.\"\n    exit 1\n    ;;\nesac\n\nAPI_KEY_AVAILABLE=false\nif [ -n \"$AUTH_ENV\" ] && [ -n \"${!AUTH_ENV:-}\" ]; then\n  API_KEY_AVAILABLE=true\nfi\n\nrm -f \"$PROOFS_DIR\u002Fphase5-acceptance.json\"\njq -n \\\n  --arg api \"$API_SLUG\" \\\n  --arg run \"$RUN_ID\" \\\n  --arg reason \"$SKIP_LIVE_TEST_REASON\" \\\n  --arg auth \"$AUTH_TYPE\" \\\n  --argjson api_key_available \"$API_KEY_AVAILABLE\" \\\n  --argjson browser_session_available false \\\n  '{\n    schema_version: 1,\n    api_name: $api,\n    run_id: $run,\n    status: \"skip\",\n    level: \"none\",\n    skip_reason: $reason,\n    auth_context: {\n      type: $auth,\n      api_key_available: $api_key_available,\n      browser_session_available: $browser_session_available\n    }\n  }' > \"$PROOFS_DIR\u002Fphase5-skip.json\"\nif [ \"$SKIP_REASON_LOWER\" = \"lan-unreachable-from-generation-host\" ]; then\n  tmp_marker=$(mktemp \"${TMPDIR:-\u002Ftmp}\u002Fphase5-skip.XXXXXX\")\n  jq '.auth_context.local_network_only = true' \"$PROOFS_DIR\u002Fphase5-skip.json\" > \"$tmp_marker\" &&\n    mv \"$tmp_marker\" \"$PROOFS_DIR\u002Fphase5-skip.json\"\nfi\nLIVE_GATE_JSON=\"\"\n```\n\nThen rerun Step 4's validation:\n\n```bash\n\"$PRINTING_PRESS_BIN\" publish validate --dir \"$CLI_DIR\" --json\n```\n\nThis second validation proves the fresh acceptance or skip marker satisfies the\nsame Phase 5 contract that package and publish rely on. If it fails, stop\nbefore Step 5.\n\n## Step 5: Managed Clone\n\nThe publish skill manages its own clone of the library repo at `$PUBLISH_REPO_DIR`.\n\n### First-time setup\n\nIf `$PUBLISH_REPO_DIR` does not exist:\n\n1. **Detect push access:**\n   ```bash\n   GH_USER=$(gh api user --jq '.login')\n   HAS_PUSH=$(gh api repos\u002Fmvanhorn\u002Fprinting-press-library --jq '.permissions.push' 2>\u002Fdev\u002Fnull || echo \"false\")\n   ```\n\n2. **Detect git protocol:**\n   ```bash\n   USE_SSH=false\n   if ssh -T git@github.com 2>&1 | grep -q \"successfully authenticated\"; then\n     USE_SSH=true\n   fi\n   ```\n\n3. **Clone based on access:**\n\n   **Push access** (`HAS_PUSH` is `true`):\n   ```bash\n   # Clone directly — origin IS the upstream\n   if [ \"$USE_SSH\" = \"true\" ]; then\n     REPO_URL=\"git@github.com:mvanhorn\u002Fprinting-press-library.git\"\n   else\n     REPO_URL=\"https:\u002F\u002Fgithub.com\u002Fmvanhorn\u002Fprinting-press-library.git\"\n   fi\n   # Lightweight clone: blobless + shallow + sparse. The publish flow only\n   # touches the target CLI's own directory — it no longer regenerates the\n   # cli-skills\u002Fregistry mirror (see Step 6) — so materializing every other\n   # CLI's source is wasted bandwidth and disk (a full clone is multiple GB;\n   # this is tens of MB). The cone keeps `tools`, `cli-skills`, and the target\n   # `library\u002F\u003Ccategory>` so the in-category find\u002Frm\u002Fcopy operations below work\n   # on a real working tree. Cross-category collision checks use `git ls-tree`\n   # (which reads the full tree from the blobless clone) instead of `ls`.\n   git clone --filter=blob:none --depth 1 --sparse \"$REPO_URL\" \"$PUBLISH_REPO_DIR\"\n   git -C \"$PUBLISH_REPO_DIR\" sparse-checkout set tools cli-skills library\u002F\u003Ccategory>\n   ```\n\n   **No push access** (`HAS_PUSH` is `false`):\n   ```bash\n   # Fork first — fail explicitly if forking is blocked\n   if ! gh repo fork mvanhorn\u002Fprinting-press-library --clone=false 2>&1; then\n     echo \"ERROR: Could not fork mvanhorn\u002Fprinting-press-library.\"\n     echo \"The repo may restrict forking, or you may already have a fork with a different name.\"\n     echo \"Fork manually at https:\u002F\u002Fgithub.com\u002Fmvanhorn\u002Fprinting-press-library\u002Ffork\"\n     exit 1\n   fi\n   FORK=\"$GH_USER\u002Fprinting-press-library\"\n\n   # Build URLs based on protocol preference\n   if [ \"$USE_SSH\" = \"true\" ]; then\n     FORK_URL=\"git@github.com:$FORK.git\"\n     UPSTREAM_URL=\"git@github.com:mvanhorn\u002Fprinting-press-library.git\"\n   else\n     FORK_URL=\"https:\u002F\u002Fgithub.com\u002F$FORK.git\"\n     UPSTREAM_URL=\"https:\u002F\u002Fgithub.com\u002Fmvanhorn\u002Fprinting-press-library.git\"\n   fi\n\n   # Lightweight clone (blobless + shallow + sparse) — see the push-access\n   # branch above for the rationale and cone contents.\n   git clone --filter=blob:none --depth 1 --sparse \"$FORK_URL\" \"$PUBLISH_REPO_DIR\"\n   cd \"$PUBLISH_REPO_DIR\"\n   git sparse-checkout set tools cli-skills library\u002F\u003Ccategory>\n   git remote add upstream \"$UPSTREAM_URL\"\n   git fetch --filter=blob:none --depth 1 upstream\n   ```\n\n4. **Cache the config:**\n   ```json\n   {\n     \"managed_by\": \"printing-press-publish\",\n     \"repo_url\": \"https:\u002F\u002Fgithub.com\u002Fmvanhorn\u002Fprinting-press-library\",\n     \"access\": \"push or fork\",\n     \"gh_user\": \"\u003Cgh username>\",\n     \"protocol\": \"ssh or https\",\n     \"clone_path\": \"\u003Cexpanded $PUBLISH_REPO_DIR>\",\n     \"scope_dir\": \"\u003Cabsolute source worktree path>\",\n     \"module_path_base\": \"github.com\u002Fmvanhorn\u002Fprinting-press-library\u002Flibrary\"\n   }\n   ```\n   Write to `$PUBLISH_CONFIG`. The `access` field determines the flow for all subsequent steps. The `gh_user` field is used for cross-repo PR heads. The `module_path_base` always references the upstream repo (PRs land there).\n\n### Subsequent publishes\n\nRead `$PUBLISH_CONFIG`, then re-check access in case it changed (user was granted push access, or access was revoked):\n\n```bash\nCURRENT_ACCESS=$(gh api repos\u002Fmvanhorn\u002Fprinting-press-library --jq '.permissions.push' 2>\u002Fdev\u002Fnull || echo \"false\")\nCACHED_ACCESS=$(jq -r .access \"$PUBLISH_CONFIG\")\n\nif [ \"$CURRENT_ACCESS\" = \"true\" ] && [ \"$CACHED_ACCESS\" = \"fork\" ]; then\n  echo \"Access upgraded to push. Reconfiguring clone...\"\n  rm -rf \"$PUBLISH_REPO_DIR\"\n  # Re-run first-time setup with push access\nfi\nif [ \"$CURRENT_ACCESS\" = \"false\" ] && [ \"$CACHED_ACCESS\" = \"push\" ]; then\n  echo \"Push access revoked. Reconfiguring clone with fork...\"\n  rm -rf \"$PUBLISH_REPO_DIR\"\n  # Re-run first-time setup with fork access\nfi\n```\n\nIf the clone was removed due to an access change, re-run first-time setup above. Otherwise, freshen the clone to match the canonical upstream:\n\n```bash\ncd \"$PUBLISH_REPO_DIR\"\n\nif [ \"$(jq -r .access $PUBLISH_CONFIG)\" = \"push\" ]; then\n  # Push access: origin IS the upstream\n  git fetch --filter=blob:none --depth 1 origin\n  git checkout main\n  git reset --hard origin\u002Fmain\nelse\n  # Fork: origin is the fork, upstream is canonical\n  git fetch --filter=blob:none --depth 1 upstream\n  git checkout main\n  git reset --hard upstream\u002Fmain\n  # Also sync origin (fork) so git push works cleanly\n  git push origin main --force-with-lease 2>\u002Fdev\u002Fnull || true\nfi\n\n# Existing managed clones may already be sparse for a different publish\n# category. Refresh the cone for the current target category before Step 6 uses\n# filesystem-based removal and copy operations.\nif git -C \"$PUBLISH_REPO_DIR\" config --bool core.sparseCheckout | grep -qx true; then\n  git -C \"$PUBLISH_REPO_DIR\" sparse-checkout set tools cli-skills library\u002F\u003Ccategory>\nfi\n```\n\nVerify the clone is healthy:\n\n```bash\ngit rev-parse --is-inside-work-tree\ntest \"$(git rev-parse --abbrev-ref HEAD)\" = \"main\"\n```\n\nIf this fails, the clone is corrupt. Remove `$PUBLISH_REPO_DIR` and re-run first-time setup.\n\n### Interrupted state recovery\n\nBefore creating a new branch, check for uncommitted changes:\n\n```bash\ncd \"$PUBLISH_REPO_DIR\"\ngit status --porcelain\n```\n\nIf there are uncommitted changes, ask the user via AskUserQuestion:\n- \"Reset and start fresh\"\n- \"Continue with existing changes\"\n\nIf reset, run `git checkout -- . && git clean -fd`.\n\n### Pre-package publication-state snapshot\n\nBefore Step 6 mutates the managed clone, record whether this API slug already\nexists in the public library tree. Step 6 removes and replaces\n`library\u002F*\u002F\u003Capi-slug>`, so any collision or publication-path decision made\nafter packaging must use this pre-package snapshot, not a fresh `ls`.\n\n```bash\n# Read from the git tree, not the working dir: the sparse checkout only\n# materializes the target category, but a slug can collide in any category.\nPREEXISTING_MERGED_PATHS=$(git -C \"$PUBLISH_REPO_DIR\" ls-tree -r --name-only HEAD \\\n  | sed -n 's#^\\(library\u002F[^\u002F]*\u002F\u003Capi-slug>\\)\u002F.*#\\1#p' | sort -u || true)\nPREEXISTING_MERGED_COLLISION=false\nif [ -n \"$PREEXISTING_MERGED_PATHS\" ]; then\n  PREEXISTING_MERGED_COLLISION=true\n  # If this is a category-change reprint, materialize the existing category path\n  # before Step 6 runs filesystem-based ledger preservation and removal.\n  if git -C \"$PUBLISH_REPO_DIR\" config --bool core.sparseCheckout | grep -qx true; then\n    while IFS= read -r EXISTING_MERGED_PATH; do\n      [ -n \"$EXISTING_MERGED_PATH\" ] || continue\n      if [ \"$EXISTING_MERGED_PATH\" != \"library\u002F\u003Ccategory>\u002F\u003Capi-slug>\" ]; then\n        git -C \"$PUBLISH_REPO_DIR\" sparse-checkout add \"$EXISTING_MERGED_PATH\"\n      fi\n    done \u003C\u003CEOF\n$PREEXISTING_MERGED_PATHS\nEOF\n  fi\nfi\n```\n\n## Step 6: Package\n\nRead `$PUBLISH_CONFIG` to get `module_path_base`. Construct the full module path using the API slug (not the CLI name):\n\n```\nMODULE_PATH=\"\u003Cmodule_path_base>\u002F\u003Ccategory>\u002F\u003Capi-slug>\"\n```\n\nFor example: `github.com\u002Fmvanhorn\u002Fprinting-press-library\u002Flibrary\u002Fproductivity\u002Fnotion`\n\nRun `publish package` with `--target` to stage the CLI into a unique temporary\ndirectory, then copy it into the publish repo:\n\n```bash\nPUBLISH_STAGING_ROOT=\"\u002Ftmp\u002Fprinting-press\u002Fpublish\"\nmkdir -p \"$PUBLISH_STAGING_ROOT\"\nSTAGING_PARENT=\"$(mktemp -d \"$PUBLISH_STAGING_ROOT\u002F\u003Capi-slug>-XXXXXX\")\"\nSTAGING_DIR=\"$STAGING_PARENT\u002Fpackage\"\n\ncli-printing-press publish package \\\n  --dir \u003Ccli-dir> \\\n  --category \u003Ccategory> \\\n  --target \"$STAGING_DIR\" \\\n  --module-path \"$MODULE_PATH\" \\\n  --json\n```\n\nParse the JSON result. Note the `staged_dir`, `module_path`, `manuscripts_included`, and `run_id`. The `module_path` field confirms the Go module path that was set in the packaged CLI's `go.mod` and import paths.\n\n`publish package` performs the mandatory vendor-prefix secret scan over the staged CLI, including copied manuscripts, before returning success. If it reports `vendor-prefix tokens detected`, stop and remove or redact the reported file:line findings before retrying. This is a hard gate and does not depend on `gitleaks`, `trufflehog`, or destination-repo push protection.\n\nThen copy the staged CLI into the publish repo, replacing any existing version\nwhile preserving the public library's release ledger files when this is a\nreprint:\n\n```bash\nSTAGED_CLI_DIR=\"$STAGING_DIR\u002Flibrary\u002F\u003Ccategory>\u002F\u003Capi-slug>\"\nDEST_CATEGORY_DIR=\"$PUBLISH_REPO_DIR\u002Flibrary\u002F\u003Ccategory>\"\nDEST_CLI_DIR=\"$DEST_CATEGORY_DIR\u002F\u003Capi-slug>\"\n\nif [ ! -d \"$STAGED_CLI_DIR\" ]; then\n  echo \"missing staged CLI directory: $STAGED_CLI_DIR\" >&2\n  exit 1\nfi\nmkdir -p \"$DEST_CATEGORY_DIR\"\n\n# Preserve release-ledger files from the current public-library entry before\n# removing it. New CLIs omit .printing-press-release.json until the library's\n# post-merge workflow stamps a real release; reprints keep existing changelog\n# history and release metadata until that workflow stamps the next release.\nRELEASE_LEDGER_TMP=\"$(mktemp -d)\"\nPUBLISH_SWAP_DIR=\"$(mktemp -d \"$DEST_CATEGORY_DIR\u002F.\u003Capi-slug>.XXXXXX\")\"\ntrap 'rm -rf \"$RELEASE_LEDGER_TMP\" \"$PUBLISH_SWAP_DIR\"' EXIT\nfor LEDGER_FILE in CHANGELOG.md .printing-press-release.json; do\n  EXISTING_LEDGER=\"$(find \"$PUBLISH_REPO_DIR\u002Flibrary\" -mindepth 3 -maxdepth 3 -path \"*\u002F\u003Capi-slug>\u002F$LEDGER_FILE\" -print -quit)\"\n  if [ -n \"$EXISTING_LEDGER\" ]; then\n    cp \"$EXISTING_LEDGER\" \"$RELEASE_LEDGER_TMP\u002F$LEDGER_FILE\"\n  fi\ndone\n\n# Copy staged CLI into a same-category swap dir before deleting the current\n# public-library entry. This keeps a failed copy from leaving the publish repo\n# with the old CLI removed.\ncp -R \"$STAGED_CLI_DIR\u002F.\" \"$PUBLISH_SWAP_DIR\u002F\"\n\nfor LEDGER_FILE in CHANGELOG.md .printing-press-release.json; do\n  if [ -f \"$RELEASE_LEDGER_TMP\u002F$LEDGER_FILE\" ]; then\n    cp \"$RELEASE_LEDGER_TMP\u002F$LEDGER_FILE\" \"$PUBLISH_SWAP_DIR\u002F$LEDGER_FILE\"\n  fi\ndone\n\n# Remove existing version (handles category changes), then atomically install\n# the prepared replacement within the destination category.\nrm -rf \"$PUBLISH_REPO_DIR\u002Flibrary\"\u002F*\u002F\"\u003Capi-slug>\"\nmv \"$PUBLISH_SWAP_DIR\" \"$DEST_CLI_DIR\"\nrm -rf \"$RELEASE_LEDGER_TMP\"\ntrap - EXIT\n\n# Remove root-level binaries (should not be committed). publish package\n# already strips these before the copy; this rm -f is belt-and-suspenders\n# for the agent path. Cover the names local build paths can drop: bare slug,\n# CLI binary, live-dogfood probe binary, and MCP peer.\nrm -f \"$PUBLISH_REPO_DIR\u002Flibrary\u002F\u003Ccategory>\u002F\u003Capi-slug>\u002F\u003Capi-slug>\" \\\n      \"$PUBLISH_REPO_DIR\u002Flibrary\u002F\u003Ccategory>\u002F\u003Capi-slug>\u002F\u003Ccli-name>\" \\\n      \"$PUBLISH_REPO_DIR\u002Flibrary\u002F\u003Ccategory>\u002F\u003Capi-slug>\u002F\u003Ccli-name>-dogfood\" \\\n      \"$PUBLISH_REPO_DIR\u002Flibrary\u002F\u003Ccategory>\u002F\u003Capi-slug>\u002F\u003Capi-slug>-pp-mcp\"\n\n# Defense-in-depth: validate printer attribution before README and registry surfaces.\nPRINTER=$(jq -r '.printer \u002F\u002F \"\"' \"$PUBLISH_REPO_DIR\u002Flibrary\u002F\u003Ccategory>\u002F\u003Capi-slug>\u002F.printing-press.json\")\nPRINTER_NAME=$(jq -r '.printer_name \u002F\u002F \"\"' \"$PUBLISH_REPO_DIR\u002Flibrary\u002F\u003Ccategory>\u002F\u003Capi-slug>\u002F.printing-press.json\")\nif [ -z \"$PRINTER\" ]; then\n  echo \"ERROR: manifest .printer is empty. Set 'git config --global github.user \u003Cyour-handle>' and re-print before publishing.\"\n  exit 1\nfi\nif [ \"$PRINTER\" = \"USER\" ] || [ \"$PRINTER\" = \"user\" ]; then\n  echo \"ERROR: manifest .printer is the literal sentinel \\\"$PRINTER\\\" (git config github.user was unset at print time). Set it and re-print before publishing.\"\n  exit 1\nfi\nif [ -z \"$PRINTER_NAME\" ]; then\n  echo \"ERROR: manifest .printer_name is empty. Set 'git config --global user.name \u003Cyour display name>' and re-print before publishing.\"\n  exit 1\nfi\n\n# Do NOT regenerate or commit `cli-skills\u002Fpp-\u003Capi-slug>\u002FSKILL.md` or\n# `registry.json` here. Both are regenerated post-merge by the library's\n# `generate-skills.yml` and `generate-registry.yml` workflows via\n# `[skip ci]` bot commits. The library's `Fail on changes to generated\n# artifacts` check in `verify-library-conventions.yml` hard-fails any PR\n# whose diff against base touches these files, regardless of fork vs\n# same-repo origin. The library no longer has an in-PR auto-fix path;\n# do not re-introduce a mirror or registry regen here. Also do NOT hand-update\n# CHANGELOG.md, .printing-press-release.json, or runtime version strings for\n# release accounting; the library release-ledger workflow owns those post-merge.\n\n# Verify this changed\u002Fnew CLI builds and has no reachable Go vulnerabilities from the publish repo\ncd \"$PUBLISH_REPO_DIR\u002Flibrary\u002F\u003Ccategory>\u002F\u003Capi-slug>\" \\\n  && go build .\u002F... \\\n  && go run golang.org\u002Fx\u002Fvuln\u002Fcmd\u002Fgovulncheck@v1.3.0 .\u002F...\n```\n\nKeep vulnerability verification scoped to `library\u002F\u003Ccategory>\u002F\u003Capi-slug>` in\npublish PRs. The public library is a historical collection and cannot be kept\nfully current on every unrelated PR; whole-library govulncheck sweeps belong in\na scheduled\u002Freporting workflow, while blocking CI should scan only added or\nchanged CLI modules.\n\nAfter the publish repo copy and build verification are complete, remove the staging\ndirectory:\n\n```bash\nrm -rf \"$STAGING_PARENT\"\n```\n\nNote: `staged_dir` is keyed by the API slug (e.g., `espn`), matching the publish repo's directory layout. The copy step is a same-name copy, not a rename.\n\n## Step 6.5: Record Customizations\n\nBefore collision detection or branch creation, inspect the packaged CLI's\ncustomizations index:\n\nThe index ships in one of two shapes: the per-patch directory\n`.printing-press-patches\u002F` (current) or the legacy single-array\n`.printing-press-patches.json` (older prints, not yet normalized). Validate\nwhichever is present:\n\n```bash\nPATCHES_DIR=\"$PUBLISH_REPO_DIR\u002Flibrary\u002F\u003Ccategory>\u002F\u003Capi-slug>\u002F.printing-press-patches\"\nPATCHES_INDEX=\"$PUBLISH_REPO_DIR\u002Flibrary\u002F\u003Ccategory>\u002F\u003Capi-slug>\u002F.printing-press-patches.json\"\nif [ -d \"$PATCHES_DIR\" ]; then\n  # Per-patch directory: every \u003Cid>.json must be a JSON object carrying the same\n  # provenance the legacy single-array file kept at its top level (now per file),\n  # so validation is at parity with the legacy branch below. _meta.json\n  # (CLI-global lists) and .gitkeep are exempt.\n  for f in \"$PATCHES_DIR\"\u002F*.json; do\n    [ -e \"$f\" ] || continue\n    [ \"$(basename \"$f\")\" = \"_meta.json\" ] && continue\n    if ! jq -e '\n      (type == \"object\") and\n      (.schema_version | type == \"number\") and\n      (.id | type == \"string\" and length > 0) and\n      (.applied_at | type == \"string\" and length > 0) and\n      (.base_run_id | type == \"string\" and length > 0) and\n      (.base_printing_press_version | type == \"string\" and length > 0)\n    ' \"$f\" >\u002Fdev\u002Fnull; then\n      echo \"ERROR: packaged CLI has a malformed patch file $f. Reprint with a current cli-printing-press binary before publishing.\"\n      exit 1\n    fi\n  done\nelif [ -f \"$PATCHES_INDEX\" ]; then\n  if ! jq -e '\n    (.schema_version | type == \"number\") and\n    (.applied_at | type == \"string\" and length > 0) and\n    (.base_run_id | type == \"string\" and length > 0) and\n    (.base_printing_press_version | type == \"string\" and length > 0) and\n    (.patches | type == \"array\")\n  ' \"$PATCHES_INDEX\" >\u002Fdev\u002Fnull; then\n    echo \"ERROR: packaged CLI has malformed .printing-press-patches.json. Reprint with a current cli-printing-press binary before publishing.\"\n    exit 1\n  fi\nelse\n  echo \"ERROR: packaged CLI is missing its patches index (.printing-press-patches\u002F or .printing-press-patches.json). Reprint with a current cli-printing-press binary before publishing.\"\n  exit 1\nfi\n```\n\nFresh prints from current `cli-printing-press generate` include the\n`.printing-press-patches\u002F` directory with just a `.gitkeep`; leave it unchanged\nwhen no hand customization was made after generation. If neither shape is\npresent, the CLI was generated by an older binary; reprint with a current\n`cli-printing-press` build rather than synthesizing the\ndeterministic provenance fields by hand.\n\n## Step 6.6: Record contributor attribution\n\nWhen the human running this publish is **not** the CLI's original creator,\nrecord them as a contributor so they are credited in the README byline, NOTICE,\nand the public registry. The command is idempotent — it skips the creator and\nanyone already listed — so it is safe to run on every publish:\n\n```bash\n\"$PRINTING_PRESS_BIN\" contributors add \\\n  --dir \"$PUBLISH_REPO_DIR\u002Flibrary\u002F\u003Ccategory>\u002F\u003Capi-slug>\" \\\n  || echo \"note: this binary predates 'contributors add'; skipping contributor recording\"\n```\n\nThe step is best-effort: `contributors add` is an additive command, so a binary\nthat predates it simply skips recording rather than blocking the publish (the\n`min-binary-version` floor only tracks the major). Pass `--front` when this\npublish is a reprint (a from-scratch regeneration) so the reprinter is listed\nfirst among contributors. Never edit `contributors[]` or the `creator` block by\nhand — the creator is permanent, and the command owns the list (matching the\nmanifest-as-authority rule).\n\nIf you changed generated CLI files during the print or publish session, record\none concise entry per customization before opening the library PR — one\n`.printing-press-patches\u002F\u003Cid>.json` file per patch (the directory supersedes the\nlegacy `patches[]` array, so concurrent PRs never conflict). These entries are\nthe durable hand-edit contract that tells future agents and regen tooling what\nmust be preserved beyond generator output.\n\nUse this shape (one file, `.printing-press-patches\u002F\u003Cid>.json`):\n\n```json\n{\n  \"schema_version\": 2,\n  \"id\": \"\u003Capi-slug>-\u003Cshort-feature-name>\",\n  \"applied_at\": \"\u003CYYYY-MM-DD>\",\n  \"base_run_id\": \"\u003Ccopy from .printing-press.json>\",\n  \"base_printing_press_version\": \"\u003Ccopy from .printing-press.json>\",\n  \"summary\": \"What changed (one sentence).\",\n  \"reason\": \"Why the generated output needed this customization.\",\n  \"files\": [\"internal\u002Fcli\u002Fexample.go\"],\n  \"validated_outcome\": \"Optional: focused check that proved the customization.\",\n  \"upstream_issue\": \"Optional: https:\u002F\u002Fgithub.com\u002Fmvanhorn\u002Fcli-printing-press\u002Fissues\u002F\u003Cn>\"\n}\n```\n\nRules:\n\n- Filename is the patch `id`. Use kebab-case ids prefixed with the API slug for\n  grep-ability across the public library.\n- Keep `summary` and `reason` short. Each entry is an index, not a duplicate\n  of the git diff.\n- Include non-Go support files in `files` when they are part of the same\n  code-level customization. README\u002FSKILL.md-only polish does not need a patch\n  manifest entry.\n- Inline `\u002F\u002F PATCH(...)` source comments are optional navigation aids. The public\n  library verifier requires a patches index (the directory or the legacy file)\n  and well-formed entries; it does not require a marker\u002Fcomment pairing.\n- If an entry exists only to work around an old verifier or pipeline bug that no\n  longer applies, delete the stale workaround file instead of carrying it\n  forward.\n\nFor the authoritative public-library authoring contract, read the\n`mvanhorn\u002Fprinting-press-library` `AGENTS.md` section\n\"`.printing-press-patches\u002F` records library-side customizations\".\n\n## Step 7: Collision Detection & Resolution\n\nAfter the managed clone is freshened, check for name collisions before creating a branch or PR. This replaces the previous \"Check for Existing PR\" step.\n\n### Detection\n\nRun these checks in sequence:\n\n**1. Check merged CLIs in managed clone:**\n\n```bash\nMERGED_COLLISION=\"$PREEXISTING_MERGED_COLLISION\"\nMERGED_PATHS=\"$PREEXISTING_MERGED_PATHS\"\n```\n\nUse the pre-package snapshot from Step 5. Do not re-run `ls\n\"$PUBLISH_REPO_DIR\u002Flibrary\"\u002F*\u002F\"\u003Capi-slug>\"` here: Step 6 has already copied the\nnew package into that path, so a fresh `ls` would make every new print look like\na merged collision. If `MERGED_COLLISION=true`, note the category path from\n`MERGED_PATHS`.\n\n**2. Check all open PRs (any author):**\n\n```bash\ngh pr list --repo mvanhorn\u002Fprinting-press-library --head \"feat\u002F\u003Capi-slug>\" --state open --json number,title,url,author\n```\n\nIf the list is non-empty, record `PR_COLLISION=true`. For each PR, note the PR number, URL, and author login.\n\n**3. Identify own PRs:**\n\nFilter the PR list from step 2 by `--author @me`:\n\nFor fork-based PRs, the head includes the username prefix:\n\n```bash\nACCESS=$(jq -r .access \"$PUBLISH_CONFIG\")\nGH_USER=$(jq -r .gh_user \"$PUBLISH_CONFIG\")\n\nif [ \"$ACCESS\" = \"fork\" ]; then\n  HEAD_REF=\"$GH_USER:feat\u002F\u003Capi-slug>\"\nelse\n  HEAD_REF=\"feat\u002F\u003Capi-slug>\"\nfi\n\ngh pr list --repo mvanhorn\u002Fprinting-press-library --head \"$HEAD_REF\" --state open --author @me --json number,title,url\n```\n\nIf found, record `OWN_PR=true`, store `EXISTING_PR_NUMBER` and `EXISTING_PR_URL`.\n\n**If no open PR was found**, also check for a previously merged PR on the same branch — by ANY author, not just yours:\n\n```bash\nMERGED_PR=$(gh pr list --repo mvanhorn\u002Fprinting-press-library --head \"$HEAD_REF\" --state merged --json number --jq '.[0].number' 2>\u002Fdev\u002Fnull)\n```\n\nIf `MERGED_PR` is non-empty, the branch name was already used and merged. Set `BRANCH_MERGED=true` so Step 8 creates a new branch name (e.g., `feat\u002F\u003Capi-slug>-YYYYMMDD`) instead of reusing the merged branch. Do NOT force-push onto a merged branch — `gh pr edit` would silently update a closed PR nobody is watching.\n\nThe author-agnostic lookup also catches **squash-zombie branches**: GitHub squash-merge leaves the source branch behind on the remote, with pre-squash commit refs that look \"ahead of main\" but are content-equivalent to the squash commit. Without this check, the skill misclassifies the zombie as fresh-publish, then `git push -u` fails because the remote branch already exists. Timestamping sidesteps the issue entirely.\n\n### No collision\n\nIf no merged CLI exists and no open PRs match (other than your own), set `EXISTING_PR_NUMBER` from the own-PR check (or empty if none) and proceed to Step 8 normally.\n\nIf an existing open PR of yours was found, inform the user:\n> \"Found your open PR #N for `\u003Capi-slug>`. Will update it with the new version.\"\n\n### Collision detected — display info\n\nShow the user what was found:\n\n```\n⚠️  Name collision detected for \u003Capi-slug>\n\n  Merged: \u003Ccategory>\u002F\u003Capi-slug> exists in the library\n  Open PR: #\u003Cnumber> by \u003Cauthor> — \u003Curl>\n```\n\nShow all applicable lines. If `OWN_PR=true`, tag the PR as \"(yours)\".\n\n### Resolution paths\n\nPresent three options via AskUserQuestion:\n\n**If `OWN_PR=true` (your own open PR exists):**\n- **Update** — Update your existing PR with the new version (default, preserves current behavior)\n- **Alongside** — Rename yours with a qualifier and publish next to the existing one\n- **Bail** — Cancel the publish\n\n**If PR collision exists but is another user's, or merged collision only:**\n- **Replace** — Intentionally overwrite the existing CLI\n- **Alongside** — Rename yours with a qualifier and publish next to the existing one\n- **Bail** — Cancel the publish and view the existing CLI\u002FPR\n\n#### Update path (own PR)\n\nThis is the existing update flow with a divergence guard. Set\n`EXISTING_PR_NUMBER` from the detection step and proceed to Step 8, which\nfetches the current PR branch head, checks for branch-only fixes that the new\npackage would revert, and only then handles force-push and PR description\nupdate.\n\n#### Replace path\n\n**For merged CLIs or your own PR:** Standard confirmation:\n> \"This will replace the existing `\u003Capi-slug>`. Continue?\"\n\n**For another user's PR:** Stronger confirmation naming the other author:\n> \"⚠️  This will replace `\u003Cauthor>`'s `\u003Capi-slug>` (PR #N). Are you sure?\"\n\nIf confirmed:\n- The PR description must include: `⚠️ **Replaces existing \\`\u003Capi-slug>\\`** — \u003Creason provided by user or \"newer version\">`\n- Set `EXISTING_PR_NUMBER=\"\"` (create a new PR, don't update theirs)\n- Proceed to Step 8 normally\n\n#### Alongside path (rename)\n\n**1. Extract the original API slug** from the manifest's `api_name` field:\n\n```bash\n# Read from .printing-press.json in the publish repo's staged CLI\nORIGINAL_API_SLUG=$(cat \"$PUBLISH_REPO_DIR\u002Flibrary\u002F\u003Ccategory>\u002F\u003Capi-slug>\u002F.printing-press.json\" | jq -r '.api_name')\n```\n\n**2. Generate rename suggestions** using slug format. Derive the new CLI name from the chosen slug:\n\n- Numeric: `\u003Capi-slug>-2` (if that collides, try `-3`, `-4`, etc.)\n- Non-numeric: `\u003Capi-slug>-alt`\n- Custom: prompt the user for a qualifier word\n\nAfter the user chooses a slug, compute:\n\n```bash\nNEW_API_SLUG=\"\u003Cchosen-slug>\"\nNEW_CLI_NAME=\"${NEW_API_SLUG}-pp-cli\"\n```\n\nPresent the format to the user:\n> \"Rename format: `\u003Capi-slug>-\u003Cqualifier>`. Pick a qualifier:\"\n>\n> 1. `2` → `\u003Capi-slug>-2`\n> 2. `alt` → `\u003Capi-slug>-alt`\n> 3. Enter custom qualifier\n\n**3. Verify each suggestion is non-colliding** before presenting:\n\n```bash\n# Check merged (read the git tree, not the sparse working dir)\ngit -C \"$PUBLISH_REPO_DIR\" ls-tree -r --name-only HEAD \\\n  | sed -n 's#^\\(library\u002F[^\u002F]*\u002F\u003Csuggestion>\\)\u002F.*#\\1#p' | sort -u\n# Check open PRs\ngh pr list --repo mvanhorn\u002Fprinting-press-library --head \"feat\u002F\u003Csuggestion>\" --state open --json number\n```\n\nIf a suggestion collides, skip it or increment the numeric suffix.\n\n**4. Rename the CLI in the publish repo:**\n\nSince Step 6 copied the staged CLI into `$PUBLISH_REPO_DIR`, the rename operates on that directory. Note: `--old-name`\u002F`--new-name` still use CLI-name format (e.g., `dub-pp-cli`) because `RenameCLI` does content replacement — bare slugs would cause collateral damage. The `--dir` path uses the slug-keyed directory.\n\n```bash\ncli-printing-press publish rename \\\n  --dir \"$PUBLISH_REPO_DIR\u002Flibrary\u002F\u003Ccategory>\u002F\u003Capi-slug>\" \\\n  --old-name \u003Cold-cli-name> \\\n  --new-name \"$NEW_CLI_NAME\" \\\n  --json\n```\n\nParse the JSON result. Verify `\"success\": true`. Note that `new_dir` should now be `$PUBLISH_REPO_DIR\u002Flibrary\u002F\u003Ccategory>\u002F$NEW_API_SLUG`.\n\n**5. Update all downstream references for Step 8:**\n\n- Branch name: `feat\u002F$NEW_API_SLUG` (not the old slug)\n- PR title: `feat($NEW_API_SLUG): add $NEW_API_SLUG`\n- Commit message: `feat($NEW_API_SLUG): add $NEW_API_SLUG`\n- Registry.json entry: `name` → `$NEW_API_SLUG`\n- Set `EXISTING_PR_NUMBER=\"\"` (always a new PR for a renamed CLI)\n\nProceed to Step 8 with the new name.\n\n#### Bail path\n\nShow links to what exists:\n- If merged: \"Existing CLI at `library\u002F\u003Ccategory>\u002F\u003Capi-slug>\u002F`\"\n- If open PR: \"Open PR: \u003Curl>\"\n\nExit the publish flow. If Step 6 already wrote files into `$PUBLISH_REPO_DIR`, clean up with `git checkout -- . && git clean -fd` in the managed clone.\n\n## Step 8: Branch, Commit, and PR\n\n### Create branch\n\n**If `EXISTING_PR_NUMBER` is set** (updating an existing PR):\n\nFetch and inspect the current PR branch before replacing it. The latest\n`origin\u002Fmain` plus the newly packaged `library\u002F\u003Ccategory>\u002F\u003Capi-slug>\u002F` tree is\nthe proposed update. The remote PR branch may also contain accepted review\nfixes from the drive-to-green loop. Those branch-only edits must not be erased\nsilently.\n\n```bash\nUPDATE_BRANCH=\"feat\u002F\u003Capi-slug>\"\nUPDATE_BASE_REF=\"refs\u002Fprinting-press-update-base\u002F\u003Capi-slug>\"\n\ngit fetch origin \"+main:refs\u002Fremotes\u002Forigin\u002Fmain\" \"+$UPDATE_BRANCH:$UPDATE_BASE_REF\"\n\n# Show the scoped change from the current PR head to the new packaged working\n# tree. This is informational for clean updates and mandatory context for holds.\ngit diff --stat \"$UPDATE_BASE_REF\" -- \"library\u002F\u003Ccategory>\u002F\u003Capi-slug>\u002F\"\n\n# Branch-only paths are files that exist on the current PR branch but are absent\n# from the new packaged working tree. These are always a hold because a\n# force-push would delete them.\nWORKTREE_PATHS=$(find \"library\u002F\u003Ccategory>\u002F\u003Capi-slug>\" -type f -print 2>\u002Fdev\u002Fnull | sort)\nBRANCH_ONLY_PATHS=$(comm -23 \\\n  \u003C(git ls-tree -r --name-only \"$UPDATE_BASE_REF\" -- \"library\u002F\u003Ccategory>\u002F\u003Capi-slug>\u002F\" | sort) \\\n  \u003C([ -n \"$WORKTREE_PATHS\" ] && printf '%s\\n' \"$WORKTREE_PATHS\" || true))\n\n# Modified paths need human review only when a branch patch relative to\n# origin\u002Fmain is not present in the new packaged working tree. A strict superset\n# passes: if the branch patch can be reverse-applied from the working tree, the\n# fix is still there even if the file also has fresh generated changes.\nBRANCH_ONLY_EDITS=$(git diff --name-only origin\u002Fmain \"$UPDATE_BASE_REF\" -- \"library\u002F\u003Ccategory>\u002F\u003Capi-slug>\u002F\" | while read -r path; do\n  [ -n \"$path\" ] || continue\n  if git diff origin\u002Fmain \"$UPDATE_BASE_REF\" -- \"$path\" | git apply --check --reverse >\u002Fdev\u002Fnull 2>&1; then\n    continue\n  else\n    printf '%s\\n' \"$path\"\n  fi\ndone | sort -u)\n\nif [ -n \"$BRANCH_ONLY_PATHS$BRANCH_ONLY_EDITS\" ]; then\n  echo \"HOLD: updating PR #$EXISTING_PR_NUMBER would overwrite branch-only changes.\"\n  if [ -n \"$BRANCH_ONLY_PATHS\" ]; then\n    echo \"Files present on the PR branch but missing from the new package:\"\n    printf '%s\\n' \"$BRANCH_ONLY_PATHS\" | sed 's\u002F^\u002F- \u002F'\n  fi\n  if [ -n \"$BRANCH_ONLY_EDITS\" ]; then\n    echo \"Files edited on the PR branch and changed again by the new package:\"\n    printf '%s\\n' \"$BRANCH_ONLY_EDITS\" | sed 's\u002F^\u002F- \u002F'\n  fi\n  echo \"Do not push yet. Reconcile by restoring the branch-only fixes onto the new tree, or ask the user for explicit overwrite confirmation after showing the paths above.\"\n  exit 1\nfi\n```\n\nIf the guard exits, offer the user two choices via `AskUserQuestion`:\n\n- **Reconcile first** — restore the named branch-only files or edits onto the\n  new packaged tree, keep or add matching `.printing-press-patches\u002F\u003Cid>.json`\n  records for code-level fixes, rerun Step 6 verification, then rerun this\n  divergence guard.\n- **Overwrite intentionally** — only after the user confirms the listed paths\n  are obsolete, continue and include a PR-body note naming the overwritten\n  branch-only paths.\n\nIf the guard finds no branch-only paths or edits, overwrite the local branch:\n\n```bash\ngit checkout -B feat\u002F\u003Capi-slug>\n```\n\n**If `EXISTING_PR_NUMBER` is empty and `BRANCH_MERGED` is true** (previous PR was merged):\n\nAuto-create a timestamped branch — do not reuse the merged branch name:\n\n```bash\ngit checkout -b feat\u002F\u003Capi-slug>-$(date +%Y%m%d)\n```\n\n**If `EXISTING_PR_NUMBER` is empty and `BRANCH_MERGED` is not set** (no open or merged PR):\n\nCheck for stale branches and competing PRs:\n\n```bash\n# Check local and remote branches\nLOCAL_BRANCH=$(git branch --list \"feat\u002F\u003Capi-slug>\" | head -1)\nREMOTE_BRANCH=$(git ls-remote --heads origin \"feat\u002F\u003Capi-slug>\" 2>\u002Fdev\u002Fnull | head -1)\n\n# If a remote branch exists, check who owns it\nif [ -n \"$REMOTE_BRANCH\" ]; then\n  # Check for ANY open PR on this branch (not just ours)\n  OTHER_PR=$(gh pr list --repo mvanhorn\u002Fprinting-press-library --head \"feat\u002F\u003Capi-slug>\" --state open --json number,author --jq '.[0]' 2>\u002Fdev\u002Fnull)\nfi\n```\n\n**If another user's open PR exists on this branch** (`OTHER_PR` is non-empty and author is not `@me`):\n> \"Someone else has an open PR for `\u003Capi-slug>` (PR #N by @author). Creating a timestamped branch to avoid conflicts.\"\n\nAuto-create a timestamped branch: `feat\u002F\u003Capi-slug>-YYYYMMDD`. Do NOT offer to overwrite — that would stomp their work.\n\n**If the branch exists but no competing PR** (stale branch from a previously closed\u002Fmerged PR):\n\nAsk via AskUserQuestion:\n> \"Found a stale branch `feat\u002F\u003Capi-slug>` (likely from a previous publish). Overwrite it?\"\n\n- \"Overwrite existing branch\" — reuse the branch name\n- \"Create timestamped variant (feat\u002F\u003Capi-slug>-YYYYMMDD)\"\n\n**If no branch exists:** Create normally.\n\n```bash\n# New branch:\ngit checkout -b feat\u002F\u003Capi-slug>\n\n# Overwrite existing:\ngit checkout -B feat\u002F\u003Capi-slug>\n```\n\n### Commit and push\n\n```bash\ncd \"$PUBLISH_REPO_DIR\"\ngit add library\u002F\n# The library .gitignore has a `*-pp-mcp` rule intended for the built MCP\n# binary, but the pattern also matches the generated MCP *source* directory\n# `cmd\u002F\u003Capi-slug>-pp-mcp\u002F`. A plain `git add library\u002F` silently skips it, and\n# the PR then fails the \"Validate MCPB manifest contract\" CI check with\n# \"cmd\u002F\u003Capi-slug>-pp-mcp directory is missing\". Force-add the source directory\n# so all MCP entry-point files ship. The built binary stays ignored because it\n# lives at the packaged CLI root, not under cmd\u002F.\ngit add -f \"library\u002F\u003Ccategory>\u002F\u003Capi-slug>\u002Fcmd\u002F\u003Capi-slug>-pp-mcp\u002F\" 2>\u002Fdev\u002Fnull || true\ngit commit -m \"feat(\u003Capi-slug>): add \u003Capi-slug>\"\n```\n\nPush to origin (which is the fork for non-push users, or the upstream for push users):\n\n**If updating an existing PR** (`EXISTING_PR_NUMBER` is set):\n\n```bash\n# Only run this after the update-path divergence guard above has passed, or\n# after the user explicitly confirmed an intentional overwrite of the named\n# branch-only paths.\ngit push --force-with-lease -u origin feat\u002F\u003Capi-slug>\n```\n\n**If creating a new PR** and you chose \"Overwrite existing branch\" earlier:\n\n```bash\ngit push --force-with-lease -u origin feat\u002F\u003Capi-slug>\n```\n\n**Otherwise** (new branch, no conflicts):\n\n```bash\ngit push -u origin feat\u002F\u003Capi-slug>\n```\n\n### Capture the pushed commit SHA\n\nAfter pushing, capture the head commit SHA. This is used to build durable manuscript links in the PR body (see \"Build the PR description\" below).\n\n```bash\nHEAD_SHA=$(git rev-parse HEAD)\n```\n\nThe SHA stays resolvable on `mvanhorn\u002Fprinting-press-library` for the life of the PR (GitHub mirrors fork-PR head commits to `refs\u002Fpull\u002F\u003CN>\u002Fhead` on the upstream), and remains valid after the PR is merged and the branch is deleted. Each invocation of this skill captures a fresh `HEAD_SHA` after its push and rewrites the body, so links stay current across updates the skill performs. If the branch is force-pushed outside this skill, re-run `\u002Fprinting-press-publish` to refresh the body — the prior links will still resolve, but they'll point at the manuscript contents from before the out-of-band push.\n\n### Create or update PR\n\nRead `access` and `gh_user` from `$PUBLISH_CONFIG`. These determine how `gh pr create` is called.\n\n**For fork-based PRs** (`access` is `fork`): use `--head \u003Cgh_user>:feat\u002F\u003Capi-slug>` so GitHub creates a cross-repo PR from the fork to the upstream. Without `--head`, `gh pr create` would try to find the branch on the upstream repo (where the user can't push) and fail.\n\n**For push-access PRs** (`access` is `push`): use `--head feat\u002F\u003Capi-slug>` so GitHub creates the PR from the branch this flow just pushed, even when the managed clone or shell session has other branches checked out.\n\nBuild the PR description from:\n- The manifest (`description`, `api_name`, `category`, `printing_press_version`, `spec_url`)\n- The manifest's `novel_features` array from the packaged CLI after Step 6\n- The `help_output` captured in Step 4\n- The CLI's README (first 2-3 paragraphs, or note that README is missing)\n- Links to every file under `.manuscripts\u002F\u003Crun-id>\u002Fresearch\u002F` and `.manuscripts\u002F\u003Crun-id>\u002Fproofs\u002F`. Each link must be a full `https:\u002F\u002Fgithub.com\u002Fmvanhorn\u002Fprinting-press-library\u002Fblob\u002F\u003CHEAD_SHA>\u002Flibrary\u002F\u003Ccategory>\u002F\u003Capi-slug>\u002F.manuscripts\u002F\u003Crun-id>\u002F\u003Csubdir>\u002F\u003Cfilename>` URL — never a relative path (GitHub resolves those against `…\u002Fpull\u002F`, producing broken `…\u002Fpull\u002Flibrary\u002F…` URLs) and never a directory (the blob view requires a file). Enumerate the actual files; do not invent or skip them.\n- The validation results from Step 4\n- The publish live gate result from Step 4.5, including any explicit\n  `--skip-live-test` reason\n- A Gaps section listing any missing manifest fields\n\nRead `novel_features` from\n`$PUBLISH_REPO_DIR\u002Flibrary\u002F\u003Ccategory>\u002F\u003Capi-slug>\u002F.printing-press.json` after\npackaging. Preserve the manifest order. Do not derive\nthis section from README prose, SKILL prose, root help, or memory of the run:\nthose surfaces may be summarized or hand-edited, while the packaged manifest is\nthe publish-time source of truth. For each entry, include the command, name, and\ndescription. If the array is empty, write `No novel commands recorded in\n.printing-press.json.` and include the missing field in **Gaps**; do not omit the\nsection.\n\nAlso include a publication-path line so new prints, reprints, PR updates, and\ncollision renames are distinguishable:\n- `New print` — no merged CLI and no existing PR matched this slug.\n- `Update existing PR #\u003CN>` — this publish refreshes an open PR.\n- `Reprint\u002Freplace` — a merged library CLI existed before this publish and the\n  selected path replaces it. This must be based on\n  `PREEXISTING_MERGED_COLLISION=true`, not on the post-package tree.\n- `Alongside print` — this publish renamed the API slug to avoid a collision;\n  include the original slug.\nIf `\u002Fprinting-press-reprint` handed off a degraded reprint with no prior\npublic-library source, use `New print` and add the degraded-reprint note only if\nthat context is available from the handoff.\n\n**MANDATORY: Before constructing the PR body, scrub all workspace PII.** The library\nrepo is public. Scan any live test results, acceptance data, or manuscript excerpts\nfor organization names, team member names, and email addresses. Replace with generic\ndescriptions (\"the workspace\", \"5 team members\", \"12 users\"). Team keys (e.g., \"ESP\")\nare OK but org names (e.g., \"Acme Corp\") are not. See `references\u002Fsecret-protection.md`\nin the printing-press skill for the full policy.\n\nWrite the constructed PR body to a temporary Markdown file and pass it with\n`--body-file`. Do this for both PR creation and PR updates. Do not inline the\nbody in a shell argument; large fenced help output, Markdown tables, and\nbackticks are too easy to mangle.\n\n**PR description template:**\n\n```markdown\n## \u003Capi-slug>\n\n\u003CIf this is a Replace path, add: \"⚠️ **Replaces existing `\u003Capi-slug>`** — \u003Creason from user>\">\n\n\u003Cdescription from manifest, or \"No description available\">\n\n**API:** \u003Capi_name> | **Category:** \u003Ccategory> | **Press version:** \u003Cprinting_press_version>\n**Spec:** \u003Cspec_url or \"Not specified\">\n\n### Publication Path\n\n\u003CNew print | Update existing PR #N | Reprint\u002Freplace | Alongside print from \u003Coriginal-api-slug>>\n\n### CLI Shape\n\n\\`\\`\\`bash\n$ \u003Ccli-name> --help\n\u003Chelp_output from validation>\n\\`\\`\\`\n\n### Novel Commands\n\n| Command | Name | Description |\n|---------|------|-------------|\n| `\u003Ccommand>` | \u003Cname> | \u003Cdescription> |\n\n### What This CLI Does\n\n\u003CFirst 2-3 paragraphs from README.md in the CLI directory, or \"README not found\">\n\n### Manuscripts\n\n\u003C!-- One bullet per file, NOT one per directory. Repeat the research\u002F row for every file in research\u002F, and the proofs\u002F row for every file in proofs\u002F. Use a human label that matches the file (e.g. `Research Brief`, `Absorb Manifest`, `Novel Features Brainstorm`, `Phase 5 Acceptance`). Substitute `\u003CHEAD_SHA>` with the value captured after push. Do NOT use relative paths. -->\n\n- [\u003Clabel>](https:\u002F\u002Fgithub.com\u002Fmvanhorn\u002Fprinting-press-library\u002Fblob\u002F\u003CHEAD_SHA>\u002Flibrary\u002F\u003Ccategory>\u002F\u003Capi-slug>\u002F.manuscripts\u002F\u003Crun-id>\u002Fresearch\u002F\u003Cfilename>)\n- [\u003Clabel>](https:\u002F\u002Fgithub.com\u002Fmvanhorn\u002Fprinting-press-library\u002Fblob\u002F\u003CHEAD_SHA>\u002Flibrary\u002F\u003Ccategory>\u002F\u003Capi-slug>\u002F.manuscripts\u002F\u003Crun-id>\u002Fresearch\u002F\u003Cfilename>)\n- … (one bullet for each remaining file in `.manuscripts\u002F\u003Crun-id>\u002Fresearch\u002F`)\n- [\u003Clabel>](https:\u002F\u002Fgithub.com\u002Fmvanhorn\u002Fprinting-press-library\u002Fblob\u002F\u003CHEAD_SHA>\u002Flibrary\u002F\u003Ccategory>\u002F\u003Capi-slug>\u002F.manuscripts\u002F\u003Crun-id>\u002Fproofs\u002F\u003Cfilename>)\n- [\u003Clabel>](https:\u002F\u002Fgithub.com\u002Fmvanhorn\u002Fprinting-press-library\u002Fblob\u002F\u003CHEAD_SHA>\u002Flibrary\u002F\u003Ccategory>\u002F\u003Capi-slug>\u002F.manuscripts\u002F\u003Crun-id>\u002Fproofs\u002F\u003Cfilename>)\n- … (one bullet for each remaining file in `.manuscripts\u002F\u003Crun-id>\u002Fproofs\u002F`)\n\n### Validation Results\n\n| Check | Result |\n|-------|--------|\n| Manifest | PASS\u002FFAIL |\n| Phase 5 | PASS\u002FFAIL |\n| go mod tidy | PASS\u002FFAIL |\n| govulncheck (this CLI only, reachable findings) | PASS\u002FFAIL |\n| go vet | PASS\u002FFAIL |\n| go build | PASS\u002FFAIL |\n| --help | PASS\u002FFAIL |\n| --version | PASS\u002FFAIL |\n| Manuscripts | PRESENT\u002FMISSING |\n\n### Publish Live Gate\n\n\u003CIf Step 4.5 ran dogfood: \"Full live dogfood reran at publish time and passed. Proof: `\u003Cproof path or manuscript link>`\">\n\u003CIf Step 4.5 was skipped: \"Skipped with explicit reason: `\u003CSKIP_LIVE_TEST_REASON>`\">\n\n### Gaps\n\n\u003CList any missing manifest fields, or omit this section if everything is present>\n```\n\n**If updating an existing PR** (`EXISTING_PR_NUMBER` is set):\n\n```bash\ncd \"$PUBLISH_REPO_DIR\"\nPR_BODY_FILE=\"$(mktemp)\"\n# Write the constructed PR body Markdown to \"$PR_BODY_FILE\".\ngh pr edit \"$EXISTING_PR_NUMBER\" \\\n  --repo mvanhorn\u002Fprinting-press-library \\\n  --body-file \"$PR_BODY_FILE\"\nrm -f \"$PR_BODY_FILE\"\n```\n\nDisplay the full PR URL: \"Updated PR: \u003CEXISTING_PR_URL>\" (use the full `https:\u002F\u002F` URL, not shorthand).\n\n**If creating a new PR:**\n\n```bash\ncd \"$PUBLISH_REPO_DIR\"\n\n# Read access mode from config\nACCESS=$(jq -r .access \"$PUBLISH_CONFIG\")\nGH_USER=$(jq -r .gh_user \"$PUBLISH_CONFIG\")\n\nif [ \"$ACCESS\" = \"fork\" ]; then\n  PR_HEAD_REF=\"$GH_USER:feat\u002F\u003Capi-slug>\"\nelse\n  PR_HEAD_REF=\"feat\u002F\u003Capi-slug>\"\nfi\n\nPR_BODY_FILE=\"$(mktemp)\"\n# Write the constructed PR body Markdown to \"$PR_BODY_FILE\".\n\ngh pr create \\\n  --repo mvanhorn\u002Fprinting-press-library \\\n  --head \"$PR_HEAD_REF\" \\\n  --base main \\\n  --title \"feat(\u003Capi-slug>): add \u003Capi-slug>\" \\\n  --body-file \"$PR_BODY_FILE\"\n\nrm -f \"$PR_BODY_FILE\"\n```\n\nDisplay the full PR URL (e.g., `https:\u002F\u002Fgithub.com\u002Fmvanhorn\u002Fprinting-press-library\u002Fpull\u002F10`), not the shorthand `org\u002Frepo#N` format. The full URL is clickable in all terminals and contexts.\n\n## After the PR opens\n\nOnce the PR is open, it enters the public library repo's review contract. That contract is owned by [`mvanhorn\u002Fprinting-press-library` AGENTS.md → \"Automated code review with Greptile\"](https:\u002F\u002Fgithub.com\u002Fmvanhorn\u002Fprinting-press-library\u002Fblob\u002Fmain\u002FAGENTS.md#automated-code-review-with-greptile); read it for the canonical version. An agent invoking this skill from `cli-printing-press` will not have loaded the library's AGENTS.md, so the obligations are summarized here.\n\nGreptile reviews **incrementally**: every commit you push re-triggers a fresh review, which can surface new findings the previous round didn't. This is a loop, not a single pass — drive the PR to a *stable* green and don't declare done after round one.\n\n### Drive the PR to stable green\n\nIterate until **all** of these hold, confirmed by the review that your most recent fix commit triggered:\n\n- **Greptile score ≥ 4.** The 0-5 score is a confidence signal, not a hard gate; 4\u002F5 and 5\u002F5 are both acceptable end states, and the score lands there naturally once threads are addressed.\n- **No unresolved review threads.** For each P0\u002FP1\u002FP2 thread, either push a fix or reply with a concrete reason it shouldn't fire — not \"won't fix\", but *why* the code is right as written or *why* deferral is justified.\n- **All CI checks pass.** `verify-library-conventions`, `Govulncheck`, and any other workflow on the PR.\n\nRead findings from two surfaces — they don't overlap:\n\n- `gh pr view \u003CPR> --repo \u003Cowner>\u002F\u003Crepo> --comments` returns the top-level issue conversation (Greptile's summary comment, score, CI bots).\n- `gh api repos\u002F\u003Cowner>\u002F\u003Crepo>\u002Fpulls\u002F\u003CPR>\u002Fcomments` returns the inline diff-anchored review comments — Greptile posts each P0\u002FP1\u002FP2 finding here, **and these are NOT included in `--comments`**. Skipping this call is how an agent silently declares \"all findings resolved\" while every inline thread is still open.\n\n**Monitoring is the harness's job, not a busy-loop you hand-roll.** Use whatever PR-activity monitoring your environment provides — react to review\u002FCI events as they arrive, or re-check on an interval if it doesn't push events. After each fix push, wait for the re-triggered review to land before judging done; a new round can reopen the gate.\n\n**Don't hand-edit `registry.json` or `cli-skills\u002Fpp-\u003Capi-slug>\u002FSKILL.md` to satisfy a finding** — both are bot-regenerated post-merge by `[skip ci]` commits, and the library's `Fail on changes to generated artifacts` check pre-rejects any PR that touches them.\n\n### Terminal state — then hand back\n\nOnce the PR is stably green, the skill's job is done. **Do not merge it and do not poll waiting for it to merge** — merges into the public library are the maintainer's manual review, not this skill's and (for a fork contributor) not the user's either.\n\nRead `access` from `$PUBLISH_CONFIG` (`jq -r .access \"$PUBLISH_CONFIG\"`) to determine what to do next:\n\n- **If `access` is `push`** (maintainer\u002Fadmin with push access): apply the `awaiting-maintainer` label to signal the PR is ready for manual review:\n  ```bash\n  gh pr edit \u003CPR> --repo mvanhorn\u002Fprinting-press-library --add-label awaiting-maintainer\n  ```\n- **If `access` is `fork`** (community contributor): you cannot merge or label the upstream PR. There is nothing more to do once it's green.\n\nThen **report the terminal state and return control to the caller.** Do not offer a retro or any follow-up menu from this skill by default — that decision belongs to whoever invoked publish. The `printing-press` pipeline offers retro as its own post-publish tail; a direct human invocation without `--from-polish` just ends here.\n\nIf `POLISH_HANDOFF=true`, offer retro as a soft tail after the PR is green. This preserves the standalone polish -> publish workflow without allowing polish's same-turn `AskUserQuestion` answer to create or update a public-library PR.\n\nPresent via `AskUserQuestion`:\n\n> \"PR opened: \u003CPR_URL>. Run a retro? It surfaces systemic gaps from this session (generator misses, scorer bugs, skill-doc drift) as a GitHub issue for the Printing Press maintainers. Every retro filed raises the floor for the next CLI, and your session context is freshest right now.\"\n>\n> 1. **No, I'm done** (default)\n> 2. **Yes, run retro now**\n\nIf the user picks yes, invoke `\u002Fprinting-press-retro`.\n\n## Secret & PII Protection\n\nBefore creating the PR, verify that no secrets leaked into the packaged CLI.\n\n**This matters because the library repo is public.** A leaked API key in a PR is\na security incident — anyone can see it, even if the PR is later closed.\n\n### What the Printing Press checks (deterministic)\n\nThe generation skill (`\u002Fprinting-press`) runs an exact-value scan during Phase 5.5\nif the user provided an API key. By the time publish runs, the Printing Press's own\nmistakes should already be caught. But the user may have edited files between\ngeneration and publish.\n\n### What publish checks\n\n1. **Mandatory binary scan:** `cli-printing-press publish package` scans the staged CLI and manuscripts for live-looking vendor-prefix tokens (`sk-or-v1-*`, `sk_live_*`, `ghp_*`, `ghs_*`, `xoxb-*`, `AKIA*`, and similar). If it fails with `vendor-prefix tokens detected`, treat the package as unpublishable. Do not copy, commit, push, or open a PR until the reported file:line findings are removed or redacted.\n\n2. **If the user's exact API key value is known**, scan the packaged tree before creating the PR. This catches edits or manuscripts added after Phase 5.5:\n   ```bash\n   if [ -n \"$API_KEY_VALUE\" ] && [ ${#API_KEY_VALUE} -ge 16 ]; then\n     if grep -rF \"$API_KEY_VALUE\" \"$PUBLISH_REPO_DIR\u002Flibrary\u002F\u003Ccategory>\u002F\u003Capi-slug>\" 2>\u002Fdev\u002Fnull; then\n       echo \"BLOCKING: API key value found in staged publish tree.\"\n       exit 1\n     fi\n   fi\n   ```\n\n3. **If `gitleaks` or `trufflehog` is installed**, run it as an enrichment pass on the staged directory:\n   ```bash\n   if command -v gitleaks >\u002Fdev\u002Fnull 2>&1; then\n     gitleaks detect --source \"\u003Cstaging-dir>\u002Flibrary\" --no-git --verbose 2>&1\n   elif command -v trufflehog >\u002Fdev\u002Fnull 2>&1; then\n     trufflehog filesystem \"\u003Cstaging-dir>\u002Flibrary\" 2>&1\n   fi\n   ```\n   These tools use vendor-specific patterns (Steam keys, Stripe keys, GitHub\n   tokens) with low false-positive rates. Their findings add detector breadth\n   beyond the mandatory floor. Review any finding before proceeding.\n\n4. **Always do the lightweight structural check:**\n   - Verify no `.env` files, `session-state.json`, or `config.toml` with\n     real credentials exist in the staged directory\n   - Check README examples use `\"your-key-here\"` placeholders, not real values\n   - Check manuscripts (if included) don't contain auth headers or cookie values\n\n5. **Never include** in the staged directory:\n   - `.env` files\n   - `session-state.json`\n   - Config files with real credentials\n   - HAR captures with un-stripped auth headers\n\nIf the mandatory binary scan or exact-value scan finds issues, stop. For\nexternal-tool or lightweight structural findings, warn the user and ask whether\nto proceed. The user makes the final call on those non-mandatory findings.\n\n### PII pattern scanning (mandatory)\n\nBeyond the secret scans above, run the **PII pattern scanning** step from\n[..\u002Fprinting-press\u002Freferences\u002Fsecret-protection.md](..\u002Fprinting-press\u002Freferences\u002Fsecret-protection.md#pii-pattern-scanning)\n(section \"PII pattern scanning\"). This catches PII captured during live dogfood\nthat the prose guidance missed — emails, real attendee names, account\nidentifiers — before they ship to the public library repo.\n\nThe scan has two tiers:\n- **Tier 1 (auto-redact silently):** vendor-prefix-anchored bearer tokens\n  (`Bearer cal_live_*`, `Bearer sk_live_*`, `Bearer ghp_*`, `xoxp-*`, etc.).\n  Near-zero false-positive rate.\n- **Tier 2 (warn, batched user prompt):** generic emails, generic bearer tokens,\n  capitalized first+last name patterns. Allowlist suppresses spec-derived API\n  vocabulary (\"Event Types\", \"Booking Links\") automatically.\n\nA pre-scrub copy of the staging directory is preserved at\n`\u003Cstaging>.pre-pii-scrub\u002F` so the user can recover from a wrong redaction.\n\nTwo prior PII leaks shipped to the public library before this scan existed.\nThe scan is the mechanical defense layer the prose guidance alone could not\nprovide.\n\n## Error Handling\n\n- **`gh` not authenticated:** Detect in Step 1, tell user to run `gh auth login`\n- **CLI not found:** Show available CLIs in Step 2, let user pick\n- **Validation fails:** Show per-check results in Step 4, stop\n- **Repo unreachable:** Report clearly in Step 5\n- **Fork creation fails:** `gh repo fork` may fail if the user already has a fork with a different name, or if the org restricts forking. Report the error and suggest the user fork manually via the GitHub web UI.\n- **Collision check fails:** If `gh pr list` or `ls` commands fail (network, auth), warn but don't block — proceed as if no collision exists\n- **Rename fails:** Show the error from `publish rename --json`. Offer to retry with a different qualifier or bail. If the publish repo is in a partial state, reset with `git checkout -- . && git clean -fd` before retrying\n- **Branch conflict (no existing PR):** Ask user in Step 8 (overwrite or timestamp)\n- **Push fails:** For fork users, ensure they're pushing to their fork (origin), not upstream. Report the error, suggest checking `gh auth status` and `git remote -v`\n- **Cross-repo PR creation fails:** If `gh pr create --head user:branch` fails with \"head not found\", the branch wasn't pushed to the fork. Verify with `git ls-remote origin feat\u002F\u003Capi-slug>`\n","# \u002Fprinting-press publish\n\nPublish a generated CLI from your local library to the [printing-press-library](https:\u002F\u002Fgithub.com\u002Fmvanhorn\u002Fprinting-press-library) repo as a pull request.\n\n```bash\n\u002Fprinting-press publish notion-pp-cli\n\u002Fprinting-press publish notion\n\u002Fprinting-press publish notion --from-polish\n\u002Fprinting-press publish notion --skip-live-test=auth-unavailable\n\u002Fprinting-press publish notion --blocked-api-journal notion\n\u002Fprinting-press publish\n```\n\n## Direct User Invocation Required\n\nPublishing can fork `mvanhorn\u002Fprinting-press-library`, push a branch, and open or\nupdate a PR. Before setup or validation, check the invocation context. If this\nskill was invoked as a chained continuation from `printing-press-polish`'s\nPublish Offer, including an `AskUserQuestion` answer or auto-resolved polish\nrecommendation, stop immediately and tell the user to send\n`\u002Fprinting-press-publish \u003Ccli-name> --from-polish` in a fresh message. A fresh\nuser-authored request that explicitly asks to publish is sufficient; do not add\nanother confirmation prompt on top of a direct publish request.\n\nIf the fresh user-authored request includes `--from-polish`, record\n`POLISH_HANDOFF=true` for the terminal-state step and ignore that marker when\nresolving the CLI name. The marker is not a second confirmation and is not\npassed to `cli-printing-press`; it only preserves standalone polish's old\npost-publish retro offer after the fresh-turn publish completes.\n\nIf the request includes `--blocked-api-journal`, enter **Blocked API Journal\nMode** below instead of the normal printed-CLI publish flow. This mode may be\ninvoked from `\u002Fprinting-press`'s hold-path menu after the user explicitly chose\n\"Add to blocked-API journal\"; that parent menu choice is sufficient user\nauthorization for the public-library journal write. Do not require a second\nfresh-turn invocation for this journal-only mode.\n\nIf the fresh user-authored request includes `--skip-live-test=\u003Creason>`, record\nthe exact non-empty reason as `SKIP_LIVE_TEST_REASON` and remove the flag before\nresolving the CLI name. This is the only supported escape valve for the\npublish-time live test gate. Use it only for auth-unavailable, known upstream\noutage, LAN-unreachable hardware APIs, or similarly concrete operator-approved\ncases; never infer a skip from ordinary latency or from the presence of an\nolder Phase 5 marker.\n\nThe public library treats `library\u002F\u003Ccategory>\u002F\u003Capi-slug>\u002F.printing-press.json`\nand `manifest.json` as the source of truth for registry-display fields. Do not\nedit `registry.json`, README catalog cells, or `cli-skills\u002Fpp-\u003Capi-slug>\u002FSKILL.md`\nin publish PRs; all three are bot-regenerated post-merge by the library's own\nworkflows. The library's `Fail on changes to generated artifacts` check in\n`verify-library-conventions.yml` hard-fails any PR — fork or same-repo — whose\ndiff against base touches `registry.json` or `cli-skills\u002Fpp-*\u002FSKILL.md`, so a\npublish that includes either is pre-rejected before review.\n\nThe public library also owns per-CLI release accounting. Do not manually bump\n`CHANGELOG.md`, `.printing-press-release.json`, or runtime `var version = ...`\nfor a publish PR. Fresh printed CLIs may include blank release-ledger skeletons;\nthe library's post-merge workflow assigns the final `YYYY.M.N` release and\nstamps the runtime version after merge. When replacing an existing public\nlibrary CLI, preserve its existing release-ledger files so changelog history is\nnot lost in the reprint PR.\n\n`blocked-apis.json` is different: it is a hand-maintained public-library journal,\nnot a generated registry surface. Journal-only PRs may edit `blocked-apis.json`\nand must not stage `library\u002F`, `registry.json`, README catalog cells, or\n`cli-skills\u002F`.\n\n## Blocked API Journal Mode\n\nUse this mode only when the invocation includes `--blocked-api-journal`. It\nrecords a held `\u002Fprinting-press` attempt whose blocker is likely to repeat for\nother users until a machine or upstream issue changes.\n\nRequired fields from the caller:\n\n- `slug`: canonical API slug, not the CLI binary name.\n- `attempted_at`: `YYYY-MM-DD`.\n- `verdict`: `hold`.\n- `reason`: concise blocker reason, with no secrets, local paths, cookies,\n  tokens, or account-specific details.\n- `blocking_issue`: Printing Press issue number if known, otherwise `null`.\n- `permanent`: boolean.\n\nIf the caller did not provide one of these fields, infer only safe values from\nthe current run context. If `reason` is missing or vague, stop and ask for one\nspecific blocker sentence; do not write an unhelpful journal entry.\n\nRun the normal Setup, Configuration, scoped clone cleanup, and GitHub auth\nchecks, then prepare the public-library clone exactly as the normal publish\nflow does: fork if needed, ensure `upstream` points to\n`mvanhorn\u002Fprinting-press-library`, fetch `upstream`, and reset the clone to\n`upstream\u002Fmain` before editing.\n\nThen update only `$PUBLISH_REPO_DIR\u002Fblocked-apis.json`:\n\n```bash\ncd \"$PUBLISH_REPO_DIR\"\nif [ ! -f blocked-apis.json ]; then\n  printf '[]\\n' > blocked-apis.json\nfi\njq --arg slug \"\u003Capi-slug>\" \\\n   --arg attempted_at \"\u003CYYYY-MM-DD>\" \\\n   --arg verdict \"hold\" \\\n   --arg reason \"\u003Creason>\" \\\n   --argjson blocking_issue '\u003Cnumber-or-null>' \\\n   --argjson permanent '\u003Ctrue-or-false>' '\n  (if type == \"array\" then . else [] end)\n  | map(select(.slug != $slug))\n  + [{\n      slug: $slug,\n      attempted_at: $attempted_at,\n      verdict: $verdict,\n      reason: $reason,\n      blocking_issue: $blocking_issue,\n      permanent: $permanent\n    }]\n  | sort_by(.slug)\n' blocked-apis.json > blocked-apis.json.tmp || {\n  rm -f blocked-apis.json.tmp\n  echo \"Error: jq failed to update blocked-apis.json\"\n  exit 1\n}\nif ! jq empty blocked-apis.json.tmp; then\n  rm -f blocked-apis.json.tmp\n  echo \"Error: blocked-apis.json update produced invalid JSON\"\n  exit 1\nfi\nmv blocked-apis.json.tmp blocked-apis.json\n```\n\nCreate a journal branch and PR:\n\n```bash\ngit checkout -B chore\u002Fblocked-api-\u003Capi-slug>\ngit add blocked-apis.json\ngit commit -m \"chore(\u003Capi-slug>): journal blocked API\"\ngit push --force-with-lease -u origin chore\u002Fblocked-api-\u003Capi-slug>\n```\n\nOpen the PR against `mvanhorn\u002Fprinting-press-library` with a body that includes:\n\n- the held API slug and reason\n- whether the block is permanent or tied to `blocking_issue`\n- the expected Phase 0 behavior: future `\u002Fprinting-press \u003Capi-slug>` runs warn\n  before repeating the attempt\n\nAfter the PR is open, report the URL and stop. Do not continue into normal\nprinted-CLI package, live-test, registry, or skill-mirror steps.\n\n## Setup\n\nBefore doing anything else:\n\n\u003C!-- PRESS_SETUP_CONTRACT_START -->\n```bash\n# min-binary-version: 4.0.0\n\n# Derive scope first — needed for local build detection\n_scope_dir=\"$(git rev-parse --show-toplevel 2>\u002Fdev\u002Fnull || echo \"$PWD\")\"\n_scope_dir=\"$(cd \"$_scope_dir\" && pwd -P)\"\n\n# Prefer local build when running from inside the printing-press repo.\n_press_repo=false\nif [ -x \"$_scope_dir\u002Fcli-printing-press\" ] && [ -d \"$_scope_dir\u002Fcmd\u002Fcli-printing-press\" ]; then\n  _press_repo=true\n  export PATH=\"$_scope_dir:$PATH\"\n  echo \"Using local build: $_scope_dir\u002Fcli-printing-press\"\nelif ! command -v cli-printing-press >\u002Fdev\u002Fnull 2>&1; then\n  if [ -x \"$HOME\u002Fgo\u002Fbin\u002Fcli-printing-press\" ]; then\n    echo \"cli-printing-press found at ~\u002Fgo\u002Fbin\u002Fcli-printing-press but not on PATH.\"\n    echo \"Add GOPATH\u002Fbin to your PATH:  export PATH=\\\"\\$HOME\u002Fgo\u002Fbin:\\$PATH\\\"\"\n  else\n    echo \"cli-printing-press binary not found.\"\n    echo \"Install with:  go install github.com\u002Fmvanhorn\u002Fcli-printing-press\u002Fv4\u002Fcmd\u002Fcli-printing-press@latest\"\n  fi\n  return 1 2>\u002Fdev\u002Fnull || exit 1\nfi\n\n# Resolve and emit the absolute path the agent must use for every later\n# `cli-printing-press` invocation. `export PATH` above only affects this one\n# Bash tool call; subsequent calls open a fresh shell and resolve bare\n# `cli-printing-press` against the user's default PATH, where a stale global\n# can silently shadow the local build. The agent captures this marker and\n# substitutes the absolute path into every later invocation.\nif [ \"$_press_repo\" = \"true\" ]; then\n  PRINTING_PRESS_BIN=\"$_scope_dir\u002Fcli-printing-press\"\nelse\n  PRINTING_PRESS_BIN=\"$(command -v cli-printing-press 2>\u002Fdev\u002Fnull || true)\"\nfi\necho \"PRINTING_PRESS_BIN=$PRINTING_PRESS_BIN\"\n\nPRESS_BASE=\"$(basename \"$_scope_dir\" | tr '[:upper:]' '[:lower:]' | sed -E 's\u002F[^a-z0-9_-]\u002F-\u002Fg; s\u002F^-+\u002F\u002F; s\u002F-+$\u002F\u002F')\"\nif [ -z \"$PRESS_BASE\" ]; then\n  PRESS_BASE=\"workspace\"\nfi\n\nPRESS_SCOPE=\"$PRESS_BASE-$(printf '%s' \"$_scope_dir\" | shasum -a 256 | cut -c1-8)\"\nPRESS_HOME=\"${PRINTING_PRESS_HOME:-$HOME\u002Fprinting-press}\"\nPRESS_RUNSTATE=\"$PRESS_HOME\u002F.runstate\u002F$PRESS_SCOPE\"\nPRESS_LIBRARY=\"$PRESS_HOME\u002Flibrary\"\nPRESS_MANUSCRIPTS=\"$PRESS_HOME\u002Fmanuscripts\"\nPRESS_CURRENT=\"$PRESS_RUNSTATE\u002Fcurrent\"\n\nmkdir -p \"$PRESS_RUNSTATE\" \"$PRESS_LIBRARY\" \"$PRESS_MANUSCRIPTS\" \"$PRESS_CURRENT\"\n```\n\u003C!-- PRESS_SETUP_CONTRACT_END -->\n\nAfter running the setup contract, capture the `PRINTING_PRESS_BIN=\u003Cabs-path>` line from stdout. **Every subsequent `cli-printing-press ...` invocation in this skill must use that absolute path** (substitute the value, not the literal `$PRINTING_PRESS_BIN` token) — `export PATH` above only affects the single Bash tool call it runs in, so later calls open a fresh shell where bare `cli-printing-press` resolves against the user's default `PATH` and a stale global can shadow the local build.\n\nAfter capturing the binary path, check binary version compatibility. Read the `min-binary-version` field from this skill's YAML frontmatter. Run `\u003CPRINTING_PRESS_BIN> version --json` and parse the version from the output. Compare it to `min-binary-version` using semver rules. If the installed binary is older than the minimum, stop immediately and tell the user: \"cli-printing-press binary vX.Y.Z is older than the minimum required vA.B.C. Run `go install github.com\u002Fmvanhorn\u002Fcli-printing-press\u002Fv4\u002Fcmd\u002Fcli-printing-press@latest` to update.\"\n\n## Configuration\n\n```\nPUBLISH_REPO_URL=\"https:\u002F\u002Fgithub.com\u002Fmvanhorn\u002Fprinting-press-library\"\nPUBLISH_REPO_DIR=\"$PRESS_HOME\u002F.publish-repo-$PRESS_SCOPE\"\nPUBLISH_CONFIG=\"$PRESS_HOME\u002F.publish-config-$PRESS_SCOPE.json\"\n```\n\n### Publish config\n\n`$PUBLISH_CONFIG` stores persistent publish settings as JSON. On first publish, create it with defaults. The user can edit it to change the library repo or module path base.\n\n```json\n{\n  \"managed_by\": \"printing-press-publish\",\n  \"repo_url\": \"https:\u002F\u002Fgithub.com\u002Fmvanhorn\u002Fprinting-press-library\",\n  \"access\": \"push\",\n  \"protocol\": \"ssh\",\n  \"clone_path\": \"\u003Chome>\u002Fprinting-press\u002F.publish-repo-\u003Cscope>\",\n  \"scope_dir\": \"\u002Fabsolute\u002Fpath\u002Fto\u002Fsource\u002Fworktree\",\n  \"module_path_base\": \"github.com\u002Fmvanhorn\u002Fprinting-press-library\u002Flibrary\"\n}\n```\n\nThe `module_path_base` field sets the Go module path prefix for published CLIs. During packaging, the full module path is constructed as `\u003Cmodule_path_base>\u002F\u003Ccategory>\u002F\u003Capi-slug>`. If the user wants CLIs published to a different repo or path, they edit this field.\nStore expanded absolute paths for `clone_path` and `scope_dir` so cleanup can\ncheck them without relying on shell-specific `~` expansion. The `managed_by`\nfield is required before cleanup may delete anything.\n\n### Scoped clone cleanup\n\nBefore creating or reusing `$PUBLISH_REPO_DIR`, prune scoped publish clones whose\nsource worktree no longer exists. This keeps concurrent worktrees isolated\nwithout accumulating one library clone forever per short-lived worktree.\n\n```bash\nfind \"$PRESS_HOME\" -maxdepth 1 -name '.publish-config-*.json' -type f | while read -r cfg; do\n  [ \"$cfg\" = \"$PUBLISH_CONFIG\" ] && continue\n  managed_by=$(jq -r '.managed_by \u002F\u002F empty' \"$cfg\" 2>\u002Fdev\u002Fnull || true)\n  scope_dir=$(jq -r '.scope_dir \u002F\u002F empty' \"$cfg\" 2>\u002Fdev\u002Fnull || true)\n  clone_path=$(jq -r '.clone_path \u002F\u002F empty' \"$cfg\" 2>\u002Fdev\u002Fnull || true)\n  [ \"$managed_by\" = \"printing-press-publish\" ] || continue\n  [ -z \"$scope_dir\" ] && continue\n  [ -e \"$scope_dir\" ] && continue\n  [ -d \"$clone_path\u002F.git\" ] || continue\n  case \"$clone_path\" in \"$PRESS_HOME\"\u002F.publish-repo-*) ;; *) continue ;; esac\n  origin=$(git -C \"$clone_path\" remote get-url origin 2>\u002Fdev\u002Fnull || true)\n  case \"$origin\" in *mvanhorn\u002Fprinting-press-library*|*\u002F*\u002Fprinting-press-library*) ;; *) continue ;; esac\n  [ -z \"$(git -C \"$clone_path\" status --porcelain)\" ] || continue\n  [ \"$(git -C \"$clone_path\" rev-parse --abbrev-ref HEAD 2>\u002Fdev\u002Fnull || true)\" = \"main\" ] || continue\n  rm -rf \"$clone_path\" \"$cfg\"\ndone\n```\n\n## Step 1: Prerequisites\n\nVerify `gh` is authenticated:\n\n```bash\ngh auth status\n```\n\nIf this fails, stop and tell the user: \"GitHub CLI is not authenticated. Run `gh auth login` first.\"\n\n## Step 2: Resolve API Slug\n\nRun:\n\n```bash\ncli-printing-press library list --json\n```\n\nParse the JSON output into a list of CLIs. The library is now keyed by API slug (the directory name), not CLI name.\n\n**Name resolution order** (matches the score skill for consistency):\n\n1. **Exact match:** If the argument matches a directory name (API slug) exactly, use it\n2. **CLI name match:** If no exact match, try matching against `cli_name` fields, then derive the API slug from the manifest's `api_name` field\n3. **Suffix match:** If no match yet, try `\u003Cargument>-pp-cli` against `cli_name` fields\n4. **Glob match:** If no suffix match, search for entries where `cli_name` or `api_name` contains the argument as a substring. Cap at 5 most-recent matches. If multiple matches, present them via AskUserQuestion and let the user pick\n5. **No match:** List all available CLIs and ask the user to pick or re-enter\n6. **No argument:** If invoked with no name, list all CLIs sorted by modification time and let the user pick\n\nOnce resolved, read the manifest's `api_name` field to get the API slug. Use this slug for all downstream operations (branch names, registry entries, collision detection, path construction). The `cli_name` from the manifest is only used for binary-level operations.\n\nWhen presenting matches, show the API slug and modification time in a human-friendly format (e.g., \"2 hours ago\", \"3 days ago\").\n\n## Step 3: Determine Category\n\nRead `.printing-press.json` from the resolved CLI directory.\n\n**Category resolution order:**\n\n1. If the manifest has a `category` field, present it for confirmation:\n   > \"Publishing as **\u003Ccategory>**. OK?\"\n   Give the user the option to change it\n\n2. If no `category` but `catalog_entry` is present, look it up:\n   ```bash\n   cli-printing-press catalog show \u003Ccatalog_entry> --json\n   ```\n   Extract the category from the result. Present for confirmation\n\n3. If neither provides a category, present the full list via AskUserQuestion:\n   - developer-tools, monitoring, cloud, project-management\n   - productivity, social-and-messaging, sales-and-crm, marketing\n   - payments, auth, commerce, ai, food-and-dining, health, maps, media-and-entertainment, devices, other\n   - travel\n\n## Step 4: Validate\n\nRun:\n\n```bash\ncli-printing-press publish validate --dir \u003Ccli-dir> --json\n```\n\n`govulncheck` in this step is intentionally scoped to `\u003Ccli-dir>` only. It\nuses the default `govulncheck .\u002F...` mode so reachable symbol findings block\npublish, while merely-required vulnerable modules without a call path do not\nbecome release blockers. Do not replace this with a full public-library scan or\n`govulncheck -show verbose`.\n\nParse the JSON result. Display each check result to the user:\n\n```\nValidating \u003Capi-slug>...\n  manifest        PASS\n  phase5          PASS\n  go mod tidy     PASS\n  govulncheck     PASS\n  go vet          PASS\n  go build        PASS\n  --help          PASS\n  --version       PASS\n  manuscripts     WARN (no manuscripts found)\n```\n\nIf `\"passed\": false`, report the failing checks and **stop**. Do not create a partial PR.\nThe `manifest` check is authoritative for the public-library provenance\ncontract: current `schema_version`, `run_id`, `printing_press_version`,\n`printer`, `printer_name`, and MCP metadata files when MCP is advertised. If it\nfails, tell the user to re-print or re-package with current Printing Press\nmetadata before opening the library PR.\n\nSave the `help_output` field from the result — it's used in the PR description.\n\n## Step 4.5: Live End-to-End Gate\n\nBefore touching the managed publish clone, rerun the live behavioral gate\nagainst the CLI that is about to be published. Step 4 proves the source builds\nand validates structurally; this step proves the current post-edit tree still\nworks against the real upstream API. Do not rely on an older\n`phase5-acceptance.json` from generation or polish because the CLI may have\nbeen hand-edited since that marker was written.\n\nResolve the Phase 5 proofs directory from the CLI manifest:\n\n```bash\nMANIFEST=\"$CLI_DIR\u002F.printing-press.json\"\nAPI_SLUG=$(jq -r '.api_name \u002F\u002F empty' \"$MANIFEST\")\nCLI_NAME=$(jq -r '.cli_name \u002F\u002F empty' \"$MANIFEST\")\nRUN_ID=$(jq -r '.run_id \u002F\u002F empty' \"$MANIFEST\")\nAUTH_TYPE=$(jq -r '.auth_type \u002F\u002F \"none\"' \"$MANIFEST\")\nAUTH_ENV=$(jq -r '.auth_env_vars[0] \u002F\u002F empty' \"$MANIFEST\")\n\nif [ -z \"$API_SLUG\" ] || [ -z \"$RUN_ID\" ]; then\n  echo \"ERROR: manifest is missing api_name or run_id; cannot run publish live gate.\"\n  exit 1\nfi\n\nPROOFS_DIR=\"$CLI_DIR\u002F.manuscripts\u002F$RUN_ID\u002Fproofs\"\nif [ ! -d \"$PROOFS_DIR\" ] && [ -n \"$API_SLUG\" ] && [ -d \"$PRESS_MANUSCRIPTS\u002F$API_SLUG\u002F$RUN_ID\u002Fproofs\" ]; then\n  PROOFS_DIR=\"$PRESS_MANUSCRIPTS\u002F$API_SLUG\u002F$RUN_ID\u002Fproofs\"\nelif [ ! -d \"$PROOFS_DIR\" ] && [ -n \"$CLI_NAME\" ] && [ -d \"$PRESS_MANUSCRIPTS\u002F$CLI_NAME\u002F$RUN_ID\u002Fproofs\" ]; then\n  PROOFS_DIR=\"$PRESS_MANUSCRIPTS\u002F$CLI_NAME\u002F$RUN_ID\u002Fproofs\"\nfi\nmkdir -p \"$PROOFS_DIR\"\n```\n\nIf `SKIP_LIVE_TEST_REASON` is unset, run full live dogfood and write a fresh\nacceptance marker into that proofs directory:\n\n```bash\nLIVE_GATE_JSON=\"$PROOFS_DIR\u002Fpublish-live-gate.json\"\nLIVE_GATE_ARGS=(\n  dogfood\n  --dir \"$CLI_DIR\"\n  --live\n  --level full\n  --timeout 120s\n  --write-acceptance \"$PROOFS_DIR\u002Fphase5-acceptance.json\"\n  --json\n)\nif [ -n \"$AUTH_ENV\" ]; then\n  LIVE_GATE_ARGS+=(--auth-env \"$AUTH_ENV\")\nfi\n\nrm -f \"$PROOFS_DIR\u002Fphase5-skip.json\"\nif ! \"$PRINTING_PRESS_BIN\" \"${LIVE_GATE_ARGS[@]}\" >\"$LIVE_GATE_JSON\"; then\n  echo \"Publish live gate failed. See $LIVE_GATE_JSON and $PROOFS_DIR\u002Fphase5-acceptance.json.\"\n  jq -r '.tests[]? | select(.status == \"fail\") | \"- \\(.command) [\\(.kind)]: \\(.reason \u002F\u002F \"failed\")\"' \"$LIVE_GATE_JSON\" 2>\u002Fdev\u002Fnull || true\n  exit 1\nfi\n```\n\nOn failure, stop exactly like Step 4's `passed: false`: no managed clone, no\nbranch, no package, no PR. Report the failed command, exit code when present,\nstderr or reason snippet, and the path to the fresh proof files so the operator\ncan re-run dogfood and fix the CLI.\n\nIf `SKIP_LIVE_TEST_REASON` is set from `--skip-live-test=\u003Creason>`, write a\nfresh skip marker instead of running dogfood:\n\n```bash\nSKIP_REASON_LOWER=$(printf '%s' \"$SKIP_LIVE_TEST_REASON\" | tr '[:upper:]' '[:lower:]')\ncase \"$AUTH_TYPE\" in\n  api_key|bearer_token|oauth2)\n    ;;\n  none)\n    case \"$SKIP_REASON_LOWER\" in\n      *upstream*outage*|lan-unreachable-from-generation-host)\n        ;;\n      *)\n        echo \"ERROR: --skip-live-test is only valid for auth_type=none during a known upstream outage or LAN-unreachable hardware case.\"\n        exit 1\n        ;;\n    esac\n    ;;\n  *)\n    echo \"ERROR: --skip-live-test is not valid for auth_type=$AUTH_TYPE. Run the live gate instead.\"\n    exit 1\n    ;;\nesac\n\nAPI_KEY_AVAILABLE=false\nif [ -n \"$AUTH_ENV\" ] && [ -n \"${!AUTH_ENV:-}\" ]; then\n  API_KEY_AVAILABLE=true\nfi\n\nrm -f \"$PROOFS_DIR\u002Fphase5-acceptance.json\"\njq -n \\\n  --arg api \"$API_SLUG\" \\\n  --arg run \"$RUN_ID\" \\\n  --arg reason \"$SKIP_LIVE_TEST_REASON\" \\\n  --arg auth \"$AUTH_TYPE\" \\\n  --argjson api_key_available \"$API_KEY_AVAILABLE\" \\\n  --argjson browser_session_available false \\\n  '{\n    schema_version: 1,\n    api_name: $api,\n    run_id: $run,\n    status: \"skip\",\n    level: \"none\",\n    skip_reason: $reason,\n    auth_context: {\n      type: $auth,\n      api_key_available: $api_key_available,\n      browser_session_available: $browser_session_available\n    }\n  }' > \"$PROOFS_DIR\u002Fphase5-skip.json\"\nif [ \"$SKIP_REASON_LOWER\" = \"lan-unreachable-from-generation-host\" ]; then\n  tmp_marker=$(mktemp \"${TMPDIR:-\u002Ftmp}\u002Fphase5-skip.XXXXXX\")\n  jq '.auth_context.local_network_only = true' \"$PROOFS_DIR\u002Fphase5-skip.json\" > \"$tmp_marker\" &&\n    mv \"$tmp_marker\" \"$PROOFS_DIR\u002Fphase5-skip.json\"\nfi\nLIVE_GATE_JSON=\"\"\n```\n\nThen rerun Step 4's validation:\n\n```bash\n\"$PRINTING_PRESS_BIN\" publish validate --dir \"$CLI_DIR\" --json\n```\n\nThis second validation proves the fresh acceptance or skip marker satisfies the\nsame Phase 5 contract that package and publish rely on. If it fails, stop\nbefore Step 5.\n\n## Step 5: Managed Clone\n\nThe publish skill manages its own clone of the library repo at `$PUBLISH_REPO_DIR`.\n\n### First-time setup\n\nIf `$PUBLISH_REPO_DIR` does not exist:\n\n1. **Detect push access:**\n   ```bash\n   GH_USER=$(gh api user --jq '.login')\n   HAS_PUSH=$(gh api repos\u002Fmvanhorn\u002Fprinting-press-library --jq '.permissions.push' 2>\u002Fdev\u002Fnull || echo \"false\")\n   ```\n\n2. **Detect git protocol:**\n   ```bash\n   USE_SSH=false\n   if ssh -T git@github.com 2>&1 | grep -q \"successfully authenticated\"; then\n     USE_SSH=true\n   fi\n   ```\n\n3. **Clone based on access:**\n\n   **Push access** (`HAS_PUSH` is `true`):\n   ```bash\n   # Clone directly — origin IS the upstream\n   if [ \"$USE_SSH\" = \"true\" ]; then\n     REPO_URL=\"git@github.com:mvanhorn\u002Fprinting-press-library.git\"\n   else\n     REPO_URL=\"https:\u002F\u002Fgithub.com\u002Fmvanhorn\u002Fprinting-press-library.git\"\n   fi\n   # Lightweight clone: blobless + shallow + sparse. The publish flow only\n   # touches the target CLI's own directory — it no longer regenerates the\n   # cli-skills\u002Fregistry mirror (see Step 6) — so materializing every other\n   # CLI's source is wasted bandwidth and disk (a full clone is multiple GB;\n   # this is tens of MB). The cone keeps `tools`, `cli-skills`, and the target\n   # `library\u002F\u003Ccategory>` so the in-category find\u002Frm\u002Fcopy operations below work\n   # on a real working tree. Cross-category collision checks use `git ls-tree`\n   # (which reads the full tree from the blobless clone) instead of `ls`.\n   git clone --filter=blob:none --depth 1 --sparse \"$REPO_URL\" \"$PUBLISH_REPO_DIR\"\n   git -C \"$PUBLISH_REPO_DIR\" sparse-checkout set tools cli-skills library\u002F\u003Ccategory>\n   ```\n\n   **No push access** (`HAS_PUSH` is `false`):\n   ```bash\n   # Fork first — fail explicitly if forking is blocked\n   if ! gh repo fork mvanhorn\u002Fprinting-press-library --clone=false 2>&1; then\n     echo \"ERROR: Could not fork mvanhorn\u002Fprinting-press-library.\"\n     echo \"The repo may restrict forking, or you may already have a fork with a different name.\"\n     echo \"Fork manually at https:\u002F\u002Fgithub.com\u002Fmvanhorn\u002Fprinting-press-library\u002Ffork\"\n     exit 1\n   fi\n   FORK=\"$GH_USER\u002Fprinting-press-library\"\n\n   # Build URLs based on protocol preference\n   if [ \"$USE_SSH\" = \"true\" ]; then\n     FORK_URL=\"git@github.com:$FORK.git\"\n     UPSTREAM_URL=\"git@github.com:mvanhorn\u002Fprinting-press-library.git\"\n   else\n     FORK_URL=\"https:\u002F\u002Fgithub.com\u002F$FORK.git\"\n     UPSTREAM_URL=\"https:\u002F\u002Fgithub.com\u002Fmvanhorn\u002Fprinting-press-library.git\"\n   fi\n\n   # Lightweight clone (blobless + shallow + sparse) — see the push-access\n   # branch above for the rationale and cone contents.\n   git clone --filter=blob:none --depth 1 --sparse \"$FORK_URL\" \"$PUBLISH_REPO_DIR\"\n   cd \"$PUBLISH_REPO_DIR\"\n   git sparse-checkout set tools cli-skills library\u002F\u003Ccategory>\n   git remote add upstream \"$UPSTREAM_URL\"\n   git fetch --filter=blob:none --depth 1 upstream\n   ```\n\n4. **Cache the config:**\n   ```json\n   {\n     \"managed_by\": \"printing-press-publish\",\n     \"repo_url\": \"https:\u002F\u002Fgithub.com\u002Fmvanhorn\u002Fprinting-press-library\",\n     \"access\": \"push or fork\",\n     \"gh_user\": \"\u003Cgh username>\",\n     \"protocol\": \"ssh or https\",\n     \"clone_path\": \"\u003Cexpanded $PUBLISH_REPO_DIR>\",\n     \"scope_dir\": \"\u003Cabsolute source worktree path>\",\n     \"module_path_base\": \"github.com\u002Fmvanhorn\u002Fprinting-press-library\u002Flibrary\"\n   }\n   ```\n   Write to `$PUBLISH_CONFIG`. The `access` field determines the flow for all subsequent steps. The `gh_user` field is used for cross-repo PR heads. The `module_path_base` always references the upstream repo (PRs land there).\n\n### Subsequent publishes\n\nRead `$PUBLISH_CONFIG`, then re-check access in case it changed (user was granted push access, or access was revoked):\n\n```bash\nCURRENT_ACCESS=$(gh api repos\u002Fmvanhorn\u002Fprinting-press-library --jq '.permissions.push' 2>\u002Fdev\u002Fnull || echo \"false\")\nCACHED_ACCESS=$(jq -r .access \"$PUBLISH_CONFIG\")\n\nif [ \"$CURRENT_ACCESS\" = \"true\" ] && [ \"$CACHED_ACCESS\" = \"fork\" ]; then\n  echo \"Access upgraded to push. Reconfiguring clone...\"\n  rm -rf \"$PUBLISH_REPO_DIR\"\n  # Re-run first-time setup with push access\nfi\nif [ \"$CURRENT_ACCESS\" = \"false\" ] && [ \"$CACHED_ACCESS\" = \"push\" ]; then\n  echo \"Push access revoked. Reconfiguring clone with fork...\"\n  rm -rf \"$PUBLISH_REPO_DIR\"\n  # Re-run first-time setup with fork access\nfi\n```\n\nIf the clone was removed due to an access change, re-run first-time setup above. Otherwise, freshen the clone to match the canonical upstream:\n\n```bash\ncd \"$PUBLISH_REPO_DIR\"\n\nif [ \"$(jq -r .access $PUBLISH_CONFIG)\" = \"push\" ]; then\n  # Push access: origin IS the upstream\n  git fetch --filter=blob:none --depth 1 origin\n  git checkout main\n  git reset --hard origin\u002Fmain\nelse\n  # Fork: origin is the fork, upstream is canonical\n  git fetch --filter=blob:none --depth 1 upstream\n  git checkout main\n  git reset --hard upstream\u002Fmain\n  # Also sync origin (fork) so git push works cleanly\n  git push origin main --force-with-lease 2>\u002Fdev\u002Fnull || true\nfi\n\n# Existing managed clones may already be sparse for a different publish\n# category. Refresh the cone for the current target category before Step 6 uses\n# filesystem-based removal and copy operations.\nif git -C \"$PUBLISH_REPO_DIR\" config --bool core.sparseCheckout | grep -qx true; then\n  git -C \"$PUBLISH_REPO_DIR\" sparse-checkout set tools cli-skills library\u002F\u003Ccategory>\nfi\n```\n\nVerify the clone is healthy:\n\n```bash\ngit rev-parse --is-inside-work-tree\ntest \"$(git rev-parse --abbrev-ref HEAD)\" = \"main\"\n```\n\nIf this fails, the clone is corrupt. Remove `$PUBLISH_REPO_DIR` and re-run first-time setup.\n\n### Interrupted state recovery\n\nBefore creating a new branch, check for uncommitted changes:\n\n```bash\ncd \"$PUBLISH_REPO_DIR\"\ngit status --porcelain\n```\n\nIf there are uncommitted changes, ask the user via AskUserQuestion:\n- \"Reset and start fresh\"\n- \"Continue with existing changes\"\n\nIf reset, run `git checkout -- . && git clean -fd`.\n\n### Pre-package publication-state snapshot\n\nBefore Step 6 mutates the managed clone, record whether this API slug already\nexists in the public library tree. Step 6 removes and replaces\n`library\u002F*\u002F\u003Capi-slug>`, so any collision or publication-path decision made\nafter packaging must use this pre-package snapshot, not a fresh `ls`.\n\n```bash\n# Read from the git tree, not the working dir: the sparse checkout only\n# materializes the target category, but a slug can collide in any category.\nPREEXISTING_MERGED_PATHS=$(git -C \"$PUBLISH_REPO_DIR\" ls-tree -r --name-only HEAD \\\n  | sed -n 's#^\\(library\u002F[^\u002F]*\u002F\u003Capi-slug>\\)\u002F.*#\\1#p' | sort -u || true)\nPREEXISTING_MERGED_COLLISION=false\nif [ -n \"$PREEXISTING_MERGED_PATHS\" ]; then\n  PREEXISTING_MERGED_COLLISION=true\n  # If this is a category-change reprint, materialize the existing category path\n  # before Step 6 runs filesystem-based ledger preservation and removal.\n  if git -C \"$PUBLISH_REPO_DIR\" config --bool core.sparseCheckout | grep -qx true; then\n    while IFS= read -r EXISTING_MERGED_PATH; do\n      [ -n \"$EXISTING_MERGED_PATH\" ] || continue\n      if [ \"$EXISTING_MERGED_PATH\" != \"library\u002F\u003Ccategory>\u002F\u003Capi-slug>\" ]; then\n        git -C \"$PUBLISH_REPO_DIR\" sparse-checkout add \"$EXISTING_MERGED_PATH\"\n      fi\n    done \u003C\u003CEOF\n$PREEXISTING_MERGED_PATHS\nEOF\n  fi\nfi\n```\n\n## Step 6: Package\n\nRead `$PUBLISH_CONFIG` to get `module_path_base`. Construct the full module path using the API slug (not the CLI name):\n\n```\nMODULE_PATH=\"\u003Cmodule_path_base>\u002F\u003Ccategory>\u002F\u003Capi-slug>\"\n```\n\nFor example: `github.com\u002Fmvanhorn\u002Fprinting-press-library\u002Flibrary\u002Fproductivity\u002Fnotion`\n\nRun `publish package` with `--target` to stage the CLI into a unique temporary\ndirectory, then copy it into the publish repo:\n\n```bash\nPUBLISH_STAGING_ROOT=\"\u002Ftmp\u002Fprinting-press\u002Fpublish\"\nmkdir -p \"$PUBLISH_STAGING_ROOT\"\nSTAGING_PARENT=\"$(mktemp -d \"$PUBLISH_STAGING_ROOT\u002F\u003Capi-slug>-XXXXXX\")\"\nSTAGING_DIR=\"$STAGING_PARENT\u002Fpackage\"\n\ncli-printing-press publish package \\\n  --dir \u003Ccli-dir> \\\n  --category \u003Ccategory> \\\n  --target \"$STAGING_DIR\" \\\n  --module-path \"$MODULE_PATH\" \\\n  --json\n```\n\nParse the JSON result. Note the `staged_dir`, `module_path`, `manuscripts_included`, and `run_id`. The `module_path` field confirms the Go module path that was set in the packaged CLI's `go.mod` and import paths.\n\n`publish package` performs the mandatory vendor-prefix secret scan over the staged CLI, including copied manuscripts, before returning success. If it reports `vendor-prefix tokens detected`, stop and remove or redact the reported file:line findings before retrying. This is a hard gate and does not depend on `gitleaks`, `trufflehog`, or destination-repo push protection.\n\nThen copy the staged CLI into the publish repo, replacing any existing version\nwhile preserving the public library's release ledger files when this is a\nreprint:\n\n```bash\nSTAGED_CLI_DIR=\"$STAGING_DIR\u002Flibrary\u002F\u003Ccategory>\u002F\u003Capi-slug>\"\nDEST_CATEGORY_DIR=\"$PUBLISH_REPO_DIR\u002Flibrary\u002F\u003Ccategory>\"\nDEST_CLI_DIR=\"$DEST_CATEGORY_DIR\u002F\u003Capi-slug>\"\n\nif [ ! -d \"$STAGED_CLI_DIR\" ]; then\n  echo \"missing staged CLI directory: $STAGED_CLI_DIR\" >&2\n  exit 1\nfi\nmkdir -p \"$DEST_CATEGORY_DIR\"\n\n# Preserve release-ledger files from the current public-library entry before\n# removing it. New CLIs omit .printing-press-release.json until the library's\n# post-merge workflow stamps a real release; reprints keep existing changelog\n# history and release metadata until that workflow stamps the next release.\nRELEASE_LEDGER_TMP=\"$(mktemp -d)\"\nPUBLISH_SWAP_DIR=\"$(mktemp -d \"$DEST_CATEGORY_DIR\u002F.\u003Capi-slug>.XXXXXX\")\"\ntrap 'rm -rf \"$RELEASE_LEDGER_TMP\" \"$PUBLISH_SWAP_DIR\"' EXIT\nfor LEDGER_FILE in CHANGELOG.md .printing-press-release.json; do\n  EXISTING_LEDGER=\"$(find \"$PUBLISH_REPO_DIR\u002Flibrary\" -mindepth 3 -maxdepth 3 -path \"*\u002F\u003Capi-slug>\u002F$LEDGER_FILE\" -print -quit)\"\n  if [ -n \"$EXISTING_LEDGER\" ]; then\n    cp \"$EXISTING_LEDGER\" \"$RELEASE_LEDGER_TMP\u002F$LEDGER_FILE\"\n  fi\ndone\n\n# Copy staged CLI into a same-category swap dir before deleting the current\n# public-library entry. This keeps a failed copy from leaving the publish repo\n# with the old CLI removed.\ncp -R \"$STAGED_CLI_DIR\u002F.\" \"$PUBLISH_SWAP_DIR\u002F\"\n\nfor LEDGER_FILE in CHANGELOG.md .printing-press-release.json; do\n  if [ -f \"$RELEASE_LEDGER_TMP\u002F$LEDGER_FILE\" ]; then\n    cp \"$RELEASE_LEDGER_TMP\u002F$LEDGER_FILE\" \"$PUBLISH_SWAP_DIR\u002F$LEDGER_FILE\"\n  fi\ndone\n\n# Remove existing version (handles category changes), then atomically install\n# the prepared replacement within the destination category.\nrm -rf \"$PUBLISH_REPO_DIR\u002Flibrary\"\u002F*\u002F\"\u003Capi-slug>\"\nmv \"$PUBLISH_SWAP_DIR\" \"$DEST_CLI_DIR\"\nrm -rf \"$RELEASE_LEDGER_TMP\"\ntrap - EXIT\n\n# Remove root-level binaries (should not be committed). publish package\n# already strips these before the copy; this rm -f is belt-and-suspenders\n# for the agent path. Cover the names local build paths can drop: bare slug,\n# CLI binary, live-dogfood probe binary, and MCP peer.\nrm -f \"$PUBLISH_REPO_DIR\u002Flibrary\u002F\u003Ccategory>\u002F\u003Capi-slug>\u002F\u003Capi-slug>\" \\\n      \"$PUBLISH_REPO_DIR\u002Flibrary\u002F\u003Ccategory>\u002F\u003Capi-slug>\u002F\u003Ccli-name>\" \\\n      \"$PUBLISH_REPO_DIR\u002Flibrary\u002F\u003Ccategory>\u002F\u003Capi-slug>\u002F\u003Ccli-name>-dogfood\" \\\n      \"$PUBLISH_REPO_DIR\u002Flibrary\u002F\u003Ccategory>\u002F\u003Capi-slug>\u002F\u003Capi-slug>-pp-mcp\"\n\n# Defense-in-depth: validate printer attribution before README and registry surfaces.\nPRINTER=$(jq -r '.printer \u002F\u002F \"\"' \"$PUBLISH_REPO_DIR\u002Flibrary\u002F\u003Ccategory>\u002F\u003Capi-slug>\u002F.printing-press.json\")\nPRINTER_NAME=$(jq -r '.printer_name \u002F\u002F \"\"' \"$PUBLISH_REPO_DIR\u002Flibrary\u002F\u003Ccategory>\u002F\u003Capi-slug>\u002F.printing-press.json\")\nif [ -z \"$PRINTER\" ]; then\n  echo \"ERROR: manifest .printer is empty. Set 'git config --global github.user \u003Cyour-handle>' and re-print before publishing.\"\n  exit 1\nfi\nif [ \"$PRINTER\" = \"USER\" ] || [ \"$PRINTER\" = \"user\" ]; then\n  echo \"ERROR: manifest .printer is the literal sentinel \\\"$PRINTER\\\" (git config github.user was unset at print time). Set it and re-print before publishing.\"\n  exit 1\nfi\nif [ -z \"$PRINTER_NAME\" ]; then\n  echo \"ERROR: manifest .printer_name is empty. Set 'git config --global user.name \u003Cyour display name>' and re-print before publishing.\"\n  exit 1\nfi\n\n# Do NOT regenerate or commit `cli-skills\u002Fpp-\u003Capi-slug>\u002FSKILL.md` or\n# `registry.json` here. Both are regenerated post-merge by the library's\n# `generate-skills.yml` and `generate-registry.yml` workflows via\n# `[skip ci]` bot commits. The library's `Fail on changes to generated\n# artifacts` check in `verify-library-conventions.yml` hard-fails any PR\n# whose diff against base touches these files, regardless of fork vs\n# same-repo origin. The library no longer has an in-PR auto-fix path;\n# do not re-introduce a mirror or registry regen here. Also do NOT hand-update\n# CHANGELOG.md, .printing-press-release.json, or runtime version strings for\n# release accounting; the library release-ledger workflow owns those post-merge.\n\n# Verify this changed\u002Fnew CLI builds and has no reachable Go vulnerabilities from the publish repo\ncd \"$PUBLISH_REPO_DIR\u002Flibrary\u002F\u003Ccategory>\u002F\u003Capi-slug>\" \\\n  && go build .\u002F... \\\n  && go run golang.org\u002Fx\u002Fvuln\u002Fcmd\u002Fgovulncheck@v1.3.0 .\u002F...\n```\n\nKeep vulnerability verification scoped to `library\u002F\u003Ccategory>\u002F\u003Capi-slug>` in\npublish PRs. The public library is a historical collection and cannot be kept\nfully current on every unrelated PR; whole-library govulncheck sweeps belong in\na scheduled\u002Freporting workflow, while blocking CI should scan only added or\nchanged CLI modules.\n\nAfter the publish repo copy and build verification are complete, remove the staging\ndirectory:\n\n```bash\nrm -rf \"$STAGING_PARENT\"\n```\n\nNote: `staged_dir` is keyed by the API slug (e.g., `espn`), matching the publish repo's directory layout. The copy step is a same-name copy, not a rename.\n\n## Step 6.5: Record Customizations\n\nBefore collision detection or branch creation, inspect the packaged CLI's\ncustomizations index:\n\nThe index ships in one of two shapes: the per-patch directory\n`.printing-press-patches\u002F` (current) or the legacy single-array\n`.printing-press-patches.json` (older prints, not yet normalized). Validate\nwhichever is present:\n\n```bash\nPATCHES_DIR=\"$PUBLISH_REPO_DIR\u002Flibrary\u002F\u003Ccategory>\u002F\u003Capi-slug>\u002F.printing-press-patches\"\nPATCHES_INDEX=\"$PUBLISH_REPO_DIR\u002Flibrary\u002F\u003Ccategory>\u002F\u003Capi-slug>\u002F.printing-press-patches.json\"\nif [ -d \"$PATCHES_DIR\" ]; then\n  # Per-patch directory: every \u003Cid>.json must be a JSON object carrying the same\n  # provenance the legacy single-array file kept at its top level (now per file),\n  # so validation is at parity with the legacy branch below. _meta.json\n  # (CLI-global lists) and .gitkeep are exempt.\n  for f in \"$PATCHES_DIR\"\u002F*.json; do\n    [ -e \"$f\" ] || continue\n    [ \"$(basename \"$f\")\" = \"_meta.json\" ] && continue\n    if ! jq -e '\n      (type == \"object\") and\n      (.schema_version | type == \"number\") and\n      (.id | type == \"string\" and length > 0) and\n      (.applied_at | type == \"string\" and length > 0) and\n      (.base_run_id | type == \"string\" and length > 0) and\n      (.base_printing_press_version | type == \"string\" and length > 0)\n    ' \"$f\" >\u002Fdev\u002Fnull; then\n      echo \"ERROR: packaged CLI has a malformed patch file $f. Reprint with a current cli-printing-press binary before publishing.\"\n      exit 1\n    fi\n  done\nelif [ -f \"$PATCHES_INDEX\" ]; then\n  if ! jq -e '\n    (.schema_version | type == \"number\") and\n    (.applied_at | type == \"string\" and length > 0) and\n    (.base_run_id | type == \"string\" and length > 0) and\n    (.base_printing_press_version | type == \"string\" and length > 0) and\n    (.patches | type == \"array\")\n  ' \"$PATCHES_INDEX\" >\u002Fdev\u002Fnull; then\n    echo \"ERROR: packaged CLI has malformed .printing-press-patches.json. Reprint with a current cli-printing-press binary before publishing.\"\n    exit 1\n  fi\nelse\n  echo \"ERROR: packaged CLI is missing its patches index (.printing-press-patches\u002F or .printing-press-patches.json). Reprint with a current cli-printing-press binary before publishing.\"\n  exit 1\nfi\n```\n\nFresh prints from current `cli-printing-press generate` include the\n`.printing-press-patches\u002F` directory with just a `.gitkeep`; leave it unchanged\nwhen no hand customization was made after generation. If neither shape is\npresent, the CLI was generated by an older binary; reprint with a current\n`cli-printing-press` build rather than synthesizing the\ndeterministic provenance fields by hand.\n\n## Step 6.6: Record contributor attribution\n\nWhen the human running this publish is **not** the CLI's original creator,\nrecord them as a contributor so they are credited in the README byline, NOTICE,\nand the public registry. The command is idempotent — it skips the creator and\nanyone already listed — so it is safe to run on every publish:\n\n```bash\n\"$PRINTING_PRESS_BIN\" contributors add \\\n  --dir \"$PUBLISH_REPO_DIR\u002Flibrary\u002F\u003Ccategory>\u002F\u003Capi-slug>\" \\\n  || echo \"note: this binary predates 'contributors add'; skipping contributor recording\"\n```\n\nThe step is best-effort: `contributors add` is an additive command, so a binary\nthat predates it simply skips recording rather than blocking the publish (the\n`min-binary-version` floor only tracks the major). Pass `--front` when this\npublish is a reprint (a from-scratch regeneration) so the reprinter is listed\nfirst among contributors. Never edit `contributors[]` or the `creator` block by\nhand — the creator is permanent, and the command owns the list (matching the\nmanifest-as-authority rule).\n\nIf you changed generated CLI files during the print or publish session, record\none concise entry per customization before opening the library PR — one\n`.printing-press-patches\u002F\u003Cid>.json` file per patch (the directory supersedes the\nlegacy `patches[]` array, so concurrent PRs never conflict). These entries are\nthe durable hand-edit contract that tells future agents and regen tooling what\nmust be preserved beyond generator output.\n\nUse this shape (one file, `.printing-press-patches\u002F\u003Cid>.json`):\n\n```json\n{\n  \"schema_version\": 2,\n  \"id\": \"\u003Capi-slug>-\u003Cshort-feature-name>\",\n  \"applied_at\": \"\u003CYYYY-MM-DD>\",\n  \"base_run_id\": \"\u003Ccopy from .printing-press.json>\",\n  \"base_printing_press_version\": \"\u003Ccopy from .printing-press.json>\",\n  \"summary\": \"What changed (one sentence).\",\n  \"reason\": \"Why the generated output needed this customization.\",\n  \"files\": [\"internal\u002Fcli\u002Fexample.go\"],\n  \"validated_outcome\": \"Optional: focused check that proved the customization.\",\n  \"upstream_issue\": \"Optional: https:\u002F\u002Fgithub.com\u002Fmvanhorn\u002Fcli-printing-press\u002Fissues\u002F\u003Cn>\"\n}\n```\n\nRules:\n\n- Filename is the patch `id`. Use kebab-case ids prefixed with the API slug for\n  grep-ability across the public library.\n- Keep `summary` and `reason` short. Each entry is an index, not a duplicate\n  of the git diff.\n- Include non-Go support files in `files` when they are part of the same\n  code-level customization. README\u002FSKILL.md-only polish does not need a patch\n  manifest entry.\n- Inline `\u002F\u002F PATCH(...)` source comments are optional navigation aids. The public\n  library verifier requires a patches index (the directory or the legacy file)\n  and well-formed entries; it does not require a marker\u002Fcomment pairing.\n- If an entry exists only to work around an old verifier or pipeline bug that no\n  longer applies, delete the stale workaround file instead of carrying it\n  forward.\n\nFor the authoritative public-library authoring contract, read the\n`mvanhorn\u002Fprinting-press-library` `AGENTS.md` section\n\"`.printing-press-patches\u002F` records library-side customizations\".\n\n## Step 7: Collision Detection & Resolution\n\nAfter the managed clone is freshened, check for name collisions before creating a branch or PR. This replaces the previous \"Check for Existing PR\" step.\n\n### Detection\n\nRun these checks in sequence:\n\n**1. Check merged CLIs in managed clone:**\n\n```bash\nMERGED_COLLISION=\"$PREEXISTING_MERGED_COLLISION\"\nMERGED_PATHS=\"$PREEXISTING_MERGED_PATHS\"\n```\n\nUse the pre-package snapshot from Step 5. Do not re-run `ls\n\"$PUBLISH_REPO_DIR\u002Flibrary\"\u002F*\u002F\"\u003Capi-slug>\"` here: Step 6 has already copied the\nnew package into that path, so a fresh `ls` would make every new print look like\na merged collision. If `MERGED_COLLISION=true`, note the category path from\n`MERGED_PATHS`.\n\n**2. Check all open PRs (any author):**\n\n```bash\ngh pr list --repo mvanhorn\u002Fprinting-press-library --head \"feat\u002F\u003Capi-slug>\" --state open --json number,title,url,author\n```\n\nIf the list is non-empty, record `PR_COLLISION=true`. For each PR, note the PR number, URL, and author login.\n\n**3. Identify own PRs:**\n\nFilter the PR list from step 2 by `--author @me`:\n\nFor fork-based PRs, the head includes the username prefix:\n\n```bash\nACCESS=$(jq -r .access \"$PUBLISH_CONFIG\")\nGH_USER=$(jq -r .gh_user \"$PUBLISH_CONFIG\")\n\nif [ \"$ACCESS\" = \"fork\" ]; then\n  HEAD_REF=\"$GH_USER:feat\u002F\u003Capi-slug>\"\nelse\n  HEAD_REF=\"feat\u002F\u003Capi-slug>\"\nfi\n\ngh pr list --repo mvanhorn\u002Fprinting-press-library --head \"$HEAD_REF\" --state open --author @me --json number,title,url\n```\n\nIf found, record `OWN_PR=true`, store `EXISTING_PR_NUMBER` and `EXISTING_PR_URL`.\n\n**If no open PR was found**, also check for a previously merged PR on the same branch — by ANY author, not just yours:\n\n```bash\nMERGED_PR=$(gh pr list --repo mvanhorn\u002Fprinting-press-library --head \"$HEAD_REF\" --state merged --json number --jq '.[0].number' 2>\u002Fdev\u002Fnull)\n```\n\nIf `MERGED_PR` is non-empty, the branch name was already used and merged. Set `BRANCH_MERGED=true` so Step 8 creates a new branch name (e.g., `feat\u002F\u003Capi-slug>-YYYYMMDD`) instead of reusing the merged branch. Do NOT force-push onto a merged branch — `gh pr edit` would silently update a closed PR nobody is watching.\n\nThe author-agnostic lookup also catches **squash-zombie branches**: GitHub squash-merge leaves the source branch behind on the remote, with pre-squash commit refs that look \"ahead of main\" but are content-equivalent to the squash commit. Without this check, the skill misclassifies the zombie as fresh-publish, then `git push -u` fails because the remote branch already exists. Timestamping sidesteps the issue entirely.\n\n### No collision\n\nIf no merged CLI exists and no open PRs match (other than your own), set `EXISTING_PR_NUMBER` from the own-PR check (or empty if none) and proceed to Step 8 normally.\n\nIf an existing open PR of yours was found, inform the user:\n> \"Found your open PR #N for `\u003Capi-slug>`. Will update it with the new version.\"\n\n### Collision detected — display info\n\nShow the user what was found:\n\n```\n⚠️  Name collision detected for \u003Capi-slug>\n\n  Merged: \u003Ccategory>\u002F\u003Capi-slug> exists in the library\n  Open PR: #\u003Cnumber> by \u003Cauthor> — \u003Curl>\n```\n\nShow all applicable lines. If `OWN_PR=true`, tag the PR as \"(yours)\".\n\n### Resolution paths\n\nPresent three options via AskUserQuestion:\n\n**If `OWN_PR=true` (your own open PR exists):**\n- **Update** — Update your existing PR with the new version (default, preserves current behavior)\n- **Alongside** — Rename yours with a qualifier and publish next to the existing one\n- **Bail** — Cancel the publish\n\n**If PR collision exists but is another user's, or merged collision only:**\n- **Replace** — Intentionally overwrite the existing CLI\n- **Alongside** — Rename yours with a qualifier and publish next to the existing one\n- **Bail** — Cancel the publish and view the existing CLI\u002FPR\n\n#### Update path (own PR)\n\nThis is the existing update flow with a divergence guard. Set\n`EXISTING_PR_NUMBER` from the detection step and proceed to Step 8, which\nfetches the current PR branch head, checks for branch-only fixes that the new\npackage would revert, and only then handles force-push and PR description\nupdate.\n\n#### Replace path\n\n**For merged CLIs or your own PR:** Standard confirmation:\n> \"This will replace the existing `\u003Capi-slug>`. Continue?\"\n\n**For another user's PR:** Stronger confirmation naming the other author:\n> \"⚠️  This will replace `\u003Cauthor>`'s `\u003Capi-slug>` (PR #N). Are you sure?\"\n\nIf confirmed:\n- The PR description must include: `⚠️ **Replaces existing \\`\u003Capi-slug>\\`** — \u003Creason provided by user or \"newer version\">`\n- Set `EXISTING_PR_NUMBER=\"\"` (create a new PR, don't update theirs)\n- Proceed to Step 8 normally\n\n#### Alongside path (rename)\n\n**1. Extract the original API slug** from the manifest's `api_name` field:\n\n```bash\n# Read from .printing-press.json in the publish repo's staged CLI\nORIGINAL_API_SLUG=$(cat \"$PUBLISH_REPO_DIR\u002Flibrary\u002F\u003Ccategory>\u002F\u003Capi-slug>\u002F.printing-press.json\" | jq -r '.api_name')\n```\n\n**2. Generate rename suggestions** using slug format. Derive the new CLI name from the chosen slug:\n\n- Numeric: `\u003Capi-slug>-2` (if that collides, try `-3`, `-4`, etc.)\n- Non-numeric: `\u003Capi-slug>-alt`\n- Custom: prompt the user for a qualifier word\n\nAfter the user chooses a slug, compute:\n\n```bash\nNEW_API_SLUG=\"\u003Cchosen-slug>\"\nNEW_CLI_NAME=\"${NEW_API_SLUG}-pp-cli\"\n```\n\nPresent the format to the user:\n> \"Rename format: `\u003Capi-slug>-\u003Cqualifier>`. Pick a qualifier:\"\n>\n> 1. `2` → `\u003Capi-slug>-2`\n> 2. `alt` → `\u003Capi-slug>-alt`\n> 3. Enter custom qualifier\n\n**3. Verify each suggestion is non-colliding** before presenting:\n\n```bash\n# Check merged (read the git tree, not the sparse working dir)\ngit -C \"$PUBLISH_REPO_DIR\" ls-tree -r --name-only HEAD \\\n  | sed -n 's#^\\(library\u002F[^\u002F]*\u002F\u003Csuggestion>\\)\u002F.*#\\1#p' | sort -u\n# Check open PRs\ngh pr list --repo mvanhorn\u002Fprinting-press-library --head \"feat\u002F\u003Csuggestion>\" --state open --json number\n```\n\nIf a suggestion collides, skip it or increment the numeric suffix.\n\n**4. Rename the CLI in the publish repo:**\n\nSince Step 6 copied the staged CLI into `$PUBLISH_REPO_DIR`, the rename operates on that directory. Note: `--old-name`\u002F`--new-name` still use CLI-name format (e.g., `dub-pp-cli`) because `RenameCLI` does content replacement — bare slugs would cause collateral damage. The `--dir` path uses the slug-keyed directory.\n\n```bash\ncli-printing-press publish rename \\\n  --dir \"$PUBLISH_REPO_DIR\u002Flibrary\u002F\u003Ccategory>\u002F\u003Capi-slug>\" \\\n  --old-name \u003Cold-cli-name> \\\n  --new-name \"$NEW_CLI_NAME\" \\\n  --json\n```\n\nParse the JSON result. Verify `\"success\": true`. Note that `new_dir` should now be `$PUBLISH_REPO_DIR\u002Flibrary\u002F\u003Ccategory>\u002F$NEW_API_SLUG`.\n\n**5. Update all downstream references for Step 8:**\n\n- Branch name: `feat\u002F$NEW_API_SLUG` (not the old slug)\n- PR title: `feat($NEW_API_SLUG): add $NEW_API_SLUG`\n- Commit message: `feat($NEW_API_SLUG): add $NEW_API_SLUG`\n- Registry.json entry: `name` → `$NEW_API_SLUG`\n- Set `EXISTING_PR_NUMBER=\"\"` (always a new PR for a renamed CLI)\n\nProceed to Step 8 with the new name.\n\n#### Bail path\n\nShow links to what exists:\n- If merged: \"Existing CLI at `library\u002F\u003Ccategory>\u002F\u003Capi-slug>\u002F`\"\n- If open PR: \"Open PR: \u003Curl>\"\n\nExit the publish flow. If Step 6 already wrote files into `$PUBLISH_REPO_DIR`, clean up with `git checkout -- . && git clean -fd` in the managed clone.\n\n## Step 8: Branch, Commit, and PR\n\n### Create branch\n\n**If `EXISTING_PR_NUMBER` is set** (updating an existing PR):\n\nFetch and inspect the current PR branch before replacing it. The latest\n`origin\u002Fmain` plus the newly packaged `library\u002F\u003Ccategory>\u002F\u003Capi-slug>\u002F` tree is\nthe proposed update. The remote PR branch may also contain accepted review\nfixes from the drive-to-green loop. Those branch-only edits must not be erased\nsilently.\n\n```bash\nUPDATE_BRANCH=\"feat\u002F\u003Capi-slug>\"\nUPDATE_BASE_REF=\"refs\u002Fprinting-press-update-base\u002F\u003Capi-slug>\"\n\ngit fetch origin \"+main:refs\u002Fremotes\u002Forigin\u002Fmain\" \"+$UPDATE_BRANCH:$UPDATE_BASE_REF\"\n\n# Show the scoped change from the current PR head to the new packaged working\n# tree. This is informational for clean updates and mandatory context for holds.\ngit diff --stat \"$UPDATE_BASE_REF\" -- \"library\u002F\u003Ccategory>\u002F\u003Capi-slug>\u002F\"\n\n# Branch-only paths are files that exist on the current PR branch but are absent\n# from the new packaged working tree. These are always a hold because a\n# force-push would delete them.\nWORKTREE_PATHS=$(find \"library\u002F\u003Ccategory>\u002F\u003Capi-slug>\" -type f -print 2>\u002Fdev\u002Fnull | sort)\nBRANCH_ONLY_PATHS=$(comm -23 \\\n  \u003C(git ls-tree -r --name-only \"$UPDATE_BASE_REF\" -- \"library\u002F\u003Ccategory>\u002F\u003Capi-slug>\u002F\" | sort) \\\n  \u003C([ -n \"$WORKTREE_PATHS\" ] && printf '%s\\n' \"$WORKTREE_PATHS\" || true))\n\n# Modified paths need human review only when a branch patch relative to\n# origin\u002Fmain is not present in the new packaged working tree. A strict superset\n# passes: if the branch patch can be reverse-applied from the working tree, the\n# fix is still there even if the file also has fresh generated changes.\nBRANCH_ONLY_EDITS=$(git diff --name-only origin\u002Fmain \"$UPDATE_BASE_REF\" -- \"library\u002F\u003Ccategory>\u002F\u003Capi-slug>\u002F\" | while read -r path; do\n  [ -n \"$path\" ] || continue\n  if git diff origin\u002Fmain \"$UPDATE_BASE_REF\" -- \"$path\" | git apply --check --reverse >\u002Fdev\u002Fnull 2>&1; then\n    continue\n  else\n    printf '%s\\n' \"$path\"\n  fi\ndone | sort -u)\n\nif [ -n \"$BRANCH_ONLY_PATHS$BRANCH_ONLY_EDITS\" ]; then\n  echo \"HOLD: updating PR #$EXISTING_PR_NUMBER would overwrite branch-only changes.\"\n  if [ -n \"$BRANCH_ONLY_PATHS\" ]; then\n    echo \"Files present on the PR branch but missing from the new package:\"\n    printf '%s\\n' \"$BRANCH_ONLY_PATHS\" | sed 's\u002F^\u002F- \u002F'\n  fi\n  if [ -n \"$BRANCH_ONLY_EDITS\" ]; then\n    echo \"Files edited on the PR branch and changed again by the new package:\"\n    printf '%s\\n' \"$BRANCH_ONLY_EDITS\" | sed 's\u002F^\u002F- \u002F'\n  fi\n  echo \"Do not push yet. Reconcile by restoring the branch-only fixes onto the new tree, or ask the user for explicit overwrite confirmation after showing the paths above.\"\n  exit 1\nfi\n```\n\nIf the guard exits, offer the user two choices via `AskUserQuestion`:\n\n- **Reconcile first** — restore the named branch-only files or edits onto the\n  new packaged tree, keep or add matching `.printing-press-patches\u002F\u003Cid>.json`\n  records for code-level fixes, rerun Step 6 verification, then rerun this\n  divergence guard.\n- **Overwrite intentionally** — only after the user confirms the listed paths\n  are obsolete, continue and include a PR-body note naming the overwritten\n  branch-only paths.\n\nIf the guard finds no branch-only paths or edits, overwrite the local branch:\n\n```bash\ngit checkout -B feat\u002F\u003Capi-slug>\n```\n\n**If `EXISTING_PR_NUMBER` is empty and `BRANCH_MERGED` is true** (previous PR was merged):\n\nAuto-create a timestamped branch — do not reuse the merged branch name:\n\n```bash\ngit checkout -b feat\u002F\u003Capi-slug>-$(date +%Y%m%d)\n```\n\n**If `EXISTING_PR_NUMBER` is empty and `BRANCH_MERGED` is not set** (no open or merged PR):\n\nCheck for stale branches and competing PRs:\n\n```bash\n# Check local and remote branches\nLOCAL_BRANCH=$(git branch --list \"feat\u002F\u003Capi-slug>\" | head -1)\nREMOTE_BRANCH=$(git ls-remote --heads origin \"feat\u002F\u003Capi-slug>\" 2>\u002Fdev\u002Fnull | head -1)\n\n# If a remote branch exists, check who owns it\nif [ -n \"$REMOTE_BRANCH\" ]; then\n  # Check for ANY open PR on this branch (not just ours)\n  OTHER_PR=$(gh pr list --repo mvanhorn\u002Fprinting-press-library --head \"feat\u002F\u003Capi-slug>\" --state open --json number,author --jq '.[0]' 2>\u002Fdev\u002Fnull)\nfi\n```\n\n**If another user's open PR exists on this branch** (`OTHER_PR` is non-empty and author is not `@me`):\n> \"Someone else has an open PR for `\u003Capi-slug>` (PR #N by @author). Creating a timestamped branch to avoid conflicts.\"\n\nAuto-create a timestamped branch: `feat\u002F\u003Capi-slug>-YYYYMMDD`. Do NOT offer to overwrite — that would stomp their work.\n\n**If the branch exists but no competing PR** (stale branch from a previously closed\u002Fmerged PR):\n\nAsk via AskUserQuestion:\n> \"Found a stale branch `feat\u002F\u003Capi-slug>` (likely from a previous publish). Overwrite it?\"\n\n- \"Overwrite existing branch\" — reuse the branch name\n- \"Create timestamped variant (feat\u002F\u003Capi-slug>-YYYYMMDD)\"\n\n**If no branch exists:** Create normally.\n\n```bash\n# New branch:\ngit checkout -b feat\u002F\u003Capi-slug>\n\n# Overwrite existing:\ngit checkout -B feat\u002F\u003Capi-slug>\n```\n\n### Commit and push\n\n```bash\ncd \"$PUBLISH_REPO_DIR\"\ngit add library\u002F\n# The library .gitignore has a `*-pp-mcp` rule intended for the built MCP\n# binary, but the pattern also matches the generated MCP *source* directory\n# `cmd\u002F\u003Capi-slug>-pp-mcp\u002F`. A plain `git add library\u002F` silently skips it, and\n# the PR then fails the \"Validate MCPB manifest contract\" CI check with\n# \"cmd\u002F\u003Capi-slug>-pp-mcp directory is missing\". Force-add the source directory\n# so all MCP entry-point files ship. The built binary stays ignored because it\n# lives at the packaged CLI root, not under cmd\u002F.\ngit add -f \"library\u002F\u003Ccategory>\u002F\u003Capi-slug>\u002Fcmd\u002F\u003Capi-slug>-pp-mcp\u002F\" 2>\u002Fdev\u002Fnull || true\ngit commit -m \"feat(\u003Capi-slug>): add \u003Capi-slug>\"\n```\n\nPush to origin (which is the fork for non-push users, or the upstream for push users):\n\n**If updating an existing PR** (`EXISTING_PR_NUMBER` is set):\n\n```bash\n# Only run this after the update-path divergence guard above has passed, or\n# after the user explicitly confirmed an intentional overwrite of the named\n# branch-only paths.\ngit push --force-with-lease -u origin feat\u002F\u003Capi-slug>\n```\n\n**If creating a new PR** and you chose \"Overwrite existing branch\" earlier:\n\n```bash\ngit push --force-with-lease -u origin feat\u002F\u003Capi-slug>\n```\n\n**Otherwise** (new branch, no conflicts):\n\n```bash\ngit push -u origin feat\u002F\u003Capi-slug>\n```\n\n### Capture the pushed commit SHA\n\nAfter pushing, capture the head commit SHA. This is used to build durable manuscript links in the PR body (see \"Build the PR description\" below).\n\n```bash\nHEAD_SHA=$(git rev-parse HEAD)\n```\n\nThe SHA stays resolvable on `mvanhorn\u002Fprinting-press-library` for the life of the PR (GitHub mirrors fork-PR head commits to `refs\u002Fpull\u002F\u003CN>\u002Fhead` on the upstream), and remains valid after the PR is merged and the branch is deleted. Each invocation of this skill captures a fresh `HEAD_SHA` after its push and rewrites the body, so links stay current across updates the skill performs. If the branch is force-pushed outside this skill, re-run `\u002Fprinting-press-publish` to refresh the body — the prior links will still resolve, but they'll point at the manuscript contents from before the out-of-band push.\n\n### Create or update PR\n\nRead `access` and `gh_user` from `$PUBLISH_CONFIG`. These determine how `gh pr create` is called.\n\n**For fork-based PRs** (`access` is `fork`): use `--head \u003Cgh_user>:feat\u002F\u003Capi-slug>` so GitHub creates a cross-repo PR from the fork to the upstream. Without `--head`, `gh pr create` would try to find the branch on the upstream repo (where the user can't push) and fail.\n\n**For push-access PRs** (`access` is `push`): use `--head feat\u002F\u003Capi-slug>` so GitHub creates the PR from the branch this flow just pushed, even when the managed clone or shell session has other branches checked out.\n\nBuild the PR description from:\n- The manifest (`description`, `api_name`, `category`, `printing_press_version`, `spec_url`)\n- The manifest's `novel_features` array from the packaged CLI after Step 6\n- The `help_output` captured in Step 4\n- The CLI's README (first 2-3 paragraphs, or note that README is missing)\n- Links to every file under `.manuscripts\u002F\u003Crun-id>\u002Fresearch\u002F` and `.manuscripts\u002F\u003Crun-id>\u002Fproofs\u002F`. Each link must be a full `https:\u002F\u002Fgithub.com\u002Fmvanhorn\u002Fprinting-press-library\u002Fblob\u002F\u003CHEAD_SHA>\u002Flibrary\u002F\u003Ccategory>\u002F\u003Capi-slug>\u002F.manuscripts\u002F\u003Crun-id>\u002F\u003Csubdir>\u002F\u003Cfilename>` URL — never a relative path (GitHub resolves those against `…\u002Fpull\u002F`, producing broken `…\u002Fpull\u002Flibrary\u002F…` URLs) and never a directory (the blob view requires a file). Enumerate the actual files; do not invent or skip them.\n- The validation results from Step 4\n- The publish live gate result from Step 4.5, including any explicit\n  `--skip-live-test` reason\n- A Gaps section listing any missing manifest fields\n\nRead `novel_features` from\n`$PUBLISH_REPO_DIR\u002Flibrary\u002F\u003Ccategory>\u002F\u003Capi-slug>\u002F.printing-press.json` after\npackaging. Preserve the manifest order. Do not derive\nthis section from README prose, SKILL prose, root help, or memory of the run:\nthose surfaces may be summarized or hand-edited, while the packaged manifest is\nthe publish-time source of truth. For each entry, include the command, name, and\ndescription. If the array is empty, write `No novel commands recorded in\n.printing-press.json.` and include the missing field in **Gaps**; do not omit the\nsection.\n\nAlso include a publication-path line so new prints, reprints, PR updates, and\ncollision renames are distinguishable:\n- `New print` — no merged CLI and no existing PR matched this slug.\n- `Update existing PR #\u003CN>` — this publish refreshes an open PR.\n- `Reprint\u002Freplace` — a merged library CLI existed before this publish and the\n  selected path replaces it. This must be based on\n  `PREEXISTING_MERGED_COLLISION=true`, not on the post-package tree.\n- `Alongside print` — this publish renamed the API slug to avoid a collision;\n  include the original slug.\nIf `\u002Fprinting-press-reprint` handed off a degraded reprint with no prior\npublic-library source, use `New print` and add the degraded-reprint note only if\nthat context is available from the handoff.\n\n**MANDATORY: Before constructing the PR body, scrub all workspace PII.** The library\nrepo is public. Scan any live test results, acceptance data, or manuscript excerpts\nfor organization names, team member names, and email addresses. Replace with generic\ndescriptions (\"the workspace\", \"5 team members\", \"12 users\"). Team keys (e.g., \"ESP\")\nare OK but org names (e.g., \"Acme Corp\") are not. See `references\u002Fsecret-protection.md`\nin the printing-press skill for the full policy.\n\nWrite the constructed PR body to a temporary Markdown file and pass it with\n`--body-file`. Do this for both PR creation and PR updates. Do not inline the\nbody in a shell argument; large fenced help output, Markdown tables, and\nbackticks are too easy to mangle.\n\n**PR description template:**\n\n```markdown\n## \u003Capi-slug>\n\n\u003CIf this is a Replace path, add: \"⚠️ **Replaces existing `\u003Capi-slug>`** — \u003Creason from user>\">\n\n\u003Cdescription from manifest, or \"No description available\">\n\n**API:** \u003Capi_name> | **Category:** \u003Ccategory> | **Press version:** \u003Cprinting_press_version>\n**Spec:** \u003Cspec_url or \"Not specified\">\n\n### Publication Path\n\n\u003CNew print | Update existing PR #N | Reprint\u002Freplace | Alongside print from \u003Coriginal-api-slug>>\n\n### CLI Shape\n\n\\`\\`\\`bash\n$ \u003Ccli-name> --help\n\u003Chelp_output from validation>\n\\`\\`\\`\n\n### Novel Commands\n\n| Command | Name | Description |\n|---------|------|-------------|\n| `\u003Ccommand>` | \u003Cname> | \u003Cdescription> |\n\n### What This CLI Does\n\n\u003CFirst 2-3 paragraphs from README.md in the CLI directory, or \"README not found\">\n\n### Manuscripts\n\n\u003C!-- One bullet per file, NOT one per directory. Repeat the research\u002F row for every file in research\u002F, and the proofs\u002F row for every file in proofs\u002F. Use a human label that matches the file (e.g. `Research Brief`, `Absorb Manifest`, `Novel Features Brainstorm`, `Phase 5 Acceptance`). Substitute `\u003CHEAD_SHA>` with the value captured after push. Do NOT use relative paths. -->\n\n- [\u003Clabel>](https:\u002F\u002Fgithub.com\u002Fmvanhorn\u002Fprinting-press-library\u002Fblob\u002F\u003CHEAD_SHA>\u002Flibrary\u002F\u003Ccategory>\u002F\u003Capi-slug>\u002F.manuscripts\u002F\u003Crun-id>\u002Fresearch\u002F\u003Cfilename>)\n- [\u003Clabel>](https:\u002F\u002Fgithub.com\u002Fmvanhorn\u002Fprinting-press-library\u002Fblob\u002F\u003CHEAD_SHA>\u002Flibrary\u002F\u003Ccategory>\u002F\u003Capi-slug>\u002F.manuscripts\u002F\u003Crun-id>\u002Fresearch\u002F\u003Cfilename>)\n- … (one bullet for each remaining file in `.manuscripts\u002F\u003Crun-id>\u002Fresearch\u002F`)\n- [\u003Clabel>](https:\u002F\u002Fgithub.com\u002Fmvanhorn\u002Fprinting-press-library\u002Fblob\u002F\u003CHEAD_SHA>\u002Flibrary\u002F\u003Ccategory>\u002F\u003Capi-slug>\u002F.manuscripts\u002F\u003Crun-id>\u002Fproofs\u002F\u003Cfilename>)\n- [\u003Clabel>](https:\u002F\u002Fgithub.com\u002Fmvanhorn\u002Fprinting-press-library\u002Fblob\u002F\u003CHEAD_SHA>\u002Flibrary\u002F\u003Ccategory>\u002F\u003Capi-slug>\u002F.manuscripts\u002F\u003Crun-id>\u002Fproofs\u002F\u003Cfilename>)\n- … (one bullet for each remaining file in `.manuscripts\u002F\u003Crun-id>\u002Fproofs\u002F`)\n\n### Validation Results\n\n| Check | Result |\n|-------|--------|\n| Manifest | PASS\u002FFAIL |\n| Phase 5 | PASS\u002FFAIL |\n| go mod tidy | PASS\u002FFAIL |\n| govulncheck (this CLI only, reachable findings) | PASS\u002FFAIL |\n| go vet | PASS\u002FFAIL |\n| go build | PASS\u002FFAIL |\n| --help | PASS\u002FFAIL |\n| --version | PASS\u002FFAIL |\n| Manuscripts | PRESENT\u002FMISSING |\n\n### Publish Live Gate\n\n\u003CIf Step 4.5 ran dogfood: \"Full live dogfood reran at publish time and passed. Proof: `\u003Cproof path or manuscript link>`\">\n\u003CIf Step 4.5 was skipped: \"Skipped with explicit reason: `\u003CSKIP_LIVE_TEST_REASON>`\">\n\n### Gaps\n\n\u003CList any missing manifest fields, or omit this section if everything is present>\n```\n\n**If updating an existing PR** (`EXISTING_PR_NUMBER` is set):\n\n```bash\ncd \"$PUBLISH_REPO_DIR\"\nPR_BODY_FILE=\"$(mktemp)\"\n# Write the constructed PR body Markdown to \"$PR_BODY_FILE\".\ngh pr edit \"$EXISTING_PR_NUMBER\" \\\n  --repo mvanhorn\u002Fprinting-press-library \\\n  --body-file \"$PR_BODY_FILE\"\nrm -f \"$PR_BODY_FILE\"\n```\n\nDisplay the full PR URL: \"Updated PR: \u003CEXISTING_PR_URL>\" (use the full `https:\u002F\u002F` URL, not shorthand).\n\n**If creating a new PR:**\n\n```bash\ncd \"$PUBLISH_REPO_DIR\"\n\n# Read access mode from config\nACCESS=$(jq -r .access \"$PUBLISH_CONFIG\")\nGH_USER=$(jq -r .gh_user \"$PUBLISH_CONFIG\")\n\nif [ \"$ACCESS\" = \"fork\" ]; then\n  PR_HEAD_REF=\"$GH_USER:feat\u002F\u003Capi-slug>\"\nelse\n  PR_HEAD_REF=\"feat\u002F\u003Capi-slug>\"\nfi\n\nPR_BODY_FILE=\"$(mktemp)\"\n# Write the constructed PR body Markdown to \"$PR_BODY_FILE\".\n\ngh pr create \\\n  --repo mvanhorn\u002Fprinting-press-library \\\n  --head \"$PR_HEAD_REF\" \\\n  --base main \\\n  --title \"feat(\u003Capi-slug>): add \u003Capi-slug>\" \\\n  --body-file \"$PR_BODY_FILE\"\n\nrm -f \"$PR_BODY_FILE\"\n```\n\nDisplay the full PR URL (e.g., `https:\u002F\u002Fgithub.com\u002Fmvanhorn\u002Fprinting-press-library\u002Fpull\u002F10`), not the shorthand `org\u002Frepo#N` format. The full URL is clickable in all terminals and contexts.\n\n## After the PR opens\n\nOnce the PR is open, it enters the public library repo's review contract. That contract is owned by [`mvanhorn\u002Fprinting-press-library` AGENTS.md → \"Automated code review with Greptile\"](https:\u002F\u002Fgithub.com\u002Fmvanhorn\u002Fprinting-press-library\u002Fblob\u002Fmain\u002FAGENTS.md#automated-code-review-with-greptile); read it for the canonical version. An agent invoking this skill from `cli-printing-press` will not have loaded the library's AGENTS.md, so the obligations are summarized here.\n\nGreptile reviews **incrementally**: every commit you push re-triggers a fresh review, which can surface new findings the previous round didn't. This is a loop, not a single pass — drive the PR to a *stable* green and don't declare done after round one.\n\n### Drive the PR to stable green\n\nIterate until **all** of these hold, confirmed by the review that your most recent fix commit triggered:\n\n- **Greptile score ≥ 4.** The 0-5 score is a confidence signal, not a hard gate; 4\u002F5 and 5\u002F5 are both acceptable end states, and the score lands there naturally once threads are addressed.\n- **No unresolved review threads.** For each P0\u002FP1\u002FP2 thread, either push a fix or reply with a concrete reason it shouldn't fire — not \"won't fix\", but *why* the code is right as written or *why* deferral is justified.\n- **All CI checks pass.** `verify-library-conventions`, `Govulncheck`, and any other workflow on the PR.\n\nRead findings from two surfaces — they don't overlap:\n\n- `gh pr view \u003CPR> --repo \u003Cowner>\u002F\u003Crepo> --comments` returns the top-level issue conversation (Greptile's summary comment, score, CI bots).\n- `gh api repos\u002F\u003Cowner>\u002F\u003Crepo>\u002Fpulls\u002F\u003CPR>\u002Fcomments` returns the inline diff-anchored review comments — Greptile posts each P0\u002FP1\u002FP2 finding here, **and these are NOT included in `--comments`**. Skipping this call is how an agent silently declares \"all findings resolved\" while every inline thread is still open.\n\n**Monitoring is the harness's job, not a busy-loop you hand-roll.** Use whatever PR-activity monitoring your environment provides — react to review\u002FCI events as they arrive, or re-check on an interval if it doesn't push events. After each fix push, wait for the re-triggered review to land before judging done; a new round can reopen the gate.\n\n**Don't hand-edit `registry.json` or `cli-skills\u002Fpp-\u003Capi-slug>\u002FSKILL.md` to satisfy a finding** — both are bot-regenerated post-merge by `[skip ci]` commits, and the library's `Fail on changes to generated artifacts` check pre-rejects any PR that touches them.\n\n### Terminal state — then hand back\n\nOnce the PR is stably green, the skill's job is done. **Do not merge it and do not poll waiting for it to merge** — merges into the public library are the maintainer's manual review, not this skill's and (for a fork contributor) not the user's either.\n\nRead `access` from `$PUBLISH_CONFIG` (`jq -r .access \"$PUBLISH_CONFIG\"`) to determine what to do next:\n\n- **If `access` is `push`** (maintainer\u002Fadmin with push access): apply the `awaiting-maintainer` label to signal the PR is ready for manual review:\n  ```bash\n  gh pr edit \u003CPR> --repo mvanhorn\u002Fprinting-press-library --add-label awaiting-maintainer\n  ```\n- **If `access` is `fork`** (community contributor): you cannot merge or label the upstream PR. There is nothing more to do once it's green.\n\nThen **report the terminal state and return control to the caller.** Do not offer a retro or any follow-up menu from this skill by default — that decision belongs to whoever invoked publish. The `printing-press` pipeline offers retro as its own post-publish tail; a direct human invocation without `--from-polish` just ends here.\n\nIf `POLISH_HANDOFF=true`, offer retro as a soft tail after the PR is green. This preserves the standalone polish -> publish workflow without allowing polish's same-turn `AskUserQuestion` answer to create or update a public-library PR.\n\nPresent via `AskUserQuestion`:\n\n> \"PR opened: \u003CPR_URL>. Run a retro? It surfaces systemic gaps from this session (generator misses, scorer bugs, skill-doc drift) as a GitHub issue for the Printing Press maintainers. Every retro filed raises the floor for the next CLI, and your session context is freshest right now.\"\n>\n> 1. **No, I'm done** (default)\n> 2. **Yes, run retro now**\n\nIf the user picks yes, invoke `\u002Fprinting-press-retro`.\n\n## Secret & PII Protection\n\nBefore creating the PR, verify that no secrets leaked into the packaged CLI.\n\n**This matters because the library repo is public.** A leaked API key in a PR is\na security incident — anyone can see it, even if the PR is later closed.\n\n### What the Printing Press checks (deterministic)\n\nThe generation skill (`\u002Fprinting-press`) runs an exact-value scan during Phase 5.5\nif the user provided an API key. By the time publish runs, the Printing Press's own\nmistakes should already be caught. But the user may have edited files between\ngeneration and publish.\n\n### What publish checks\n\n1. **Mandatory binary scan:** `cli-printing-press publish package` scans the staged CLI and manuscripts for live-looking vendor-prefix tokens (`sk-or-v1-*`, `sk_live_*`, `ghp_*`, `ghs_*`, `xoxb-*`, `AKIA*`, and similar). If it fails with `vendor-prefix tokens detected`, treat the package as unpublishable. Do not copy, commit, push, or open a PR until the reported file:line findings are removed or redacted.\n\n2. **If the user's exact API key value is known**, scan the packaged tree before creating the PR. This catches edits or manuscripts added after Phase 5.5:\n   ```bash\n   if [ -n \"$API_KEY_VALUE\" ] && [ ${#API_KEY_VALUE} -ge 16 ]; then\n     if grep -rF \"$API_KEY_VALUE\" \"$PUBLISH_REPO_DIR\u002Flibrary\u002F\u003Ccategory>\u002F\u003Capi-slug>\" 2>\u002Fdev\u002Fnull; then\n       echo \"BLOCKING: API key value found in staged publish tree.\"\n       exit 1\n     fi\n   fi\n   ```\n\n3. **If `gitleaks` or `trufflehog` is installed**, run it as an enrichment pass on the staged directory:\n   ```bash\n   if command -v gitleaks >\u002Fdev\u002Fnull 2>&1; then\n     gitleaks detect --source \"\u003Cstaging-dir>\u002Flibrary\" --no-git --verbose 2>&1\n   elif command -v trufflehog >\u002Fdev\u002Fnull 2>&1; then\n     trufflehog filesystem \"\u003Cstaging-dir>\u002Flibrary\" 2>&1\n   fi\n   ```\n   These tools use vendor-specific patterns (Steam keys, Stripe keys, GitHub\n   tokens) with low false-positive rates. Their findings add detector breadth\n   beyond the mandatory floor. Review any finding before proceeding.\n\n4. **Always do the lightweight structural check:**\n   - Verify no `.env` files, `session-state.json`, or `config.toml` with\n     real credentials exist in the staged directory\n   - Check README examples use `\"your-key-here\"` placeholders, not real values\n   - Check manuscripts (if included) don't contain auth headers or cookie values\n\n5. **Never include** in the staged directory:\n   - `.env` files\n   - `session-state.json`\n   - Config files with real credentials\n   - HAR captures with un-stripped auth headers\n\nIf the mandatory binary scan or exact-value scan finds issues, stop. For\nexternal-tool or lightweight structural findings, warn the user and ask whether\nto proceed. The user makes the final call on those non-mandatory findings.\n\n### PII pattern scanning (mandatory)\n\nBeyond the secret scans above, run the **PII pattern scanning** step from\n[..\u002Fprinting-press\u002Freferences\u002Fsecret-protection.md](..\u002Fprinting-press\u002Freferences\u002Fsecret-protection.md#pii-pattern-scanning)\n(section \"PII pattern scanning\"). This catches PII captured during live dogfood\nthat the prose guidance missed — emails, real attendee names, account\nidentifiers — before they ship to the public library repo.\n\nThe scan has two tiers:\n- **Tier 1 (auto-redact silently):** vendor-prefix-anchored bearer tokens\n  (`Bearer cal_live_*`, `Bearer sk_live_*`, `Bearer ghp_*`, `xoxp-*`, etc.).\n  Near-zero false-positive rate.\n- **Tier 2 (warn, batched user prompt):** generic emails, generic bearer tokens,\n  capitalized first+last name patterns. Allowlist suppresses spec-derived API\n  vocabulary (\"Event Types\", \"Booking Links\") automatically.\n\nA pre-scrub copy of the staging directory is preserved at\n`\u003Cstaging>.pre-pii-scrub\u002F` so the user can recover from a wrong redaction.\n\nTwo prior PII leaks shipped to the public library before this scan existed.\nThe scan is the mechanical defense layer the prose guidance alone could not\nprovide.\n\n## Error Handling\n\n- **`gh` not authenticated:** Detect in Step 1, tell user to run `gh auth login`\n- **CLI not found:** Show available CLIs in Step 2, let user pick\n- **Validation fails:** Show per-check results in Step 4, stop\n- **Repo unreachable:** Report clearly in Step 5\n- **Fork creation fails:** `gh repo fork` may fail if the user already has a fork with a different name, or if the org restricts forking. Report the error and suggest the user fork manually via the GitHub web UI.\n- **Collision check fails:** If `gh pr list` or `ls` commands fail (network, auth), warn but don't block — proceed as if no collision exists\n- **Rename fails:** Show the error from `publish rename --json`. Offer to retry with a different qualifier or bail. If the publish repo is in a partial state, reset with `git checkout -- . && git clean -fd` before retrying\n- **Branch conflict (no existing PR):** Ask user in Step 8 (overwrite or timestamp)\n- **Push fails:** For fork users, ensure they're pushing to their fork (origin), not upstream. Report the error, suggest checking `gh auth status` and `git remote -v`\n- **Cross-repo PR creation fails:** If `gh pr create --head user:branch` fails with \"head not found\", the branch wasn't pushed to the fork. Verify with `git ls-remote origin feat\u002F\u003Capi-slug>`\n",{"name":5,"version":24,"description":7,"allowed-tools":25,"min-binary-version":33},"0.1.0",[26,27,28,29,30,31,32],"Bash","Read","Write","Edit","Glob","Grep","AskUserQuestion","4.0.0","main","e7b39d448c7d905feed2b044d3ccdf60822596ab","skills\u002Fprinting-press-publish",0,"https:\u002F\u002Fgithub.com\u002Fbarkleesanders\u002Fclaude-code-starter","https:\u002F\u002Fgithub.com\u002Fbarkleesanders","barkleesanders.com","Stay Hungry, Stay Foolish","2026-11-06 08:47:06",{"source":8,"skillName":5,"commands":44,"prompt":54,"zipAvailable":55},[45,48,51],{"tool":46,"command":47},"npx","npx skills add barkleesanders\u002Fclaude-code-starter --skill printing-press-publish",{"tool":49,"command":50},"bunx","bunx skills add barkleesanders\u002Fclaude-code-starter --skill printing-press-publish",{"tool":52,"command":53},"pnpm","pnpm dlx skills add barkleesanders\u002Fclaude-code-starter --skill printing-press-publish","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fbarkleesanders\u002Fclaude-code-starter\u002Fblob\u002Fmain\u002Fskills\u002Fprinting-press-publish\u002FSKILL.md",true,[],[58,64,71,78,85,92],{"skillNo":59,"name":60,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":61,"categories":62,"keywords":63,"publishedAt":19},"01M7AWV75B37B6YKG7ZKGZ783F","zi-search","https:\u002F\u002Fgithub.com\u002Fbarkleesanders\u002Fclaude-code-starter\u002Fblob\u002Fmain\u002Fskills\u002Fzi-search\u002FSKILL.md",[],[],{"skillNo":65,"name":66,"nameZh":6,"description":67,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":68,"categories":69,"keywords":70,"publishedAt":19},"01M7AWTZA3JGK1T7V1HS543FG7","visualise","Render inline interactive visuals — SVG diagrams, HTML widgets, charts, and explainers — directly in the conversation. Use this skill whenever the user asks to visualize, diagram, chart, illustrate, or explain something visually, or when an explanation would genuinely benefit from a spatial\u002Finteractive diagram rather than text. Also triggers for: flowcharts, architecture diagrams, data visualizations, interactive explainers, comparison layouts, UI mockups, and any request containing 'show me', 'draw', 'map out', 'visualize', or 'diagram'. Even when the user doesn't explicitly ask for a visual, use this skill proactively when the topic has spatial, sequential, or systemic relationships that a diagram would clarify better than prose.","https:\u002F\u002Fgithub.com\u002Fbarkleesanders\u002Fclaude-code-starter\u002Fblob\u002Fmain\u002Fskills\u002Fvisualise\u002FSKILL.md",[],[],{"skillNo":72,"name":73,"nameZh":6,"description":74,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":75,"categories":76,"keywords":77,"publishedAt":19},"01M7AWTR056C3P9R3VS8YVM2WX","video","When the user wants to create, generate, or produce video content using AI tools or programmatic frameworks. Also use when the user mentions 'video production,' 'AI video,' 'Remotion,' 'Hyperframes,' 'HeyGen,' 'Synthesia,' 'Veo,' 'Runway,' 'Kling,' 'Pika,' 'video generation,' 'AI avatar,' 'talking head video,' 'programmatic video,' 'video template,' 'explainer video,' 'product demo video,' 'video pipeline,' or 'make me a video.' Use this for video creation, generation, and production workflows. For video content strategy and what to post, see social-content. For paid video ad creative, see ad-creative.","https:\u002F\u002Fgithub.com\u002Fbarkleesanders\u002Fclaude-code-starter\u002Fblob\u002Fmain\u002Fskills\u002Fvideo\u002FSKILL.md",[],[],{"skillNo":79,"name":80,"nameZh":6,"description":81,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":19},"01M7AWTHTWBMTYZPMHHEYX3TTG","manim-video","Production pipeline for mathematical and technical animations using Manim Community Edition. Creates 3Blue1Brown-style explainer videos, algorithm visualizations, equation derivations, architecture diagrams, and data stories. Use when users request: animated explanations, math animations, concept visualizations, algorithm walkthroughs, technical explainers, 3Blue1Brown style videos, or any programmatic animation with geometric\u002Fmathematical content.","https:\u002F\u002Fgithub.com\u002Fbarkleesanders\u002Fclaude-code-starter\u002Fblob\u002Fmain\u002Fskills\u002Fvideo-use\u002Fskills\u002Fmanim-video\u002FSKILL.md",[],[],{"skillNo":86,"name":87,"nameZh":6,"description":88,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":89,"categories":90,"keywords":91,"publishedAt":19},"01M7AWTCXDJ9NWFQW51ENM8A2Z","video-use","Edit any video by conversation. Transcribe, cut, color grade, generate overlay animations, burn subtitles — for talking heads, montages, tutorials, travel, interviews. No presets, no menus. Ask questions, confirm the plan, execute, iterate, persist. Production-correctness rules are hard; everything else is artistic freedom.","https:\u002F\u002Fgithub.com\u002Fbarkleesanders\u002Fclaude-code-starter\u002Fblob\u002Fmain\u002Fskills\u002Fvideo-use\u002FSKILL.md",[],[],{"skillNo":93,"name":94,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":95,"categories":96,"keywords":97,"publishedAt":19},"01M7AWTA1D5FP895S33GHSA2G5","ui-improver","https:\u002F\u002Fgithub.com\u002Fbarkleesanders\u002Fclaude-code-starter\u002Fblob\u002Fmain\u002Fskills\u002Fui-improver\u002FSKILL.md",[],[]]