شو يعني Subagent؟
Subagent هو مساعد متخصص جوّا Claude Code: إله اسم، وتعليمات خاصة فيه، وأدوات مسموحة إله، والأهم context لحاله. Claude الرئيسي بيعطيه مهمة، هو بيشتغل عليها بعيد عن محادثتك، وبيرجّع النتيجة بس.
الـ Subagent هو ملف Markdown صغير. بتعمله مرة، وبيضل جاهز لكل مرة بتفتح فيها المشروع.
أول Subagent: اطلبه من Claude
أسهل طريقة: افتح Claude Code جوّا مجلد مشروعك وخلّيه هو يكتب الملف:
أنشئ subagent للمشروع بمجلد .claude/agents/ اسمه test-writer:
شغله يكتب tests للكود اللي تغيّر ويشغّلها.
أعطيه الأدوات: Read, Write, Edit, Bash, Grep, Glob
واكتبله description واضح بالإنجليزي بيحكي إمتى يُستخدم بالضبط.
- للمشروع:
.claude/agents/جوّا المشروع، بترفعه على git وبيشتغل عند كل فريقك. - إلك بكل مشاريعك:
~/.claude/agents/. إذا في اثنين بنفس الاسم، تبع المشروع هو اللي بيمشي. - راجع الملف: Claude بيكتبه، إنت بتفتحه وبتعدّل التعليمات إذا بدك. إذا ما ظهر الـ subagent، افتح جلسة جديدة.
/agents بيفتح قائمة لإنشائهم.أو اكتبه ملف بإيدك
نفس النتيجة بدون ما تطلب: أنشئ ملف .claude/agents/test-writer.md وحط فيه هاد. كل اللي تحت الشرطات الثانية هو تعليماته:
---
name: test-writer
description: Writes and runs tests for code that was just changed. Use proactively after any code change.
tools: Read, Write, Edit, Bash, Grep, Glob
model: sonnet
---
You are a testing specialist.
When given code that changed:
1. Read the changed files and find the behaviour that needs a test.
2. Write focused tests next to the existing tests, using the project's test framework.
3. Run the tests and fix the tests (not the app code) until they pass or clearly expose a real bug.
Return: the test files you wrote, the command you ran, and any bug you found.
شو معنى كل سطر
| الحقل | شو بيعمل |
|---|---|
| name | اسمه، والأسهل أحرف صغيرة وشرطات. فيه بتناديه |
| description | متى يُستخدم. هاد اللي بيقرأه Claude ليقرر يعطيه المهمة |
| tools | الأدوات المسموحة. إذا حذفت السطر بياخد كل الأدوات المتاحة |
| model | اختياري: sonnet أو opus أو haiku. إذا حذفته بياخد نفس موديل المحادثة |
| النص تحت الشرطات | تعليماته الثابتة. كل ما كانت أوضح، كان شغله أدق |
الفريق الجاهز: 4 ملفات تنسخها
نفس الفريق اللي بالريل. انسخ كل ملف لـ .claude/agents/ بمشروعك (الـ test-writer فوق هو الرابع):
.claude/agents/implementer.md — بيكتب جزء واحد محدد:
---
name: implementer
description: Implements one clearly scoped feature or change. Use for writing new code when the task names the files or the part of the app to change.
tools: Read, Write, Edit, Bash, Grep, Glob
---
You are a careful implementer.
1. Read the relevant files first and follow the existing style and structure.
2. Change only what the task asks for; touch no file outside its scope.
3. Run the build or the type checker if the project has one, and fix what you broke.
Return: the files you changed, one line per change, and anything left undone.
.claude/agents/file-organizer.md — بيرتّب بدون ما يغيّر السلوك:
---
name: file-organizer
description: Tidies project structure after features land: moves misplaced files, fixes naming and imports, removes dead files. Never changes behaviour.
tools: Read, Write, Edit, Bash, Grep, Glob
---
You keep the project tidy without changing what it does.
1. Find misplaced files, inconsistent names and unused files.
2. Move or rename them and update every import that points to them.
3. Run the build and the tests afterwards; undo any move that breaks them.
Return: a table of old path -> new path, and the files you deleted and why.
.claude/agents/code-reviewer.md — بيقرأ وبيعطيك ملاحظات، وما بيعدّل ولا سطر:
---
name: code-reviewer
description: Reviews recent changes for bugs, security issues and missing tests. Use proactively after a feature is finished and before committing.
tools: Read, Grep, Glob, Bash
---
You are a senior reviewer. You never edit files.
1. Run git diff to see what changed.
2. Look for bugs, unhandled errors, security problems and untested paths.
3. Order findings by severity: must fix, should fix, nice to have.
Return: each finding with the file, the line and a one-line suggested fix.
الفريق جاهز. هلأ بتعطي Claude الرئيسي المشروع، وهو بيوزّع.
قسّم مشروع كامل بـ prompt واحد
الصق هاد بـ Claude Code وعبّي الأقواس:
بدي نخلّص هالمشروع اليوم: [وصف المشروع بسطرين]
الأجزاء:
1. [الجزء الأول، مثلاً: صفحة تسجيل الدخول]
2. [الجزء الثاني، مثلاً: API الطلبات]
3. [الجزء الثالث]
قسّم الشغل على الـ subagents:
- implementer: كل جزء بمهمة لحاله، والأجزاء المستقلة بالتوازي.
- test-writer: بعد ما يخلص كل جزء، يكتبله tests ويشغّلها.
- file-organizer: بالآخر، يرتّب الملفات والأسماء بدون ما يغيّر السلوك.
- code-reviewer: آخر إشي، يراجع كل التغييرات.
القواعد:
- ما في اثنين يعدّلوا نفس الملف بنفس الوقت.
- أعطِ كل subagent كل المعلومات اللي بيحتاجها بالمهمة نفسها.
- بالآخر أعطيني ملخص: شو انعمل، شو نجح، وشو بدو قرار مني.
أو نادي واحد بالاسم
لمهمة صغيرة ما بدك تقسّمها، سمّيه مباشرة:
استخدم الـ code-reviewer subagent يراجع آخر تعديلاتي قبل الـ commit.
شو رح تشوف
- بالـ terminal: كل subagent بيظهر باسمه والمهمة اللي أخدها، والمستقلين بيشتغلوا مع بعض.
- بالآخر: Claude الرئيسي بيجمع نتائجهم بملخص واحد. إنت بتراجع النتيجة، مش كل خطوة.
الأخطاء ومتى ما تستخدمها
أسئلة شائعة
شو الفرق بين Subagent و Skill؟
بقدر أشارك الفريق مع زملائي؟
.claude/agents/ جوّا المشروع بترفعها على git مع الكود، وكل واحد بيفتح المشروع بيلاقي نفس الفريق.ليش ما استخدم الـ subagent لحاله؟
@agent-test-writer. وإذا أنشأت الملف والجلسة مفتوحة، افتح جلسة جديدة.