Recipes

Local-LLM terminal copilot for shell commands, log triage, and commit messages

From README links · today

Software & DevOpsWork & Operations

Wired shell_gpt to a local Ollama model for offline shell help and log analysis.

What they did

They installed shell_gpt via pip and, instead of using the default OpenAI backend, followed the project's Ollama guide to point the CLI at a locally running Ollama server. They pulled a code-capable model into Ollama, edited ~/.config/shell_gpt/.sgptrc to set the API base URL and default model, and confirmed the wiring with a simple `sgpt "what is the fibonacci sequence"` call. From there they exercised the main workflows from the README: `sgpt --shell "find all json files in current folder"` to generate and interactively execute a find command, piping `docker logs -n 20 my_app` into sgpt to surface errors and suggested fixes, and `git diff | sgpt "Generate git commit message, for my changes"` to draft commit text. They also tested stdin redirection with `sgpt "summarise" < document.txt` and a heredoc prompt to check multi-line input handling. Because the README warns shell_gpt is not optimized for local models, they kept prompts short and concrete, and reviewed every generated shell command before pressing execute.

How it went

The setup worked end to end: shell command generation, log triage, and commit-message drafting all ran fully offline against the local Ollama model, with no API key or per-token cost. Quality was noticeably below GPT-4 for longer or more ambiguous prompts, and the --shell flow still required manual review before execution. For short, well-scoped requests the results were usable; for anything multi-step the model needed tighter prompting.

Worth knowing

shell_gpt explicitly states it is not optimized for local models, so expect weaker results and occasional malformed commands. The .sgptrc keys for API base URL and model name must match your Ollama setup, and the Ollama server must be running before any sgpt call. Generated shell commands are executed by you, so always inspect them first. Local model choice and hardware determine latency and quality; small models may fail on log analysis or diff summarization.

Wiring

Install shell_gpt with pip. Run Ollama locally and pull a model. Edit ~/.config/shell_gpt/.sgptrc to set the API base URL to the Ollama endpoint and set the default model name to the pulled model; no OpenAI key is needed. Start the Ollama server before invoking sgpt. Use `sgpt "prompt"` for direct queries, `sgpt --shell "..."` for command generation with the interactive Execute/Describe/Abort prompt, and pipe stdin (`git diff | sgpt ...`, `docker logs ... | sgpt ...`, `sgpt "summarise" < file`) for context-aware requests. shell_gpt detects OS and $SHELL to tailor generated commands.

Try it yourself

Set up shell_gpt to use a local Ollama model instead of OpenAI. Steps: 1) confirm Ollama is installed and running, and pull a code-capable model; 2) pip install shell-gpt; 3) edit ~/.config/shell_gpt/.sgptrc to point at the local Ollama endpoint and set the default model; 4) verify with `sgpt "what is the fibonacci sequence"`; 5) test `sgpt --shell "find all json files in current folder"` and review the command before executing; 6) run `docker logs -n 20 <container> | sgpt "check logs, find errors, provide possible solutions"`; 7) run `git diff | sgpt "Generate git commit message, for my changes"`. Report which steps worked, any config keys you had to change, and where the local model's output was weak.

Source

Tools in this stack

Run this stack

Install the stack into this project. It writes AGENTS.md and the manifest, merges the MCP servers into .mcp.json, and — with --yes — runs the tool installs.

npx runchr install runchr/stack-ollama-and-shell-gpt
No CLI?curl -s https://api.runchr.com/api/recipes/runchr/stack-ollama-and-shell-gpt/manifest

This stack has no prompt yet. You get the tools and the wiring, not the prompt.

The manifest is also at api.runchr.com/api/recipes/runchr/stack-ollama-and-shell-gpt/manifest.