Skip to content

Feature/one shot flag#5144

Open
code-quad3 wants to merge 11 commits into
Aider-AI:mainfrom
code-quad3:feature/one-shot-flag
Open

Feature/one shot flag#5144
code-quad3 wants to merge 11 commits into
Aider-AI:mainfrom
code-quad3:feature/one-shot-flag

Conversation

@code-quad3
Copy link
Copy Markdown

@code-quad3 code-quad3 commented May 18, 2026

Add --one-shot flag for sessionless single-prompt execution

Closes #5143

Summary

Adds a --one-shot flag for running a single prompt without git or session context, then exiting. Useful for quick lookups, code analysis, and scripting use cases.

Usage

# Simple prompt
aider --one-shot "what is 2+2"

Explain a file

aider --one-shot "explain this file" src/utils.py

Modify a file

aider --one-shot "add type hints" src/utils.py --one-shot-mode code

Behavior

  • Implies --no-git — no repository initialization
  • Non-interactive — no prompts, auto-accepts all actions
  • Disables repo map
  • Exits with code 0 on success, 1 on error
  • Default mode is ask (read-only); use --one-shot-mode code to apply edits

New Flags

Flag Description
--one-shot PROMPT Run a single prompt and exit
--one-shot-mode ask|code Mode to use (default: ask)

Changes

  • aider/args.py — added --one-shot and --one-shot-mode arguments
  • aider/main.py — early block sets git/session defaults; handler block runs prompt and exits
  • tests/basic/test_main.py — 5 new tests covering no-git, prompt execution, exit behavior, and file context in both modes

Tests

tests/basic/test_main.py::TestMain::test_one_shot_no_git                   PASSED
tests/basic/test_main.py::TestMain::test_one_shot_runs_prompt              PASSED
tests/basic/test_main.py::TestMain::test_one_shot_exits_after_response     PASSED
tests/basic/test_main.py::TestMain::test_one_shot_ask_mode_files_readonly  PASSED
tests/basic/test_main.py::TestMain::test_one_shot_code_mode_files_editable PASSED

code-quad3 and others added 9 commits May 18, 2026 05:59
Co-authored-by: aider (openrouter/qwen/qwen3-coder) <aider@aider.chat>
Co-authored-by: aider (openrouter/qwen/qwen3-coder) <aider@aider.chat>
Co-authored-by: aider (openrouter/qwen/qwen3-coder) <aider@aider.chat>
Co-authored-by: aider (openrouter/qwen/qwen3-coder) <aider@aider.chat>
Co-authored-by: aider (openrouter/qwen/qwen3-coder) <aider@aider.chat>
Co-authored-by: aider (openrouter/qwen/qwen3-coder) <aider@aider.chat>
Co-authored-by: aider (openrouter/qwen/qwen3-coder) <aider@aider.chat>
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 18, 2026

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Add --one-shot flag for sessionless single-prompt execution

2 participants