Claude Code और Codex के लिए उन्नत Prompt Engineering: काम आने वाला Task Brief
Claude Code/Codex के लिए task brief, acceptance criteria, context budget और सुरक्षित iteration loop की practical guide।
Claude Code या Codex से कभी बहुत अच्छा और कभी कमजोर परिणाम आता है, तो अक्सर समस्या मॉडल में नहीं होती। समस्या यह होती है कि काम कैसे सौंपा गया। Advanced prompt engineering कोई जादुई वाक्य नहीं है। यह workflow design है: लक्ष्य, scope, context, constraints, acceptance criteria, verification और handoff को एक ही काम के पैकेट में लिखना।
इस लेख में हम Claude Code/Codex के लिए reusable “prompt packet” बनाएंगे। नया उपयोगकर्ता template कॉपी करके शुरू कर सकता है, लेकिन pattern इतना मजबूत है कि team workflow, parallel editing, production code और published articles में भी काम आए। अगर basic prompt pattern चाहिए, तो पहले better prompts guide और CLAUDE.md best practices पढ़ें।
Tool behavior बदल सकता है, इसलिए product behavior पर दावा करते समय official docs देखें। Claude Code के लिए Claude Code overview, Memory और Anthropic का prompt engineering overview उपयोगी है। Codex के लिए OpenAI Codex docs और AGENTS.md guidance देखें।
Advanced का अर्थ है काम का contract
कमजोर prompt केवल छोटा नहीं होता। उसमें decision rules नहीं होते, यह नहीं लिखा होता कि कौन सी files नहीं छूनी हैं, “done” का अर्थ नहीं होता और अंत में proof नहीं मांगा जाता। तब agent अनुमान लगाता है।
एक practical prompt को छोटे work contract की तरह लिखें।
| हिस्सा | क्या लिखें | कमी होने पर failure |
|---|---|---|
| Goal | अपेक्षित परिणाम | उत्तर सही दिखता है, पर गलत समस्या हल करता है |
| Scope | क्या बदल सकता है और क्या नहीं | unrelated refactor diff में आ जाता है |
| Context | docs, similar code, official links | पुराना pattern या कल्पना इस्तेमाल होती है |
| Constraints | rules और forbidden changes | dependencies, API या tone बदल जाते हैं |
| Acceptance criteria | completion कैसे judge होगी | review taste पर निर्भर हो जाता है |
| Verification | commands और manual checks | काम proof के बिना खत्म होता है |
Anthropic का prompt engineering overview success criteria और empirical tests से शुरू करता है। Coding agents के लिए यह और जरूरी है, क्योंकि Claude Code और Codex files पढ़ सकते हैं, edit कर सकते हैं और commands चला सकते हैं।
Prompt packet को file में रखें
हर बार chat में लंबा prompt लिखना मुश्किल है। prompt-packet.md जैसी file task को repeatable और reviewable बनाती है। यह Bash snippet एक minimal packet बनाता है।
cat > prompt-packet.md <<'EOF'
# Goal
Improve one published article so it is practical, accurate, and ready for review.
# Scope
May edit:
- site/src/content/blog/example-article.mdx
Do not edit:
- heroImage
- slug
- unrelated articles
- package or deployment files
# Context to read
- AGENTS.md
- site/src/content/blog/claude-md-best-practices.mdx
- Official docs relevant to the article topic
# Constraints
- Preserve existing frontmatter keys unless this task explicitly changes them.
- Use copy-pasteable examples, not pseudocode.
- Avoid unsupported claims. Link to official docs for tool behavior.
- Keep paragraphs short enough for mobile reading.
# Acceptance criteria
- updatedDate is 2026-06-02.
- The article has at least three concrete use cases.
- The article names specific pitfalls and how to avoid them.
- The article includes an internal link, an official external link, and a natural CTA.
- The final section explains what was actually verified.
# Verification
- node scripts/check-code-fences.mjs
- node scripts/check-updated-article-quality.mjs
- Read the diff once as a critical reviewer.
# Return format
- Changed files
- Key improvements
- Checks run
- Residual risks
EOF
Agent को कहें: “पहले prompt-packet.md पढ़ें, target file और listed context inspect करें, फिर केवल Scope के अंदर काम करें।” यह extra ceremony नहीं है। यह agent को पड़ोसी pages, images, config या unrelated code बदलने से रोकता है।
Prompt को इस्तेमाल से पहले lint करें
Prompt prose है, इसलिए quality drift कर सकती है। छोटा checker missing structure पकड़ सकता है। इसे check-prompt-packet.cjs के रूप में save करें।
// save as check-prompt-packet.cjs
const fs = require("node:fs");
const file = process.argv[2] || "prompt-packet.md";
const text = fs.readFileSync(file, "utf8");
const required = [
"# Goal",
"# Scope",
"# Context to read",
"# Acceptance criteria",
"# Verification",
"# Return format",
];
const missing = required.filter((heading) => !text.includes(heading));
const hasDoNotTouch = /do not (edit|change|touch)/i.test(text);
const hasCommand = /npm run|npm test|pnpm |yarn |node scripts\//i.test(text);
if (missing.length || !hasDoNotTouch || !hasCommand) {
console.error("Prompt packet is not ready.");
if (missing.length) console.error("Missing headings: " + missing.join(", "));
if (!hasDoNotTouch) console.error("Add an explicit do-not-touch boundary.");
if (!hasCommand) console.error("Add at least one verification command.");
process.exit(1);
}
console.log("Prompt packet looks actionable.");
इसे ऐसे चलाएं।
node check-prompt-packet.cjs prompt-packet.md
यह छोटा है, पर उपयोगी है। Masa के article workflow में अधिकतर failure तब हुए जब “do not edit” boundary या final proof missing था। Product code में भी यही होता है। अगर prompt done की definition नहीं देता, reviewer को taste से निर्णय लेना पड़ता है।
Vague goals को acceptance criteria में बदलें
“बेहतर बनाओ”, “SEO मजबूत करो” और “production ready करो” अच्छे intent हैं, पर testable नहीं। इन्हें pass/fail criteria में बदलें।
कमजोर prompt:
इस article को improve करें और SEO भी strong करें।
बेहतर prompt:
Article को Claude Code शुरू करने वाले developers के लिए practical guide के रूप में rewrite करें।
Acceptance criteria:
- Title में "Claude Code" और "prompt engineering" हो।
- description 120 characters से कम हो।
- Body में कम से कम तीन concrete use cases हों।
- दो bad prompt examples और दो improved versions हों।
- Official docs और related internal articles के links हों।
- Final section बताए कि वास्तव में क्या verify किया गया।
- Edit के बाद code-fence check चलाकर result report करें।
Implementation task के लिए criteria technical बनाएं।
Acceptance criteria:
- Public API type न बदलें।
- Validation और user-visible error handling जोड़ें।
- कम से कम एक failing-path test add या update करें।
- npm test और npm run build चलाकर results report करें।
- Changed files और inspect की गई लेकिन unchanged relevant files explain करें।
Acceptance criteria agent को micromanage करने के लिए नहीं हैं। वे review standard पहले से share करते हैं।
Context budget तय करें
Claude Code Memory docs बताती हैं कि CLAUDE.md और auto memory context के रूप में load होते हैं, enforced configuration के रूप में नहीं। इसलिए लंबी instruction हमेशा बेहतर नहीं होती। लंबा context महत्वपूर्ण rule को छिपा सकता है।
Context को तीन layers में रखें।
| Layer | Example | कहाँ रखें |
|---|---|---|
| हमेशा जरूरी | build commands, naming rules, forbidden areas | CLAUDE.md या AGENTS.md |
| task-specific | target file, similar implementation, quality bar | prompt-packet.md |
| जरूरत पर पढ़ना | long specs, old notes, raw logs | सिर्फ file name दें |
Common trap है कि सब कुछ prompt में paste कर दिया जाए। Meeting notes, old design, logs और current task साथ हों, तो agent priority guess करेगा। Read order लिखें।
Context to read in order:
1. AGENTS.md for project rules.
2. The target article.
3. One similar high-quality article for tone and structure.
4. Official docs only for tool behavior.
Ignore:
- Old brainstorming notes unless they contradict the current implementation.
- Unrelated product pages.
- Generated files and build output.
यह exploration कम करता है। Parallel workers हों तो यह और जरूरी है, क्योंकि दिखाई देने वाली हर file edit permission नहीं होती।
Examples और constraints अलग रखें
Example दिखाता है कि कैसी shape चाहिए। Constraint boundary बताता है। दोनों मिलाने से prompt unclear हो जाता है।
कमजोर prompt:
इस page को productivity tips article जैसा बना दें।
बेहतर prompt:
Reference style:
- Use site/src/content/blog-hi/claude-code-productivity-tips.mdx only for section density and CTA placement.
- Do not copy its examples or claims.
Constraints:
- Keep this article focused on prompt engineering.
- Do not introduce pricing claims.
- Preserve heroImage and slug.
“कुछ मत तोड़ना” पर न रुकें। Positive boundary भी दें। “Libraries add मत करना” से बेहतर है “only existing dependencies use करें”। “बहुत मत बदलना” से बेहतर है “listed file only edit करें और public API preserve करें”।
Safe iteration loop मांगें
गंभीर काम में एक बड़ा prompt कम reliable होता है। एक loop लिखें।
- Target, rules और nearest good example पढ़ें।
- Short plan दें।
- Scope के अंदर edit करें।
- Commands और manual checks से verify करें।
- Changes, proof और risks report करें।
Prompt में यह लिख सकते हैं।
Workflow:
- First inspect the target file and the nearest quality reference.
- If the change is larger than two files, explain the plan before editing.
- Edit only the files listed in Scope.
- After editing, run the Verification commands if feasible.
- End with a verification receipt, not a general summary.
Verification receipt काम की रसीद है। विस्तार के लिए verification receipt workflow पढ़ें, लेकिन daily work के लिए यह format काफी है।
Verification receipt:
- Changed files:
- Commands run:
- Results:
- Manual checks:
- Could not verify:
- Residual risks:
चार practical use cases
पहला use case bug fix है। Symptom, reproduction steps, expected behavior, logs और allowed files दें। Agent से पहले likely cause explain करवाएं, फिर smallest fix और failing-path test मांगें। इससे केवल cosmetic fix से बचाव होता है।
दूसरा use case छोटा feature है। User-visible change, API/DB change की अनुमति, existing UI pattern और test proof लिखें। Contact form में category field जोड़ना हो, तो options, validation, submitted payload, analytics event और localization behavior भी criteria में रखें।
तीसरा use case article rewrite है। Reader, search intent, target length, required examples, failure cases, internal links, CTA और official sources दें। ClaudeCodeLab में यह इसलिए जरूरी है कि article केवल smooth summary न बने, बल्कि reader के लिए actionable guide बने।
चौथा use case code review है। Review prompt में creativity से ज्यादा output shape जरूरी है। Severity, file and line, reproduction condition, fix direction और missing tests मांगें। “सब देखो” की जगह security, data loss, public API changes और untested error paths prioritize करें।
Common failures
Failure 1: goals mix करना। “Refactor करो, speed बढ़ाओ, SEO सुधारो, CTA बदलो” कई jobs हैं। एक packet में एक goal रखें।
Failure 2: केवल prohibitions लिखना। “कुछ मत तोड़ना” यह नहीं बताता कि क्या कर सकते हैं। Forbidden और allowed areas दोनों लिखें।
Failure 3: पुरानी जानकारी को official behavior मानना। Claude Code, Codex, memory, settings और AGENTS.md behavior बदल सकते हैं। Official docs link करें और उनसे ज्यादा claim न करें।
Failure 4: verification optional रखना। Command नहीं चल सकती तो agent को यह report करना चाहिए। Silent gap से declared risk बेहतर है।
Failure 5: अच्छे prompts chat में छोड़ देना। काम करने वाली instructions को prompt-packet.md, CLAUDE.md या team review checklist में ले जाएं। Team handoff के लिए Claude Code team handoff rules देखें।
CTA: scale करने से पहले standardize करें
यह packet हर दिन फिर से लिखने की जरूरत नहीं है। Daily checks के लिए free cheatsheet से शुरू करें, reusable prompts के लिए products and templates देखें, और अगर team को real repository में CLAUDE.md, permissions, review, verification receipts और article quality rules सेट करने हैं, तो Claude Code training और consultation उपयोगी है।
इस लेख में मैंने क्या verify किया
इस लेख के लिए मैंने official Claude Code overview में यह पुष्टि की कि Claude Code codebase पढ़ सकता है, files edit कर सकता है और commands चला सकता है। Memory docs से CLAUDE.md, auto memory और enforced configuration के बीच फर्क की पुष्टि की। Anthropic prompt engineering overview से success criteria और tests पहले तय करने की जरूरत की पुष्टि की। Codex वाले हिस्से को OpenAI Codex docs और AGENTS.md guidance से align किया। Practical निष्कर्ष यह है कि prompt को one-off chat message नहीं, बल्कि reviewable work contract मानें।
मुफ़्त PDF: Claude Code cheatsheet
Email डालें और commands, review habits तथा safe workflow वाली एक-page PDF पाएँ.
हम आपका data सुरक्षित रखते हैं और spam नहीं भेजते.
लेखक के बारे में
Masa
Claude Code workflow और team adoption पर काम करने वाला engineer.
संबंधित लेख
Claude Code Permission Receipt Pattern: scope, proof और rollback लिखना
Claude Code के लिए permission receipt: allowed actions, approval boundary, verification commands, rollback note और revenue CTA checks।
Claude Code और Codex के लिए सुरक्षित Agent Harness: permissions, verification और rollback
Claude Code और Codex agents के लिए सुरक्षित harness: permissions, plan, verification और rollback.
Claude Code Subagents गाइड: article और code work को सुरक्षित तरीके से delegate करें
Claude Code subagents से article और code work बांटें: delegation rules, prompts, pitfalls, checklist और examples.