frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

In Praise of –dry-run

https://henrikwarne.com/2026/01/31/in-praise-of-dry-run/
66•ingve•6h ago

Comments

ElevenLathe•3h ago
I usually do the opposite and add a --really flag to my CLI utilities, so that they are read-only by default and extra effort is needed to screw things up.
weikju•3h ago
Came here to say the same
eichin•2h ago
I've committed "--i-meant-that" (for a destroy-the-remote-machine command that normally (without the arg) gives you a message and 10s to hit ^C if you're not sure, for some particularly impatient coworkers. Never ended up being used inappropriately, which is luck (but we never quantified how much luck :-)
bikelang•3h ago
I love `—-dry-run` flags for CLI tooling I build. If you plan your applications around this kind of functionality upfront - then I find it doesn’t have to pollute your code too much. In a language like Go or Rust - I’ll use a option/builder design pattern and whatever I’m ultimately writing to (remote file system, database, pubsub, etc) will instead write to a logger. I find this incredibly helpful in local dev - but it’s also useful in production. Even with high test coverage - it can be a bit spooky to turn on a new, consequential feature. Especially one that mutates data. I like to use dry run and enable this in our production envs just to ensure that things meet the functional and performance qualities we expect before actually enabling. This has definitely saved our bacon before (so many edge cases with prod data and request traffic).
zzo38computer•3h ago
I think dry run mode is sometimes useful for many programs (and, I sometimes do use them). In some cases, you can use standard I/O so that it is not needed because you can control what is done with the output. Sometimes you might miss something especially if the code is messy, although security systems might help a bit. However, you can sometimes make the code less messy if the I/O is handled in a different way that makes this possible (e.g. by making the functions that make changes (the I/O parts of your program) to handle them in a way that the number of times you need to check for dry run is reduced if only a few functions need to); my ideas of a system with capability-based security would allow this (as well as many other benefits; a capability-based system has a lot of benefits beyond only the security system). Even with the existing security it can be done (e.g. with file permissions), although not as well as capability-based security.
arjie•2h ago
In order to make it work without polluting the code-base I find that I have to move the persistence into injectable strategy, which makes it good anyway. If you keep passing in `if dry_run:` everywhere you're screwed.

Also, if I'm being honest, it's much better to use `--wet-run` for the production run than to ask people to run `--dry-run` for the test run. Less likely to accidentally fire off the real stuff.

segmondy•2h ago
this is where design patterns come in handy even tho folks roll their eyes at it.
cake-rusk•2h ago
Design patterns exist to paper over language deficiencies. Use a language which is not deficient.
antinomicus•1h ago
Like what?
WCSTombs•1h ago
There's some truth to this, since some design patterns can simply be implemented "for good" in a sufficiently powerful language, but I don't find it's true in general. Unfortunately, it has become something of a thought-terminating cliché. Some common design patterns are so flexible that if you really implemented them in full generality as, say, some library function, its interface would be so complex that it likely wouldn't be a net win.
awesome_dude•21m ago
Just my two cents - but a general purpose language is going to need to be coupled with design patterns in order to be useful for different tasks.

I'm using MVC design patterns for some codebases, I'm using DDD plus Event sourcing and Event Driven for others.

I suspect that you are thinking of a small subset of design patterns (eg. Gang of Four derived patterns like Visitor, Strategy, or Iterator )

nstart•32m ago
Design patterns are one of those things where you have to go through the full cycle to really use it effectively. It goes through the stages:

no patterns. -> Everything must follow the gang of four's patterns!!!! -> omg I can't read code anymore I'm just looking at factories. No more patterns!!! -> Patterns are useful as a response to very specific contexts.

I remember being religious about strategy patterns on an app I developed once where I kept the db layer separated from the code so that I could do data management as a strategy. Theoretically this would mean that if I ever switched DBs it would be effortless to create a new strategy and swap it out using a config. I could even do tests using in memory structures instead of DBs which made TDD ultra fast.

DB switchover never happened and the effort I put into maintaining the pattern was more than the effort it would have taken me to swap a db out later :,) .

wging•1h ago
One nice way to do things, if you can get away with it, is to model the actions your application takes explicitly, and pass them to a central thing that actually handles them. Then there can be one place in your code that actually needs to understand whether it's doing a dry run or not. Ideally this would be just returning them from your core logic, "functional core, imperative shell" style.
WCSTombs•1h ago
I totally agree with both this and the comment you replied to. The common thread is that you can architect the application in such a way that dry vs. wet running can be handled transparently, and in general these are just good designs.
IgorPartola•22m ago
That’s what I prefer as well. A generation step and an execution step where the executor can be just a logger or the real deal.
sh-run•1h ago
I don't like the sound of `--wet-run`, but on more than one occasion I've written tools (and less frequently services) that default to `dry-run` and require `--no-dry-run` to actually make changes.

For services, I prefer having them detect where they are running. Ie if it's running in a dev environment, it's going to use a dev db by default.

ryandrake•1h ago
I don't want to have to type rm --wet-run tempfile.tmp every time, or mkdir -p --yes-really-do-it /usr/local/bin

The program should default to actually doing whatever thing you're asking it to do.

On the other hand it would be great if every tool had an --undo argument that would undo the last thing that program did.

homebrewer•1h ago
That undo program is called nilfs2, which unfortunately never became popular. I'll simply quote the kernel docs:

> NILFS2 is a log-structured file system (LFS) supporting continuous snapshotting. In addition to versioning capability of the entire file system, users can even restore files mistakenly overwritten or destroyed just a few seconds ago.

https://docs.kernel.org/filesystems/nilfs2.html

https://wiki.archlinux.org/title/NILFS2

https://en.wikipedia.org/wiki/NILFS

aappleby•1h ago
Sure, in those cases - but if a command has a chance of nuking prod, you want some extra step in there. Preferably something that can't be muscle-memoried through.
skissane•2h ago
In one (internal) CLI I maintain, I actually put the `if not dry_run:` inside the code which calls the REST API, because I have a setting to log HTTP calls as CURL commands, and that way in dry-run mode I can get the HTTP calls it would have made without it actually making them.

And this works well if your CLI command is simply performing a single operation, e.g. call this REST API

But the moment it starts to do anything more complex: e.g. call API1, and then send the results of API1 to API2 – it becomes a lot more difficult

Of course, you can simulate what API1 is likely to have returned; but suddenly you have something a lot more complex and error-prone than just `if not dry_run:`

awesome_dude•2h ago
pffft, if you aren't dropping production databases first thing in the morning by accident, how are you going to wake yourself up :-)
cjonas•1h ago
We have an internal framework for building migrations and the "dry run" it's a core part of the dev cycle. Allows you to test your replication plan and transformations without touching the target. Not to mention, a load that could take >24 hours completes in minutes
mycall•1h ago
I like the opposite too, -commit or -execute as it is assumed running it with defaults is immutable as the dry run, simplifying validation complexity and making the go live explicit.
Twirrim•58m ago
I've biased towards this heavily in the last 8 or so years now.

I've yet to have anyone mistakenly modify anything when they need to pass --commit, when I've repeatedly had people repeatedly accidentally modify stuff because they forgot --dry-run.

IgorPartola•26m ago
I wouldn’t want most things to work this way:

    $ rm file.bin
    $ rm —-commit file.bin
    $ cat foo.txt > bar.txt
    $ cat foo.txt | tee —-write-for-real bar.txt
    $ cp balm.mp3 pow.mp3
    $ cp —-i-mean-it balm.mp3 pow.mp3
There is a time and a place for it but it should not be the majority of use cases.
Darfk•13m ago
Totally agree it shouldn't be for basic tools; but if I'm ever developing a script that performs any kind of logic before reaching out to a DB or vendor API and modifies 100k user records, creating a flag to just verify the sanity of the logic is a necessity.
james_marks•8m ago
Yep. First thing I do for this kind thing is make a preview=true flag so I don’t accidentally run destructive actions.
Joker_vD•5m ago

    if [ -n "$DRY_RUN" ] ; then
        alias rm='echo rm'
        alias cp='echo cp'
    fi
Of course, output redirects will still overwrite the files, since the shell does it and IIRC this behaviour can't be changed.
hdjrudni•6m ago
Even in those basic examples, it probably would be useful. `cp` to a blank file? No problem. `cp` over an existing file? Yeah, I want to be warned.

`rm` a single file? Fine. `rm /`? Maybe block that one.

xyse53•56m ago
Yeah I'm more of a `--wet-run` `-w` fan myself. But it does depend on how serious/annoying the opposite is.
aqme28•48m ago
I've done that, but I hate the term "wet run."

I use "live run" now, which I think gets the point across without being sort of uncomfortable.

IgorPartola•24m ago
--with-danger

--make-it-so

--do-the-thing

--go-nuts

--safety-off

So many fun options.

Darfk•8m ago
I'm a fan of --safety-off. It gives off a 'aim away from face' or 'mishandle me and I'll blow a chunk out of your DB' vibe.
taude•1h ago
Funny enough, when creating CLIs with Claude Code (and Github Copilot), they've both added `--dry-run` to my CLIs without me even prompting it.

I prefer the inverse, better, though. Default off, and then add `--commit` or `--just-do-it` to make it actually run.

CGamesPlay•1h ago
For me the ideal case is three-state. When run interactively with no flags, print a dry run result and prompt the user to confirm the action; and choose a default for non-interactive invocations. In both cases, accept either a --dry-run or a --yes flag that indicates the choice to be made.

This should always be included in any application that has a clear plan-then-execute flow, and it's definitely nice to have in other cases as well.

throwaway314155•1h ago
Sort of a strange article. You don't see that many people _not_ praising --dry-run (speaking of which, the author should really learn to use long options with a double dash).
CGamesPlay•1h ago
I'm not aware of any CLI arguments that accept emdash for long arguments–but I'm here for it. "A CLI framework for the LLM era"
calvinmorrison•1h ago
--dry-run

--really

--really-really

--yolo

homebrewer•1h ago
You'll like fontconfig then, which has both --force and --really-force

https://man.archlinux.org/man/fc-cache.1.en

aappleby•58m ago
What if the tool required an "un-safeword" to do destructive things?

"Do you really want to 'rm -rf /'? Type 'fiberglass' to proceed."

nthdeui•47m ago
Like tarsnap's --nuke command:

  --nuke  Delete all of the archives stored.  To protect against accidental
          data loss, tarsnap will ask you to type the text "No Tomorrow"
          when using the --nuke command.
TZubiri•50m ago
I use --dry-run when I'm coding and I control the code.

Otherwise it's not very wise to trust the application on what should be a deputy responsibility.

Nowadays I'd probably use OverlayFS (or just Docker) to see what the changes would be, without ever risking the original FS.

gooseyman•37m ago
https://news.ycombinator.com/item?id=27263136

Related

tegiddrone•19m ago
I’m interested to know the etymology and history of the term. Somehow I imagine an inked printing press as the “wet run.”

Gemini 3 Pro on AI Studio has been capped at 10 uses per day

https://old.reddit.com/r/Bard/comments/1qqw8o4/gemini_3_pro_on_ai_studio_has_finally_been_capped/
1•Kholin•41s ago•0 comments

SpacemiT K3 RISC-V AI CPU launch event [video]

https://www.youtube.com/watch?v=PxxUsUqgOFg
1•sxzygz•2m ago•0 comments

Reasoning with Sampling: Your Base Model Is Smarter Than You Think

https://medium.com/@haitham.bouammar71/we-didnt-train-the-model-it-started-reasoning-better-anywa...
1•verdverm•2m ago•1 comments

'Spy Sheikh' Bought Secret Stake in Trump Company for Access to USA AI Chips

https://www.wsj.com/politics/policy/spy-sheikh-secret-stake-trump-crypto-tahnoon-ea4d97e8
1•NN88•4m ago•0 comments

I dropped my Google Pixel 9 XL Pro from 6th floor balcony to the street

https://ercanermis.com/i-dropped-my-google-pixel-9-xl-pro-from-6th-floor-balcony-to-the-street/
1•ermis•4m ago•0 comments

Tangible Media: A Historical Collection of Information Storage Technology

https://tangiblemediacollection.com/
1•vinhnx•6m ago•0 comments

Dealing with logical omniscience: Expressiveness and pragmatics (2011)

https://www.sciencedirect.com/science/article/pii/S0004370210000457
1•measurablefunc•12m ago•0 comments

Technical interviews are broken. I built a tool that proves it

1•ruannawe•23m ago•0 comments

What the US TikTok takeover is revealing about new forms of censorship

https://www.theguardian.com/commentisfree/2026/jan/30/tiktok-us-takeover-new-type-of-censorship
3•thunderbong•25m ago•0 comments

Show HN: OpenJuris – AI legal research with citations from primary sources

https://openjuris.org/
1•Zachzhao•30m ago•0 comments

BoTTube – A YouTube-like platform where AI agents create and share videos

https://bottube.ai/
1•AutoJanitor•37m ago•1 comments

ChatGPT is pulling answers from Elon Musk's Grokipedia

https://techcrunch.com/2026/01/25/chatgpt-is-pulling-answers-from-elon-musks-grokipedia/
5•abdelhousni•42m ago•0 comments

AI chatbots like ChatGPT are using info from Elon Musk's Grokipedia

https://mashable.com/article/ai-chatbots-chatgpt-sourcing-elon-musk-grokipedia
5•abdelhousni•46m ago•0 comments

The Disconnected Git Workflow

https://ploum.net/2026-01-31-offline-git-send-email.html
2•zdw•47m ago•0 comments

Ex-Googler nailed for stealing AI secrets for Chinese startups

https://www.theregister.com/2026/01/30/google_engineer_convicted_ai_secrets_china/
2•jacquesm•49m ago•1 comments

Show HN: Yesterdays, a platform for exploring historical photos of my city

https://yesterdays.maprva.org
1•uneekname•52m ago•0 comments

Apple-1 Computer Prototype Board #0 sold for $2.75M

https://www.rrauction.com/auctions/lot-detail/350902407346003-apple-1-computer-prototype-board-0-...
20•qingcharles•53m ago•6 comments

Show HN: Inverting Agent Model (App as Clients, Chat as Server and Reflection)

https://github.com/RAIL-Suite/RAIL
1•ddddazed•54m ago•0 comments

IP

https://blog.cloudflare.com/post-quantum-warp/
3•Ryori•58m ago•0 comments

High-res nanoimprint patterning of quantum-dot LEDs via capillary self-assembly

https://www.nature.com/articles/s41566-025-01836-5
2•westurner•1h ago•0 comments

Pre-Steal This Book

https://seths.blog/2008/12/pre-steal-this/
2•herbertl•1h ago•0 comments

Aasha – and the Royal Game of Ur

https://maddy06.blogspot.com/2024/11/aasha-and-royal-game-of-ur.html
1•gomboc-18•1h ago•0 comments

The paper is not the song: why "Spotify for Science" keeps missing the point

https://articles.continuousfoundation.org/articles/how-modularity-changes-systems
2•rowanc1•1h ago•3 comments

Beelancer.ai – AI Agents bid for work and earn money for their owners

https://beelancer.ai
1•nclgrt•1h ago•1 comments

Show HN: Peptide calculators ask the wrong question. I built a better one

https://www.joyapp.com/peptides/
2•silviogutierrez•1h ago•0 comments

Why do math libraries produce different results across platforms?

https://github.com/RegularJoe-CEO/LuxiDemo/releases/tag/v2.0.1
3•luxiedge•1h ago•2 comments

Moltbook is exposing their database to the public

https://twitter.com/theonejvo/status/2017732898632437932
7•taytus•1h ago•1 comments

OpenClaw Security Assessment by ZeroLeaks [pdf]

https://zeroleaks.ai/reports/openclaw-analysis.pdf
26•nreece•1h ago•9 comments

Show HN: Molty Overflow – Stack Overflow for AI Agents

https://www.moltyoverflow.com/
1•zknowledge•1h ago•0 comments

U.S. life expectancy hits all-time high

https://www.scientificamerican.com/article/u-s-life-expectancy-hits-all-time-high/
24•brandonb•1h ago•16 comments