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 पहले से तय रखें। इससे “किसने क्या मान लिया” जैसी अस्पष्टता कम होती है।

भूमिकामुख्य जिम्मेदारीInputOutput
Author Agentcode implementation और स्थानीय unit testtask, acceptance criteriaGit branch, diff, focused test
Reviewer Agentedge case और regression checkdiff, handoff card, verification commandPass/Block review checklist
Human Decision Makerarchitecture की स्वीकृति और अंतिम mergereviewer summary, CI statusmain में manual merge

Author को scope से बाहर refactor करने की आवश्यकता नहीं होनी चाहिए। Reviewer का काम नया feature लिखना नहीं, बल्कि बदलाव और उसके failure modes को स्वतंत्र रूप से देखना है। मानव निर्णयकर्ता तय करता है कि जोखिम स्वीकार्य है या task वापस भेजना चाहिए।

2. Context और workspace को अलग रखें

Author और Reviewer को एक ही working directory या एक ही conversation thread में न चलाएँ। तीन स्तरों पर isolation रखें:

  1. Session context: अलग threads mutual confirmation और circular reasoning को कम करते हैं।
  2. Filesystem: अलग Git worktrees में Reviewer केवल उस branch और recorded diff को देखता है, किसी दूसरे dirty state को नहीं।
  3. Environment security: API Key और runtime credentials environment variables में रखें; उन्हें prompt, handoff card या chat transcript में न डालें।

Worktree तैयार करने के commands

git worktree add ../agent-author -b feat/payment-retry git worktree add ../agent-reviewer feat/payment-retry

हर 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.
`Passed` केवल Author का recorded result है। Reviewer उसी command को अपने clean worktree में फिर चलाता है और `Retry-After` जैसे edge case को अलग से देखता है। अगर command fail होती है, source unclear है या diff में unrelated change है, handoff `Block` हो सकता है।

4. मानव की अंतिम स्वीकृति रखें

Reviewer isolated worktree में जाता है, verification command चलाता है, side effects और regressions के लिए diff पढ़ता है और lead engineer को structured summary देता है। उसके बाद मानव:

  1. reviewer की findings पढ़ता है;
  2. CI status और main के साथ conflict देखता है;
  3. स्वीकार्य होने पर branch को खुद merge करता है।
git merge feat/payment-retry

यह प्रक्रिया perfect correctness की guarantee नहीं देती। इसका उद्देश्य assumptions को अलग रखना, evidence को repeat करना और code ownership को मानव के पास रखना है। API usage के लिए अपना BetterToken account और API Key बनाएँ, फिर request status तथा input, output और cache Token usage को Dashboard में जाँचें।

अपना LLM वर्कफ़्लो बेहतर बनाना चाहते हैं?

एक API से मॉडल जोड़ें, कुंजियाँ प्रबंधित करें और AI खर्च नियंत्रित करें।