# AI use cases for Shell GPT (TheR1D/shell_gpt)

Repo: [TheR1D/shell_gpt](https://github.com/TheR1D/shell_gpt) | Use cases: 3 | Page: https://dedupedai.com/use-cases/ther1d-shell-gpt/

ShellGPT (sgpt) is a command-line productivity tool that uses large language models to generate shell commands, code snippets and documentation from plain-language prompts. It reads from arguments or stdin, knows your OS and shell, can execute suggested commands after you confirm, keeps chat sessions and a REPL, and adds a Ctrl+l hotkey to Bash and Zsh. It uses OpenAI by default and can be pointed at local models through Ollama.

This file holds every use case of this repo. Each one starts with a "## " heading and ends with its URL.

- Turn plain English into shell commands you can run: https://dedupedai.com/use-cases/ther1d-shell-gpt/turn-plain-english-into-shell-commands/
- Pipe logs and diffs into an LLM for quick answers: https://dedupedai.com/use-cases/ther1d-shell-gpt/analyze-logs-and-diffs-from-stdin/
- Build and refine code in a named terminal chat session: https://dedupedai.com/use-cases/ther1d-shell-gpt/iterate-on-code-in-a-chat-session/

## How to turn plain English into shell commands you can run with Shell GPT

Repo: [TheR1D/shell_gpt](https://github.com/TheR1D/shell_gpt) | Difficulty: Beginner | Time: 10 minutes | Basis: From the README

Ask sgpt --shell for a command, then execute, describe or abort it with one key.

**Who it is for:** Anyone who forgets find, ffmpeg or docker flags and is tired of searching for them.

**The problem:** Looking up command syntax breaks your flow and leads to copy-pasting commands you do not understand.

**The outcome:** A command tailored to your OS and shell, shown before it runs so you can check it.

### Steps

1. Run `pip install shell-gpt` and enter your OpenAI API key when prompted
2. Ask for a command: `sgpt --shell "find all json files in current folder"`
3. Choose [E]xecute, [D]escribe or [A]bort; use Describe when you are not sure what it does
4. Install the hotkey with `sgpt --install-integration` and restart your terminal, then press Ctrl+l to turn your input line into a command
5. Use `--no-interaction` to print the command without running it, for example to pipe it to the clipboard

### Prompt to paste into your agent

```text
Install TheR1D/shell_gpt, set up the shell integration for my <bash or zsh>, and show me three examples of sgpt --shell for tasks I do often: <tasks>. Always choose Describe before Execute.
```

### Caveat

Generated commands can be wrong or destructive, so read each one before choosing Execute, especially anything with sudo.

Risk, credentials: Your OpenAI API key is saved in ~/.config/shell_gpt/.sgptrc, and every prompt is a paid API call.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/ther1d-shell-gpt/turn-plain-english-into-shell-commands/

## How to pipe logs and diffs into an LLM for quick answers with Shell GPT

Repo: [TheR1D/shell_gpt](https://github.com/TheR1D/shell_gpt) | Difficulty: Beginner | Time: 10 minutes | Basis: From the README

Send docker logs or a git diff to sgpt with a prompt to find errors or write a commit message.

**Who it is for:** A developer debugging a failing container or writing commit messages at the end of a long day.

**The problem:** Reading long logs for the one real error, or summarizing a diff, takes time you would rather spend fixing.

**The outcome:** A short list of detected errors with suggested fixes, or a ready-to-edit commit message.

### Steps

1. Install with `pip install shell-gpt`
2. Analyze logs: `docker logs -n 20 my_app | sgpt "check logs, find errors, provide possible solutions"`
3. Write a commit message: `git diff | sgpt "Generate git commit message, for my changes"`
4. Use any redirection operator to pass a file in with a prompt such as summarise
5. Review the output before acting on it

### Prompt to paste into your agent

```text
Using TheR1D/shell_gpt, pipe the last 50 lines of <service> logs into sgpt and ask it to find errors and suggest fixes. Then pipe my staged git diff into sgpt for a commit message and show me both before doing anything.
```

### Caveat

ShellGPT is not optimized for local models, so results with Ollama may be weaker than with OpenAI.

Risk, credentials: Anything you pipe in is sent to the model provider, so do not pipe logs or diffs that contain secrets or customer data.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/ther1d-shell-gpt/analyze-logs-and-diffs-from-stdin/

## How to build and refine code in a named terminal chat session with Shell GPT

Repo: [TheR1D/shell_gpt](https://github.com/TheR1D/shell_gpt) | Difficulty: Beginner | Time: 15 minutes | Basis: From the README

Use sgpt --chat with --code to generate a snippet and keep improving it across follow-up prompts.

**Who it is for:** A developer who wants quick scripts from the terminal without switching to a browser chat.

**The problem:** One-shot prompts lose context, so every follow-up means re-explaining what you already asked for.

**The outcome:** A working script refined step by step in a session you can return to later.

### Steps

1. Install with `pip install shell-gpt`
2. Start a session: `sgpt --chat conversation_2 --code "make a request to localhost using python"`
3. Refine it in the same session: `sgpt --chat conversation_2 --code "add caching"`
4. Redirect pure code output to a file, as in `sgpt --code "solve classic fizz buzz problem using Python" > fizz_buzz.py`
5. Use the REPL mode for longer back and forth; sessions live at the configurable CHAT_CACHE_PATH

### Prompt to paste into your agent

```text
Using TheR1D/shell_gpt, start a chat session named <name> with --code to write a Python script that <task>, refine it with two follow-ups about <changes>, and save the final code to <file>. Run it once to check it works.
```

### Caveat

Generated code is unreviewed: test it before relying on it.

Risk, credentials: Each prompt is billed to your OpenAI key; set a usage limit in your OpenAI account if you use it heavily.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/ther1d-shell-gpt/iterate-on-code-in-a-chat-session/
