The trick with Gemini is to uploading the whole (or the relevant part of the) codebase (depending on the size) as an xml (using repomix et al) then telling it to output whole files.
With a good prompt and soem trial and error in system instructions, as long as you agree to play the agent yourself, it's unmatched.
CLI? Never had any success. Claude Code leaves it in dust.