How it keeps things
Before a file in a watched place is deleted or changed, ScriptKitty already holds an old copy of it or a second name for it. This page explains how, for an engineer who wants to check the reasoning before trusting it.

A small background service watches the files on the machine's own disks, its Docker containers and volumes, its systemd units and a local PostgreSQL. It needs nothing from the agent: no plugin, no approvals, no prompts. It does not read command text and uses no model. It watches what the kernel does, so a delete looks the same whether it came from a shell, a script or Docker.
A question at every open
Linux lets a program be asked before a file is opened. The service asks the kernel to wait at every open on whole disks, using fanotify. An open for writing waits while a before-picture is taken if the file has none, and then it goes on.
Reads are never held and never written down.
Why deletes are made harmless in advance
The kernel offers no such question before a delete or a rename. So deletes are made harmless in advance: by the time one arrives, the file already holds an old copy or a second name.
Three ways a file is held
How a file is held depends on its size and on the disk it sits on.
| Kind of file | How it is held | What an undo does |
|---|---|---|
| Small files, 4 KB or less | A real copy, packed into the store. | Brings the copy back. |
| Bigger files on ext4 | A second name (a hard link) in a hidden store on the same disk. It costs no room and no copying. | For a delete, gives the very same file its name back, in one call at any size. A changed file is copied back. |
| Files on btrfs and xfs | A free clone, which shares blocks until one side changes. | For a changed file, puts the clone back. |
The store is on the same disk as the file, outside every user folder, and only root can read it.
The diary
ScriptKitty writes a diary of what appeared, vanished, moved or changed, and when. Each line also says which program did it, with its parents.
The sk command reads the diary and puts things back. One change goes back with sk undo 12. Everything as it was at a clock time or a bookmark goes back with sk back 10m, sk back 14:32 or sk back m1234, and sk mark saves a bookmark. An ordinary user can undo only what they could have changed by hand, while sudo includes everyone's changes.
Keep time and room
The default keep time is 24 hours of fine-grained history, and sudo sk keep 3d changes it. When the keep time passes, old copies are let go.
sk space shows how much room the copies take. sudo sk free PATH lets go of the copies held for one file.
When the disk is full
On a nearly full disk ScriptKitty gives way. The program's write goes through with no copy, and the file and the moment are named in sk status. It never refuses a change because the disk is full. Its own copies take room, so a full disk can come earlier than it would without it.
What it costs on ext4
The first write-open of a big file on ext4 after each save waits for a copy of it. That wait is the cost of ext4. On btrfs and xfs the clone is free.
Docker, systemd and PostgreSQL
Docker containers and volumes, and systemd units, come back through recorded steps.
A local PostgreSQL has its own trash can. The database's own change log is kept, and tables are put back from it. That covers deleted, overwritten, emptied and dropped tables, added rows taken out, a changed shape and a dropped database. How the database was just now is saved to a file first, and the reply names that file and the command that loads it. Some database cases are not covered, and the limits page lists them.
Every undo can be taken back
Every undo is itself written down. A go-back ends with a bookmark of how things were just before it, and sk back to that bookmark takes the go-back back.
Where it has run. The Linux build is in testing and has run only in throwaway test VMs. It needs a kernel with fanotify permission events (it has run on 6.12 only), root for the service, and Python 3 with only its standard library. The disks are ext4, xfs and btrfs.
Next: clouds, or what it cannot undo.