← Back to Portfolio

ai-shell-loop: AI Agent that Generates & Executes Shell Commands

Built in September 2024 — two months before Claude Code launched

PythonAI AgentOpenAI APICLIPyPI

Project Overview

ai-shell-loop is a command-line AI agent I built in September 2024 — two months before Claude Code launched. It lets you describe a goal in plain English; the tool calls GPT to generate bash commands, executes them, observes the results, and iterates until the goal is reached.

How It Works

  • Natural Language Input: Describe what you want done, e.g. "create a python program that lists primes below 100"
  • Command Generation: The tool calls the OpenAI API to translate the goal into concrete shell commands
  • Execution & Observation: Commands run locally, and their output feeds back into the loop
  • Iteration: If a command fails or the goal isn't met, the agent tries alternative approaches until it succeeds

Technical Details

  • Language: Python, packaged and published on PyPI
  • Distribution: Installable via pip, runs on Linux and macOS
  • License: Apache License 2.0

Building an agentic shell loop before agentic coding tools went mainstream gave me early, hands-on experience with the exact problem space — goal decomposition, tool execution, and iterative self-correction — that later became central to tools like Claude Code.