Building a CLI Agent That Creates a Streamlit TODO App 📃📃📃

Chethan GChethan G
2 min read

Imagine asking your terminal to “Create me a TODO app” — and it just builds and runs it for you.
That’s what we’re doing today: building a CLI Agent that talks to GPT, plans steps, executes commands, and launches a ready-to-use Streamlit TODO app.

Why This Project Is Cool

  • Most AI demos stop at answering questions. But here, we’re giving AI real hands — the ability to:

    • Plan the steps needed to complete a task

    • Execute shell commands

    • Create Python files

    • Launch apps directly

This blends autonomous agents with app development — a mini Copilot for your terminal.


What You’ll Build

  • A Python CLI Agent powered by OpenAI GPT-4.1

  • Tools for running shell commands and fetching weather

  • An agent that can generate a complete TODO app in Streamlit and run it instantly

Setup Requirements 🖥️🖥️🖥️

Before starting, make sure you have to install:

pip install python-dotenv openai requests streamlit

And an .env file containing your OpenAI API key:

OPENAI_API_KEY=your_api_key_here

Core Agent Code and The Flow 🧑🏻‍💻🧑‍💻👩🏼‍💻

  • Here’s the agent script that:

    • Reads your query

    • Plans the execution

    • Choose the right tool

    • Executes step-by-step

    • Runs the app

# cli_agent.py
from dotenv import load_dotenv
from openai import OpenAI
import requests
import json
import os

load_dotenv()
client = OpenAI()

def run_command(cmd: str):
    return os.system(cmd)

def get_weather(city: str):
    url = f"https://wttr.in/{city}?format=%C+%t"
    response = requests.get(url)
    if response.status_code == 200:
        return f"The weather in {city} is {response.text}."
    return "Something went wrong"

available_tools = {
    "get_weather": get_weather,
    "run_command": run_command,
}

SYSTEM_PROMPT = """
You are a helpful AI Assistant...
(keep rest of your SYSTEM_PROMPT here as in your original code)
"""

messages = [
  { "role": "system", "content": SYSTEM_PROMPT }
]

while True:
    query = input("> Hey I'm a TODO AI builder: ")
    messages.append({ "role": "user", "content": query })

    while True:
        response = client.chat.completions.create(
            model="gpt-4.1",
            response_format={"type": "json_object"},
            messages=messages
        )

        messages.append({ "role": "assistant", "content": response.choices[0].message.content })
        parsed_response = json.loads(response.choices[0].message.content)

        if parsed_response.get("step") == "plan":
            print(f"🧠: {parsed_response.get('content')}")
            continue

        if parsed_response.get("step") == "action":
            tool_name = parsed_response.get("function")
            tool_input = parsed_response.get("input")
            print(f"🛠️: Calling Tool: {tool_name} with input {tool_input}")

            if available_tools.get(tool_name):
                output = available_tools[tool_name](tool_input)
                messages.append({ "role": "user", "content": json.dumps({ "step": "observe", "output": output }) })
                continue

        if parsed_response.get("step") == "output":
            print(f"🤖: {parsed_response.get('content')}")
            break
  • The AI will:

    1. Create the TODO-APP folder

    2. Write the todo_app.py file

    3. Launch streamlit run TODO-APP/todo_app.py

What’s Next? Add your creativity and excitement to create your custom AI agent.

  • Add more tools like web search or database integration

  • Deploy your TODO app to Streamlit Cloud

  • Turn this into a multi-agent CLI workspace

0
Subscribe to my newsletter

Read articles from Chethan G directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Chethan G
Chethan G