1.8 KiB
| name | description |
|---|---|
| state-not-tmp | Never put work that needs to persist under /tmp - it's cleared on restart, so anything written there is lost the moment your environment restarts. Durable work (clones, notes, intermediate artifacts, anything you might need again) belongs under your own persistent state directory instead. /tmp is fine only for genuinely disposable scratch you're happy to lose. Use this whenever you're about to write a file and deciding where it should live. |
State, Not /tmp
/tmp is cleared on restart. Anything you put there that you'd actually
miss later is gone the next time your environment restarts - and a
restart isn't a rare event, it can happen mid-task.
The rule
- Durable work - clones you're actively developing in, notes, intermediate artifacts, anything you'd want back after a restart - goes under your own persistent state directory.
/tmpis for genuinely disposable scratch - a one-shot verification build you'll tear down in the same turn, a throwaway intermediate file you're done with before you stop. If losing it would cost you nothing,/tmpis fine and even preferable (keeps your persistent state directory from accumulating cruft).
The test
Before writing a file, ask: "if this disappeared right now, would I
care?" If yes, it doesn't belong in /tmp. This matters most for
anything that took real work to produce - a clone you've made several
commits in, a report you'll want to reference later, config you're
mid-way through editing.
You can delete files from your own state directory freely once they're
no longer needed - storage isn't the concern there, persistence is. The
asymmetry is the point: /tmp disappears on a schedule you don't
control, your state directory disappears only when you decide it should.