A handbook by Lunario
Programming with AI
How to give an AI a task, read the code it wrote, and check what came out. For people who already write code together with an AI and don't want to take it on trust.
- Ask
- a request with context, a goal, constraints and a definition of done — so the AI builds what you meant, not what it guessed.
- Read
- files, functions, tracebacks and diffs well enough to tell what the code does and where it will break.
- Check
- run it, test it, catch invented methods and silent errors, and know when to roll back.
How it reads
113 short articles, each built the same way: what it is, what it looks like in code, what to tell the AI, what to look for, and a cheat sheet. Read in order, or jump to the one you need today.
Next to the text is a console: the JavaScript and Python examples run right in your browser and are compared with the output recorded in the book.
Contents
Foundations
1Mental model and working cycle
2Reading code
- 2.1Why read code if the AI writes it
- 2.2Anatomy of a file
- 2.3Anatomy of a project
- 2.4Variables, types, data structures
- 2.5Functions
- 2.6Conditions and loops
- 2.7Classes and objects
- 2.8Exceptions and error handling
- 2.9Decorators and “magic”
- 2.10Asynchrony
- 2.11Dependencies
- 2.12Reading a traceback
- 2.13Reading a diff
- 2.14Red flags in generated code
3Stating the task
- 3.1Why the AI does the wrong thing
- 3.2Anatomy of a prompt
- 3.3Levels of detail
- 3.4Template — a new function
- 3.5Template — fix a bug
- 3.6Template — refactoring
- 3.7Template — explain this code
- 3.8Template — review this
- 3.9Template — write tests
- 3.10Technique — plan first, code second
- 3.11Technique — let the AI ask the questions
- 3.12Technique — input → output examples
- 3.13Technique — limit the blast radius
- 3.14The project context file
- 3.15How to write a mini-spec
- 3.16Prompt antipatterns
4Checking and debugging
Stacks
6Python and application logic
7Web backend
8Frontend
9JavaScript and TypeScript
10React in TypeScript
11Flutter and Dart
Cross-cutting topics
13Architecture in plain terms
14Workshop