Home / Glossary / Prompt Engineering for Code

Definition

Prompt Engineering for Code

Code के लिए prompt engineering clear, specific instructions तैयार करने की practice है जो AI coding टूल्स को accurate, relevant output produce करने में help करती है। इसमें right level of context, constraints और examples के साथ requests structure करना शामिल है ताकि AI समझे कि आप क्या चाहते हैं और कैसे चाहते हैं।

Coding के लिए prompt quality क्यों महत्वपूर्ण है

आपके prompt की quality directly AI के output की quality निर्धारित करती है। "bug fix करो" जैसा vague prompt AI को guess करने पर मजबूर करता है। "the /api/users endpoint returns 500 when the email field is missing — add input validation with Zod and return a 400 with a descriptive error message" जैसा specific prompt AI को वह सब देता है जो first try पर correct code produce करने के लिए चाहिए।

Effective code prompts के लिए key techniques

  • +केवल problem नहीं, desired outcome के बारे में specific रहें
  • +Constraints शामिल करें: follow करने वाली language, framework, patterns और conventions
  • +Existing files को name से reference करें ताकि AI जाने कहाँ देखना है और क्या match करना है
  • +जरूरत पड़ने पर complex tasks को smaller, sequential prompts में तोड़ें
  • +Output format specify करें: "write a function," "modify the existing handler," "add a test file"
  • +Negative constraints शामिल करें: "do not use any external dependencies" या "do not modify the database schema"
text
# Weak prompt
> "Add authentication"

# Strong prompt
> "Add JWT authentication to the Express API:
   - Use the existing User model in lib/models/user.ts
   - Add login and register endpoints to routes/auth.ts
   - Protect all /api/admin/* routes with middleware
   - Store JWT secret in environment variable AUTH_SECRET
   - Write tests in __tests__/auth.test.ts
   - Follow the error handling pattern used in routes/users.ts"

Claude Code जैसे agentic टूल्स के साथ, आप हर prompt में repeat करने के बजाय CLAUDE.md में context front-load कर सकते हैं। अपनी CLAUDE.md file में coding conventions, architecture decisions और common patterns डालें।

क्या agentic AI के साथ भी prompt engineering ज़रूरी है?+
हाँ, लेकिन यह exact syntax के बारे में होने से clear intent के बारे में shift हो जाता है। Claude Code जैसे agentic टूल्स context के लिए आपका project पढ़ सकते हैं, लेकिन आपको अभी भी clearly communicate करना होगा कि आप क्या चाहते हैं और कौन से constraints apply होते हैं।
सबसे common prompt engineering mistake क्या है?+
बहुत vague होना। Developers अक्सर "feature X add करो" के साथ prompt करते हैं बिना specify किए कहाँ, कैसे या किन conventions को follow करना है। आप constraints और expected behavior के बारे में जितने specific हों, result उतना बेहतर।
क्या code prompts में few-shot examples use करने चाहिए?+
हाँ, जब output format matter करे। यदि आप AI को एक specific pattern follow करवाना चाहते हैं, तो उस pattern का एक example दिखाएं। Coding कार्यों के लिए, एक existing file reference करना जो desired pattern follow करती है ("routes/users.ts की style follow करो") अक्सर scratch से example लिखने से अधिक effective है।
CLAUDE.md files का prompt engineering से क्या संबंध है?+
CLAUDE.md persistent prompt engineering का एक रूप है। हर prompt में project context repeat करने के बजाय, आप इसे एक बार CLAUDE.md में लिखते हैं और Claude Code इसे हर session में automatically apply करता है। यह आपकी team की conventions, rules और preferences को standing instructions के रूप में encode करता है।

Related terms

Agentic CodingCLAUDE.mdAI Pair ProgrammingVibe Coding

Master Claude Code in days, not months

37 hands-on lessons from beginner to CI/CD automation. Module 1 is free.

START FREE →
← ALL TERMS