How to Write Prompts (Coding Edition)

AI Navigate Original / 5/16/2026

共有:

Key Points

  • Coding AI output changes greatly with how you prompt
  • 5 rules: enough context, completion condition, constraints, file refs, plan first
  • Use frequent patterns for features, bug fixes, refactors, tests
  • Avoid vague asks; language-specific tips; persist via Rules files

Basics of Prompting Coding AI

AI coding tools' output quality changes greatly with how you ask. Here are coding-specific tips distinct from general prompts.

5 Golden Rules

1. Give Enough Context

Over "fix this code," say "this project uses Next.js 16, TypeScript strict, Vitest. Fix module X like Y."

2. State the Completion Condition

Over "make it nice," say "all tests pass, no lint errors, existing API compatible."

3. Convey Constraints

  • "Libraries you may use: existing dependencies only"
  • "Don't call external APIs"
  • "O(N) or less"
  • "Within 100 lines"

4. Use File References

  • Cursor: reference with @filename
  • Claude Code: "refer to @auth.ts"
  • Copilot Chat: auto-references the file open in the editor

5. Ask for a Plan First

"First a 5-step implementation plan.
Start implementing after I OK it.
Ask if questions arise midway"

Frequent Patterns

1. New Feature Addition

Sign up to read the full article

Create a free account to access the full content of our original articles.