gemini-cli icon indicating copy to clipboard operation
gemini-cli copied to clipboard

Gemini CLI does not respect linter preferences and/or best-practices

Open gundermanc opened this issue 11 months ago • 1 comments

What happened?

I used Gemini CLI to refactor code from an async code path into its own helper function. I observed it...

  • Moving the code to a new non-async function.
  • Trying to build and hitting a warning about a floating promise, triggered by this: https://github.com/google-gemini/gemini-cli/pull/14605
  • Then it choosing to suppress the warning rather than making its function async.

What did you expect to happen?

I would expect Gemini CLI to follow style best practices and/or declared repo conventions in eslint and other configuration files, falling back to suppressions only as a last resort.

I suspect this behavior can be corrected through revising the prompts and is due to some combination of:

  • "strictly adhering to the project's established conventions" -- the codebase has lots of examples of floating promises to emulate.
  • no prompt to adhere to best practices -- we instruct the agent to follow existing patterns (even if bad) and follow security best practices but we don't instruct the agent to fallback to ecosystem best practices.
  • no prompt to follow linter preferences or to avoid suppressions -- it's ambiguous whether the agent should follow existing coding conventions or the ones configured for the linter.

Client information

Client Information

Run gemini to enter the interactive CLI, then run the /about command.

> /about
│ About Gemini CLI                                                                                                                                                                         │
│                                                                                                                                                                                          │
│ CLI Version                                                     0.21.0                                                                                                                   │
│ Git Commit                                                      1f1bbc462                                                                                                                │
│ Model                                                           auto                                                                                                                     │
│ Sandbox                                                         no sandbox                                                                                                               │
│ OS                                                              darwin                                                                                                                   │
│ Auth Method                                                     OAuth                                                                                                                    │
│ User Email                                                      [email protected]                                                                                                     │
│ IDE Client                                                      VS Code                     

Login information

No response

Anything else we need to know?

No response

gundermanc avatar Dec 17 '25 00:12 gundermanc

Potentially related: I find that Gemini CLI sometimes uses casts present in the code to make assumptions about the types of variables instead of looking at the definitive source.

Here is an example where a redundant cast was added:

Image

And it's explanation of what it thinks happened:

Image

Here's the model's musings on what might have gone wrong given the prompt:

Image Image

gundermanc avatar Dec 17 '25 00:12 gundermanc

+1 on this, I agree with what you have found.

The system prompt (packages/core/src/core/prompts.ts) says "rigorously adhere to existing project conventions" and "mimic the style of existing code." No hierarchy exists between "what the linter config says" vs "what patterns exist in the code." When the model sees existing eslint-disable comments, it learns "this project suppresses lint errors" and replicates that.

My workaround (and I've had good results) is using GEMINI_SYSTEM_MD env var to override the default prompt. I have project-specific (and agent-role-specific) launcher scripts that inject custom system instructions including linter-respect guidance, and it's made a noticeable difference.

The best news is that this appears to be a gemini-cli system prompt issue, not a gemini-the-llm issue, and I can provide anecdotal evidence that this behavior is easily worked around.

As far as the type assumption issue, take a look at claude code's recent LSP additions, also https://github.com/google-gemini/gemini-cli/issues/2465, it's made a noticeable difference and a reduction of "inner loop," code/debug cycle time.

jw409 avatar Jan 09 '26 05:01 jw409

Hello! As part of our effort to keep our backlog manageable and focus on the most active issues, we are tidying up older reports.

It looks like this issue hasn't been active for a while, so we are closing it for now. However, if you are still experiencing this bug on the latest stable build, please feel free to comment on this issue or create a new one with updated details.

Thank you for your contribution!

gemini-cli[bot] avatar Mar 22 '26 00:03 gemini-cli[bot]