Skip to content

noUnusedImports fix: "safe" causes race condition with Claude Code hooksΒ #483

@gmickel

Description

@gmickel

Hey! Following up on my tweet you liked πŸ˜„

The problem

Ultracite sets noUnusedImports: { fix: "safe" } in the core config. This causes a race condition when using Claude Code with a PostToolUse hook that runs ultracite fix:

  1. Claude adds an import via Edit tool
  2. PostToolUse hook fires, runs ultracite fix
  3. Import gets removed (it's "unused" - the usage hasn't landed yet)
  4. Claude's next edit adds the usage... but the import is gone πŸ’€

Workaround

Setting fix: "unsafe" in my local biome.jsonc fixes it:

"noUnusedImports": { "level": "error", "fix": "unsafe" }

The hook then skips the fix (unsafe fixes need --unsafe true), but I can still clean up manually when needed.

Suggestion

Would it make sense to change the default to fix: "unsafe"? I think that's actually Biome's default behavior anyway. Safe fixes are nice in theory but the AI tooling race condition is pretty painful.

Happy to hear if there's a better approach I'm missing!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions