promptdojo

Python for AI-first builders.

The Python you need to direct AI agents, read what they wrote, and catch what they got wrong.

Built for the marketing managers, PMs, and ops folks who use Cursor daily and have hit the ceiling of what they can do without code literacy. Free forever, open source. No certificate, no leaderboards, no paywall.

Read what AI wrote

Most lessons start with code Cursor or Claude already produced. You learn to read it, predict its output, and judge whether it works.

Catch what it got wrong

Hallucinated APIs, silent type bugs, off-by-one errors, broken imports. The bugs AI ships are different from the bugs humans ship. We drill those.

Direct it deliberately

When you understand mutation, scope, and control flow, you can prompt the AI like a tech lead instead of a passenger.

25 chapters · production-AI track included · free forever

new here? start the 5-question onboarding →
Ch 01
Variables

When AI writes Python, the first thing it does is name things. Learn to read those names on sight, and to write a few yourself.

26 steps · 3 lessons
Ch 02
Functions

AI writes functions constantly, and silently forgets the `return` line about a third of the time. Learn to spot the missing return on sight.

27 steps · 3 lessons
Ch 03
Lists and dicts

Every JSON response you've ever copied out of ChatGPT or a REST API is some mix of two things: lists and dicts. Read them on sight.

27 steps · 3 lessons
Ch 04
Loops

AI writes a loop every time you say *for each*. Half the time it's wrong by one. Read it before you trust it.

28 steps · 3 lessons
Ch 05
Conditionals

`if` looks simple. The traps inside it — empty values, `==` vs `is`, the difference between `0` and `None` — are where AI quietly ships wrong code.

17 steps · 2 lessons
Ch 06
Tracebacks

When Python crashes, it tells you exactly what happened and where. Most non-engineers panic at the wall of text. You're going to learn to read it.

26 steps · 3 lessons
Ch 07
Mutation

When a list inside a function changes the list outside the function, that's mutation. AI does this constantly without flagging it, and it's the bug class that takes the longest to find.

17 steps · 2 lessons
Ch 08
Modules, imports, and why your venv hates you

Half of `pip install x` failures are environment confusion, not Python bugs. Learn what `import` actually does, what a virtual env is for, and why your script can't find the package you just installed.

17 steps · 2 lessons
Ch 09
Error handling

AI loves a happy path. The moment a file isn't there or an API blinks, the script blows up. `try/except` is how you keep the program alive long enough to log what went wrong.

27 steps · 3 lessons
Ch 10
Files and I/O

Reading a CSV, writing a log, parsing a JSON dump. The first thing AI does in any real project is touch a file. Learn the few patterns it reaches for and the one it forgets.

27 steps · 3 lessons
Ch 11
Classes

AI ships classes constantly: SQLAlchemy models, FastAPI schemas, custom exceptions. You don't need to design them. You need to read one without flinching.

27 steps · 3 lessons
Ch 12
HTTP and APIs

Every AI script eventually calls an API. Learn the shape of `httpx.get`, what a status code means, and how to pull a value out of the JSON that comes back.

27 steps · 3 lessons
Ch 13
LLM APIs

Every AI feature you ship eventually calls a model API. Learn the messages pattern, how to read the response, and the four lines AI writes every single time.

9 steps · 1 lesson
Ch 14
Structured output

Free-form text breaks every pipeline. Learn the schema-first pattern AI uses to get reliable JSON back, validate it with Pydantic, and catch the model's lies before they hit prod.

9 steps · 1 lesson
Ch 15
MCP

MCP is the new standard for plugging tools and data sources into AI agents. Learn what an MCP server actually is, how Claude Code lists tools, and why this is replacing one-off integrations everywhere.

9 steps · 1 lesson
Ch 16
Agent loops

An agent isn't a magic. It's a while loop. Learn the actual cycle Claude Code, Cursor, and every other agent uses: model returns tool_use, you run the tool, you send the result back, repeat until end_turn.

18 steps · 2 lessons
Ch 17
Git and GitHub CLI

Cursor and Claude Code commit on your behalf. Reading those commits — and undoing the bad ones — is your job. Learn the four-state model, the commands you'll run every day, and what `gh` does that `git` can't.

9 steps · 1 lesson
Ch 18
Secrets

AI ships keys to GitHub all the time. Learn the .env pattern, why os.getenv is non-negotiable, what to do when a key leaks, and the gitignore lines you need on day one.

9 steps · 1 lesson
Ch 19
Prompting Cursor and Claude Code effectively

The difference between a one-shot AI session and a four-hour debugging spiral is almost always the first prompt. Learn the structure that gets you usable code.

9 steps · 1 lesson
Ch 20
Reading agent traces and telemetry

When an agent fails, the trace tells you exactly where. Learn to read tool calls, tool results, and stop reasons — the JSON breadcrumbs every agent leaves behind.

9 steps · 1 lesson
Ch 21
Eval-driven AI development

If you can't test it, you can't ship it. Learn the simple-but-strict eval patterns that separate AI features that work from ones that just feel like they do.

9 steps · 1 lesson
Ch 22
Context and retrieval

RAG without the overengineering. Chunking, embeddings, vector search, and the small set of patterns that make a model answer from your data instead of its training set.

1 steps · 1 lesson
Ch 23
Production tradeoffs

The three numbers every shipped LLM feature lives or dies by. Token math, caching, streaming, batching, and the small set of decisions that move the product more than a model swap ever will.

1 steps · 1 lesson
Ch 24
Debugging broken AI output

When the model lies to your customer. The methodology for narrowing down what went wrong, the four most-common breakage classes, and the discipline that separates 'we shipped a fix' from 'we blamed the model and shrugged'.

1 steps · 1 lesson
Ch 25
Capstone

Wire it all together. Context, retrieval, the prompt, the call, the trace, the eval, the cost. Less a tutorial demo, more the smallest end-to-end LLM feature you could ship to a real user.

12 steps · 1 lesson
Legacy 28-chapter course (old style)