Jarvis · Chapter 1

What You Are Building 🗺️

Twelve chapters from an empty folder to an assistant that remembers you, runs your own code, reads your notes, and refuses to overspend. This chapter is the map. No code yet, and that is deliberate.

Goal

Understand the whole project before writing a line of it, including what it will cost.

about 15 minutes

The honest brief

You are going to build a program you can run in a terminal, type at, and get useful answers from. It will remember the conversation. It will be able to do things on your computer that you explicitly allow, like reading a file or checking the time. It will know about notes you have written. And it will stop itself before it spends more of your money than you agreed to.

It is not magic and it is not a person. Underneath, every single one of those features is ordinary Python: a list, a loop, a dictionary, a file. You have already learned all of it. The only genuinely new thing is one function call to somebody else's computer.

Volition[Medium: Success]

Here is the part nobody tells beginners: the assistant is the easy bit. Ninety percent of this project is a while loop and a list. Once you see that, the mystery evaporates and what is left is just work you already know how to do.

What it will look like when it works

By the last chapter, this is a real session with the thing you built:

$ jarvis
Jarvis ready. Ctrl-C to leave.

you> what files are in my notes folder?
jarvis> You have three: groceries.md, book-ideas.md and standup.md.

you> what did I say I wanted to read?
jarvis> From book-ideas.md, you listed three: Piranesi, The Dispossessed,
        and something you only wrote down as "the octopus one".

you> how much have I spent talking to you today?
jarvis> $0.0143 across 22 messages. Your daily cap is $0.50.

Every one of those answers involves a different piece you will build: the third needs tools, the second needs your notes, the fourth needs the cost tracker.

The twelve chapters

Four parts. Each chapter ends with a program that runs, so you are never left holding half a thing.

PartChaptersWhat you end up with
Get it talking1 to 4A working chat loop with memory, and an API key stored safely
Make it feel real5 to 7Words appearing as they are written, a personality, and history that survives restarts
Give it hands8 to 10Tools it can call, tools you wrote, and knowledge of your own notes
Make it yours11 to 12A real installed command, a spending cap, and somewhere to go next

What you need before chapter 2

What this will cost you

This is the question beginners are too polite to ask, so here is the arithmetic in public.

You pay per token, which is roughly three quarters of a word. You pay a small amount for what you send and more for what comes back. This build defaults to the cheapest current model, claude-haiku-4-5, which is $1 per million tokens in, $5 per million out.

A chatty back-and-forth message costs a few hundred tokens each way. So:

# Rough cost of one exchange with a small model.
# Prices in dollars per MILLION tokens.
price_in = 1.00
price_out = 5.00

tokens_in = 600     # your message plus the conversation so far
tokens_out = 300    # its reply

cost = (tokens_in / 1_000_000) * price_in + (tokens_out / 1_000_000) * price_out
print(f"one exchange: ${cost:.5f}")
print(f"100 exchanges: ${cost * 100:.3f}")
one exchange: $0.00210
100 exchanges: $0.210

Twenty-one cents for a hundred messages. Working through this entire build, testing as you go, will very likely cost you less than a cup of coffee. Chapter 12 adds a hard cap so it cannot quietly become more.

💸 Two ways this gets expensive, and neither is a surprise

Costs climb when the conversation gets long, because you resend the whole history every time (chapter 4 explains why), and when you switch to a bigger model. Both are under your control, and chapter 12 puts a wall in front of both.

Which model, and why the cheapest one

There are three you would plausibly use. They are the same API; you change one string.

ModelPrice per 1M tokens (in / out)Reach for it when
claude-haiku-4-5$1 / $5Chat, small tools, anything where speed and cost matter. This build's default.
claude-sonnet-5$3 / $15You want noticeably better reasoning and writing for everyday work
claude-opus-5$5 / $25The hardest problems: long analysis, tricky code, anything you would ask an expert

Starting cheap is not a compromise for a personal assistant, it is the right default. You will change one line in chapter 12 and feel the difference immediately if you want it. What you must not do is start expensive and find out at the end of the month.

📅 Prices and model names change

These were correct when this chapter was written. Model ids and prices do move, so if a call fails with a model-not-found error, check the current list in Anthropic's own docs rather than assuming this page is right forever. That is true of every tutorial on the internet, including this one; the difference is that this one says so.

The rule that makes this project safe

You are about to give a program an API key that spends money, and later the ability to run functions on your machine. Two rules, followed from chapter 2, keep that entirely boring:

  1. The key never appears in your code. Not once, not temporarily, not "just to test it". Chapter 2 shows the alternative, which is easier anyway.
  2. The assistant can only do what you wrote a function for. It cannot invent abilities. When we give it tools in chapter 8, you will see exactly why that is structurally true rather than a promise.
🎒 How to work through this

One chapter per sitting. Type the code rather than pasting it; the point is the reading, not the file. Run it at every checkpoint, and do not move on while something is broken, because chapter N+1 assumes chapter N works. If you get stuck, every chapter ends with the three things that actually go wrong.

✅ Checkpoint

Nothing to run yet. You should be able to say, in one sentence, what you are building and roughly what it will cost. If you cannot, read the brief again before spending money in chapter 2.

+150 XP