scriptable.com

Implementation-focused, hands-on tutorials for software engineers.

To get the source, just point your LLM at an article and ask it to build it.

Install and Manage CLI Tools with uv tool on macOS

uvx ruff check . works without installing anything. That is the whole appeal: one command, a throwaway environment, nothing left behind. It is also the problem. Every invocation re-resolves the package, the version you get today is not necessarily the version you got last week, and which ruff comes back empty because there is nothing on PATH. uv tool install is the other half of the story. It builds a persistent, isolated environment for a Python CLI and links its executables into a directory on your PATH, so ruff becomes a real command with a version you chose and control. Homebrew’s pipx niche, in other words, handled by the tool you already have. ...

23 min

Build MCP Prompts That Trigger Multi-Step Workflows on macOS

Most teams have a procedure that only lives in someone’s head. Cutting release notes, triaging a breaking change, prepping an on-call handoff: five steps, done slightly differently every time, and badly the week the person who knows them is on vacation. MCP gives you three primitives to fix that, and the interesting one is the least used. Tools are called by the model. Resources are read for context. Prompts are chosen by a person: named, parameterized templates a client surfaces as a slash command. That makes a prompt the natural home for a procedure — the user picks it, fills in one argument, and the model runs the same five steps in the same order every time. ...

26 min

Serve an Updating Image as an MCP Resource on macOS — and Where You Can Actually See It

A resource that returns a picture is the most demanding shape an MCP resource takes. It has to survive base64 encoding, arrive with a MIME type the client will accept, stay small enough to attach, and — if the picture is meant to reflect something live — return different bytes the next time the same URI is read. Serve Resources Well from an MCP Server on macOS covered the shapes of resources with an eight-byte PNG magic number standing in for a binary body. This article replaces that stub with a real image: a bar chart rendered on every read from state that anything can change, packaged so uvx runs it from a local directory, and wired into opencode so a model can read it, watch it change, and read it again. ...

69 min

Add an MCP Server to opencode on macOS

opencode attaches an MCP server in a single command, with no config file to hand-edit and no JSON to get wrong. Everything after the -- separator is the command that launches the server, and because uvx resolves the package on first launch, there is nothing to install beforehand either: opencode mcp add hello -- uvx mcp-hello-server This tutorial uses that command to attach mcp-hello-server — a small FastMCP server on PyPI exposing two tools, server_info and greet — then drives it from a free model. You will confirm the server connects, prove the launch command works without involving a model at all, pin the same server to a single project instead of your whole machine, and finally ask North Mini Code Free to say hello to Alice in Japanese. ...

17 min

How to Create a JavaScript Module (Node and Browser)

A JavaScript module is a file that exports values other files import by name. ES modules (import/export) are the standard form and run unchanged in modern browsers and Node.js. This tutorial builds a small module with a default export and a named factory function, imports it from another file, tests it with Node’s built-in runner, and loads it in the browser — the same module code in both environments, no bundler. ...

7 min

How to Create a Random Boolean Function in JavaScript (Node and Browser)

A random boolean — a coin flip that returns 1 or 0 about half the time — is the smallest building block for simulations and generative art. The function is one line; the useful part is confirming it lands on each value roughly equally and never returns anything else. This tutorial writes the function as an ES module, pins its rounding behavior with a Node test suite, prints a distribution, and paints the flips on a browser canvas. ...

9 min

How to Create a Weighted Random Function in JavaScript (Node and Browser)

A fair coin flip returns true half the time. A weighted coin flip returns true a chosen fraction of the time — 10%, 25%, whatever the simulation or generative-art piece needs. The function is one line built on Math.random(); the useful part is confirming the true rate tracks the weight and that the boundaries behave. This tutorial writes it as an ES module, pins the behavior with a Node test suite, prints a distribution at 10%, and paints the results on a browser canvas. ...

9 min

How to Select a Random Item from a JavaScript Array (Node and Browser)

Picking a random element from an array comes up constantly: rolling dice, shuffling prompts, choosing a color. The whole job is one line of JavaScript, but the interesting part is proving it behaves — that the picks are spread across the array and never fall off either end. This tutorial builds that one-liner as an ES module, backs it with a Node test suite that pins down the boundary behavior, adds a distribution demo, and then draws the results on a browser canvas so you can see the spread. ...

11 min

How to Install Tree on macOS

tree prints the contents of a directory as an indented, ASCII-art hierarchy. It is one of the fastest ways to understand or document a project layout, and it ships as a small Homebrew package. This tutorial installs tree on macOS, walks through the flags you reach for most often, and wraps them in a reproducible demo project whose output is checked against committed golden files. Prerequisites macOS with a Terminal (the built-in Terminal.app or iTerm2) Homebrew (installed in Step 1 if you do not have it) make (pre-installed with the Xcode Command Line Tools on macOS) No programming language or runtime required The commands were validated with tree v2.3.2 and Homebrew 6.0.10 on macOS. ...

8 min

Build a Safe Read-Only SQLite MCP Server on macOS

The read-only Postgres MCP server built its safety on the database server: a SELECT-only role, a read-only transaction, a statement timeout, all enforced by a process on the other side of a socket. SQLite has none of that machinery. There is no server, no accounts, no GRANT. The database is a file, the engine runs inside your process, and any connection that can open the file read-write can do anything to it. ...

29 min