Update a lean-agents install through its script. Use when the user asks to update lean-agents or its tools, check what is outdated, or bring a hand-made install under the script. Detects, asks in plain words, shows a table, runs the script only on yes.
4 stars
0 votes
0 copies
2 views
Added November 11, 2026
ai-agentsjavascriptgojavashellbashnodegit
Works with
terminal
cli
Security analysis
F27/100
criticalPipes output to a shell interpreter
mediumUses curl or wget to download content
highPerforms destructive filesystem operations
criticalDownloads and executes remote scripts — classic supply chain attack
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Lean Update?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/estebanmr99-lean-update)
---
name: lean-update
description: Update a lean-agents install through its script. Use when the user asks to update lean-agents or its tools, check what is outdated, or bring a hand-made install under the script. Detects, asks in plain words, shows a table, runs the script only on yes.
---
# lean-update
The script (`lean-agents`, `scripts/lean.mjs`) is the only thing that changes files: deterministic, tested, undone by `--uninstall`. You are the middleware: detect, ask, run it, read it back. Change nothing before the user says yes.
Run the script with `npx -y lean-agents@<version> <flags>` (the latest release version, below). Without npm access or Node.js 22.20+, use the bootstrap, which downloads that release and checks its SHA256: `curl -fsSL https://github.com/estebanmr99/lean-agents/releases/download/<tag>/install.sh | bash -s -- <flags>` (Windows: `install.ps1` from the same release). In a clone, `node scripts/lean.mjs ...` works too. Use the latest release tag: `gh release view --repo estebanmr99/lean-agents --json tagName -q .tagName`.
1. **Read the release.** Fetch `core/pins.json` at that tag from `https://raw.githubusercontent.com/estebanmr99/lean-agents/<tag>/`. Then read every release between the installed lean-agents version (`version` in `state.json`; for a hand install, ask or say it is unknown and read from the oldest release you can match) and the latest: `gh release view <tag> --repo estebanmr99/lean-agents --json body -q .body`, and the matching `CHANGELOG.md` sections. A pin's `note` adds to the impact.
- Start your answer with the **breaking changes and upgrade steps** from those notes, before any table.
- lean-agents never installs or upgrades OpenCode, and some agent CLIs may be owned by the user's IT (a system install with managed settings). Name those as the user's own step; this skill never runs them.
- A release with no clear "Upgrade" or "Breaking" notes: say so in plain words, and put "none in the release notes" in the table.
2. **Detect.**
- `~/.config/lean-agents/state.json` exists (or `--doctor --json` works): run `--doctor --json`. Its `behind` list is what is older than the pins.
- No `state.json` (installed by hand): run the read-only commands in "Detect what is installed" in `docs/manual-install.md` to learn which agents and tools are there. Say that this install has no state yet and that the script will take it over without overwriting user files.
3. **Dry run as JSON, with the script.**
- With state: `--update --dry-run --yes --json`.
- Without state: `--dry-run --yes --json --agents <detected> --tools <detected>`.
The JSON lists files, commands (exact `npx`/`winget`/`brew` lines, all pinned) and, on update, `behind`. When the user asked to update everything and an Orca or Warp app is older than its pin, pass `--install-terminal orca|warp|both` on the dry run and the real run: non-interactively that is the only way a user-installed app is adopted and updated.
4. **Show one table** in plain words: `tool | installed | pinned | impact | upgrade notes | what it would run`. Installed comes from `behind` or the detection; impact from step 1 ("not in the changelog" when it is not); upgrade notes from the releases in step 1 ("none in the release notes" when there are none); what it would run from the JSON `commands`. Then, as its own last line, ask the question word for word: `Update these N tools?` (N is the number of rows in the table). Add nothing after it and ask no other question in that message. Stop on no.
5. **Back up only what changes, then run.** One backup folder in the OS temp directory holding the files the JSON says will change (paths start with `~`: expand them to full paths first) and that the engine does not already restore. Save this JavaScript to a `.js` file in the temp folder and run `node <file> <path1> <path2>` (inline `node -e` quoting differs between bash and PowerShell); it prints the folder and copies each path in as `<n>-<name>`: `const fs=require('fs'),os=require('os'),p=require('path');const d=fs.mkdtempSync(p.join(os.tmpdir(),'lean-agents-backup-'));process.argv.slice(2).forEach((f,i)=>{if(fs.existsSync(f))fs.cpSync(f,p.join(d,i+'-'+p.basename(f)),{recursive:true})});console.log(d)`. Then run the same flags without `--dry-run`: `--update --yes`, or `--yes --agents ... --tools ...`.
- From an agent's terminal there is no TTY: after the user approves the dry run, always pass `--yes` on the real run.
- If the run refuses because an `opencode` process is running: when the refusal names `opencode service stop` (outside OpenCode), run that command once, then retry the run once. When it says "you are running inside OpenCode", stop, never run `opencode service stop` (it stops the service your own session runs on), and give the user the terminal command it names.
- If the output has a line starting `deferred (OpenCode is running this session)`, the run succeeded for everything else: tell the user the deferred steps finish on the next `lean-agents --update` from a terminal (or after this OpenCode session ends). Do not retry and ask no new question.
- Stop at the first failure: report it with a redacted draft (step 7), instead of trying workarounds such as removing a plugin marketplace.
6. **Read it back.** Run `--doctor --json`. When `ok` is true and `behind` is empty, delete the backup folder (`fs.rmSync(<folder>, { recursive: true, force: true })` from a `.js` file) and tell the user it is gone and that `--uninstall` still undoes everything. When it is not, keep the backup, say where it is, and offer to restore.
7. **Share findings (optional).** Only if you found a problem or an improvement (a failed command, a tool the detection cannot see, a missing changelog note):
- Never offer under `--privacy strict`, `--network off` or `--outbound off`. Read the saved preset from `state.json`; with no state, ask once whether outbound calls are allowed.
- Ask: "Draft a redacted issue for lean-agents?" Stop on no.
- Write the draft yourself: title, the failed command, the error text, and the lean-agents, Node and OS versions. Replace usernames, home paths, machine and company names, internal hosts, proxy addresses and emails with `<user>`, `<home>`, `<pc>`, `<company>`, `<host>`, `<proxy>`, `<email>`.
- Duplicates: `gh issue list --repo estebanmr99/lean-agents --search "<title words>"`. If one matches, show it and stop.
- Show the full draft. Only after a yes: `gh issue create --repo estebanmr99/lean-agents --title "<title>" --body-file <draft>`.
8. **Report**: old -> new per tool, what you verified (`--doctor --json`), what is left for the user.
## Remove a tool
"remove <tool>" maps to `--remove-tools <tool>`, not to `--uninstall`. Run `--remove-tools <tool> --dry-run --yes`, show its plan in plain words, and run `--remove-tools <tool> --yes` once the user's request or reply says to remove it. Add no new question. A core tool (`rtk`, `context-mode`) is refused with exit 2: relay that line.
## Fallback: the script cannot run
Only when Node is missing or the machine blocks the script. Use the table of commands and the install lines in `docs/manual-install.md` by hand, with the same table, the same ask, the same backup and the same read-back. Say that this is the fallback: nothing here is recorded in `state.json`, so `--uninstall` will not know about it.