> mthadley_

Inline Script Dependencies

As part of my day job building out a developer platform, I do a lot of prototyping and testing. These are often multi-step workflows, with an end user’s browser involved to boot (we do a lot of auth stuff).

I find myself first reaching for Ruby here for several reasons:

More on that last piece.

Inline Bundler

Pretty quickly, I’ll need some third-party gem for the task. For example, maybe I’m standing up a quick web-server that implements a new /.well-known endpoint I want to prototype against. Bundler makes this so easy:

require "bundler/inline"

gemfile do
  source "https://rubygems.org"

  gem "puma"
  gem "rackup"
  gem "sinatra"
  gem "sinatra-contrib"
end

get "/.well-known/oauth-protected-resource" do
  json resource: "https://example.com/resource",
       authorization_servers: ["https://auth.example.com"],
       bearer_methods_supported: ["header"]
end

Paste that into a .rb file, run it with ruby, and you’re off to the races. Gems are installed somewhere in the background automagically.

I find this pattern really lowers the barrier to experimentation. Of course, we live in the era of AI, where that barrier has already been steadily dropping. But even here, small and focused files play well with a coding agent’s limited context window.

Elsewhere

I wish more tools embraced this pattern. The few I know of:

Node is the main place I’d like to see this pattern supported, since I spend much of my time these days writing JavaScript and TypeScript (though I think ESM imports with Deno may “just work”).

Anyway, hopefully this nudges you (or your agent) toward writing more scripts that do more than you’d normally expect.