微信扫码
添加专属顾问
我要投稿
OpenAI最新旗舰模型GPT-5带来编程与代理任务的革命性突破,掌握这些提示技巧让你事半功倍。 核心内容: 1. GPT-5在编程、代理任务和工具调用领域的重大升级 2. 控制模型主动性的关键提示技巧 3. 通过context_gathering等方法优化模型输出的实战策略
GPT-5 提示词指南
大家好,我是绛烨!
今天要给大家带来一篇关于 GPT-5 提示词的深度解析,这是 OpenAI 最新推出的旗舰级模型,它在编程、代理任务、工具调用等多个领域都实现了质的飞跃。
别急,我会用通俗易懂的方式,带你领略 GPT-5 的强大之处,还会分享一些实用的提示技巧,让你在使用时得心应手。
GPT-5 是 OpenAI 最新推出的旗舰模型,它在多个领域都展现了强大的能力。无论是处理复杂的编程任务,还是作为代理完成各种任务,它都能游刃有余。它在编码、原始智能和可纵性方面都有了重大突破,堪称 AI 领域的一次重大飞跃。
虽然 GPT-5 在很多场景下都能“开箱即用”,但掌握一些提示技巧,可以进一步提升模型输出的质量。这些技巧都是基于我们训练和实际应用模型的经验总结出来的。
GPT-5 可以在完全自主和完全听从指令之间灵活调整。
如果你希望它更主动,可以增加它的“推理努力”(reasoning_effort),让它更积极地探索和解决问题。比如,你可以这样提示它:“你是一个智能助手,请主动完成用户的请求,直到问题完全解决。”
<context_gathering>
Goal: Get enough context fast. Parallelize discovery and stop as soon as you can act.
Method:
- Start broad, then fan out to focused subqueries.
- In parallel, launch varied queries; read top hits per query. Deduplicate paths and cache; don’t repeat queries.
- Avoid over searching for context. If needed, run targeted searches in one parallel batch.
Early stop criteria:
- You can name exact content to change.
- Top hits converge (~70%) on one area/path.
Escalate once:
- If signals conflict or scope is fuzzy, run one refined parallel batch, then proceed.
Depth:
- Trace only symbols you’ll modify or whose contracts you rely on; avoid transitive expansion unless necessary.
Loop:
- Batch search → minimal plan → complete task.
- Search again only if validation fails or new unknowns appear. Prefer acting over more searching.
</context_gathering>
相反,如果你希望它更谨慎一些,可以降低推理努力,或者明确告诉它在什么情况下需要暂停或询问用户。
<persistence>
- You are an Agent - please keep going until the user's query is completely resolved, before ending your turn and yielding back to the user.
- Only terminate your turn when you are sure that the problem is solved.
- Never stop or hand back to the user when you encounter uncertainty — research or deduce the most reasonable approach and continue.
- Do not ask the human to confirm or clarify assumptions, as you can always adjust later — decide what the most reasonable assumption is, proceed with it, and document it for the user's reference after you finish acting
</persistence>
当 GPT-5 执行任务时,它会调用各种工具来完成工作。
为了让用户更好地理解它的操作过程,GPT-5 可以在调用工具之前,先给出一个简短的说明,这就是工具前言。
<tool_preambles>
- Always begin by rephrasing the user's goal in a friendly, clear, and concise manner, before calling any tools.
- Then, immediately outline a structured plan detailing each logical step you’ll follow. - As you execute your file edit(s), narrate each step succinctly and sequentially, marking progress clearly.
- Finish by summarizing completed work distinctly from your upfront plan.
</tool_preambles>
你可以根据需要,让 GPT-5 提供更详细或更简洁的工具前言。比如,你可以要求它在执行任务前,先概述一下它的计划和步骤。
"output": [
{
"id": "rs_6888f6d0606c819aa8205ecee386963f0e683233d39188e7",
"type": "reasoning",
"summary": [
{
"type": "summary_text",
"text": "**Determining weather response**\n\nI need to answer the user's question about the weather in San Francisco. ...."
},
},
{
"id": "msg_6888f6d83acc819a978b51e772f0a5f40e683233d39188e7",
"type": "message",
"status": "completed",
"content": [
{
"type": "output_text",
"text": "I\u2019m going to check a live weather service to get the current conditions in San Francisco, providing the temperature in both Fahrenheit and Celsius so it matches your preference."
}
],
"role": "assistant"
},
{
"id": "fc_6888f6d86e28819aaaa1ba69cca766b70e683233d39188e7",
"type": "function_call",
"status": "completed",
"arguments": "{\"location\":\"San Francisco, CA\",\"unit\":\"f\"}",
"call_id": "call_XOnF4B9DvB8EJVB3JvWnGg83",
"name": "get_weather"
},
],
reasoning_effort
这个参数决定了 GPT-5 在思考和调用工具时的深度。
对于复杂的任务,建议将推理努力设置为高,这样它可以更全面地考虑问题。而对于简单的任务,降低推理努力可以提高效率。
使用 Responses API 可以让 GPT-5 在多次调用中保留之前的推理上下文。
这意味着它可以在后续的任务中,直接参考之前的推理过程,而不需要重新开始。这不仅可以节省时间,还能提高任务的连贯性和准确性。
GPT-5 在编程方面表现出色,无论是修复代码错误、进行代码重构,还是从零开始开发一个新应用,它都能轻松应对。
为了更好地利用它的编程能力,你可以根据自己的需求,选择合适的编程框架和工具,并在提示中明确告诉 GPT-5。
比如,如果你想开发一个前端应用,可以告诉它使用 Next.js 和 Tailwind CSS。
对于新应用,建议使用以下框架和包来充分利用模型的前端功能:
<code_editing_rules>
<guiding_principles>
- Clarity and Reuse: Every component and page should be modular and reusable. Avoid duplication by factoring repeated UI patterns into components.
- Consistency: The user interface must adhere to a consistent design system—color tokens, typography, spacing, and components must be unified.
- Simplicity: Favor small, focused components and avoid unnecessary complexity in styling or logic.
- Demo-Oriented: The structure should allow for quick prototyping, showcasing features like streaming, multi-turn conversations, and tool integrations.
- Visual Quality: Follow the high visual quality bar as outlined in OSS guidelines (spacing, padding, hover states, etc.)
</guiding_principles>
<frontend_stack_defaults>
- Framework: Next.js (TypeScript)
- Styling: TailwindCSS
- UI Components: shadcn/ui
- Icons: Lucide
- State Management: Zustand
- Directory Structure:
\`\`\`
/src
/app
/api/<route>/route.ts # API endpoints
/(pages) # Page routes
/components/ # UI building blocks
/hooks/ # Reusable React hooks
/lib/ # Utilities (fetchers, helpers)
/stores/ # Zustand stores
/types/ # Shared TypeScript types
/styles/ # Tailwind config
\`\`\`
</frontend_stack_defaults>
<ui_ux_best_practices>
- Visual Hierarchy: Limit typography to 4–5 font sizes and weights for consistent hierarchy; use `text-xs` for captions and annotations; avoid `text-xl` unless for hero or major headings.
- Color Usage: Use 1 neutral base (e.g., `zinc`) and up to 2 accent colors.
- Spacing and Layout: Always use multiples of 4 for padding and margins to maintain visual rhythm. Use fixed height containers with internal scrolling when handling long content streams.
- State Handling: Use skeleton placeholders or `animate-pulse` to indicate data fetching. Indicate clickability with hover transitions (`hover:bg-*`, `hover:shadow-md`).
- Accessibility: Use semantic HTML and ARIA roles where appropriate. Favor pre-built Radix/shadcn components, which have accessibility baked in.
</ui_ux_best_practices>
<code_editing_rules>
AI 代码编辑器 Cursor 是 GPT-5 的早期使用者之一。他们在使用 GPT-5 的过程中,积累了一些宝贵的经验。
Cursor 的系统提示侧重于可靠的工具调用,平衡冗长性和自主行为,同时让用户能够配置自定义指令。Cursor 的系统提示目标是让 Agent 在长距离任务中相对自主地运行,同时仍然忠实地遵循用户提供的指令。
Cursor 的团队发现,GPT-5 在处理复杂的编程任务时,能够提供高质量的代码输出,但有时代码的可读性有待提高。为了解决这个问题,他们调整了模型的冗长度参数,让模型在生成代码时使用更清晰易读的格式。
Write code for clarity first. Prefer readable, maintainable solutions with clear names, comments where needed, and straightforward control flow. Do not produce code-golf or overly clever one-liners unless explicitly requested. Use high verbosity for writing code and code tools.
此外,Cursor 还发现,GPT-5 在处理长任务时,有时会过于依赖用户输入来确认下一步操作。为了避免这种情况,他们调整了提示,让模型在执行任务时更加自主,减少对用户输入的依赖。
Be aware that the code edits you make will be displayed to the user as proposed changes, which means (a) your code edits can be quite proactive, as the user can always reject, and (b) your code should be well-written and easy to quickly review (e.g., appropriate variable names instead of single letters). If proposing next steps that would involve changing the code, make those changes proactively for the user to approve / reject rather than asking the user whether to proceed with a plan. In general, you should almost never ask the user whether to proceed with a plan; instead you should proactively attempt the plan and then ask the user if they want to accept the implemented changes.
GPT-5 非常注重指令的准确性。如果提示中存在模糊或矛盾的地方,它会花费更多的时间来尝试理解。
You are CareFlow Assistant, a virtual admin for a healthcare startup that schedules patients based on priority and symptoms. Your goal is to triage requests, match patients to appropriate in-network providers, and reserve the earliest clinically appropriate time slot. Always look up the patient profile before taking any other actions to ensure they are an existing patient.
- Core entities include Patient, Provider, Appointment, and PriorityLevel (Red, Orange, Yellow, Green). Map symptoms to priority: Red within 2 hours, Orange within 24 hours, Yellow within 3 days, Green within 7 days. When symptoms indicate high urgency, escalate as EMERGENCY and direct the patient to call 911 immediately before any scheduling step.
+Core entities include Patient, Provider, Appointment, and PriorityLevel (Red, Orange, Yellow, Green). Map symptoms to priority: Red within 2 hours, Orange within 24 hours, Yellow within 3 days, Green within 7 days. When symptoms indicate high urgency, escalate as EMERGENCY and direct the patient to call 911 immediately before any scheduling step.
*Do not do lookup in the emergency case, proceed immediately to providing 911 guidance.*
- Use the following capabilities: schedule-appointment, modify-appointment, waitlist-add, find-provider, lookup-patient and notify-patient. Verify insurance eligibility, preferred clinic, and documented consent prior to booking. Never schedule an appointment without explicit patient consent recorded in the chart.
- For high-acuity Red and Orange cases, auto-assign the earliest same-day slot *without contacting* the patient *as the first action to reduce risk.* If a suitable provider is unavailable, add the patient to the waitlist and send notifications. If consent status is unknown, tentatively hold a slot and proceed to request confirmation.
- For high-acuity Red and Orange cases, auto-assign the earliest same-day slot *after informing* the patient *of your actions.* If a suitable provider is unavailable, add the patient to the waitlist and send notifications. If consent status is unknown, tentatively hold a slot and proceed to request confirmation.
因此,我们需要确保提示清晰、明确,避免使用模糊的语言。比如,不要同时要求它“在没有用户明确同意的情况下不要安排预约”和“在紧急情况下自动安排最早的预约”。
如果你需要快速得到答案,可以选择最小化推理模式。
在这种模式下,GPT-5 会以最快的速度给出答案,但可能会牺牲一些准确性和全面性。
在这种情况下,你需要更加明确地告诉 GPT-5 你的需求,并且在提示中加入一些规划和反思的步骤,以确保它能够更好地完成任务。
Remember, you are an agent - please keep going until the user's query is completely resolved, before ending your turn and yielding back to the user. Decompose the user's query into all required sub-request, and confirm that each is completed. Do not stop after completing only part of the request. Only terminate your turn when you are sure that the problem is solved. You must be prepared to answer multiple queries and only finish the call once the user has confirmed they're done.
You must plan extensively in accordance with the workflow steps before making subsequent function calls, and reflect extensively on the outcomes each function call made, ensuring the user's query, and related sub-requests are completely resolved.
GPT-5 是一个功能强大的模型,它在多个领域都展现了巨大的潜力。
通过掌握一些提示技巧,你可以更好地利用它的能力,解决实际问题。
但请记住,提示并不是一成不变的,你需要根据具体任务进行调整和优化。希望这篇文章能帮助你更好地理解和使用 GPT-5,让它成为你工作中的得力助手。
如果你对 GPT-5 还有其他疑问,或者在使用过程中遇到了什么问题,欢迎在评论区留言,我们一起探讨。
推荐一下自己搞的claude Code服务+claude code课程手册,方便一站式学习。
cc课程手册付费用户搭配claude code交流群,搭配Claude Code服务两不误。
初级CC(基本操作):Claude code 概述、环境搭建与安装、基本操作和命令、实际操作流程与案例
中级CC(高级功能与技巧):Claude Code GitHub Actions(代码库)、子Agent(你的开发团队)、 Claude Code Hooks(触发事件)、模型上下文协议 (MCP)(工具)、Claude Code SDK(带一下,需要编程能力)
高级CC(企业组织使用、多租户、监控运维等):企业级优化部署、故障排除与支持、项目实战(待补充)
适合哪些人?
服务平台目前支持诸多的大模型API,有以下优势:
点击关注下方账号,你将获得更多关于AI的前沿信息。
参考:
https://cookbook.openai.com/examples/gpt-5/gpt-5_prompting_guide
https://cursor.com/cn/blog/gpt-5
https://docs.cursor.com/en/context/rules
建议使用apply_patch
用于文件编辑以匹配训练分布。在绝大多数情况下,最新的实现应该与 GPT-4.1 实现相匹配。
## Set 1: 4 functions, no terminal
type apply_patch = (_: {
patch: string, // default: null
}) => any;
type read_file = (_: {
path: string, // default: null
line_start?: number, // default: 1
line_end?: number, // default: 20
}) => any;
type list_files = (_: {
path?: string, // default: ""
depth?: number, // default: 1
}) => any;
type find_matches = (_: {
query: string, // default: null
path?: string, // default: ""
max_results?: number, // default: 50
}) => any;
## Set 2: 2 functions, terminal-native
type run = (_: {
command: string[], // default: null
session_id?: string | null, // default: null
working_dir?: string | null, // default: null
ms_timeout?: number | null, // default: null
environment?: object | null, // default: null
run_as_user?: string | null, // default: null
}) => any;
type send_input = (_: {
session_id: string, // default: null
text: string, // default: null
wait_ms?: number, // default: 100
}) => any;
53AI,企业落地大模型首选服务商
产品:场景落地咨询+大模型应用平台+行业解决方案
承诺:免费POC验证,效果达标后再合作。零风险落地应用大模型,已交付160+中大型企业
2025-08-11
大模型提示词编写与优化超级详细教程
2025-08-11
prompt-optimizer:帮助用户快速编写更高质量的提示词
2025-08-11
Context Engineering 上下文工程是什么?和提示词工程有什么联系?
2025-08-10
如何通俗的理解上下文工程?
2025-08-09
你真的会写Prompt吗?高质量提示词指南来了!
2025-08-09
学习 Coze Studio 的代码架构
2025-08-07
Spring AI Alibaba 动态 Prompt 最佳实践:用 Nacos 实现 Prompt 实时更新
2025-08-07
借助上下文工程优化任何AI代理框架
2025-05-19
2025-06-27
2025-06-12
2025-06-21
2025-06-10
2025-07-03
2025-05-17
2025-07-03
2025-06-03
2025-05-15
2025-08-11
2025-08-10
2025-07-24
2025-07-22
2025-07-19
2025-07-08
2025-07-04
2025-06-23