Amazon Q Developer CLI は インタラクティブモードなしで動かす「--no-interactive」オプションがあります。これを利用することでAmazon Q Developer CLI をワンライナーで動かすことができます。
例えば、バッチシェルで動かしたり、スケジュールで実行したり、git commmi hook でコミット前レビューをしたり、色々な用途が考えられます。
コマンドは以下です。
q chat --no-interactive --trust-all-tools "プロンプト"
(「--trust-all-tools」は確認を求めることなく、モデルが任意のツールを使用してコマンドを実行することを許可します)
なお、MCPサーバーが多い場合はタイムアウトが発生したため、注意してください。
2025-10-07T05:22:33.183082Z ERROR chat_cli::cli::chat: 854: An error occurred processing the current state err=SendMessage(SendMessageError { source: CodewhispererGenerateAssistantResponse(DispatchFailure(DispatchFailure { source: ConnectorError { kind: Other(None), source: TimedOutError(5s), connection: Unknown } })), request_metadata: RequestMetadata { request_id: None, message_id: "xxxxxxxx", request_start_timestamp_ms: 1759814530371, stream_end_timestamp_ms: 1759814536978, time_to_first_chunk: None, time_between_chunks: [], user_prompt_length: 192, response_size: 0, chat_conversation_type: None, tool_use_ids_and_names: [], model_id: Some("claude-sonnet-4"), message_meta_tags: [] } })
Amazon Q is having trouble responding right now:
0: Failed to send the request: dispatch failure (other): identity resolver timed out after 5s
1: dispatch failure (other): identity resolver timed out after 5s
2: dispatch failure
3: other
4: identity resolver timed out after 5s
Location:
crates/chat-cli/src/cli/chat/mod.rs:1081
Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.
できるだけデフォルトの mcp.json には MCPサーバーの設定を書かずに、 ワンライナー用の カスタムエージェントを作り、それを利用するのが良さそうです。
以上です。