SyntaxPilot
Courses/Vibe Coding/Lesson 39
Video coming soonThis lesson’s video is being made

Start with the notes below; the video appears here as soon as it is on YouTube.

Vibe Coding · Lesson 39 of 40

Capstone part 2: test, secure and launch

testssecurity checklistperformance passdeploydomainlaunch postfirst users

Vibe Coding: build real apps with AI · Episode 39. Every agent run below is real: Claude Code 2.1.323 (model claude-opus-5-5) in print mode (claude -p --permission-mode acceptEdits), on 13 November 2026 (India time), in /home/asha/projects/tuition-register, the project from episode 38. The agent could edit files and run only npm test, npm install, npm audit, node --test, mkdir and ls; anything else needed approval and was refused. Replies are quoted exactly, shortened where marked "...". Every curl request, browser test (Playwright Chromium at 360 × 740), sqlite3 query, timing, backup/restore drill and git command below was run by us.

What was written by hand: the prompts, SPEC.md decisions 7-9, the launch-post edit, and our check scripts (projects/vibe_capstone/our-checks/ in the SyntaxPilot repo). All app code is the AI's. Sunita Ma'am, Asha and the students are fictional.

Setup notes: 192.0.2.2 is the network address of the test machine, which plays Sunita's laptop. 4821 is a made-up demo PIN: never put your real PIN on screen, in a prompt, or in Git.

Tools: Node.js v22, Express 4.22.3, better-sqlite3 13.1.1, Node's built-in test runner (node --test), curl, the sqlite3 command-line tool, git, Playwright Chromium.

The project: the full source after this episode (commit 9b30a80) is in video-studio/projects/vibe_capstone/ with its commit list in CHECKPOINTS.txt. Nothing was deployed to the internet.

The problem: opening day of a new sweet shop

A new sweet shop Your app
Taste every sweet before a customer does Tests: yours, not just the AI's
Locks on the shutter and the cash box, and a spare key at home Security + backups: who gets in, and what if the data is lost
Open the shutter, tell the street, watch the first customers Deploy + launch + first users

Sunita's phone opens the laptop's address on home Wi-Fi: http://<laptop's IP address>:3000.

  • An IP address is like a house number for a device on a network (here 192.0.2.2).
  • A port (here 3000) is like the flat number of one program inside that house.

The question nobody asked: who else on that Wi-Fi can open it? Our test, from another device on the same network, with no login:

$ curl -s -o /dev/null -w "GET /fees -> %{http_code}" http://192.0.2.2:3000/fees
GET /fees -> 200
$ curl -s http://192.0.2.2:3000/fees | grep -oE "(Riya|Aditya|Sana|Om|Meher)[^<]*"
Meher Gill
Om Patil
Sana Shaikh
Aditya Kulkarni
Riya Sharma
$ curl -s -X POST http://192.0.2.2:3000/attendance \
    -d "student_id=3&date=2026-11-13&status=absent" -w "%{http_code}"
303

200 means "OK, here it is"; 303 means "saved, now go to this page". A stranger just read every name and marked Sana absent. Why it failed: the app has no idea who is asking, so it answers everyone.

A launch needs four things the laptop never tested: is it finished, who can get in, what if the data is lost, and does a real person manage it?

The launch plan

Finish → Test → Lock → Back up → Hand over. Each step: one prompt, read the whole reply, check it yourself, commit. The AI's "what I did not check" list is your to-do list.

Finish the product: step 3, the Student screen (real)

Prompt F:

claude -p "Part 1 is done and committed (41a67a6, 29 tests pass). Build step 3 only, as in SPEC.md: the Student screen (details, this month's attendance, all payments), linked from the Students list and from Fees. Write tests for user story 4 and run all tests. Don't add a login yet. When you're done, tell me exactly how to test it myself, and anything you did not check."

What it did (shortened):

Edit   src/db.js, src/app.js, src/views.js
Write  test/student.test.js
Bash   npm test     # tests 41  pass 41  fail 0

Quotes from its reply:

  • "I broke two of the database queries on purpose and 4 tests failed, then restored them." (This proves the new tests can catch a bug.)
  • "I left the Fees list as it was, so tapping a row still opens the payment form as the spec says. The link is on that form ("All payments and attendance ›") and in the green "Payment saved" message."
  • What it didn't check: "I never started the real server or opened the page ... the 360 px no-sideways-scrolling rule is untested for this screen."

Our check: Chromium at 360 × 740, Riya's page: details, "November 2026: Paid", six marked days, two payments with a total. document.documentElement.scrollWidth = 360, so no sideways scrolling. Commit 9d18386 Step 3: Student screen (41 tests pass).

The Student screen at 360 px

A security review, with no edits (real)

New words first:

  • Authentication: proving who you are (a PIN, a password, a fingerprint).
  • Network interface: one connection a computer has: the Wi-Fi, a cable, or the private "loopback" one that only reaches the computer itself.
  • Security review: reading the whole app the way an attacker would, against a checklist (episode 28).

Ask for findings with no edits: a list you can read is safer than fifty changed lines you can't.

Prompt G:

claude -p "Step 3 is done and committed (9d18386, 41 tests pass). Before launch, review the whole app against this security checklist. Don't change any files: list every problem you find, most serious first, one line each with the file and line, and say how you checked it. Checklist: 1. secrets in code or Git. 2. SQL injection. 3. XSS (user text shown as HTML). 4. pages or actions with no auth check. 5. who can reach the server on the network. 6. trusting user input (validation on the server). 7. dependencies with known problems (npm audit). 8. what gets logged."

Its answer (shortened): "I found 9 problems. The app is careful about SQL, HTML escaping and secrets, but it has no login and is open to the whole network, so it isn't ready to launch yet. I changed no files."

# Problem (the AI's words, shortened) Where
1 No auth on anything src/app.js:18-177
2 Anyone on the network can reach the server: app.listen(PORT) has no host, so Node listens on every network interface server.js:9
3 Any website can submit the forms (CSRF): no Origin check, no token POST handlers in src/app.js
4 Any Host header is accepted (DNS rebinding) src/app.js:12-13
5 Stack traces are shown in the browser (NODE_ENV not set, no error handler) package.json, src/app.js
6 The app can be framed (clickjacking) src/app.js:12
7 Dates have no sensible range (attendance for 2099 passes) parse functions
8 The database file can be read by every user on the machine data/ permissions
9 No record of who changed what no request log

Checks that passed: no secrets in the code or anywhere in Git history; every SQL query uses ? placeholders; every value shown in HTML is escaped; npm audit found 0 vulnerabilities.

It also said: "I wrote a script that sends attack inputs to the app, but running it needed your approval, which I didn't get. So the findings below come from reading the code." Reading code is not the same as testing it.

Problems 3 to 6 in plain words

  • CSRF (cross-site request forgery): Sunita opens some random website on her phone. That page quietly makes her browser submit a form to the register (say "mark as left"). Her browser is logged in, so it works. Fix: check the Origin header. A header is a small label on every request; Origin says which site the form came from. Not the register? Refuse.
  • DNS rebinding: DNS is the internet's phone book: it turns names (example.com) into addresses. A bad site can make its own name point at the laptop, then read the register's pages. Fix: the Host header carries the name the browser typed; answer only to our own names.
  • Stack trace: the list of functions an error passed through, with file and folder names. Useful to you, a map for an attacker. Fix: a short message for the user, details only in the server's log.
  • Clickjacking: another page shows our app inside an invisible frame, so a tap on "Win a prize" lands on our "Mark as left". Fix: headers that forbid framing (X-Frame-Options: DENY, Content-Security-Policy: frame-ancestors 'none').

The PIN, and a context mistake (real)

Prompt H:

claude -p "Thanks. Fix problems 1 to 6 from your review, nothing else. For #1: a 4-digit PIN that Sunita types once on her phone and then stays logged in; the PIN is set in a .env file that is not committed. For #2: her phone must still reach the laptop over home Wi-Fi. Keep it simple, no new framework. Add tests and run all tests. Then tell me how to test it myself and what you did not check."

A .env file is a small settings file that holds secrets (like the PIN) outside the code; it is listed in .gitignore so Git never commits it.

The reply began:

"I've only fixed #1, the PIN login. I didn't touch #2–#6 because the earlier review isn't in this conversation, the repo or the project, so I can't see what they were. You said "nothing else", so I didn't want to guess. Please paste the list of problems 2–6 (or the review itself) and I'll do them the same way."

That mistake was ours. Every claude -p run starts with fresh context (everything the AI can see in this conversation: your prompt, files it reads, command output). The review lived in the previous run. The AI did the right thing: it asked instead of guessing six fixes. The fix: paste the findings into the prompt, or save them in a file such as REVIEW.md that every run can read. If the AI couldn't see it, the AI didn't get it.

Other parts of the reply: "All 51 tests pass ... After 5 wrong PINs, all logins pause for 15 minutes, even with the right PIN. Her phone stays logged in during the pause ... The database keeps only a scrambled copy (a hash) of the cookie." Known limits it listed: plain HTTP ("someone on the same Wi-Fi with sniffing tools could copy the cookie"), and "a 4-digit PIN with this pause can still be guessed in a few days of nonstop trying".

How the PIN login works (the AI's code, shortened)

const sha256 = (s) => crypto.createHash('sha256').update(String(s)).digest();
const sameText = (a, b) => crypto.timingSafeEqual(sha256(a), sha256(b));

app.post('/login', (req, res) => {
  if (now() < lockedUntil) return res.status(429) ...  // paused
  if (!sameText(req.body.pin ?? '', pin)) {           // wrong PIN
    fails += 1;
    if (fails >= MAX_FAILS) { fails = 0; lockedUntil = now() + LOCK_MS; }
    return res.status(401) ...
  }
  const token = crypto.randomBytes(32).toString('base64url');
  q.insert.run(hashToken(token), ...);                // store the HASH only
  res.setHeader('Set-Cookie',
    `session=${token}; Max-Age=${ONE_YEAR_S}; Path=/; HttpOnly; SameSite=Lax`);
});
// One user, so one counter for everybody (the AI's comment)
  • timingSafeEqual takes the same time whether the first digit is right or not, so nobody can guess digit by digit from the response time.
  • Rate limiting: capping how many tries anyone gets. 429 = "too many requests"; 401 = "not allowed: who are you?".
  • Session: a "you are logged in" record. The phone gets a long random token in a cookie (a small note the browser keeps and sends back on every visit), so Sunita types the PIN once.
  • Hash: a one-way scramble. The database stores only the hash of the token: you can check a token against it, but you can't get the token back from it.
  • HttpOnly: page scripts can't read the cookie. SameSite=Lax: forms posted from other sites don't carry it.
  • The PIN comes from .env (Node's built-in process.loadEnvFile); the server refuses to start without a 4-digit PIN. We checked: with no .env, node server.js prints "Set a 4-digit PIN first ..." and exits with code 1, and git check-ignore -v .env prints .gitignore:3:.env.

The lockout trap (our test)

A guest on the same Wi-Fi tries PINs 0000, 0001, ... (our-checks/guess.sh):

PIN 0000 -> 401 Wrong PIN.
PIN 0001 -> 401 Wrong PIN.
PIN 0002 -> 401 Wrong PIN.
PIN 0003 -> 401 Wrong PIN.
PIN 0004 -> 401 Wrong PIN.
PIN 0005 -> 429 Too many wrong PINs. Try again in 15 min.
PIN 0006 -> 429 Too many wrong PINs. Try again in 15 min.

# now Sunita, on her NEW phone (no cookie), types the RIGHT PIN:
429 Too many wrong PINs. Try again in 15 min.

"One counter for everybody" means anyone can lock out the owner by typing five wrong PINs. The maths: 10,000 PINs ÷ 5 tries per 15 minutes = 2,000 × 15 min = 30,000 minutes ≈ 21 days to try them all (about 10 days on average to hit the right one). The AI's "a few days" was vague: check numbers yourself.

It's a trade-off (something good bought with something bad): her phone stays logged in for a year, so the pause never touches it; the worst case is a new phone waiting 15 minutes. We kept it for version 1 and wrote it down as SPEC.md decision 7, with "version 2: a 6-digit PIN" (100 times more combinations). Commit 4175dd3.

Network, forms and errors (real)

Prompt I (with the review pasted in this time):

claude -p "You were right: each claude -p run starts fresh, so you never saw the review. The PIN is committed (51 tests pass). Here are problems 2 to 6 from that review. Fix only these, nothing else, add tests, run all tests.
2. server.js:9: app.listen(PORT) has no host, so it listens on every network interface: anyone on any Wi-Fi the laptop joins (a cafe, a friend's house) can open it. Her phone must still reach it on HOME Wi-Fi.
3. src/app.js POST handlers: no CSRF protection: no Origin check, no token. Any website opened on her phone could submit a form to the laptop.
4. No Host header check (DNS rebinding): a malicious site can point its domain at the laptop and read pages.
5. npm start doesn't set NODE_ENV=production and there is no error handler, so Express shows err.stack in the browser on bad input (broken % encoding, a body over 10 KB).
6. No X-Frame-Options or CSP frame-ancestors: another site can frame the app (clickjacking).
Then tell me how to test it myself and what you did not check."

The "her phone must still reach it" rule matters: the easiest fix for #2 (listen only on the laptop itself) would also lock out her phone. A fix that breaks the product is not a fix.

What it did (73 tests pass):

# Fix (the AI's, shortened)
2 New HOST setting in .env. Empty = 127.0.0.1 (localhost: the laptop talking to itself). Set it to the laptop's home Wi-Fi address for the phone. HOST=0.0.0.0 (every network) is refused at startup.
3 A form whose Origin (or Referer) isn't the register's own address gets 403 ("forbidden") and nothing is saved. /login too.
4 Only answers when Host is localhost, 127.0.0.1, [::1] or HOST; anything else gets 400 ("bad request").
5 An error handler: a short message (400, 413 or 415); unexpected errors go to the server log only. server.js sets NODE_ENV=production.
6 Every response sends X-Frame-Options: DENY and Content-Security-Policy: frame-ancestors 'none'.

Its most important warning: "Listening on one address is not a firewall. If a cafe's Wi-Fi gives the laptop the same address (192.168.1.x is common), the server is reachable there ... The PIN still protects it." A firewall is a guard (in the operating system or router) that blocks connections by rule.

The heart of src/security.js (the AI's code, shortened):

// #4 DNS rebinding: only answer to the laptop's own addresses.
app.use((req, res, next) => {
  if (allowed.has(hostnameOf(req.headers.host))) return next();
  res.status(400).type('text/plain').send('Wrong address. ...');
});

// #3 CSRF: only accept forms from the register's own pages.
app.use((req, res, next) => {
  if (req.method === 'GET' || req.method === 'HEAD') return next();
  const own = `http://${String(req.headers.host).toLowerCase()}`;
  if (sentFrom(req) === own) return next();
  res.status(403).send(views.errorPage('This form did not come from the register, so it was not saved.'));
});

Our checks

$ cat .env              # demo values
PIN=4821
HOST=192.0.2.2
$ curl ... http://localhost:3000/login                    -> 000  (not listening there)
$ curl -H "Host: evil.example" http://192.0.2.2:3000/login -> 400
$ curl -X POST -H "Origin: http://evil.example" -d pin=4821 http://192.0.2.2:3000/login -> 403
$ curl -sI http://192.0.2.2:3000/login | grep -iE "frame|security"
X-Frame-Options: DENY
Content-Security-Policy: frame-ancestors 'none'

And the most important one (from the AI's own "not checked" list): a real browser through the real forms (our-checks/e2e.js, Chromium 360 × 740):

open /fees -> http://192.0.2.2:3000/login
after PIN -> http://192.0.2.2:3000/today
mark Absent -> ...today?batch=Class+9+%285+pm%29&date=2026-11-13#s2 ok
bad % -> 400 Tuition Register | That address or form could not be read. |  | Back to Today

The new locks didn't block the owner's own forms, and a broken address shows one plain line, no code. Commit de2ff1c.

The PIN page

A broken address: one plain line

Backups you have restored (real)

A backup is a saved copy you can go back to; a restore puts it back. The laptop is the only copy of a year of fees.

Prompt J:

claude -p "Security fixes 2-6 are committed (73 tests pass). Last step before launch: backups. Sunita's laptop is the only copy of her register. Add 'npm run backup' that saves a copy of the database into backups/ with the date and time in the file name and keeps only the newest 30 copies, and 'npm run restore -- <file>' to put a backup back. backups/ must not be committed. Add tests, run all tests, and tell me how to test it myself and what you did not check."

What it built (88 tests pass):

  • npm run backup saves backups/register-2026-11-13_18-05-09.db (India time). "It works while the server is running, and it includes recent changes SQLite hasn't yet moved into the main database file." (It uses SQLite's VACUUM INTO, which reads a consistent snapshot, including changes still in the -wal file: SQLite's write-ahead log, where new changes wait before they're moved into the main file. Copying only register.db with a file copy could miss them.)
  • npm run restore -- <file> refuses while the server is running, refuses a damaged file (it runs PRAGMA integrity_check), and saves the current data first, "so a restore can be undone with another restore".
  • backups/ is in .gitignore.

The AI catches its own earlier mistake

"At first npm test hung ... The cause: the AC6 restart test runs the real server.js, which read HOST=192.0.2.2 from your .env. It was testing the laptop's settings, not the code. I made the test use HOST: '127.0.0.1'."

Our check: the security commit, in a separate folder, with the same .env:

$ timeout 60 npm test
    not ok 1 - students, edits, "left" and attendance survive a stop and start
      error: 'fetch failed'
        async logIn (test/helpers.js:16:15)
not ok 7 - AC6: restarting the server keeps all data
$ echo $?
124

Exit code 124 means timeout killed it: npm test never finished. The server listened on the Wi-Fi address while the test knocked on localhost. A test should test the code, never the machine's settings: set the environment inside the test.

Our restore drill

$ npm run backup                     # server running; Sana just paid
Saved backup: backups/register-2026-11-13_09-30-58.db
1 backups in backups (keeps the newest 30).
$ npm run restore -- register-2026-11-13_09-30-58.db
The register is still running (http://192.0.2.2:3000). Stop it first (Ctrl+C in its window), then run this again. Nothing was changed.
$ rm -r data                         # the disaster (server stopped)
$ npm run restore -- register-2026-11-13_09-30-58.db
Restored backups/register-2026-11-13_09-30-58.db -> data/register.db
$ sqlite3 data/register.db "SELECT s.name, p.amount, p.paid_on, p.for_month, p.mode FROM payments p JOIN students s ON s.id=p.student_id ORDER BY p.id"
Riya Sharma|1500|2026-11-05|2026-11|cash
Riya Sharma|1500|2026-10-04|2026-10|upi
Aditya Kulkarni|1000|2026-11-07|2026-11|upi
Sana Shaikh|1500|2026-11-13|2026-11|upi

Sana's payment from seconds before the backup is there. A backup you've never restored is a hope, not a backup. Commit 9a8ddf3.

The AI's honest gaps: "The backups stay on the same laptop" and "Nothing runs automatically." We answered them in SPEC.md decision 9: a daily scheduled npm run backup (a scheduler such as Windows Task Scheduler or cron, episode 24) and a weekly copy of backups/ to a pen drive kept at home. Backups hold students' names and fees, so they are personal data (episode 34): keep the pen drive safe.

A performance pass (our test)

A performance pass checks that the app stays fast. The obvious move, "add caching!", fails here: a cache keeps a copy of an answer to reuse it (episode 29), so a cached Fees page could still say "Not paid" a minute after she paid. More parts, new bugs, for speed nobody needed. Measure first; fix only what's slow.

On a copy of the data filled with three years of fake classes (our-checks/bigseed.py), each page loaded 20 times (our-checks/perf.sh):

students 18 attendance rows 17118 payments 666
/today?batch=Class 9 (5 pm)   median 1.3 ms  slowest 4.5 ms   10 KB
/fees                         median 1.2 ms  slowest 4.4 ms    8 KB
/students                     median 0.8 ms  slowest 2.2 ms    8 KB
/students/1                   median 6.7 ms  slowest 11.0 ms  13 KB

The median is the middle value when the times are sorted; 1 ms is one thousandth of a second; KB is kilobytes (about a thousand bytes). Conclusion: nothing to speed up. "Fast enough" written down is a result too.

Deploy and domain

  • Deploy = put the app where its users can reach it. Version 1 (SPEC decision 1): Sunita's laptop, home Wi-Fi, npm start with HOST set.
  • DHCP is how the router hands out addresses. A DHCP reservation tells the router to always give the laptop the same address, so HOST and her bookmark never break.
  • A domain (episode 36) is a name such as syntaxpilot.in that points to an internet address. The register isn't on the internet, so it doesn't need one yet.
  • If it ever goes online: a hosting service, a domain, HTTPS (the encrypted version of HTTP, so the PIN and cookie can't be read on the way), and a stronger login.
  • Deploy for the users you have, not the ones you imagine.

Launch post (real), and two false claims

Prompt K:

claude -p "Version 1 is ready to hand over (git log has the story). Don't change any files. Write two short drafts for me: 1) a WhatsApp message to Sunita Ma'am: the register is ready, how to open it on her phone, what to do if it stops working, and that I will sit with her for the first class; 2) a LinkedIn post for my portfolio about building this project with an AI agent."

Good parts: "I'll tell you the PIN in person, not on WhatsApp"; a fallback ("write that day's attendance and payments in the notebook as before and message me"); and "Ask Sunita Ma'am before you use her name publicly; otherwise change it to 'a home tutor'."

Two sentences were not true:

Claim in the draft The truth
"It ... refuses to listen on public networks" (LinkedIn) The AI's own warning in run I: "Listening on one address is not a firewall." A cafe that gives the laptop the same address can reach it.
"Nothing is lost: all the data is saved on the laptop and I keep backups." (WhatsApp) Backups ran only when someone typed the command, and sat on the same laptop.

The writing run never saw run I's warning (fresh context again). A launch post is a promise to real people: check it like code. Two ways to fix a false claim: change the words, or change the app. Our edited lines:

It runs on her laptop over home Wi-Fi only (v1), with a 4-digit PIN.
- It listens only on the laptop's home Wi-Fi address. It is not a
  firewall: on another network with the same address it could be
  reached, so the laptop stays home and the server stops if it goes out.
- Plain HTTP on home Wi-Fi: fine for v1, not for the internet.
- Backups: one command, and I restored one to prove it works.
  A daily backup job + a weekly copy to a pen drive kept at home.
- 88 automated tests, plus checks by hand on a phone-size screen.
(Name used with Sunita Ma'am's permission, or "a home tutor".)

Your first user

  1. Sit beside her for the first class. Don't touch the phone. If you have to explain a button, the button is wrong.
  2. Write down every pause, frown and question.
  3. After a week, ask one question: "Did you open the notebook?"
  4. One small change per week, each tested and committed, with a line in a CHANGELOG (a simple dated list of what changed).

Launched = she stops using the notebook.

Launch checklist

  • [ ] Finish every screen in the spec, and open each one yourself
  • [ ] Security review with no edits; paste it into the fix prompt
  • [ ] Test login, network, forms, errors and framing one by one
  • [ ] Try to break it as a guest; use it as the owner
  • [ ] Backups: automatic, off the machine, and restored at least once
  • [ ] Measure speed before changing anything
  • [ ] Every claim in the launch post is true; watch the first user

Common mistakes (real)

Mistake What we saw Why Fix
"Works on my laptop" GET /fees -> 200 from another device, no login The app answers everyone PIN + HOST + Origin/Host checks
"Fix problems 1 to 6" in a new run "the earlier review isn't in this conversation" Each claude -p run starts with fresh context Paste the list, or save it to REVIEW.md
One wrong-PIN counter for everybody the right PIN on a new phone -> 429 A guest can lock out the owner Decide it, write it in the spec; longer PIN in v2
A test that reads .env fetch failed, exit 124 (hang) It tested the machine's settings Set the environment inside the test
False launch claims "refuses to listen on public networks" The writing run never saw the warning Change the words, or change the app

Mini project: launch your capstone

  1. Ask your agent for a security review of your capstone with no edits; save it as REVIEW.md.
  2. From another device (or curl with no cookie), try to read and change data as a guest. Fix what works, one prompt per problem, with the review pasted in.
  3. Add npm run backup and npm run restore. Back up, delete the data folder, restore, and check the newest record is there.
  4. Time your pages on three years of fake data before you change anything for speed.
  5. Ask the AI for a launch post, then mark every claim true or false against your Git log and tests.

Practice questions

  1. Why did GET /fees from another device return 200 before the PIN?
Answer

The server listened on every network interface (app.listen(PORT) with no host) and had no authentication, so it answered every request on the Wi-Fi.

  1. You run claude -p "Fix the issues you found" right after a review run. What goes wrong, and how do you fix the prompt?
Answer

The new run can't see the previous run's review (fresh context). Paste the findings (file, line, problem) into the prompt, or save the review to a file like REVIEW.md and tell the AI to read it.

  1. A 4-digit PIN with 5 tries per 15 minutes: how long to try every PIN? And with a 6-digit PIN?
Answer

10,000 ÷ 5 = 2,000 windows × 15 min = 30,000 min ≈ 20.8 days. With 6 digits: 1,000,000 ÷ 5 × 15 min = 3,000,000 min ≈ 5.7 years.

  1. Why can copying register.db with a plain file copy lose a payment, while VACUUM INTO doesn't?
Answer

In WAL mode, recent changes wait in the -wal file before moving into register.db. A plain copy of register.db alone can miss them. VACUUM INTO reads a consistent snapshot through SQLite, including the WAL.

  1. Your test suite passes on your machine and hangs on a friend's. Name one likely cause from this episode.
Answer

A test that reads the machine's own settings (.env, environment variables, the real server config) instead of setting them itself.

Quiz

Run 1 reviewed your app. In run 2 you say "Fix problems 1 to 6." What happens?

  • A) It fixes all six from memory
  • B) It can't see run 1's review: paste the list or save it to a file
  • C) It re-reviews and finds the same six every time
  • D) It refuses to fix security problems
Answer

B. Each claude -p run starts with fresh context. Our agent asked for the list; a careless one might guess six different fixes.

Interview questions

  1. "How did you secure an app you built with AI?" A no-edit review against a checklist, fixes one problem at a time with the findings pasted in, and my own checks as a guest and as the owner: curl with a fake Host (400), a foreign Origin (403), the PIN lockout (429), and a real browser through the forms.
  2. "What's CSRF and how did you stop it?" Another site making the user's logged-in browser submit a form. I checked the Origin header (falling back to Referer) against the app's own address, and set the session cookie to SameSite=Lax.
  3. "How do you know your backups work?" I restored one: backed up while the server ran, deleted the data folder, restored, and checked the newest payment with sqlite3.
  4. "Tell me about a mistake the AI made." A test that read the laptop's .env and hung; and a launch post that claimed the app "refuses to listen on public networks", which its own earlier warning contradicted.

Glossary

Term Meaning (with an example)
Launch Putting a product in front of its real users. Here: handing the register to Sunita Ma'am.
IP address A device's number on a network, like a house number. 192.0.2.2.
Port The "flat number" of one program on a device. The register uses 3000.
Network interface One connection a computer has (Wi-Fi, cable, or loopback, which reaches only itself).
localhost / 127.0.0.1 The loopback address: the computer talking to itself.
0.0.0.0 "Every interface": listen on all networks the computer is on.
Status code The 3-digit result of a web request. 200 OK, 303 see other page, 400 bad request, 401 not logged in, 403 forbidden, 429 too many requests.
Authentication Proving who you are: a PIN, a password, a fingerprint.
Security review Reading an app the way an attacker would, against a checklist.
Context Everything the AI can see in this conversation. A new claude -p run starts with none of the last run's words.
.env file A settings file for secrets (PIN=...), kept out of Git with .gitignore.
Session A "logged in" record so the user doesn't type the PIN on every page.
Token A long random string that stands for a session.
Cookie A small note the browser keeps for a site and sends back on every visit.
Hash A one-way scramble: you can check a value against it, but not get the value back.
HttpOnly A cookie setting: page scripts can't read the cookie.
SameSite=Lax A cookie setting: forms posted from other sites don't carry the cookie.
timingSafeEqual A comparison that takes the same time whatever the input, so timing gives nothing away.
Rate limiting Capping how many tries anyone gets in a time window (5 wrong PINs → 15-minute pause).
Brute force Trying every possibility (0000 to 9999) until one works.
Trade-off Something good bought with something bad (a lockout that also stops a new phone).
Header A small label on a web request or response (Origin, Host, X-Frame-Options).
CSRF Cross-site request forgery: another site makes your logged-in browser submit a form.
Origin header Says which site a request came from. Used to refuse forms from other sites.
DNS The internet's phone book: turns names into addresses.
DNS rebinding A bad site points its own name at your device to read your app. Stopped by checking the Host header.
Host header The name the browser typed (192.0.2.2:3000).
Stack trace The list of functions an error passed through, with file paths.
NODE_ENV=production Tells Node libraries (like Express) to run in production mode, e.g. no error details in pages.
Clickjacking Showing an app inside an invisible frame so a user's tap lands on its buttons.
X-Frame-Options / frame-ancestors Response headers that forbid other pages from framing the app.
Firewall A guard that blocks network connections by rule.
Backup / restore A saved copy you can go back to / putting that copy back.
WAL (write-ahead log) SQLite's side file where new changes wait before moving into the main database file.
VACUUM INTO An SQLite command that writes a clean, consistent copy of a database to a new file.
Performance pass Checking that the app stays fast, by measuring.
Cache A saved copy of an answer, reused to save time; can go stale.
Median The middle value of sorted measurements.
Millisecond (ms) One thousandth of a second.
Deploy Putting the app where its users can reach it.
DHCP / DHCP reservation How a router hands out addresses / a rule that always gives one device the same address.
Domain A name (syntaxpilot.in) that points to an internet address.
HTTPS The encrypted version of HTTP.
CHANGELOG A dated list of what changed in each version.
First user The first real person to use the product; watch them, don't help.

Summary

  • "Works on my laptop" is not a launch: our guest device read every name and changed attendance with no login.
  • Finish every screen and look at it yourself; the AI said "I never opened the page".
  • A no-edit security review found 9 problems. A new run couldn't see it ("fix 1 to 6" pointed at nothing): paste it in.
  • The AI's PIN login was careful, but one counter for everybody lets a guest lock out the owner. We decided it and wrote it down.
  • Host and Origin checks, an error handler and anti-framing headers, each checked with curl and a real browser.
  • The AI found a test of its own that read the laptop's .env; we confirmed the hang (exit 124).
  • A backup counts only once restored: we deleted the data and got every payment back.
  • Measured three years of data: under 12 ms, nothing to speed up.
  • Deploy = her laptop on home Wi-Fi; no domain until it goes online. The launch post had two false claims: check it like code. Then watch your first user.

Next episode (40, the last): Vibe coding for jobs and freelancing: a portfolio of shipped projects, explaining AI-built code in interviews, freelancing, pricing, and what to learn next.