{
 "schema_version": 1,
 "generated": "2026-11-09",
 "id": "ther1d-shell-gpt--iterate-on-code-in-a-chat-session",
 "repo": "TheR1D/shell_gpt",
 "repo_url": "https://github.com/TheR1D/shell_gpt",
 "repo_slug": "ther1d-shell-gpt",
 "title": "Build and refine code in a named terminal chat session",
 "page_title": "How to build and refine code in a named terminal chat session with Shell GPT",
 "summary": "Use sgpt --chat with --code to generate a snippet and keep improving it across follow-up prompts.",
 "who": "A developer who wants quick scripts from the terminal without switching to a browser chat.",
 "problem": "One-shot prompts lose context, so every follow-up means re-explaining what you already asked for.",
 "outcome": "A working script refined step by step in a session you can return to later.",
 "steps": [
  "Install with `pip install shell-gpt`",
  "Start a session: `sgpt --chat conversation_2 --code \"make a request to localhost using python\"`",
  "Refine it in the same session: `sgpt --chat conversation_2 --code \"add caching\"`",
  "Redirect pure code output to a file, as in `sgpt --code \"solve classic fizz buzz problem using Python\" > fizz_buzz.py`",
  "Use the REPL mode for longer back and forth; sessions live at the configurable CHAT_CACHE_PATH"
 ],
 "agent_prompt": "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.",
 "agents": [
  "any"
 ],
 "difficulty": "Beginner",
 "time": "15 minutes",
 "basis": "readme",
 "caveat": "Generated code is unreviewed: test it before relying on it.",
 "category": "Personal productivity",
 "tags": [
  "Personal productivity"
 ],
 "lang": "python",
 "requirements": [
  "Python and pip",
  "An OpenAI API key, stored in ~/.config/shell_gpt/.sgptrc on first run, or a local backend such as Ollama",
  "Linux, macOS or Windows with Bash, Zsh, PowerShell or CMD"
 ],
 "risk": "none",
 "seen_in_the_wild": false,
 "mentioned_publicly": false,
 "risks": [
  {
   "tag": "credentials",
   "notice": "Each prompt is billed to your OpenAI key; set a usage limit in your OpenAI account if you use it heavily."
  }
 ],
 "best": false,
 "score": 0.8,
 "evidence": [],
 "url": "https://dedupedai.com/use-cases/ther1d-shell-gpt/iterate-on-code-in-a-chat-session/",
 "md": "https://dedupedai.com/use-cases/ther1d-shell-gpt/iterate-on-code-in-a-chat-session/index.md",
 "disclaimer": "Deduped lists open-source repositories that belong to other people. We do not own, maintain, audit, or vouch for any of them, and a repo appearing here is not an endorsement or a safety check. The use cases, steps, and prompts are written by AI and may be incomplete, outdated, or just wrong. Where a use case is marked \"Seen in the wild\", we link to public posts where someone described something similar, but we have not verified those posts and the use case itself is still our AI's own write-up. Use all of this at your own risk. Only run code, commands, or agents on systems and accounts you are authorized to use, and read the code and every command before you run it, especially anything that touches credentials, files, or the network. Nothing here is professional, security, legal, or financial advice. All trademarks and project names belong to their respective owners, and their use here does not imply affiliation. Content is provided as is, without warranties of any kind. Found a mistake, a safety problem, or something you want removed? Email hello@dedupedai.com and we will look at it promptly.",
 "api": "https://dedupedai.com/api/v1/usecases/ther1d-shell-gpt--iterate-on-code-in-a-chat-session.json",
 "api_version": "v1"
}
