AI プロンプトエンジニアリング:開発者必备コマンドと技巧
プロンプトエンジニアリング已になる使用 AIツールの開発者最も閉键の技できるの一つ。にかかわらずあなた使用のは ChatGPT、Claude、GitHub Copilot それとも Cursor,プロンプトの质量直接決定するた AI 出力するの质量。一つの精心設計するのプロンプトできるする模糊、なし用の対応转化のために精密に、利用可能于生产環境のコード。この包括的なガイドカバーたからベースプロンプトテクニックまで高级ストラテジー、各ツール专属技巧ならびに即用テンプレートのすべての内容,ヘルプあなたから毎回 AIインタラクション中獲得する最大价值。
とはプロンプトエンジニアリング?
プロンプトエンジニアリングはのために AI 言語モデル精心設計する有効ディレクティブもって生み出す预期出力するの艺术と科学。其核心で于沟通——学習どのように用 AI モデル最も理解するの言語来表达。正如高级開発者できるに初级開発者より精密にの指示もって獲得するより良の結果,プロンプトエンジニアリング教あなたどのようにもって明確にと精准の方式へ AI 系统传达あなたの意图。
に対して開発者そして言,プロンプトエンジニアリング理由は重する必要がある,はなぜなら AIプログラミングアシスタント已になる现代開発するワークフロー不可欠ですの一部分的に。これらのツールできる生成コード、デバッグ问题、テスト作成、重构アーキテクチャと説明する複雑系统——しかし前提はあなたに出た正しくのディレクティブ。一つの写て不良のプロンプトかもしれない生み出すできるコンパイルしかし不適合するあなた意图のコード,使用た間違いのフレームワークバージョン,または無視するた閉键のエッジケース。それに比べて,一つの精心設計するのプロンプトできる生み出すと经验丰富の開発者编写のコードなし异の出力する。
プロンプトの微小变化できる生み出す巨大の影響する。比較する一下"修正 bug"と"修正 UserService.authenticate 方法中時に email 参数のために undefined 时出现の空引用する异常。该方法位于 src/services/UserService.ts,使用 bcrypt 入行パスワード比較する"の間の違い。第一つのプロンプトほとんどないに AI 提供する任意のあり用情報。第二个提供するた明確にの问题説明する、位置とコンテキスト——させる AI できるで第一次尝试时すぐに生み出す精密に、正しくの修正。
ベースプロンプトテクニック
理解する核心プロンプトテクニックのためにあなた奠定たベース。毎種類技巧すべてあり其擅長の特定ユースケース,经验丰富のプロンプトエンジニアリング师通常できるで単个プロンプト中コンポジット多種類技巧もって达まで最良效果。
ゼロショットプロンプト
ゼロショットプロンプトは最もシンプルのヒント形式——あなた直接に AI 一つのディレクティブ,不提供する任意の例。AI 完全依赖其训练データとプロンプト中の情報来生成対応。これ種類技巧に適用される所需出力するフォーマット显そして易见の簡単任务,または AI で训练中见たことがある多くの類似して例の情况。
Write a Python function that validates an email address using regex.
The function should return True for valid emails and False for invalid ones.ゼロショットプロンプトに対して常见の、定義する明確にの任务とても有効。しかし,時にあなた必要とする特定の出力するフォーマット、风格または方法时,フューショットプロンプトできるより一層信頼できる。
フューショットプロンプト
フューショットプロンプト含むでに出实际任务前に,提供する一つのまたは多个期望の入力する-出力するパターン例。これ種類技巧非常に強力,なぜならそれ精密に示すたあなたしたいする必要がある何么,減らすた歧义かつ引导 AI 朝へ正しくのフォーマットと风格。AI からあなたの例中学習パターン,かつする其適用する于新規入力する。
Convert these database column names to camelCase JavaScript variable names:
user_first_name -> userFirstName
created_at_timestamp -> createdAtTimestamp
is_email_verified -> isEmailVerified
total_order_count ->
Now convert: product_category_idフューショットプロンプトであなた必要とする一致のフォーマット、特定のエンコードする仕様,または AI かもしれない做出不適合するあなた项目风格の偽设时特にあり价值。通常两まで三个例すぐに足もって確立する明確にのパターン。
思考連鎖プロンプト
思考連鎖プロンプト要件 AI でに出最も终答案前に段階的に推理问题。これ種類技巧显著向上させるた複雑任务の正確性,なぜならそれ迫させる AI 処理する中间步骤,そしていいえ跳までかもしれない不正しくの结论。研究表明,でプロンプト中追加する"think step by step"できるで推理任务上する正確性向上させる 30-50%。
Analyze this React component for performance issues. Think step by step:
1. First, identify all state variables and their update patterns
2. Then, check for unnecessary re-renders
3. Next, look for missing memoization opportunities
4. Finally, suggest specific optimizations with code examples
Here's the component:
[component code]思考連鎖プロンプトに対してデバッグ、アーキテクチャ决策と任意の必要とする逻辑推理の任务すべては必要不可欠ですの。を通じて要件 AI 示す其推理たことがある程,あなたまだ獲得するた検証する其推理と発見する中间步骤間違いのできる力。
ロールプレイプロンプト
ロールプレイプロンプトのために AI 分配特定の角色またはプロフェッショナル水平,これできる影響する其対応の奥行き、风格と重点。時にあなた告诉 AI "扮演高级 DevOps 工程师"时,それできる转变视角,提供するより注重运维、より適合する生产環境の提案する,そしていいえ通用のコード片段。これ種類技巧利用た AI で领域特定内容上の训练来生み出すより专家级の出力する。
Act as a senior security engineer with 15 years of experience in web application security. Review this authentication implementation and identify any vulnerabilities, ranking them by severity. For each vulnerability, explain the attack vector and provide a secure code fix.有効角色扮演の閉键で于具体的性。"扮演 Python 開発者"あまりにも模糊た。"扮演に集中する使用 Apache Airflow と pandas 構築する高パフォーマンスデータパイプラインの Python 開発者"にた AI より明確にの参照フレームワーク。
システムプロンプトとユーザープロンプト
大多数の AIツール区分系统プロンプトと用户プロンプト。系统プロンプト設定するに適用される全体の正话の持久ディレクティブ,そして用户プロンプトは単独のメッセージ。理解するこれ種類違いに対してで長時間交互中保持一貫性非常に重要です。
CLAUDE.md ファイル充時に持久の系统プロンプト。で ChatGPT 中,あなたできる設定するカスタマイズするディレクティブとしてすべての正话の系统プロンプト。
# System prompt example
You are a TypeScript expert working on a Next.js 14 project using:
- App Router (not Pages Router)
- Server Components by default
- Prisma for database access
- Tailwind CSS for styling
- Zod for validation
Always use strict TypeScript. Prefer server actions over API routes.
Never use 'any' type. Use 'unknown' and narrow with type guards.
# User prompt example
Add a user profile page that shows the current user's name, email,
avatar, and last 10 activity records. Include loading states and
error handling.開発者必备 AI コマンド
某些コマンドパターンですべての主に AIプログラミングツール中すべて证明非常に有効。これらのいいえ字面コマンド,そしては継続的にトリガーする高质量対応のディレクティブ短语。するそれ们と見なす激活 AI モデル特定できる力の力数量詞汇。
| コマンド | 用途 | 最適なシナリオ |
|---|---|---|
| "Act as..." / "You are a..." | ロール割り当て | ドメイン専門家レベルの応答を取得 |
| "Step by step" | 思考連鎖 | 複雑な推論とデバッグ |
| "Think aloud" | 推論の透明化 | AIの意思決定プロセスを理解 |
| "Explain like I'm 5" | 簡略化された説明 | 新しい概念を素早く学習 |
| "Review and critique" | コードレビュー | 建設的なコードフィードバックを取得 |
| "Write tests for" | テスト生成 | 包括的なテストカバレッジ |
| "Refactor using..." | パターンベースのリファクタリング | デザインパターンの適用 |
| "Find bugs in" | デバッグ | 隠れた問題の特定 |
| "Convert from X to Y" | コード翻訳 | 言語またはフレームワークの移行 |
| "Document this" | ドキュメント生成 | インラインドキュメントとREADMEの作成 |
| "Optimize for performance" | 最適化する | 速度と効率の向上 |
| "Add error handling" | 堅牢性の強化 | コードを本番環境対応に |
"Act as..." / "You are a..." — ロール割り当て
ロール割り当てはプロンプトエンジニアリング中最も強力のコマンドの一つ。を通じて指定角色,あなた激活た领域特定知识,かつ设定た正対応奥行きと风格の期望。角色越具体的,出力する越良。
You are a senior backend engineer at a fintech company who specializes
in building secure, high-throughput payment processing systems.
You have deep expertise in PostgreSQL, Redis, and distributed systems.
You always consider edge cases, race conditions, and failure modes.
Design a payment processing API that handles:
- Credit card payments via Stripe
- Bank transfers via Plaid
- Retry logic with exponential backoff
- Idempotency keys to prevent duplicate charges"Step by step" — 思考連鎖
でプロンプト中追加する"step by step"または"let's think step by step"できるトリガーする AI 分解其推理たことがある程。これに対してデバッグ、アルゴリズム設計するとアーキテクチャ决策特に有効。段階的に方法だけでなく生み出すより良の結果,まださせる AI の推論の透明化,させるあなたできる発見する逻辑間違い。
Debug this SQL query that's causing a timeout. Think step by step:
1. First, analyze the query structure and joins
2. Identify potential performance bottlenecks
3. Check for missing indexes
4. Suggest an optimized version with EXPLAIN analysis
SELECT u.name, COUNT(o.id), SUM(o.amount)
FROM users u
LEFT JOIN orders o ON u.id = o.user_id
LEFT JOIN order_items oi ON o.id = oi.order_id
WHERE o.created_at > '2026-01-01'
GROUP BY u.name
HAVING COUNT(o.id) > 10
ORDER BY SUM(o.amount) DESC;"Think aloud" — 推論の透明化
"Think aloud"類似して于"step by step",しかしより侧重于 AI の决策たことがある程。それ要件 AI 叙述其推理,を含む考慮するたどのの代わりに代方案ならびになぜ選択する特定方法。時にあなた理解する必要があります設計する决策中の权衡,またはしたい評価する AI の推理はいいえ合理时,これ非常にあり价值。
I need to choose between WebSocket and Server-Sent Events for a
real-time notification system. Think aloud about the trade-offs,
considering: browser support, bidirectional communication needs,
server resource usage, and scalability. Then recommend one with
justification."Explain like I'm 5" — 簡略化された説明
時に学習新規概念または试图理解する複雑コード时,"explain like I'm 5"(ELI5)去を除いて术语,提供するた直观の、に基づく类比の説明する。これに対して加入新規项目、理解する不熟悉のコードライブラリまたはへ非技术利益相閉者説明する技术概念特にあり用。
Explain like I'm 5: What is a monad in functional programming,
and why do Haskell developers keep talking about them?
Use a real-world analogy, not code."Review and critique" — コードレビュー
使用"review and critique"信号 AI 采取批判性视角,そしていいえ簡単に受け取るコード。これできる生み出すより徹底的にの分析する,を含む潜での bug、安全问题、パフォーマンス问题と风格违规。すぐにのような按需獲得する高级工程师のコードレビュー。
Review and critique this Express.js middleware. Focus on:
- Security vulnerabilities
- Error handling gaps
- Performance concerns
- Best practice violations
- Suggest improvements with code examples
[paste your middleware code]"Write tests for" — テスト生成
テスト生成は AIプログラミングツール最高价值の使用の一つ。を通じて指定"write tests for"ならびにあなたのテストするフレームワークとオーバーライド期望,あなたできる高速生成包括的のテストする套件。閉键は指定エッジケースとテストする优先级。
Write tests for the UserService.register method using Jest.
Cover these scenarios:
- Happy path with valid input
- Duplicate email registration
- Invalid email format
- Password too short
- Missing required fields
- Database connection failure
- Concurrent registration attempts
Use describe/it blocks. Include setup and teardown.
Mock the database layer."Refactor using..." — パターンベースのリファクタリング
で重构プロンプト中指定設計するパターンまたは原すなわちにた AI 明確にの目标アーキテクチャ。よりもむしろ使用模糊の"重构この"リクエストする,命名するパターンできる生み出す従う既定柔件工程原すなわちの专注、一致の重构。
Refactor this notification system using the Strategy pattern.
Currently, all notification types (email, SMS, push) are handled
in a single class with if-else chains. Create separate strategy
classes for each notification type, a context class that delegates
to the active strategy, and a factory for creating strategies.
[paste your current code]"Find bugs in" — デバッグ
"Find bugs in"コマンド激活 AI の分析するパターン,促させる其探す问题そしていいえ生成コード。時にあなた提供するコード、説明する预期行のためにかつメンションする观察までの症状时,效果最良。
Find bugs in this async Node.js function. It's supposed to process
a batch of orders and update their status, but sometimes orders
get processed twice and the status updates are inconsistent under
high load.
[paste your function code]"Add error handling" — 堅牢性の強化
多くの AI 生成のコード片段で正常路径上できる工作,しかし缺乏適切にの間違い処理する。"Add error handling"コマンド专门针正これ一差距,要件 AI 考慮する故障パターン、エッジケースと復元するストラテジー。
Add error handling to this file upload function. Consider:
- File size limits
- Invalid file types
- Network interruptions during upload
- Disk space errors
- Concurrent upload conflicts
- Partial upload cleanup
Use try-catch with specific error types. Add retry logic for
transient failures. Return meaningful error messages to the client.コード生成のプロンプトパターン
を除いて単个コマンド,某些プロンプトパターンに対して特定タイプのコード生成任务已られる证明特に有効。これらのパターンするロール割り当て、コンテキスト提供すると出力する仕様など技巧组コンポジット结构化ヒント,継続的に生み出す高质量結果。
機能実装プロンプト
で実装する新規機能时,最も効果的のプロンプト従う類似して仕様の结构:説明する機能、指定技术スタック、定義する验收標準かつメンションする任意の制約。これにた AI 必要とする構築するといったもの完全图景。
Implement a user avatar upload feature for a Next.js 14 application.
Tech stack: Next.js App Router, TypeScript, Prisma, PostgreSQL, AWS S3
Requirements:
- Accept JPEG, PNG, WebP (max 5MB)
- Resize to 200x200 and 400x400 thumbnails using Sharp
- Upload originals to S3 with unique keys
- Store S3 URLs in the User model
- Delete old avatar when uploading a new one
- Return presigned URLs for frontend display
Acceptance criteria:
- Invalid file types return 400 with error message
- Files over 5MB return 413
- Successful upload returns 200 with avatar URLs
- Old avatars are cleaned up from S3
Create: API route, service layer, Prisma schema update, and types.API設計プロンプト
API設計プロンプト词受益于预先指定アーキテクチャ风格、认证方法、バージョンストラテジーと対応フォーマット。これは以下を保証します生成の API 一致かつ従うあなた项目的约定。
Design a RESTful API for a project management application.
Architecture: Express.js with TypeScript, following clean architecture
Auth: JWT with refresh token rotation
Versioning: URL-based (/api/v1/)
Response format: { success: boolean, data?: T, error?: { code, message } }
Endpoints needed:
- Projects CRUD with team membership
- Tasks CRUD with assignee, priority, status
- Comments on tasks with mentions
- Activity feed (recent actions across projects)
Include:
- Request/response TypeScript interfaces
- Zod validation schemas
- Error handling middleware
- Pagination for list endpoints (cursor-based)データベースSchemaプロンプト
データベースSchemaプロンプト词应指定 ORM、命名する约定、インデックスストラテジーとリレーション。AI できる生成带あり適切に制約、インデックスとマイグレーションファイルの完全 Schema。
Design a Prisma schema for an e-commerce platform with these entities:
- Users (authentication, profile, addresses)
- Products (variants, categories, inventory)
- Orders (line items, status history, payments)
- Reviews (ratings, images, helpful votes)
- Cart (items, applied coupons)
Requirements:
- Use PostgreSQL with UUID primary keys
- Soft deletes with deletedAt timestamps
- Proper indexes for common query patterns
- Enums for order status, payment status
- Decimal fields for prices (not float)
- Full-text search on product name and description
- Include a migration fileUIコンポーネントプロンプト
に対して UIコンポーネント,指定フレームワーク、スタイル方法、アクセス可能性要件と交互ステート比通用の"作成するコンポーネント"プロンプト生み出すより良の結果。
Create a reusable DataTable component in React with TypeScript.
Styling: Tailwind CSS + shadcn/ui conventions
Features:
- Column definitions with sort, filter, and custom renderers
- Server-side pagination with page size selector
- Row selection (single and multi) with checkboxes
- Loading skeleton state
- Empty state with custom message
- Responsive: card layout on mobile, table on desktop
Accessibility:
- Keyboard navigation (arrow keys, Enter, Escape)
- Screen reader announcements for sort and filter changes
- ARIA labels on all interactive elements
Props interface:
- data, columns, isLoading, pagination, onSort, onFilter, onSelect
Include a usage example with a user list table.設定とDevOpsプロンプト
DevOps と設定するプロンプト应指定目标環境、安全要件と任意の组织標準。これは以下を防止します AI 生成不適合するあなたベース设施の通用設定する。
Create a Docker Compose setup for a development environment with:
- Next.js app (hot reload enabled)
- PostgreSQL 16 with persistent volume
- Redis for session storage
- MinIO (S3-compatible) for local file storage
Requirements:
- All services on a shared network
- Environment variables from .env file
- Health checks for all services
- Volumes for node_modules (avoid bind mount issues)
- PostgreSQL initialized with seed data
- Non-root containers where possible
Also create:
- Dockerfile for the Next.js app (multi-stage build)
- .env.example with all required variables
- Makefile with common commands (up, down, logs, reset-db)高级プロンプト戦略
一旦あなた掌握たベース技巧とコマンド,これらの高级ストラテジーするヘルプあなた処理する超越単个プロンプトできる力の複雑、多步骤開発する任务。
プロンプトチェーン
プロンプトチェーンする複雑任务分解のために一系列より小、より专注のプロンプト,各プロンプト確立するで前一つのの出力する以上。これ種類ストラテジー比试图で単个庞大プロンプト中完了するすべての事情生み出すより良の結果,なぜなら毎一步すべて獲得するた AI のすべて注意する力とコンテキスト。
# Step 1: Design the architecture
"Design the architecture for a real-time chat application.
List the components, their responsibilities, and how they
communicate. Use a diagram-like text format."
# Step 2: Define the data model
"Based on the architecture above, design the database schema
for the chat application. Include users, conversations,
messages, and read receipts. Use Prisma schema format."
# Step 3: Implement the API
"Implement the REST API for the chat application based on
the architecture and schema we designed. Start with the
message endpoints: send, list, delete."
# Step 4: Add WebSocket support
"Now add WebSocket support for real-time message delivery.
Use Socket.io. Integrate with the existing message API."
# Step 5: Write tests
"Write integration tests for the chat API and WebSocket
events using Jest and Supertest."有効プロンプトチェーンの閉键は確保する毎一步で入入下一步前に生み出す完全、利用可能の出力する。レビューする各出力する,必する必要がある时入行修正,それからする精炼の結果入力する下一つのプロンプト。
コンテキスト充填
コンテキスト充填含むで提问前にへ AI 提供するすべての相閉のコード、ドキュメントとコンテキスト。だがこれようだ显そして易见,しかし多くの開発者スキップするたこれ一步,それから纳闷なぜ AI 做出た間違いの偽设。あなた提供するの相閉コンテキスト越多,AI の対応すぐに越正確にと具体的。
{
await this.db.query('UPDATE users SET email = $1 WHERE id = $2', [email, id]);
await this.cache.del(`user:${id}`);
}
}
```
Here is the User type:
```typescript
interface User {
id: string;
email: string;
name: string;
role: 'admin' | 'user';
createdAt: Date;
}
```
Now, add an updateProfile method that allows updating name and email,
with validation that the email is not already taken by another user. 注意する提供する现ありコードとタイプどのようにさせる AI できる生成と现ありパターン完全一致の方法,使用同じのキャッシュストラテジー,かつ従う现ありのタイプ定義する。
制約の指定
設定する显式制約防止する AI 做出不希望するの偽设。制約定義するた AI すべきでない做何么,これ通常とそれすべき做何么同样重する必要がある。常见制約を含む技术バージョン、パフォーマンス要件、安全规すなわちとエンコードする標準。
Build a URL shortener API with these constraints:
MUST:
- Use Node.js 20+ with native fetch (no axios)
- Use PostgreSQL via pg driver (no ORM)
- Generate short codes of exactly 7 characters
- Support custom aliases (max 20 chars)
- Return 301 for existing short URLs
- Rate limit to 100 creates per hour per IP
MUST NOT:
- Use any ORM or query builder
- Store full URLs without normalization
- Allow short codes that conflict with existing routes
- Return database errors to the client
PERFORMANCE:
- Handle 10,000 requests per second
- Cache hot URLs in Redis with 5-minute TTL
- P99 latency under 50ms for redirects出力フォーマット制御
指定所需の出力するフォーマット確保する AI の対応なし需重新規フォーマットする即可直ちに使用。時に出力する必要とするられる其彼ツール解析する、挿入するドキュメントまたは用作設定ファイル时,これ特に重する必要がある。
Analyze this codebase and provide the output in this exact format:
## Architecture Overview
[2-3 paragraph summary]
## Component Diagram
```mermaid
graph TD
[components and relationships]
```
## API Endpoints
| Method | Path | Description | Auth |
|--------|------|-------------|------|
## Database Tables
| Table | Columns | Indexes | Relations |
|-------|---------|---------|-----------|
## Recommendations
1. [Priority] [Description] - [Estimated effort]
2. ...
## Technical Debt
- [ ] [Description] - [Impact: High/Medium/Low]反復最適化
反復最適化はを通じて後续プロンプト段階的に改入 AI 出力するの实践。第一次対応まれには完美の,しかしそれを提供しますできる最適化するの起点。毎回迭代比试图で単个プロンプト中做まで完美より効率的に接近期望結果。
# Iteration 1: Get a starting point
"Write a rate limiter middleware for Express.js"
# Iteration 2: Add specificity
"Good start. Now modify it to use Redis for distributed
rate limiting across multiple server instances. Use sliding
window instead of fixed window."
# Iteration 3: Add edge cases
"Add handling for: Redis connection failures (fall back to
in-memory), custom rate limits per route, burst allowance
for legitimate traffic spikes, and proper headers
(X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset)."
# Iteration 4: Add tests
"Write comprehensive tests for all the scenarios we've
covered, including Redis failures and burst handling."これ種類迭代方法比编写単个庞大プロンプトより有効,なぜなら毎回迭代許可するあなたに基づいて AI の先前出力する入行纠偏と追加する細节。それ反映たあなたと人类開発者合作の方式:から粗略実装する開始する,それから最適化する。
各ツール专属プロンプトテクニック
だが上述技巧に適用されるすべての AIツール,しかし各平台すべてあり独特の优势と特点。调全体あなたのヒント风格もって适应各ツールの特徴できる显著改善する結果。
ChatGPT / GPT-4
ChatGPT と GPT-4 擅長正话式交互,受益于结构化、组织良良のプロンプト。それ们とても良に処理する長コンテキスト,特に擅長説明する概念と生成ドキュメント。
- 使用カスタマイズするディレクティブ:で ChatGPT のカスタマイズするディレクティブ中設定するあなたの技术スタックと設定,これ样あなたすぐに不必で毎回正话中重复。
- 利用 Code Interpreter:に対してデータ分析する任务,要件 ChatGPT 使用 Code Interpreter 実行する Python コードかつ生成可視化する。
- でプロンプト中使用 markdown フォーマット:GPT-4 正带あり見出し、项目符号とコード块の结构化プロンプト対応良良。
- 指定対応長さ:GPT-4 傾向がある冗長。時にあなた必要とする简洁时,追加する"be concise"または"in under 200 words"。
- 使用系统メッセージ:で API 中,使用系统メッセージ来設定するエンコードする標準と项目コンテキストなど持久ディレクティブ。
# Effective GPT-4 prompt structure
**Role:** Senior TypeScript developer
**Task:** Implement a JWT authentication middleware
**Context:** Express.js API, PostgreSQL, existing User model
**Constraints:** No external auth libraries, use crypto module
**Output:** Complete, production-ready code with types
**Format:** Single file with inline comments for complex logicClaude / Claude Code
Claude と Claude Code で理解する大型コードライブラリ、従う複雑ディレクティブと生み出す结构良良の出力する側面特に強。Claude Code のプロキシできる力させる其非常に適合する多步骤任务。
- 使用 CLAUDE.md:これはあなたできる做の最もあり影響する力の事情。するあなたの项目コンテキスト、约定と設定放で CLAUDE.md 中。
- 明確に指定ファイル位置:Claude Code であなた指定する必要がある読み取ると変更するのファイル时效果最良。
- させるそれ実行するコマンド:Claude Code できる実行するテストすると構築するコマンド。要件それを通じて実行するテストする来検証する其工作。
- で長できる话中使用 /compact:時にコンテキスト变長时,使用 /compact 圧縮する正话同時に予約最も重要の情報。
- 利用 XML タグ:Claude 正プロンプト中 XML マークするの部分的に対応良良,できる明確に划分リクエストするの異なる部分的に。
# Effective Claude Code prompt
Read the following files to understand the current architecture:
- src/routes/userRoutes.ts
- src/middleware/authMiddleware.ts
- src/models/User.ts
Then refactor the authentication flow to support:
1. JWT access tokens (15 min expiry) + refresh tokens (7 day expiry)
2. Token rotation on refresh (invalidate old refresh token)
3. Rate limiting on the refresh endpoint (5 per minute per user)
Update all related files and run the test suite when done.GitHub Copilot
GitHub Copilot の実行する方式異なる于に基づく聊天のツール——それであなた入力する时提供する内联提案する。有効の Copilot 使用依赖于编写を通じてコメント、タイプ署名と周围コンテキスト明確に传达意图のコード。
- 编写説明する性コメント:で函数前追加する如 // Validate email format and check for duplicates のコメント,に Copilot 明確にの意图。
- 使用 TypeScript タイプ:定義する良良のタイプとインターフェース引导 Copilot 朝へ正しくの実装する。
- でコメント中提供する例:でコメント中示す预期の入力する/出力する,ヘルプ Copilot マッチするあなたしたいする必要があるのフォーマット。
- 受け取る部分的に提案する:時々 Copilot 结构正しくしかし細节あり误。受け取る提案するそれから編集する細节。
- 正複雑任务使用 Copilot Chat:に対して多ファイルより改またはアーキテクチャ决策,使用 Copilot Chat そしていいえ内联提案する。
> {
// Copilot will generate the implementation based on these types Cursor
Cursor する IDE 統合すると AI 聊天機能相組み合わせる,提供するインライン補完と理解するあなたコードライブラリの聊天界面。其优势で于奥行き项目感知と特定のファイルを参照と符号のできる力。
- 使用 @file 引用する:用 @filename 特定のファイルを参照,に Cursor 精密にのコンテキスト。
- 使用 @codebase 获取広くコンテキスト:時にあなた必要とする Cursor 検索する全体の项目时,使用 @codebase。
- 使用 @docs 获取ライブラリドキュメント:Cursor できる用 @docs 引用する第三方ライブラリドキュメント。
- 利用 Cmd+K 入行内联編集する:選択するコードかつ使用 Cmd+K 用当然言語説明するより改。
- 設定する项目规すなわち:使用 .cursorrules ファイル(類似して于 CLAUDE.md)設定する持久の项目ディレクティブ。
# Effective Cursor prompt
@src/services/paymentService.ts @src/types/payment.ts
Refactor the processPayment function to use the Strategy pattern.
Create separate strategy classes for each payment provider
(Stripe, PayPal, BankTransfer). The function should accept a
payment method and delegate to the appropriate strategy.
Keep the same public API so existing callers don't break.Codex CLI
Codex CLI は OpenAI のに基づくターミナルのプログラミングプロキシ,概念上類似して于 Claude Code。それ擅長からコマンドライン実行する多步骤開発する任务。
- 提供する明確に目标:Codex CLI であり明確にの高层目标时效果最良,そしていいえ段階的にディレクティブ。
- 指定工作目次:確保するあなたから正しくの项目根目次実行する Codex CLI。
- 先使用提案パターン:でさせる Codex 做出より改前に,使用提案パターンレビューする其計画する。
- 谨慎設定する沙箱权限:を通じて設定する沙箱权限来制御する Codex できる実行する何么。
- 迭代出力する:よりもむしろ彼ツール一样,第一次尝试かもしれない必要とするを通じて後续プロンプト入行最適化する。
よくある間違いと回避方法
たとえ〜でもはあり经验の開発者もできる犯これらの常见のヒント間違い。认识かつ避けるそれ们する直ちに改善するあなたの AIインタラクション。
曖昧な指示
最も一般的の間違いは提供する模糊、不够具体的のディレクティブ。のような"これを修正"、"より良くする"または"追加する機能"これ样のプロンプトほとんどないに AI 提供する任意のあり用情報。AI できる做出偽设,そしてこれらの偽设通常不適合するあなたの意图。
# Bad
"Fix the login bug"
# Good
"Fix the bug where users with uppercase emails cannot log in.
The issue is in src/auth/login.ts - the email comparison is
case-sensitive but emails are stored in lowercase in the database.
The fix should normalize the email to lowercase before comparison."コンテキスト不足
AI モデル不知っているあなたの项目,でない限りあなた告诉それ们。未できる提供する相閉コンテキスト——あなたの技术スタック、フレームワークバージョン、现ありコードパターンまたは项目结构——迫させる AI 猜测,さらに往々にして猜誤。常にを含む新規团队成员理解するあなたのリクエストする所需のコンテキスト。
# Bad
"Write a function to send emails"
# Good
"Write an email sending function for our NestJS application.
We use:
- @nestjs/mailer with Handlebars templates
- SMTP via AWS SES
- Templates stored in src/templates/emails/
- Existing MailService class in src/mail/mail.service.ts
The function should accept a template name, recipient, and
template variables. Include error handling for SES throttling
and bounce notifications."プロンプトの過負荷
试图で単个プロンプト中完了するあまりにも多不相閉の任务できるをもたらす各側面すべて平庸の結果。AI の注意する力られる分散,それかもしれないスキップする某些任务の重する必要がある細节,同時に過度の注目する其彼任务。する複雑リクエストする分解のために专注の、顺序のプロンプト。
# Bad - Too many tasks in one prompt
"Build a complete user management system with authentication,
profile management, email verification, password reset,
role-based access control, and an admin dashboard"
# Good - Break it into focused prompts
Prompt 1: "Design the database schema for a user management system..."
Prompt 2: "Implement the authentication endpoints..."
Prompt 3: "Add email verification flow..."
Prompt 4: "Implement role-based access control middleware..."出力フォーマットの無視
時にあなた必要とする特定フォーマットの出力する——JSON、markdown、特定ファイル结构——未指定これ一点できるをもたらす不予測可能のフォーマット。AI かもしれないであなた必要とする JSON 时戻る散文,またはで必要とする多个ファイル时戻る単个ファイル。常に明確に指定所需の出力するフォーマット。
# Bad
"List all the API endpoints"
# Good
"List all API endpoints in a markdown table with these columns:
| Method | Path | Description | Auth Required | Request Body | Response |"反復しない
不经最適化するすぐに受け取る AI の第一次対応は一つの誤失の机できる。第一次対応を提供しますあなたできるを通じて後续プロンプト改入のベース。迭代は AI支援開発する真正力量所で——各周期すべて生み出すより良、より精炼の出力する。
# Instead of accepting the first response, iterate:
"Good start. Now add input validation using Zod schemas."
"Now add proper error handling with custom error classes."
"Now add logging for all operations."
"Now write tests for all the edge cases we've discussed."プロンプトテンプレートライブラリ
もって下は常见開発者任务の即用プロンプトテンプレート。コピーするこれらのテンプレート,填入占位符,かつに基づいてあなたの具体的需求入行调全体。各テンプレートコンポジットた多種類プロンプトテクニックもって达まで最大效果。
テンプレート 1:機能実装
You are a senior {language} developer specializing in {framework}.
Implement {feature_description} for our {project_type} application.
Tech stack:
- {language} {version} with {framework} {version}
- {database} for data storage
- {orm} for database access
- {testing_framework} for tests
Requirements:
- {requirement_1}
- {requirement_2}
- {requirement_3}
Constraints:
- Must follow existing patterns in the codebase
- Must include input validation
- Must handle errors gracefully
- Must be backward compatible
Output:
1. Implementation code with inline comments for complex logic
2. Unit tests covering happy path and edge cases
3. Brief explanation of design decisionsテンプレート 2:バグ調査
You are a debugging specialist with expertise in {language}/{framework}.
Investigate and fix this bug:
**Symptom:** {describe_the_observed_behavior}
**Expected:** {describe_the_expected_behavior}
**Frequency:** {always/sometimes/under_specific_conditions}
**Environment:** {production/staging/development}
Relevant code:
```
{paste_relevant_code}
```
Error output / stack trace:
```
{paste_error_output}
```
Think step by step:
1. Identify the root cause
2. Explain why this bug occurs
3. Provide the fix with code
4. Suggest how to prevent similar bugs
5. Write a regression testテンプレート 3:コードレビュー
You are a senior code reviewer at a {company_type} company.
Review this {language} code for:
1. **Correctness:** Logic errors, off-by-one errors, null handling
2. **Security:** Injection, XSS, auth bypasses, data exposure
3. **Performance:** N+1 queries, unnecessary allocations, missing caches
4. **Maintainability:** Code smells, naming, complexity
5. **Testing:** Missing test cases, brittle tests
Code to review:
```
{paste_code}
```
For each issue found, provide:
- Severity: 🔴 Critical / 🟡 Warning / 🔵 Info
- Category: Which of the 5 areas above
- Description: What's wrong and why
- Suggestion: How to fix it, with code example
End with an overall assessment and top 3 priorities.テンプレート 4:APIエンドポイント設計
Design a {http_method} {endpoint_path} endpoint for {resource_description}.
Framework: {framework}
Auth: {auth_method}
Database: {database}
The endpoint should:
- {functionality_1}
- {functionality_2}
- {functionality_3}
Provide:
1. Route definition with middleware chain
2. Request validation schema ({validation_library})
3. Controller/handler function
4. Service layer function
5. Database query/function
6. Response types (success and error)
7. Example curl request and responseテンプレート 5:データベース移行
Create a database migration for {change_description}.
Current schema:
```
{current_schema}
```
Desired changes:
- {change_1}
- {change_2}
ORM: {orm_name}
Database: {database_type}
Requirements:
- Migration must be reversible (include down migration)
- Preserve existing data (write data migration SQL if needed)
- Add appropriate indexes for new columns
- Consider performance impact on large tables
- Include rollback safety checksテンプレート 6:テストスイート生成
Write a comprehensive test suite for {function_or_class_name}.
Testing framework: {framework}
Mocking library: {library}
Code under test:
```
{paste_code}
```
Test categories to cover:
- ✅ Happy path: All valid inputs produce correct outputs
- 🔄 Edge cases: Empty inputs, boundary values, null/undefined
- ❌ Error cases: Invalid inputs, permission denied, network failures
- 🏎️ Performance: Response time expectations for critical paths
- 🔒 Security: Auth checks, input sanitization
For each test:
- Use descriptive test names that read like documentation
- Follow Arrange-Act-Assert pattern
- Include setup/teardown for shared state
- Mock external dependenciesテンプレート 7:リファクタリング計画
You are a software architect specializing in {language} refactoring.
Current code:
```
{paste_current_code}
```
Problems with current code:
- {problem_1}
- {problem_2}
Refactor using {pattern_or_principle}.
Provide:
1. **Analysis:** What's wrong and why the current approach doesn't scale
2. **Target Architecture:** How the refactored code should be structured
3. **Step-by-step Plan:** Ordered refactoring steps (safe, incremental)
4. **Refactored Code:** Complete implementation
5. **Migration Guide:** How to transition from old to new without breaking changes
6. **Risk Assessment:** What could go wrong and how to mitigateテンプレート 8:ドキュメント生成
Generate documentation for this {language} code:
```
{paste_code}
```
Documentation type: {JSDoc/TSDoc/Python docstrings/README section}
Requirements:
- Document all public functions/classes/methods
- Include parameter descriptions with types
- Include return type descriptions
- Add usage examples for non-obvious APIs
- Note any side effects or important caveats
- Use {style_guide} conventions
For README documentation, include:
- Overview (1-2 paragraphs)
- Installation instructions
- Quick start example
- API reference table
- Configuration optionsテンプレート 9:パフォーマンス最適化
You are a performance engineering specialist.
Analyze and optimize this code for performance:
```
{paste_code}
```
Current performance:
- {metric}: {current_value}
- Target: {target_value}
- Bottleneck suspected at: {location}
Optimization constraints:
- Must not change the public API
- Must maintain all existing test passes
- Must not sacrifice readability for micro-optimizations
- {additional_constraint}
Provide:
1. **Profiling Analysis:** Where time/memory is being spent
2. **Optimization Strategies:** Ranked by expected impact
3. **Optimized Code:** With comments explaining each change
4. **Benchmark Comparison:** Before vs after expected metrics
5. **Trade-offs:** Any readability or complexity costsテンプレート 10:セキュリティ監査
You are a security engineer specializing in {language}/{framework} security.
Perform a security audit on this code:
```
{paste_code}
```
Check for:
- Injection attacks (SQL, NoSQL, command, LDAP)
- Authentication and authorization bypasses
- Cross-site scripting (XSS) vulnerabilities
- Cross-site request forgery (CSRF) exposure
- Insecure direct object references (IDOR)
- Sensitive data exposure (logging, error messages)
- Insecure cryptography or key management
- Race conditions in concurrent operations
- Denial of service vulnerabilities
For each finding:
- Severity: Critical / High / Medium / Low
- OWASP Category: Which Top 10 category
- Description: Clear explanation of the vulnerability
- Attack Scenario: How an attacker would exploit it
- Remediation: Specific code fix
- Verification: How to confirm the fix works準備はいいですか用 AI スーパーチャージあなたの開発するワークフローましたか?ToolHubを探索 精选の AIプログラミングアシスタント、プロンプト最適化するツールと開発者生产力ツールセット——すべて無料,随时利用可能。
AIツールを探索よくある質問
とはプロンプトエンジニアリング,なぜ正開発者とても重する必要がある?
プロンプトエンジニアリングはのために AI 言語モデル精心設計する有効ディレクティブもって生み出す预期出力するの实践。に対して開発者そして言,それ理由は重する必要がある,はなぜなら AI 生成コード、デバッグ辅助とドキュメントの质量直接に依存するあなた传达意图の程度。プロンプト措辞、结构とコンテキストの微小变化できる显著改善する出力する质量,する模糊または間違いの対応转化のために精密に、あり用のコードと説明する。随ている AIツールになる開発するワークフローの核心,プロンプトエンジニアリング正变てのような知っているどのように写良 bug 報告またはコードレビューコメントする一样ベース。
開発者最も重要のプロンプトテクニックありどの?
最も重要のプロンプトテクニックを含む:ゼロショットプロンプト(不提供する例の直接ディレクティブ)、フューショットプロンプト(提供する例もって引导出力するフォーマット)、思考連鎖プロンプト(要件 AI 段階的に推理)、ロールプレイプロンプト(分配角色如"扮演高级工程师")と系统プロンプト(設定する持久ディレクティブ)。するこれらの技巧と"step by step"、"think aloud"と"review and critique"など特定コマンドコンポジット,可思うプログラミング任务生み出す最良結果。閉键はする技巧と任务マッチする——デバッグ使用思考連鎖,专家级提案する使用角色扮演,一致フォーマット使用少样本。
どのようにのために AIプログラミングアシスタント写出より良のプロンプト?
する必要がある写出より良のプロンプト:具体的説明あなたの技术スタックと需求,提供する相閉コードコンテキスト,指定所需の出力するフォーマット,する複雑任务分解のためにより小の步骤,使用ロール割り当て设定プロフェッショナル水平,を含む制約とエッジケース,かつで第一次結果不完美时反復最適化あなたのプロンプト。避ける曖昧な指示、コンテキスト不足とで単个プロンプト中塞入あまりにも多任务。大多数の開発者できる做出の最もあり影響する力の改入すぐには提供するより多コンテキスト——で提问前に共有相閉コード、タイプと项目结构。
どの AIプログラミングツール最も適合するプロンプトエンジニアリング?
最良ツールに依存するあなたのユースケース。ChatGPT と GPT-4 擅長正话式デバッグと説明する。Claude と Claude Code 適合する理解する必要があります全体のコードライブラリの大コンテキスト任务とプロキシワークフロー。GitHub Copilot で IDE 中提供する最良の内联コード补全。Cursor 提供する奥行き IDE 統合する,を持つ多ファイル感知とファイル引用するできる力。Codex CLI 適合するに基づくターミナルのコード生成。大多数の開発者受益于コンポジット使用多个ツール,各取所長——Copilot に使用されるインライン補完,Claude Code に使用されるマルチファイルタスク,ChatGPT に使用される学習と説明する。
へ AI ヒントコード时应避けるどの常见間違い?
常见間違いを含む:使用"これを修正"など曖昧な指示そして不提供するコンテキスト,未できる指定あなたの技术スタックまたはフレームワークバージョン,で単个プロンプト中塞入あまりにも多不相閉任务,未指定所需の出力するフォーマット(JSON、markdown など),不经迭代すぐに受け取る第一次対応,ならびにないのために AI 提供する十分なのコードコンテキスト来理解するあなたの项目结构。最大の間違いはコンテキスト不十分な——常にで提问前に共有相閉コード、タイプと项目详情。常に迭代と最適化するあなたのプロンプトもって獲得するより良の結果。
プロンプトエンジニアリングできる取代传统プログラミング技できるか?
不,プロンプトエンジニアリング补充传统プログラミング技できるしかしできない取代それ们。あなた理解する必要がありますプログラミング概念、アーキテクチャパターンと系统設計するようやくできる写出有効のプロンプトかつ評価する AI 出力する。プロンプトエンジニアリングヘルプあなたより有効に利用 AIツール,しかしあなたまだ必要とするプロフェッショナル知识来识别 AI 出力する何时は不正しくの、安全でないのまたは次优の。する其と見なすあなた现あり技できるの乘数——を持つ良良プロンプトテクニックの高级工程师常に优于を持つ同じプロンプトテクニックの初级開発者,なぜなら彼らできる提供するより良のコンテキストかつ評価する出力する质量。
どのように処理する AI コード生成中の幻觉问题?
AIハルシネーション——即モデル生成看似合理しかし不正しくのコード——は一つの真实の担忧。緩和方法を含む:常にで使用前レビューする生成のコード,実行するテストするもって検証する正しく性,要件 AI 説明する其推理(思考連鎖プロンプト),提供する特定のライブラリバージョンとドキュメント参照,かつに基づいて官方ドキュメント交叉確認する API 使用法。時に AI 引用するあなた不熟悉の函数または方法时,で使用前検証するそれはいいえ存で。に対して閉键コード(安全、金融、医療),常にさせる人类专家徹底的にレビューする出力する。