Individual prompts produce individual files. To build a real project, you need a sequence of prompts that fit together. In this tutorial we build a small URL shortener end-to-end, using only AI prompts at each stage — and you'll see the exact prompt structure for each phase.
Most "build with AI" articles either show finished output or skip the messy middle. This one walks through every stage as it happens: planning, scaffolding, building the core, adding tests, polishing, and shipping. The project is small enough to finish in one sitting but real enough to teach you the rhythm of multi-prompt development.
The project: a tiny URL shortener with a Node.js + Express backend, a SQLite database for persistence, and a single HTML page that calls the API.
Building with AI is not "one giant prompt". It is a sequence of focused prompts, each with a clear scope, each building on the last. The trick is sequencing — you cannot ask for "the next step" until the AI knows what the project looks like so far.
The key discipline is to never lose the chat history. Every prompt in this tutorial assumes the AI has the previous prompts and outputs in context — that is what lets each stage be short and focused.
The naive approach is to ask the AI to "build me a URL shortener" in one prompt. You get something — but it will be a single file that does everything, with no tests, no error handling, and no separation of concerns.
Weak prompt
build me a url shortener in node js with html frontend
You get a single 200-line file with the database, routes, and HTML mashed together. Nothing is tested. Editing it later means re-reading everything. It works for a demo and fails for a real project.
Strong sequence (six focused prompts)
--- PROMPT 1: PLAN ---
I want to build a small URL shortener as a personal project.
Stack: Node.js 20, Express 4, better-sqlite3, plain HTML+JS frontend
(no framework). One repo. One folder.
Propose a file/folder layout, name the npm dependencies needed, and list
the 5–6 features the MVP should ship with. Keep it minimal — no auth,
no analytics.
--- PROMPT 2: SCAFFOLD ---
Great. Generate package.json, the SQLite schema (urls table with: id
INTEGER PK, slug TEXT UNIQUE, target_url TEXT NOT NULL, created_at TEXT
NOT NULL), and the initial Express server entrypoint with health check
only. No routes yet.
--- PROMPT 3: BUILD ---
Add two routes:
- POST /api/shorten { url } → returns { slug, shortUrl }. Generate a
6-char base62 slug. Validate url is http(s) before saving. On collision,
retry up to 5 times then 500.
- GET /:slug → 302 redirect to target_url, or 404 if not found.
Use better-sqlite3 prepared statements. Insert and lookup helpers in a
separate db.js module.
--- PROMPT 4: TEST ---
Write Jest tests for the slug generator (length, base62 charset) and the
URL validator. Use the supertest library to test both routes against an
in-memory SQLite database. Cover: happy path, invalid URL, 404, collision.
--- PROMPT 5: POLISH ---
Add a single index.html with a textarea for the URL, a button, and a
result area that shows the short URL with a copy button. Vanilla JS,
fetch() the /api/shorten endpoint. Inline CSS, mobile-friendly, focus
states. Errors from the API shown as a red message.
--- PROMPT 6: SHIP ---
Write a Dockerfile (Node 20 alpine, multi-stage if helpful), a docker-compose.yml
to run locally on port 8080, and a one-paragraph README section describing
how to run the project locally.
Six prompts, all in the same chat session. The AI carries forward the file layout, dependencies, and conventions from prompt to prompt. The result is a small but coherent project — not a giant ball of mud.
Tip: Save the entire chat (or a curated transcript). A complete prompt sequence for one project becomes the starting template for the next one. Six well-thought-out prompts are a portable methodology.
Actually build the URL shortener above. Run each prompt in your AI tool, paste the output into a real folder, and run it. Note where the AI made decisions you would have made differently and adjust your plan-stage prompt next time.
Pick a slightly bigger project (a notes app, a to-do API, a tiny RSS reader). Plan it as a six-prompt sequence before writing any code. Save the prompts as a numbered file. The discipline of writing the sequence ahead of time is the highest-leverage skill in this tutorial.
Take any existing small project of yours. Reverse-engineer the prompt sequence that would have produced it. Compare the six prompts to your real git history. Are they cleaner? Was the real history more chaotic? What does the difference tell you?
Sign in to join the discussion and post comments.
Sign inPrompt Engineering for Content & Copywriting
Write blogs, ads, emails, and social media content ten times faster with AI. 13 practical tutorials on prompt engineering for content creators and copywriters.
Prompt Engineering for Specific AI Tools
Tool-by-tool mastery — deep dives into ChatGPT, Claude, Gemini, GitHub Copilot, Midjourney, Stable Diffusion, and more. Learn the exact prompting techniques each platform rewards.
Prompt Engineering for Education & Learning
Use AI as your personal tutor. Learn how to study faster, create lesson plans, generate practice questions, master languages, and prepare for competitive exams with smart prompts.
Prompt Engineering Projects & Real-World Applications
Twelve hands-on projects that turn prompt engineering theory into a portfolio. Build chatbots, content generators, RAG systems, and more.
Advanced Prompt Engineering Techniques
Master the powerful techniques AI experts use every day. Chain-of-thought, RAG, agents, function calling, prompt evaluation, and much more — 20 deep-dive tutorials.
Prompt Engineering for Data Science & Analytics
Supercharge your data workflows with AI. 15 practical tutorials on using prompt engineering for data cleaning, EDA, machine learning, SQL, visualisation, and more.