On this page

Source-file headers

Beyond the LICENSE file, License Wizard can stamp a per-file license header at the top of your source files — the short notice many licenses ask you to add to each file. The interactive wizard offers this after the license is chosen; non-interactively, pass --headers with a style:

npx license-wizard --license MIT --headers short --save-npm

Two styles

  • short writes the canonical SPDX tag lines (SPDX-License-Identifier:, plus SPDX-FileCopyrightText: when you've filled in copyright fields). Available for every license.
  • full writes the license's complete standard header notice, with your copyright fields substituted. Available only for licenses that publish one (Apache-2.0, the GPL family, MPL-2.0, …). For a license without a standard header (MIT, BSD, ISC, …), only short applies.

The header is filled from the same copyright values you supply when customizing — you're never asked for them twice. A full notice that carries copyright placeholders can only be written once those values are provided: in the wizard, Full is offered only after you've customized the copyright; non-interactively, --headers full requires the matching --set values and otherwise stops, listing the fields it needs.

Comment style

By default the header is wrapped in a block comment (/* … */). Pass --headers-comment docblock to use a documentation block (/** … */) instead — the form PHPDoc and the WordPress Coding Standards expect. It applies only when a header is being written, so it requires --headers; on its own it errors rather than being silently ignored.

What gets a header

Only the source files the npm and Composer ecosystems use: .js, .jsx, .mjs, .cjs, .ts, .tsx, .cts, .mts, and .php. JSON, stylesheets, markdown, and generated output are left alone. Dependencies (node_modules/, vendor/), .git/, and everything your .gitignore excludes are skipped automatically — add more with a repeatable --headers-ignore <glob>. A #! shebang stays on top, and the header sits inside PHP's <?php tag — a .php file that opens with HTML rather than <?php is skipped instead, so the header is never emitted as page output.

Safe to re-run

License Wizard owns the headers it writes. Running it again over an unchanged project changes nothing; switching licenses updates the existing header in place rather than stacking a second one; and verification keeps them current. Any file it can't safely head — one already carrying a hand-written license notice, or an HTML-first .php file — is skipped and reported, both when writing and under --verify, so a notice you wrote by hand is always left untouched.

Every surface that reports a skip — writing, --dry-run, and --verify — now lists the paths it skipped, not just a count, so you can see exactly which files were left alone and why.

Forcing a header into a skipped file

When you know a skipped file is safe to head, override the guard for that one path with --force-header:

npx license-wizard --force-header src/legacy.ts

It writes the header configured in your saved config into the named file, even though a normal run would skip it. It's non-interactive and deliberately narrow: the target must be one of the source file types License Wizard heads, the path is resolved relative to the directory you run it in (absolute paths, and paths that resolve outside the project — including through a symlinked directory — are refused), and it only does anything when your saved config has headers enabled. The skipped-file reports print a ready-to-run example using one of the paths they list.

Removing headers

To take the headers back out, pass --remove-headers. It strips every header License Wizard added and drops the headers preference from your saved config, so verification stops checking that surface. It honors --headers-ignore and --dry-run, and your hand-written notices stay put.

npx license-wizard --remove-headers