Skip to content

File index tracking

You run the generator on every build, and it shares a folder with code people wrote by hand. It must replace what it owns, remove what no longer exists, and never touch anything else. It does that by marking every file it writes.

Every generated file (and, with separate output, generated barrel) starts with a header naming its source, generation time, and a content hash:

// @generated by Cratis. Source: Tasks.Registration.RegisterTask. Time: 2026-09-24T20:35:55.3970000Z. Hash: FDB6670D1623B9F818509BA14942A78DF19A6EDEA92F42D7DD2D75CDB7D04895

Never edit a file with this header; the next run replaces it.

FileBehavior
An owned file whose content did not changeKept byte for byte, with its timestamp
An owned file whose content changedReplaced
An owned file for an artifact that no longer existsRemoved, unless --skip-output-deletion
A hand-written fileNever overwritten or deleted
A hand-written index.ts barrel in separate outputNever replaced; when stale owned files are deleted, only its exports of those files are removed. Directory and package re-exports stay
A hand-written index.ts in the artifacts treeUntouched in co-located mode; no barrels are written there

Co-located output skips barrels automatically. With separate output, --skip-index-generation stops the generator from writing them.

The output root must exist. The generator resolves symbolic links in its ancestors, such as /tmp on macOS, to their real path, and refuses symbolic links inside the output.