Roller ve Kısıtlamalar
Daha iyi çıktılar için yapay zekanın rolünü ve sınırlarını belirleyin.
Roller ve Kısıtlamalar, CoddyKit'te ücretsiz bir Vibe Coding dersidir. Bu, 4 dersinin 1. dersidir. Aşağıdan dersin tamamını ücretsiz okuyabilir, sonra tarayıcıda yerleşik kod editörü ve 7/24 yapay zeka koçu ile uygulamalı olarak pratik yapabilirsin. Bu, Vibe Coding öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. Vibe Coding kursu toplamda 4 dersten oluşur.
Bu dersin bazı bölümleri henüz çevrilmemiş olup İngilizce olarak gösterilmektedir.
Tell the AI Who to Be
You already know how to ask AI for code. Now let's get production-quality output on the first try. The fastest upgrade? Give the AI a role and a set of constraints.
A role tells the AI what kind of expert to channel. Constraints tell it the rules it must not break. Together they turn a vague request into a precise brief — the same way a good client gets better work from a freelancer.
What Is a Role?
A role is a one-line identity you assign at the start of a prompt: "You are a senior React engineer" or "Act as a security-focused backend developer."
This isn't magic — it steers the model toward the patterns, vocabulary and standards that kind of person would use. A "senior engineer" writes cleaner, safer code than an unspecified assistant. Tools like Cursor and Claude Code respond strongly to roles because they shape the whole answer.
You are a senior front-end engineer who writes clean, accessible, well-commented JavaScript. Build a function that validates an email address and returns true or false.Why Roles Improve Output
Without a role, AI gives you the average of everything it has seen — including beginner code from tutorials. With a role, you pull from the expert slice.
- Better defaults — a "senior" picks safer patterns.
- Right vocabulary — it explains things at your level.
- Consistent style — it stays in character across edits.
Think of it as choosing which teammate shows up to help you.
What Is a Constraint?
A constraint is a hard rule the answer must obey. Roles set the vibe; constraints set the boundaries.
Examples of useful constraints:
- "Use only vanilla JavaScript — no libraries."
- "Keep the function under 20 lines."
- "Do not use any external API."
- "Return only the code, no explanation."
Each constraint removes a whole category of unwanted answers.
You are a senior JavaScript developer. Constraints: vanilla JS only, no libraries, under 20 lines, include a one-line comment above the function. Write a function that formats a number as US currency.Roles + Constraints Together
The real power comes from combining them. The role decides how the code is written; the constraints decide what's allowed. Stack them at the top of your prompt so the AI reads the rules before the task.
A reliable template:
- Role: who the AI is
- Constraints: the must/never list
- Task: what to build
ROLE: You are a senior front-end engineer focused on accessibility.
CONSTRAINTS:
- Vanilla JavaScript and HTML only
- No external libraries
- All interactive elements must be keyboard-usable
TASK: Build a button that copies the page URL to the clipboard and shows a 'Copied!' message for 2 seconds.A Constraint in Action
Here's the kind of clean, self-contained JavaScript a well-constrained prompt produces. Notice it's small, readable, and does exactly one job — because the constraints asked for exactly that.
Run it to see the output.
// Format a number as US currency
function toUSD(amount) {
return new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'USD'
}).format(amount);
}
console.log(toUSD(1999.5));
console.log(toUSD(42));Negative Constraints: The 'Never' List
Some of the most powerful constraints are things you forbid. AI loves to over-deliver — adding libraries, extra features, or rewriting your whole file. A never list reins it in.
- "Never add new dependencies."
- "Never change files I didn't mention."
- "Never use TypeScript — plain JavaScript only."
In agentic tools like Claude Code, a clear never list prevents surprise edits across your project.
You are a careful engineer working in an existing project.
NEVER:
- Add new npm packages
- Edit any file other than cart.js
- Remove existing comments
TASK: In cart.js, add a function getTotal(items) that sums item.price for all items.Scope Constraints
One constraint beginners forget: limiting scope. Without it, ask for one feature and AI may refactor everything. Pin it down:
- "Only modify the function I paste below."
- "Give me just the changed lines."
- "Don't touch the styling."
Tight scope makes AI output easier to review and far less likely to break working code.
Here is my working function. Change ONLY the sort order to descending. Do not rename anything, do not add features, return only the updated function.
function topScores(scores) {
return scores.sort((a, b) => a - b).slice(0, 3);
}Output-Format Constraints
You can also constrain the shape of the reply. This keeps answers easy to paste and use:
- "Return only a single code block, no prose."
- "Reply with the full file, ready to save."
- "List 3 options as a numbered list, code only."
App builders like v0 and Bolt already format output as runnable apps — but inside an editor, saying how you want the answer saves you cleanup time.
You are a JS engineer. Return ONLY the complete function in one code block, with no explanation before or after.
Task: Write debounce(fn, delay) that returns a debounced version of fn.Build a Reusable Role Header
Pros don't retype roles and constraints every time. They save a role header and reuse it. In Cursor you can store it in a .cursorrules file; in Claude Code, a CLAUDE.md; or just keep a note you paste in.
A good standing header sets your stack, your style, and your never list once — so every prompt inherits it automatically.
PROJECT RULES (paste once, applies to all prompts):
Role: Senior JavaScript engineer who writes clean, commented, accessible code.
Stack: Vanilla JS + HTML/CSS, no frameworks.
Never: add dependencies, use TypeScript, or edit unrelated files.
Style: short functions, descriptive names, no clever one-liners.Don't Over-Constrain
Constraints are powerful, but too many can box the AI into bad code. If you forbid everything, it can't find a good solution.
Balance:
- Constrain things you care about (stack, scope, safety).
- Leave room for the AI to choose implementation details.
If output feels stiff or wrong, loosen one constraint and re-run. Aim for a clear brief, not a straitjacket.
Quick Check
You want AI to fix one function without rewriting your whole file. Which addition to your prompt best achieves this?
Recap: Direct the AI
You learned to steer AI like a director:
- Roles pull expert-level output instead of average answers.
- Constraints set hard rules: stack, scope, never-lists and output format.
- Combine them with a Role → Constraints → Task structure.
- Save a reusable role header (.cursorrules / CLAUDE.md).
- Don't over-constrain — leave room for good solutions.
Next up: showing the AI examples so it copies the exact style you want.
Sıkça Sorulan Sorular
“Roller ve Kısıtlamalar” dersi ücretsiz mi?
Evet — “Roller ve Kısıtlamalar” dersin tüm metni burada web'de ücretsiz olarak okunabilir. Etkileşimli olarak pratik yapmak (yerleşik kod editörü ve 7/24 yapay zeka koçu) ve Vibe Coding kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. Vibe Coding kursu toplamda 4 dersten oluşur.
“Roller ve Kısıtlamalar” dersinde ne öğreneceğim?
Daha iyi çıktılar için yapay zekanın rolünü ve sınırlarını belirleyin. Vibe Coding ile uygulamalı kodu tarayıcıda doğrudan çalıştırarak pratik yaparsın ve 7/24 yapay zeka koçu dersi çalışırken sorularını yanıtlar.
Vibe Coding öğrenmeye başlamak için deneyim gerekli mi?
Önceden deneyim gerekmez. CoddyKit'te Vibe Coding, başlangıçtan ileri seviyeye kadar yapılandırıldığı için buradan başlayabilir veya başından başlayıp kendi hızında ilerleme yapabilirsin. Bu, 4 dersinin 1. dersidir.
“Roller ve Kısıtlamalar” dersi ne kadar sürer?
Çoğu CoddyKit dersi yaklaşık 5–10 dakika sürer. Her biri kısa ve etkileşimli olduğu için sabit ilerleme yaparsın ve web ile uygulama arasında tam olarak bıraktığın yerden devam edebilirsin.
Bu Vibe Coding dersinde kod yazıp çalıştırabilir miyim?
Evet. Her Vibe Coding dersi yerleşik bir kod editörü içerir, bu sayede tarayıcıda gerçek kod yazıp çalıştırabilir ve anlık yapay zeka geri bildirimi alırsın — yerel kurulum gerekli değildir.
Bu kursun tüm dersleri
- Roller ve Kısıtlamalar
- Az Örnekli İstemler
- Büyük Görevleri Adımlara Bölme
- Teknolojiyi ve Tarzı Belirtme