「AIに指示したのに、全然違うコードが出てきた」「意図しないファイルまで書き換えられた」——バイブコーディングあるあるを根本から解決するプロンプトを、GitHubで3.8万スターを獲得したawesome-cursorrulesなど複数のリポジトリから厳選しました。
まず読むべき:ガードレールプロンプト
バイブコーディングで最初に設定すべきは「AIに暴走させない制約」。このプロンプトを必ずシステムプロンプトの冒頭に置くこと。
Only make the exact changes I request — do not modify, remove, or alter any other code, styling, or page elements unless explicitly instructed.
日本語版:「私が依頼した変更だけを行うこと。明示的に指示しない限り、他のコード・スタイル・ページ要素を修正・削除・変更しないこと。」
コード前に確認させる「契約プロンプト」
Before writing any code, answer these questions:
1. What files will you touch?
2. What edge cases could break it?
3. Does this change anything outside the file I specified?Only start coding after I confirm your answers.
これだけで「頼んでないファイルまで書き換えた」問題が激減する。Medium上で広く共有されているパターン。
設計を先に説明させるプロンプト
Before you generate any code, explain exactly what you plan to do. Include affected files, components, and edge cases.
AIが「わかった」と言ってすぐコードを書き始めるのを防ぐ。説明を聞いて「それじゃない」と気づいたらそこで止められる。
役割設定プロンプト(ロールプロンプト)
You are a senior full-stack engineer with 10+ years of experience.
Your goal is to write production-ready code — not prototypes.
Constraints:
– No inline styles. Use Tailwind utility classes only.
– No magic numbers. Define constants with clear names.
– Write accessible HTML (ARIA labels, semantic elements).
– Never hard-code secrets. Use .env variables.
– Ask clarifying questions before starting any complex task.
具体的なUI構築プロンプト(Atomic UIパターン)
Lovableが公開した「Prompting Bible」で最も共有されたテクニック。
NGパターン:
Add a signup section with a button
OKパターン:
Add a form with:
– One email input field with placeholder Enter your email
– A rounded CTA button with text Get Started Free
– Inline error message below the input if the email is invalid
Do NOT add any backend logic yet — frontend/UI only.
「Do NOT add any backend logic yet」の一文が重要。AIは頼まれていないことをやりたがる。
デバッグ時の「説明先行プロンプト」
Do NOT fix the bug yet.
First:
1. Explain in plain English what this code is trying to do.
2. Identify the exact line where the bug originates.
3. Explain WHY it’s a bug.
4. List 2-3 possible fixes with trade-offs.After I choose an approach, then write the fix.
リファクタリング監査プロンプト
Act as a senior software engineer conducting a thorough code review.
Tasks:
1. Identify the top 5 functions that are too long or complex.
2. Refactor them to follow the Single Responsibility Principle.
3. Flag any security vulnerabilities.
4. Highlight missing error handling.Do NOT rewrite everything — prioritize highest-impact changes first.
本番リリース前チェックリストプロンプト
Before we ship, run through this checklist and fix what’s broken:
[ ] All API routes validate and sanitize input
[ ] No secrets hardcoded in source
[ ] Error boundaries exist on all major UI sections
[ ] Loading and empty states are handled for every async operation
[ ] All images have width/height attributes to prevent CLS
[ ] Console is clean (no errors or warnings in production build)
まとめ:プロンプトで変わること
バイブコーディングの問題の大半は「制約を与えていないAIが、必要以上のことをする」から生まれる。今回紹介したプロンプトの核心は「何をするか」より「何をしてはいけないか」を先に定義すること。特にガードレールプロンプトと契約プロンプトの2つは今日からすぐ使える。
