When I look at code, in 99% of the cases each file starts with a copy-pasted license.
Instead each file should start with a short description what the file is for. Which is almost never there. So let’s start with a description and put the license downstairs
Or just put the license in a LICENSE file and don’t repeat it in each file at all. That’s what the vast majority of projects do these days, adding at most an SPDX-License-Identifier, though even that is rare.
To slightly hijack the thread, what happened to the idea that imports might be better off relegated to the bottom of the file too? It’s Zig, so it’s fine for them to be at the very end.
I started doing it and I love it. My current ordering style is:
struct fields
public constants
heap of all other decls (functions, types, public, private; intermixed based on “vibes” - I usually try to put related things close together)
imports (including aliases like const assert = std.debug.assert; all sorted with :sort -i)
Ultimately, it doesn’t matter too much - you can either find stuff via ZLS, or if you don’t want/have that, an underrated property of Zig is that it is very greppable - you can just find things by searching for const MyType, fn init, etc.
EDIT: Back on topic, I personally don’t put license headers in my files, just a LICENSE file in the project root. Lately I’ve been thinking about putting the SPDX-License-Identifier thing in all files, but definitely not a whole big header like the GPL would prefer you to do.
I’m not a fan of that, as I’m a bit paranoid. Whenever I look at a project, the first thing I do is open zig.zon to understand what dependencies it contains. This can lead to me not even looking further into the actual source code because there are simply too many dependencies. Then, when I look at the modules, I always check the @import statement first to get a rough overview. But these are just my personal preferences after over 40 years of software development.
If all files in your project repository are covered by the same license (and copyright declaration, if applicable), then I agree that a LICENSE file is enough.
However, if your repository contains files with different license terms, like vendored headers and source files copied from other projects, then please consider declaring license information on a file-by-file basis using short machine-readable header comments like
// (c) 2026 John Doe
// SPDX-License-Identifier: MIT
or, alternatively, license declaration manifest files like REUSE.toml. This makes it easier for downstream users of your project audit the licenses of their dependencies (for aspects like GPL compatibility) and helps them Do The Right Thing with regard to license text reproduction and attribution requirements when distributing binaries.