DEDUPED Hot AI repos. Real use cases. What people build. Get the Monday 5

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

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

Short answer: Install with pip install shell-gpt; then 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". All steps.

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

Who it is forA developer who wants quick scripts from the terminal without switching to a browser chat.

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

The outcomeA working script refined step by step in a session you can return to later.

What you need first

  • 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

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 for your agent

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.

Use this in your AI agent

Ask your agent

Using the Deduped MCP, get the setup steps for TheR1D/shell_gpt and "Build and refine code in a named terminal chat session"

Add Deduped to Claude Code once

claude mcp add --transport http deduped https://dedupedai.com/mcp

Cursor, ChatGPT, others

Share: X LinkedIn Hacker News Email Copy link

Third-party repos we don't own. AI-written use cases can be wrong. Disclaimer