Skip to content

fix(patchy): the Patchy skill survives a Node version change - #673

Merged
allisonmahmood merged 2 commits into
mainfrom
fix/668-skill-survives-node-switch
Oct 14, 2026
Merged

allisonmahmood merged 2 commits into
mainfrom
fix/668-skill-survives-node-switch

Conversation

@allisonmahmood

@allisonmahmood allisonmahmood commented Oct 14, 2026 •

Copy link
Copy Markdown
Owner

What changed

The installer runs npm install --global, and patchy setup linked ~/.agents/skills/patchy and ~/.claude/skills/patchy into the bundled skill inside that npm prefix. Under a per-version Node manager (mise, nvm, fnm, asdf) that prefix belongs to one Node version. Switch away and patchy leaves PATH. Remove that version and both skill links dangle, so the agent forgets Patchy exists and nothing tells it to reinstall.

The fix:

  • A durable copy. patchy setup copies the whole bundled skill directory, references included, to ~/.patchy/skills/patchy and links both agent paths to that copy. The path comes from the home directory, never PATCHY_STATE_DIR.
  • Every setup refreshes the copy. It writes the release's skill into a private sibling under ~/.patchy/skills/, then swaps it in with two renames. Files the release no longer ships are dropped, and a run that fails mid-copy leaves the old copy whole. If the second rename fails (Windows can briefly lock freshly written files), the old copy is moved back. If that also fails, setup keeps the staging folder and its error says where the old copy is kept. A run killed between the two renames leaves no copy and dangling links until setup or the install line runs again; the README says so.
  • Ownership checks. Setup checks all three paths before changing anything. It replaces links it made before, including dangling ones into a removed prefix. Anything else at an agent path is still skill_conflict, and so is a file or link at the copy's path. A real directory at the copy's path counts as setup's own, because ~/.patchy is Patchy's directory. That avoids a marker file.
  • The way out. setup --remove removes the links first, then the copy, and warns about anything it leaves in place.
  • SKILL.md. When patchy is missing (for example after a Node version change), reinstall from the intended instance: the one the person named, otherwise the apiUrl in the state directory's config.json. Ask where to publish only when neither exists.

setup --json keeps its shape. skill now names the copy's SKILL.md, which is also what the installer prints as Skill:.

Older CLIs: an older CLI's patchy setup sees links to ~/.patchy/skills/patchy as foreign and refuses with skill_conflict. Its message already says to move them aside and rerun. There is no compatibility shim, per the issue.

Closes #668

How it was verified

  • pnpm test passes locally

  • Added or updated tests covering this change

  • Setup.test.ts:

    • links both agent paths to the copy; a rerun leaves the links untouched
    • the skill still reads after its npm prefix is deleted, and the next release's setup drops a file it no longer ships
    • legacy links into a package, including dangling ones, are replaced
    • a directory, file or foreign link at an agent path, and a file or link at the copy, is refused with nothing changed
    • a refresh that fails partway (an unreadable file in the bundle) leaves the previous copy whole and no leftover sibling
    • if the new copy cannot be swapped in and the old one cannot be put back (an injected rename that refuses the copy's path), the old copy is kept and the error names where
    • --remove takes the copy and owned links and leaves foreign entries
  • cli.test.ts, install.test.ts and scripts/packed-cli-e2e.mjs now expect the copy as the link target and skill path. The installer test also deletes the npm prefix after installing and checks that the skill still reads through ~/.claude/skills/patchy.

  • Round 1 fixes (keep the backup when the rollback fails, README crash window, contributors rerun setup after rebuilding): pnpm check and the touched suites pass. The full verify below ran on the first commit; the fixes only touch Setup.ts, its test and docs.

  • flock /tmp/patchy-heavy-suite.lock pnpm verify on the first commit: format, lint, typecheck, synth, test, postgres-concurrency, cli-smoke (including the /llms.txt front-door install on a clean HOME), tier2-smoke and browser all pass.

Windows is reasoned, not tested (CI is Linux-only, and the installer tests skip Windows). Junction targets are the absolute copy path. A junction is "current" by its resolved target or by realpath. rename, cp and rm work on directories there.

Hit every surface

  • The wire contract: no route or schema changed. setup --json keeps its shape; only skill's value moved. The /llms.txt sentence in FrontDoor.ts now says the installer copies the skill to ~/.patchy/skills/patchy and links that copy.
  • The CLI: patchy setup behaviour changed, so the packages/patchy/README.md setup section, installer paragraph and contributor build note, ADR-0004's setup row and paragraph, the global SKILL.md, and the skills-lock.json hash were all updated. The --remove flag's help text and the command description were updated too. Exit codes are unchanged.
  • The dev loop: does not apply; scripts/dev does not run setup.
  • Vocabulary and product shape: updated the Setup entry in packages/patchy/GLOSSARY.md and docs/SKILL_DISTRIBUTION.md. docs/product.md does not describe the link target. ADR-0004 was updated, not contradicted.
  • Migrations, company resources, served pages (HTML policy): do not apply.
  • Reverse states: setup --remove removes the new copy as well as the links.
  • The repo layout: does not apply.

Release impact

  • Breaking — requires action from anyone already running this
  • Not breaking — no action required

Upgrading runs the new setup, which replaces the old links into the npm prefix. The one case that needs action is running an older release's setup after this one, which refuses with skill_conflict and says how to proceed.

Made by Claude Opus 5.5 via Claude Code in T3 Code

@github-actions github-actions Bot added area:server Touches the server area area:ci CI, shared testing infrastructure, development scripts and tooling area:cli Touches the cli area area:docs Touches the docs area size:m 100-500 changed lines labels Oct 14, 2026
@allisonmahmood

Copy link
Copy Markdown
Owner Author

GPT 6.1 Sol review (xhigh), round 1

  1. Should-fix — packages/patchy/src/Setup.ts:138: failed rollback deletes the last good copy. If rename(next, copy) fails and restoring previous also fails—for example under Windows filesystem locks—the restore error is swallowed, then finally recursively deletes work, including previous. Both agent links dangle and the old skill is lost. Preserve the backup when restoration fails and report its recovery path. Add a focused test for this sequence; the existing failure test stops during copying, before either rename.

  2. Nit — packages/patchy/README.md:974: the crash guarantee is inaccurate. Killing setup between the two renames leaves the fixed copy absent, both links dangling, and staging debris. Change “an interrupted run leaves the old copy” to describe that window and recovery through another setup.

  3. Nit — packages/patchy/README.md:20 and skills/patchy/SKILL.md:298: contributor refresh instructions are missing. After setup, rebuilding changed skill content leaves agents reading the old snapshot. Tell contributors to rerun patchy setup after rebuilding.

Rulings on the flagged points:

  • No marker: accept. The exact copy path is dedicated to Patchy, and directory ownership is explicitly documented.
  • Hard-crash window and orphan staging: accept as a bounded tradeoff once the README is corrected. A recovery framework is unnecessary for fix(patchy): the Patchy skill survives a Node version change #668.
  • Windows untested: accept as a disclosed limitation, subject to fixing finding 1. No additional platform defect found by inspection; junction target handling agrees with libuv’s implementation.
  • Contributor snapshots: accept; document the refresh step.
  • Older CLI rejection: accept. The issue explicitly requests this compatibility decision, and the PR body explains it.

Completeness: the required mirrors are covered—CLI help/output, README, ADR-0004, glossary, skill distribution, /llms.txt, tests, packed e2e, and the verified skill hash. Other “Hit every surface” entries do not apply.

Repo standards: no additional Effect or simplicity findings; no rendered HTML/CSS changes.

Tests: focused and would catch the original prefix-deletion bug, reference copying, and retired-file pruning. Swap/rollback failure coverage is missing. Tests were reviewed statically, not run.

Public hygiene: clean diff and PR body; only generic documented home/tmp paths.

NOT READY — failed rollback can delete the last good skill copy.

@allisonmahmood
allisonmahmood force-pushed the fix/668-skill-survives-node-switch branch from 11b4956 to f1f43de Compare October 14, 2026 13:41
@allisonmahmood

Copy link
Copy Markdown
Owner Author

GPT 6.1 Sol review (xhigh), round 2

No blocker, should-fix, or nit findings in the full diff at f1f43de. All three round 1 findings are resolved.

  • Correctness: failed swap plus failed restore now preserves the backup and reports its recovery path. No new defect found, including by Windows inspection.
  • Completeness: crash-window and contributor-refresh documentation is corrected. CLI help/output, README, ADR-0004, glossary, distribution docs, /llms.txt, tests, packed e2e and skill hash agree. Other checklist entries do not apply.
  • Standards: the move callback is proportionate for this filesystem helper. It faults one external operation while exercising real refresh logic; an Effect service solely for this seam would add unnecessary machinery. No Effect or simplicity findings; no rendered HTML/CSS changes.
  • Tests: the new test checks both rename failures, retained contents and the recovery message; reverting backup preservation would fail it. Reviewed statically, not run.
  • Public hygiene: diff and PR body are clean.

NOT READY — code review is clean, but latest-head CI is still running.

allisonmahmood and others added 2 commits October 14, 2026 15:48
patchy setup now copies the bundled skill to ~/.patchy/skills/patchy and
links both agent paths to that copy, so removing the Node version (and npm
prefix) that installed the CLI no longer takes the skill with it. Each setup
swaps a fresh copy in whole; setup --remove removes the copy too. The skill
says to reinstall from the named instance, else the saved apiUrl.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
If swapping in the new copy fails and the old one cannot be moved back,
setup now leaves its staging folder in place and names where the old copy
is kept, instead of deleting it. The README now describes the window a
killed run leaves and how rerunning setup recovers, and contributors are
told to rerun patchy setup after rebuilding.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@allisonmahmood
allisonmahmood force-pushed the fix/668-skill-survives-node-switch branch from f1f43de to 32d5950 Compare October 14, 2026 13:48
@allisonmahmood
allisonmahmood merged commit e097d63 into main Oct 14, 2026
13 checks passed
@allisonmahmood
allisonmahmood deleted the fix/668-skill-survives-node-switch branch October 14, 2026 13:59
allisonmahmood added a commit that referenced this pull request Oct 14, 2026
… Patchy is smoother (#679)

Release 12's What's new entry, written from `b58b899`, ahead of
deploying it. `patchy` and `CURRENT_RELEASE` move to `0.12.0`, so CLIs
and patch repos installed before this deploy are told to upgrade.

| Change | PRs |
| --- | --- |
| Fixed: Links within a page jump to their section | #677 |
| Improved: Set up Patchy however you ask | #672, #674 |
| Improved: Claude Code can know Patchy is your company's own | #676 |
| Fixed: Your agent remembers Patchy after a Node.js update | #673 |
| Fixed: Sign-in codes say how many minutes they have left | #675 |
| Behind the scenes: uploaded pages and logos are checked within strict
limits | #678 |

Made by Claude Opus 5.5 via Claude Code in T3 Code

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:ci CI, shared testing infrastructure, development scripts and tooling area:cli Touches the cli area area:docs Touches the docs area area:server Touches the server area size:m 100-500 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(patchy): the Patchy skill survives a Node version change

1 participant