Kiira
ChevronDown
Github

Automatic fixes (--fix)

How the Kiira --fix flag rewrites mistagged code fences, adds group tags to continuation snippets, applies rule edits, and writes framework jsxImportSource overrides into your config. Preview with --dry-run.

Running fixes

kiira check --fix

--fix applies only safe, mechanical changes. Kiira's own fixes never edit the code inside your snippets: they rewrite fence metadata and config so your docs check correctly.

What it fixes

1. Mistagged fences (ts/typescript → tsx)

When a fence is tagged ts (or typescript) but actually contains JSX, it won't represent the example correctly and can produce misleading errors. --fix rewrites the language tag to tsx:

<!-- before -->
``ts
const el = <div>hello</div>
``
<!-- after `kiira check --fix` -->
``tsx
const el = <div>hello</div>
``

See Language-tag checking for how detection works and what Kiira does when you don't run --fix.

2. Ungrouped continuation snippets (group=)

When Kiira detects that a fence is a continuation of an earlier one (for example, it references a const declared in a previous fence), it can group them so they type-check together in document order. --fix adds matching group= tags to those fences:

<!-- before -->
``ts
const user = getUser()
``
``ts
console.log(user.name)
``
<!-- after `kiira check --fix` -->
``ts group=example-1
const user = getUser()
``
``ts group=example-1
console.log(user.name)
``

See Grouping snippets for the full model.

3. Framework jsxImportSource overrides

When a JSX snippet fails because TypeScript can't find the right JSX runtime (for example a Solid or Preact example checked with the default React runtime), --fix writes the appropriate jsxImportSource override into your config so matching files compile against the correct framework.

See Per-glob overrides for how overrides work and how the framework is detected.

4. Edits from rules

A rule can return text edits for any file the check read. --fix applies them with the same care as the fixes above.

Preview with --dry-run

kiira check --fix --dry-run

Prints a unified diff for every file --fix would change and writes nothing, not even your config. The exit code is the one the check produced. With --reporter json the diff goes to stderr.

When a file is skipped

--fix writes a file only when its text is exactly what the check read. It skips a file, prints the reason, and still fixes the others when:

  • the file changed since the check read it
  • the check did not read it
  • the file is not valid UTF-8, or it is read-only
  • its path is outside the project, inside .git or node_modules, or reaches either through a symlink
  • two fixes edit overlapping ranges

A fix is all or nothing. When a fix edits more than one file and one of them is skipped, --fix drops that fix from every file and prints why. Other fixes still apply.

--fix runs every check before it writes the first file. Files are written atomically and keep their permissions and line endings. Just before it replaces a file, --fix reads it again, so it does not overwrite a save made in the meantime.

What it never touches

Kiira's own fixes do not rewrite the body of your code snippets, change your prose, or "fix" type errors by editing the example. Real type errors are yours to fix — --fix only corrects fence tags and config so Kiira checks each example the way it was meant to be checked.