Direct answer
High-quality prompts are not stacks of modifiers, but clear scope, constraints, evidence, and stopping conditions.
What this guide helps you solve
Help developers build reusable Claude Code prompting and planning practices.
Five components of an executable prompt
Effective prompts describe the goal, relevant scope, non-negotiable constraints, expected deliverables, and verification method. Claude can explore implementation details, but it cannot infer business boundaries the team never states.
File paths, complete error messages, existing implementation examples, and test commands are more valuable than asking the model to "think hard." When the scope is uncertain, request read-only exploration first and narrow it gradually.
- Goal: A user-observable result.
- Scope: The directory, file, or module to inspect first.
- Constraints: dependencies, compatibility, prohibited modifications.
- Deliverables: Code, tests, documentation, or analysis reports.
- Verification: Tests, builds, lint checks, screenshots, or reproduction steps.
修复 src/auth 中会话过期后的登录失败。先阅读现有 token refresh 实现,
不要新增依赖,也不要修改数据库结构。先写失败测试,再修复根因,
运行 auth 模块测试和 typecheck,最后列出证据与剩余风险。Work in four phases: Explore, Plan, Implement, and Verify
Plan mode lets Claude read and analyze without editing. It suits cross-file changes, architectural tradeoffs, and unfamiliar areas of the codebase. Explore the current state, produce a reviewable plan, then exit Plan mode before implementing it.
The plan should identify specific files, data flows, migration or compatibility risks, tests, and explicit exclusions. Planning reduces rework when the goal is clear but the implementation still has meaningful choices.
- 01ExploreLimit the search area and locate the actual implementation, tests, and historical constraints.
- 02PlanList file-level changes, risks, and verification commands for approval.
- 03ImplementEdit according to the confirmed plan and pause when new facts are encountered.
- 04VerifyRun machine-readable checks and review the final diff.
保持 Plan 模式。分析新增 OAuth 登录需要修改哪些文件、会话数据如何流转、
需要哪些测试以及哪些内容明确不在本次范围;先不要写代码。Do not plan small tasks merely for the sake of process
Plan mode consumes context and time. Spelling fixes, a targeted log statement, or a clearly defined mechanical change can be requested and verified directly.
Use a simple test: if you can describe the expected diff accurately in one sentence, formal planning is usually unnecessary. If you do not know which modules are involved, explore first.
Give Claude an acceptance check it can run
Test exit codes, builds, lint results, fixed inputs and outputs, and browser screenshots can all create a verification feedback loop. Without those signals, Claude can only stop when an implementation "looks right."
Ask for the actual commands and key results instead of a bare claim that work was "verified." For critical changes, use a fresh subagent to review the requirements and diff independently.
完成后运行 `pnpm test auth` 和 `pnpm typecheck`。如果失败,读取错误并修复,
直到检查通过或遇到需要我决策的真实阻塞。最终报告命令、结果和未验证项。Correct mistakes early and reset a polluted context
Press Esc as soon as Claude heads in the wrong direction, then identify the incorrect assumptions and add specific constraints. Do not wait for it to produce many irrelevant changes before rejecting the approach.
If two consecutive corrections fail to fix the same problem, use /clear to start with a clean context and include the newly discovered constraints in the first prompt. Keep unrelated tasks in separate sessions so old logs and failure paths do not distort current decisions.
/clear
/compact 只保留已确认的接口约束、修改文件和验证命令Provide high-value context directly
Referencing a file with @, pasting the complete error, attaching a screenshot, or providing the official API URL is more precise than paraphrasing. For large inputs, let Claude read data on demand instead of loading every log into the main context at once.
When business decisions are required, ask Claude to interview you first and turn the answers into a self-contained specification. Implement that specification in a new session so the execution phase starts with clean context.
我要增加批量导入功能。先就数据格式、错误策略、幂等、权限、性能和 UX 采访我。
不要问代码已经能回答的问题。确认边界后把完整规格写入 SPEC.md,暂不实现。Official sources and verification scope
This guide is based on public official documentation. Commands and configuration may change between client versions, so verify the linked sources before use.
Read the verification methodology