Skip to main content
T1 starter · any team: the smallest safe deletion. nika:remove_file removes one existing regular file by its exact path, with nothing recursive and nothing expanded, and only after this run’s own write succeeded.

The job

A job writes a scratch file, uses it, and should clean up after itself without ever deleting something it did not create. This workflow writes the scratch file with overwrite: false, then removes exactly that path once the write has succeeded. If the path is already taken, the write refuses, the removal never runs, and the file that was there survives.

The shape

The file

remove-owned-file.nika

How it works

1

The write refuses to replace anything

overwrite: false makes publish fail when a file already sits at the path (NIKA-BUILTIN-WRITE-002). The workflow can create the scratch file; it cannot clobber one.
2

The removal waits for that write

after: { publish: success } is a state edge: remove runs only when this run’s own write succeeded. When the path was taken, remove is blocked and the existing file stays where it was.
3

Removal is a write effect

nika:remove_file needs the tool grant and a permits.fs.write entry holding the exact path. It reads no content, so the file grants no fs.read at all. A missing name, a directory, a symlink or a special file fails; nothing is recursive, and no pattern is expanded.
This is not a transaction. If the removal fails after the write, the scratch file stays visible and nothing rolls back. The removed output is the path the run asked to remove, not a proof of what is on disk.

Constructs you just used

Run it

What it needs: Nothing: no model, no key, no network.
1

Rehearse it

The rehearsal runs in a temporary folder; nothing is written in yours.
2

Check it, then run it

Save the file above as remove-owned-file.nika, then:
The run writes out/remove-owned-file/scratch.txt, removes it, and prints {"removed":"./out/remove-owned-file/scratch.txt"}.

Make it yours

  • Use your own scratch path: change both task paths and the permits.fs.write entry together. A permit is a literal, never an interpolation (NIKA-AUTH-007).
  • Put the work that uses the scratch file between the two tasks, give it the fs.read grant it needs, and make remove wait for that task too.

Level up · T2 chains

Next tier: typed outputs, in-place file edits and a webhook ping. Release day, automated.