Claude Code में Multi-agent workflow: भूमिकाएँ, अलग worktree और मानव समीक्षा
Claude Code में multi-agent code review के लिए भूमिकाओं का विभाजन, context और filesystem isolation, handoff contract और मानव की अंतिम स्वीकृति।
पूरी तरह autonomous “AI agent team” बनाकर code को अपने-आप merge कर देना अक्सर architecture की छोटी गलतियों, एक ही बदलाव के चक्र और codebase की गुणवत्ता घटने का रास्ता खोलता है। दो agents का साथ चलना स्वतंत्र सत्यापन नहीं है। अगर Author ने तर्क की गलती की, तो उसी तरह के prompt और context वाला Reviewer उसे छोड़ सकता है।
विश्वसनीय multi-agent workflow में काम अलग होता है: implementation के लिए Author, स्वतंत्र जाँच के लिए Reviewer और merge का निर्णय लेने के लिए मानव Decision Maker। AI की गति उपयोगी है, पर branch को main में मिलाने का अधिकार अलग समीक्षा के बाद ही होना चाहिए।
1. Author, Reviewer और मानव की सीमाएँ तय करें
हर भूमिका का input और output पहले से तय रखें। इससे “किसने क्या मान लिया” जैसी अस्पष्टता कम होती है।
Author को scope से बाहर refactor करने की आवश्यकता नहीं होनी चाहिए। Reviewer का काम नया feature लिखना नहीं, बल्कि बदलाव और उसके failure modes को स्वतंत्र रूप से देखना है। मानव निर्णयकर्ता तय करता है कि जोखिम स्वीकार्य है या task वापस भेजना चाहिए।
2. Context और workspace को अलग रखें
Author और Reviewer को एक ही working directory या एक ही conversation thread में न चलाएँ। तीन स्तरों पर isolation रखें:
- Session context: अलग threads mutual confirmation और circular reasoning को कम करते हैं।
- Filesystem: अलग Git worktrees में Reviewer केवल उस branch और recorded diff को देखता है, किसी दूसरे dirty state को नहीं।
- Environment security: API Key और runtime credentials environment variables में रखें; उन्हें prompt, handoff card या chat transcript में न डालें।
Worktree तैयार करने के commands
हर Claude Code session के लिए अपना API Key प्रयोग करें। API Key, Base URL और model mapping को current BetterToken Claude Code Docs से जाँचें; configuration को repository या handoff में copy न करें।
3. Structured handoff card दें
Author के पूरा करने पर एक छोटा handoff card बनता है। इसमें raw conversation, secrets और अप्रमाणित निष्कर्ष नहीं होने चाहिए। Reviewer को चलाने योग्य command और बदली हुई files चाहिए, पूरी agent history नहीं।
Handoff Card
- Task: Add HTTP 429 retry support in payment client with exponential backoff.
- Branch:
feat/payment-retry - Changed Files:
src/client/http.ts,tests/http-retry.test.ts - Verification Command:
npm test -- tests/http-retry.test.ts(Passed) - Risks & Blockers: Exponential backoff capped at 3 attempts; socket timeout left unchanged.
- Next Step: Reviewer agent validates Retry-After header handling.
4. मानव की अंतिम स्वीकृति रखें
Reviewer isolated worktree में जाता है, verification command चलाता है, side effects और regressions के लिए diff पढ़ता है और lead engineer को structured summary देता है। उसके बाद मानव:
- reviewer की findings पढ़ता है;
- CI status और
mainके साथ conflict देखता है; - स्वीकार्य होने पर branch को खुद merge करता है।
यह प्रक्रिया perfect correctness की guarantee नहीं देती। इसका उद्देश्य assumptions को अलग रखना, evidence को repeat करना और code ownership को मानव के पास रखना है। API usage के लिए अपना BetterToken account और API Key बनाएँ, फिर request status तथा input, output और cache Token usage को Dashboard में जाँचें।