When using VSCode on macOS, randomly a `sysdiagnose.tar.gz` will be generated

Most likelely you hit Control-Option-Command-Shift-. now and then which triggers system diagnostics (see How do you get system diagnostic files from macOS?) for details.