Skip to content

feat: add --one-shot flag for sessionless single-prompt execution#5149

Open
12310312long wants to merge 1 commit into
Aider-AI:mainfrom
12310312long:feat/one-shot-mode
Open

feat: add --one-shot flag for sessionless single-prompt execution#5149
12310312long wants to merge 1 commit into
Aider-AI:mainfrom
12310312long:feat/one-shot-mode

Conversation

@12310312long
Copy link
Copy Markdown

Summary

Add a --one-shot flag that allows running a single prompt without initializing a git repository, then exits immediately after delivering the response. This is useful for quick one-off tasks like explaining code or simple refactoring where you don't need a full session.

Usage

# Message via --message flag
aider --one-shot --message "explain this function" src/utils.js

# Message as positional argument (more concise)
aider --one-shot "explain this function" src/utils.js

# Message from file
aider --one-shot --message-file prompt.txt src/utils.js

Implementation

  • aider/args.py: Added --one-shot argument to the "Modes" group
  • aider/main.py: When --one-shot is set:
    • Forces --no-git to skip all git repository initialization
    • If no --message or --message-file is provided, treats the first positional argument as the message
    • Shows an error if no message source is found
  • The existing --message handler in main.py runs the coder with the message and exits, which works unchanged

Testing

  • Manually tested with both --message and positional-arg message syntax
  • Verified git repo is skipped (Git repo: none)
  • Verified file modifications work correctly
  • All existing pytest tests pass (the one failure on Windows is pre-existing and unrelated)

Closes #5143

Add a --one-shot flag that runs a single prompt without git repo
initialization, then exits. The message can be provided via --message,
--message-file, or as the first positional argument for convenience.

Closes Aider-AI#5143

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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

1 participant