In this project you'll go from an empty folder to a chatbot that holds a conversation in the terminal. It's deliberately short — the point is to see every moving part end-to-end so you can swap pieces later without feeling lost.
Tick each checkpoint off as you go. Your progress is saved in this browser.
Tip
You can use any model provider. The code snippets below use the Anthropic Python SDK as an example, but the same shape applies to OpenAI, OpenRouter, or a local model via Ollama.
Step-by-step
The build
1. Scaffold the environment
Create a new directory, set up a virtual environment, and install the SDK for whichever model provider you're using. Drop your API key into a
.envfile and load it withpython-dotenv— never commit secrets.2. Write a system prompt
Decide who the assistant is. Keep it specific: a one-paragraph role, a style guide, and one or two hard constraints. Vague system prompts produce vague replies.
3. Make your first model call
Write a small function that takes a user message, sends it plus the system prompt to the model, and prints the reply. No memory yet — each call is stateless. Confirm the round-trip works.
4. Add a conversation loop
Hold a running list of messages (role + content). On each turn, append the user message, send the whole list, append the assistant's reply. That's all "memory" is at this layer — a growing transcript.
5. Iterate on the behaviour
Try three different system prompts and note how the replies change. Add a refusal case. Add a
/resetcommand that clears history. You now have the skeleton for every chatbot you'll ever build.
What you learned
- A chatbot is a system prompt, a transcript, and a loop. Everything else is polish.
- The system prompt is doing more work than you think — invest time there before reaching for fine-tuning or tools.
- State lives wherever you put it. For this build it's a Python list; in production it's a database, but the shape is the same.
Next steps
When you're ready to extend this, look at:
- Streaming responses instead of waiting for the full reply.
- Adding tool use so the bot can call functions (search, calculator, your own APIs).
- Persisting conversation history between runs.