
ShellGPT
A command-line tool that uses AI language models to write shell commands, code, and answers.
- Stars
- 12.3k
- Forks
- 972
- Licence
- MIT
- Language
- Python
- Last update
- 4 months ago
- Type
- CLI
What it is
ShellGPT (the sgpt command) lets you ask an AI model questions straight from your terminal and get back shell commands, code snippets, or explanations. It can read input from pipes and files, so you can feed it things like a git diff or log output. People use it to avoid looking up command syntax online.
- Generate a shell command from a plain-English request, then choose whether to execute it
- Pipe a git diff into sgpt to draft a commit message
- Pass Docker logs to sgpt and ask it to find errors and suggest fixes
- Generate code snippets and save them to a file with output redirection
- Keep a named chat session to refine a command or script over several requests
Great for
- Developers who often forget shell or command-line syntax
- People who want AI answers piped in from files, logs, or git diffs
- Users comfortable with the terminal who have an OpenAI API key
- Anyone who wants to keep a multi-turn chat session from the command line
Not ideal for
- People who do not want to pay for OpenAI API usage, since the README says the default backend is paid and local models are not optimized for it
- Users who need a graphical interface, because it is a terminal tool
- People who will run shell commands without reading them first, since the tool offers to execute AI-generated commands
How to get it
- 1
Install with a package manager
You'll need: Python · An OpenAI API key (default backend)
Install ShellGPT
pip install shell-gpt - 2
Run it
- Install with pip install shell-gpt
- Run sgpt and enter your OpenAI API key when prompted; it is stored in ~/.config/shell_gpt/.sgptrc
- Ask a question, for example: sgpt "What is the fibonacci sequence"
- Try shell mode with: sgpt --shell "find all json files in current folder"
- 3
Get the most out of it
- Use --shell or -s to get a command you can execute or describe before running
- Pipe files or command output into sgpt along with a prompt to analyze them
- Use --chat with a session name to keep context across related requests
- Run sgpt --install-integration to add a hotkey (Ctrl+l by default) for Bash or Zsh
- Use --no-interaction with -s to print a generated command to stdout for piping
Downloads
Strengths
- Works from the terminal with pipes and redirection, fitting into existing workflows
- Supports Linux, macOS, and Windows, and the README says it works with common shells like Bash, Zsh, and PowerShell
- Open source under the MIT license with a large user base (about 12,000 stars)
Trade-offs
- Requires an OpenAI API key by default, and the README notes OpenAI API usage is not free
- The README states it is not optimized for local models and may not work as expected with them
- AI-generated shell commands can be wrong, so outputs need review before running
How it compares
| Project | Stars | Type | Level | Updated | Best for |
|---|---|---|---|---|---|
| shell_gpt (this) | 12.3k | CLI | beginner | 4 months ago | Developers who often forget shell or command-line syntax |
| warp | 10.4k | Library | intermediate | 3 months ago | Rust developers building HTTP APIs or web servers |
| botpress | 15k | Dev tool | intermediate | 6 days ago | Developers who want to write integrations and bots as TypeScript code using the Botpress CLI and SDK |
| ohmyzsh | 190k | Dev tool | beginner | 4 days ago | People who already use zsh and want a ready-made configuration without writing it from scratch |
| openai-cookbook | 76.9k | Learning resource | beginner | 5 days ago | Developers who are new to the OpenAI API and want working examples |
| yazi | 43.2k | App | intermediate | 4 days ago | People who already spend time in a terminal and want a faster way to browse folders |
Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.