Skip to content

Add @file command support for non-interactive cli input #3311

@zfflxx

Description

@zfflxx

What would you like to be added?

Extend the existing @file command functionality to work in non-interactive (piped) mode. Currently, when users input @filename in interactive UI, the file content is automatically read and added to the chat context. This same logic should be implemented for non-interactive mode.

Why is this needed?

In non-interactive cli mode, without direct file reading, Gemini cli needs to first create a tool call request and then read the file, requiring multiple API calls and taking longer to complete.

For example, Claude Code supports: claude -p "explain this code to me @test.js" - completing the task in a single interaction without additional ReadFile tool calls. Gemini CLI should provide the same efficient workflow.

Benefits:

  • Performance: Eliminates extra API calls and reduces response time
  • Consistency: Unified @file behavior across interactive and non-interactive modes
  • Efficiency: Enables single-command workflows for file-based queries

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Stalearea/non-interactiveIssues related to GitHub Actions, SDK, 3P Integrations, Shell Scripting, Command line automationpriority/p2Important but can be addressed in a future release.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions