StoicBuilder

HandbookI the LudusVariables

Ithe Ludus, Read code

Variables

1 min readUpdated 28 November

In plain words

A variable is a name your code gives to a value, like a cart total or a user's email, so it can read or change it later.

Where you see it

Open any file your agent wrote and you'll find lines starting with const or let. In Chirp, const MAX_POST_LENGTH = 280 is a variable: change that one line and every character counter in the app follows.

src/components/PostComposer.tsxbrowser
const MAX_POST_LENGTH = 280; // const: never reassignedlet charactersLeft = MAX_POST_LENGTH - text.length; if (charactersLeft < 0) { charactersLeft = 0; // let: allowed to change}
const keeps the same value for good. let can be given a new one.

What goes wrong

  1. Using const for a value that has to change

    The first time the code tries to update it, the app stops with "Assignment to constant variable".

    const total = 0; total = total + price;
  2. The same number typed into several files

    The agent hard-codes the delivery fee in the cart, the checkout and the receipt. You update one, and the totals stop agreeing.

  3. Names like data, temp or x

    You can't tell what the value is without tracing it back. Names such as unpaidOrders or maxGuests explain themselves.

What to tell your agent

Copy this into Lovable, Bolt, Cursor or any agent
Move any number or piece of text that appears in more than one place into a single named constant. Use const unless the value really changes, and list each variable you created with the line where it gets set.

Quick check

Sign in to earn +10 XP for it

QuickBite's menu shows a 2.99 delivery fee, but checkout charges 3.49. Most likely cause?

Got a prompt that touches variables?

Paste it. You get a better prompt first, then the cards that explain it.

Check your own prompt

Free, no sign-up.