Sub-Agents
Sub-agents parallel child processes हैं जिन्हें एक main AI coding agent एक complex task के independent हिस्सों को simultaneously handle करने के लिए spawn करता है। सब कुछ sequentially process करने के बजाय, main agent specialized child agents को sub-tasks delegate करता है जो parallel में चलते हैं और parent को results report करते हैं।
Sub-agents कैसे काम करते हैं
जब main agent को multiple independent parts वाले task का सामना होता है, तो वह उन्हें parallel में handle करने के लिए sub-agents spawn कर सकता है। उदाहरण के लिए, यदि आप पूछते हैं "authentication, payment और notification modules को नए error handling pattern का उपयोग करने के लिए refactor करो," तो main agent तीन sub-agents spawn कर सकता है — प्रत्येक module के लिए एक। प्रत्येक sub-agent relevant files पढ़ता है, independently बदलाव करता है और tests चलाता है। Main agent results collect करता है और changes में consistency ensure करता है।
Sub-agents कब useful होते हैं
- +Large refactoring tasks जो multiple independent modules span करते हैं
- +Codebase के different parts simultaneously research करना
- +Multiple analysis tasks (security audit, performance check, style review) parallel में चलाना
- +Multiple independent components के लिए एक साथ code generate करना
- +Complex bugs investigate करना जिनके multiple root causes हो सकते हैं
Sub-agents तब सबसे effective होते हैं जब sub-tasks truly independent हों — वे same files modify नहीं करते या एक-दूसरे के output पर depend नहीं करते। जब tasks में dependencies हों, तो conflicts avoid करने के लिए single agent द्वारा sequential execution अधिक appropriate है।
Claude Code अपने Task tool के माध्यम से sub-agents support करता है। Main agent specific instructions और scoped permissions के साथ child agents spawn कर सकता है, फिर उनके results को एक coherent response में synthesize करता है।
क्या sub-agents main agent के साथ context share करते हैं?+
एक साथ कितने sub-agents run कर सकते हैं?+
क्या sub-agents अपने खुद के sub-agents spawn कर सकते हैं?+
मुझे sub-agents कब avoid करने चाहिए?+
Master Claude Code in days, not months
37 hands-on lessons from beginner to CI/CD automation. Module 1 is free.
START FREE →