Tips & Tricks

Claude Code से बेहतर रिजल्ट पाने की 5 Prompt Techniques [उदाहरणों के साथ]

इन 5 आजमाई हुई prompt techniques से Claude Code की output quality को dramatically improve करें। Before/After examples और practical code snippets शामिल हैं जो आप आज से ही use कर सकते हैं।

Introduction

Claude Code की output quality सीधे तौर पर इस बात पर depend करती है कि आप अपने prompts कैसे लिखते हैं। सही technique के साथ, एक ही task “unusable code” से “production-ready code” में बदल सकता है।

इस article में, हम Before/After examples के साथ पाँच practical prompt techniques को detail में explain करेंगे जो आप तुरंत use करना शुरू कर सकते हैं। अगर आप Claude Code में नए हैं, तो पहले getting started guide देखें।

1. Specific Context दें

सबसे effective technique है अपने task की background और purpose को clearly communicate करना। Claude Code आपकी project files read कर सकता है, लेकिन आपका mind नहीं पढ़ सकता। सिर्फ क्या चाहिए यह नहीं, बल्कि क्यों चाहिए यह भी बताएं, और output accuracy dramatically improve होगी।

Before (कमज़ोर prompt):

Login feature बनाओ

After (मज़बूत prompt):

इस Next.js 14 App Router project में email/password authentication login add करो।
API routes पहले से src/app/api/ में हैं, और user table Prisma + PostgreSQL से defined है।
Auth library NextAuth.js v5 use करनी है।

Before (कमज़ोर prompt):

Bug fix करो

After (मज़बूत prompt):

src/components/UserList.tsx में bug fix करो जहाँ useEffect में user list fetch
करते समय component unmount होने के बाद setState call हो रहा है।
AbortController use करके cleanup logic add करो।

2. Tasks को Steps में Divide करें

जब आप Claude Code को एक massive task एक साथ देते हैं, तो वह big picture खो सकता है। Complex work को intentionally stages में split करें और अगले step पर जाने से पहले हर step complete होने की confirm करें।

Before (कमज़ोर prompt):

पूरा product management system बनाओ। Listing, detail, create, edit, delete,
image upload, category management, inventory management, और search filtering सब चाहिए।

After (मज़बूत prompt):

Product management stages में बनाते हैं। Step 1 के लिए,
product CRUD API create करो:

- POST /api/products (create)
- GET /api/products (list with pagination)
- GET /api/products/:id (detail)
- PUT /api/products/:id (update)
- DELETE /api/products/:id (delete)

Validation के लिए zod use करो और src/lib/db.ts में existing Prisma client use करो।

Before (कमज़ोर prompt):

सारे tests लिख दो

After (मज़बूत prompt):

src/utils/calculatePrice.ts के unit tests लिखो।
पहले happy-path cases से शुरू करो और ये cover करो:
- Base price calculation
- Discount rates (10%, 20%, 50%)
- Tax-inclusive calculation (10% tax rate)
Vitest use करो और tests/ directory के existing patterns follow करो।

3. Expected Output Format Specify करें

Programming language, framework, coding style और अन्य format expectations को explicitly state करने से rework significantly कम होता है। TypeScript type definitions और error-handling patterns के बारे में especially clear रहें।

Before (कमज़ोर prompt):

API client बनाओ

After (मज़बूत prompt):

src/lib/api-client.ts में external payment API के लिए client class बनाओ।

Requirements:
- TypeScript strict mode compatible type definitions
- fetch-based (axios नहीं)
- Custom error class (PaymentApiError) for error handling
- Retry logic (max 3 attempts, exponential backoff)
- Generic response types
- सभी public methods पर JSDoc comments

Before (कमज़ोर prompt):

React component बनाओ

After (मज़बूत prompt):

src/components/DataTable.tsx में reusable table component बनाओ।

- Client component ("use client"), React Server Component नहीं
- Props generics से typed हों जो column definitions accept करें
- Sorting और pagination support
- Tailwind CSS से styled, src/components/Button.tsx के design tokens match करें
- Accessibility: proper WAI-ARIA table roles set करें

4. Existing Codebase Reference करें

Claude Code की सबसे बड़ी strength है कि यह आपके पूरे project को understand कर सकता है। इसे maximize करने के लिए explicitly instruct करें कि existing code follow करे। Specific file paths point करने से यह और भी effective हो जाता है।

Before (कमज़ोर prompt):

New API endpoint add करो

After (मज़बूत prompt):

src/app/api/users/route.ts के same pattern follow करते हुए,
src/app/api/orders/route.ts में order management API endpoint बनाओ।

Existing users API को match करो:
- Zod schema validation
- try-catch error handling pattern
- NextResponse return style
- Prisma query approach

Before (कमज़ोर prompt):

Settings page बनाओ

After (मज़बूत prompt):

src/app/dashboard/profile/page.tsx को reference के रूप में use करते हुए,
src/app/dashboard/settings/page.tsx create करो।

Same layout structure maintain करो (DashboardLayout component, Breadcrumb,
PageHeader usage) और notification settings और security settings के forms add करो।
Form management के लिए profile page जैसा ही react-hook-form + zod use करो।

5. Feedback Loop से Iteratively Improve करें

पहली बार में perfection expect मत करो। Claude Code के साथ conversation use करके incrementally quality improve करो। Initial output को foundation मानो और specific, actionable feedback दो।

Before (कमज़ोर prompt):

यह सही नहीं है, फिर से करो

After (मज़बूत prompt):

धन्यवाद। दो changes please:
1. handleSubmit function में network errors और validation errors को
   differentiate करो जब user को messages display हों
2. Simple spinner loading state को src/components/Skeleton.tsx
   के skeleton UI से replace करो

Before (कमज़ोर prompt):

और बेहतर बनाओ

After (मज़बूत prompt):

Performance improvements चाहिए। Specifically:
1. Product list rendering पर React.memo apply करो unnecessary re-renders रोकने के लिए
2. Search input में debounce (300ms) add करो
3. Images के लिए lazy loading implement करो
हर change point पर comments add करो ताकि मैं Lighthouse score impact assess कर सकूँ।

Conclusion

पाँच techniques का recap:

  1. Specific context provide करें ताकि Claude Code आपकी intent accurately समझे
  2. Tasks को steps में divide करें ताकि हर interaction का scope manageable रहे
  3. Output format specify करें ताकि rework minimize हो
  4. Existing code reference करें ताकि project consistency maintain हो
  5. Feedback से iterate करें ताकि quality incrementally बढ़े

हर technique अकेले भी effective है, लेकिन combine करने पर ये truly shine करती हैं। CLAUDE.md file में project rules लिखना हर prompt में include करने वाले context को reduce करता है, जिससे efficiency और बढ़ती है।

Advanced usage के लिए हमारे Claude Code productivity tips देखें।

Prompt engineering के foundational concepts के लिए Anthropic की official prompt engineering guide भी ज़रूर पढ़ें।

#prompts #techniques #productivity #Claude Code #prompt engineering