Home / Glossary / Prompt Engineering for Code
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"
# 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 ज़रूरी है?+
सबसे common prompt engineering mistake क्या है?+
क्या code prompts में few-shot examples use करने चाहिए?+
CLAUDE.md files का prompt engineering से क्या संबंध है?+
Master Claude Code in days, not months
37 hands-on lessons from beginner to CI/CD automation. Module 1 is free.
START FREE →