The Most Underutilised Tool in Your Stack
Everyone focuses on what they ask the AI. Almost nobody thinks hard enough about the context they provide before asking.
A system prompt is the instruction sheet you give the AI before it ever sees your first message. Get this right and the quality of every subsequent response improves dramatically. Get it wrong, and you are fighting against the model's defaults on every single interaction.
This chapter gives you a production-tested framework for writing system prompts that work.
---
The 5-Part System Prompt Architecture
The most effective system prompts share a consistent structure:
Each part serves a different purpose:
Part 1: Role Definition
Tell the model who it is. Not just "you are a developer" β be specific about the level of expertise and perspective.Weak:
"You are a helpful coding assistant."
Strong:
"You are a senior full-stack engineer with 10 years of production experience in Next.js, Supabase, and Stripe. You write code that ships to real users, not demos. You prioritise readability, error handling, and security over cleverness."
The difference in output quality is immediate and significant.
Part 2: Tech Stack Context
Tell the model your exact toolset so it never suggests incompatible libraries or patterns.This single block prevents dozens of the most common AI code errors.
Part 3: Behaviour Rules
Define how the model should reason and respond, not just what it knows.``` Behaviour Rules:
Get advanced blueprint resources
Enter your email to receive technical blueprints, checklists, and visual configurations accompanying this chapter.
No spam. Unsubscribe any time.
- Always write complete, runnable code β never use placeholders like "// ... existing code"
- When modifying existing code, always show the full modified file
- Explain the "why" behind non-obvious decisions in inline comments
- If you are unsure about a library API, say so rather than guessing
- Propose the simplest solution that solves the problem β no over-engineering
- Start with a one-paragraph summary of what you changed and why
- Present code in labelled fenced code blocks with the filename as the label
- End with a bullet list of manual steps required after the code change (e.g., run migrations, update env vars)
- Never install new npm packages without explicitly flagging it and explaining why
- Never expose environment variables in client-side code
- Always use TypeScript β never output plain JavaScript
- All database queries must use parameterised inputs (never string interpolation)
TECH STACK:
- Next.js 14 (App Router, Server Components)
- TypeScript (strict mode)
- Supabase (Auth + PostgreSQL via supabase-js v2)
- Tailwind CSS with shadcn/ui components
- Stripe for payments
- Deployed on Vercel
- Write complete, runnable code β never truncate with "..."
- Show full file contents when modifying existing files
- Add JSDoc comments on all exported functions
- Use server-side operations for all database writes (never client-side)
- Validate all user inputs before database operations
- Brief explanation of the approach (2-3 sentences)
- Complete code in labelled code blocks
- Post-implementation checklist of manual steps required
- Use client-side environment variables for secrets
- Suggest deprecated Next.js patterns (no getServerSideProps, no pages/ directory)
- Install packages without an explicit recommendation and reason
- Write code that stores passwords in plain text
---
Storing and Reusing Your System Prompts
If you use Cursor, store your system prompt in
.cursorrules at the project root β it applies automatically to every conversation in that workspace.
If you use the API directly, inject the system prompt as the
system` field in every request payload. Do not rely on the user message to carry this context.
For web-based tools (ChatGPT, Kimi, Claude.ai), create "Custom Instructions" or "Projects" to persist your system prompt across sessions.
---
Key Takeaway
A well-written system prompt is a multiplier on every interaction you have with the model. It takes 15 minutes to write a good one for your project. It saves hours across every subsequent session. Write it once. Refine it as your project evolves.