📡Learn-in-Depth
ارجع لـ الزتونة📅 2026-06-1114 دقايق قراءة

زتونة Claude Code — كل الأوامر والسيناريوهات في صفحة واحدة

#claude-code#anthropic#cli#coder-agents

الأداة اللي ولّعت سوق الـ terminal agents كله لما Anthropic أطلقتها في فبراير 2025. الفكرة ببساطة: تفتح terminal جوه مشروعك، تكتب اللي عايزه بالعربي أو بالإنجليزي، وهو يقرا ويعدّل ويشغّل ويصلّح لحد ما يخلّص. الزتونة الكاملة أهي — من التثبيت للاحتراف.

التثبيت وأول تشغيلة

الأمر بيعمل إيه
npm install -g @anthropic-ai/claude-code التثبيت (Node 18+)
brew install claude-code التثبيت عبر Homebrew (macOS)
claude يفتح session تفاعلية في المجلد الحالي
claude "اشرحلي الـ repo ده" session بتبدأ بسؤال جاهز
claude -p "ولّد commit message" وضع non-interactive — يرد ويخرج (مفيد للـ scripts)
claude -c يكمّل آخر محادثة في المشروع ده
claude -r يفتحلك قايمة المحادثات القديمة تختار منها
claude update تحديث النسخة
claude --version التأكد من النسخة

الـ slash commands — كلها

إدارة الـ Session

الأمر Alias بيعمل إيه السيناريو
/help ? كل الأوامر المتاحة نسيت أمر
/clear يمسح الـ context ويبدأ صفحة بيضا بين tasks مختلفة
/compact يلخّص المحادثة عشان يفضّي context tokens الشغلانة طويلة
/model تبديل الموديل (Opus / Sonnet / Haiku) محتاج موديل أقوى/أرخص
/cost فلوس الـ session راحت في إيه تحكم في التكلفة
/status الحالة الحالية: model، cost، token usage check-up سريع
/settings إعدادات الـ configuration تعديل settings
/profile تبديل بين profiles مختلفة مشاريع مختلفة
/exit أو Ctrl+D /quit, q خروج خلاص شغلت النهاردة

إدارة الـ Context (أهم حاجة!)

الأمر بيعمل إيه السيناريو
/files ملفات Claude بيتابعها دلوقتي شوف إيه اللي في الـ context
/add <file> يضيف ملف للـ context ملف مهم مش متابعه
/drop <file> يشيل ملف من الـ context يفضّي مساحة
/grep <pattern> بحث في الـ codebase (rg/grep wrapper) دور على حاجة
/find <name> دور على ملف بالاسم "فين الـ auth file؟"
/read <file> اقرا ملف معين تأكد من محتوى ملف
/tree شجرة المجلدات للمشروع فهم structure

العمليات على الـ Code

الأمر بيعمل إيه السيناريو
/edit <file> يفتح ملف للتعديل مع instructions عدّل ده
/diff التغييرات اللي Claude عملها review قبل الـ commit
/undo يرجّع آخر تعديل غلطت
/redo يعيد تعديل متراجع تراجع غلط
/review code review للتغييرات review من AI
/lint يشغّل linter على التغييرات تأكد من quality
/test يشغّل tests للـ context تأكد إن مفيش حاجة اتكسر
/commit stage + commit بـ AI-generated message commit سريع

الذاكرة والـ Configuration

الأمر بيعمل إيه السيناريو
/init يولّد CLAUDE.md — ذاكرة المشروع مشروع جديد
/memory تعديل ملفات الذاكرة (CLAUDE.md) update conventions
/permissions مين مسموحله يعمل إيه تحكم في الصلاحيات
/agents إدارة الـ subagents delegate شغل
/hooks أوامر بتتنفّذ أوتوماتيك قبل/بعد tools automation
/mcp حالة الـ MCP servers المتوصلة check integrations
/bash ينفّذ bash command مباشرة run حاجة سريعة

Plan Mode (للـ Tasks الكبيرة)

الأمر Alias بيعمل إيه
/plan /p يدخل Plan Mode
/execute ينفّذ الخطة الحالية
/next ينفّذ الخطوة الجاية
/skip يتخطّى الخطوة الحالية
/abort يلغي الخطة كلها
/edit-plan يعدّل الخطة
/show يعرض الخطة الحالية

Advanced / Hidden

الأمر بيعمل إيه
/editor يفتح current task في الـ $EDITOR
/debug toggle debug mode (يظهر tool calls)
/export يحفظ المحادثة كـ JSON
/tokens token breakdown per message
/vim وضع vim للكتابة
/delegate "<task>" spawn subagent
/agent <id> switch لـ subagent
/kill <id> قفّل subagent
/merge <id> ادمج نتيجة subagent

حركات الكيبورد

Input Shortcuts

الزرار بيعمل إيه
Ctrl+C يوقف الـ generation في نص الشغل
Ctrl+D يقفّل Claude Code (زي /exit)
Tab autocomplete للـ paths والـ commands
↑/↓ navigate في تاريخ الأوامر
Ctrl+R بحث في تاريخ الأوامر
Ctrl+L يفضّي الشاشة
Shift+Enter new line في multi-line input

Approval Shortcuts (لما Claude يسألك)

الزرار بيعمل إيه
y أو Enter Yes / Approve مرة واحدة
n No / Deny
a Yes to all (لـ بقية الـ session)
d Show diff قبل ما تقرر
e Edit الـ command قبل التنفيذ
q Quit approval و cancel

Power User Shortcuts

الزرار بيعمل إيه
Esc يوقف الـ agent (pause، مش quit)
Esc مرتين يرجّع المحادثة لورا — تعدّل رسالة قديمة
Shift+Tab تبديل أوضاع الصلاحيات (normal → auto-accept → plan)
# في أول السطر يضيف note للـ CLAUDE.md على طول
! في أول السطر ينفّذ bash command والنتيجة تيجي في المحادثة
@ mention ملف — autocomplete للـ paths

Approval Modes (أمان!)

Full Approval (Default) — الأمان

  • كل file write: y/n
  • كل shell command: y/n
  • كل external API: y/n
  • استخدمه في: production codebases

Partial Approval — التوازن

  • File reads: automatic
  • File writes: محتاج approval
  • Shell commands: محتاج approval
  • استخدمه في: active development

No Approval (--no-approval) — الخطر ⚠️

  • كل حاجة بتتنفّذ أوتوماتيك
  • استخدمه في: isolated containers/test environments بس!
  • مينفعش في: جهازك الأساسي أبداً

الـ CLI Flags — كلها

Flag Alias بيعمل إيه السيناريو
--help -h help
--version -v النسخة
--model <model> يبدأ بموديل معين --model opus
--debug debug mode من البداية
--no-approval auto-approve كل حاجة ⚠️
--approval-mode <mode> full / partial / none
--profile <name> يبدأ بـ profile معين
--plan يبدأ في Plan Mode
--verbose verbose output
--no-color يشيل الألوان
--context <file> preload ملف في الـ context
--execute <command> يشغّل command واحد ويخرج CI/CD
--silent بدون TUI — output بس scripting
--batch <file> يشغّل sequence من JSON automation
--offline بدون network (limited)
--recover يسترجع session بعد crash

الـ Configuration

ملفات الـ Config

الملف الغرض
~/.claude/config.json Global user configuration
~/.claude/profiles/<name>.json Profile-specific
./.claude/settings.json Project-specific
./.claude/ignore Files to ignore (زي .gitignore)

مثال على config.json

{
  "model": "claude-3-7-sonnet",
  "approvalMode": "full",
  "autoUpdate": true,
  "theme": "dark",
  "editor": "vim",
  "maxContextTokens": 200000,
  "shell": "/bin/zsh",
  "aliases": {
    "test": "npm test",
    "build": "npm run build"
  }
}

Environment Variables

Variable الغرض
ANTHROPIC_API_KEY API key (مطلوب)
CLAUDE_MODEL Default model
CLAUDE_DEBUG Enable debug
CLAUDE_NO_COLOR Disable colors
CLAUDE_EDITOR Default editor
CLAUDE_SHELL Default shell
CLAUDE_PROFILE Default profile

Plan Mode — Deep Dive

إمتى تستخدمه: أي task > 3 files أو > 5 steps

إزاي يشتغل:

  1. Describe Goal: إنت بتقول عايز إيه
  2. Claude Proposes Plan: numbered list من الخطوات
  3. Review & Edit: تقدر تعدّل، تررّتب، أو تمسح
  4. Execute: ينفّذ خطوة خطوة مع approval
  5. Checkpoint: بعد كل خطوة: /undo، /skip، /abort

مثال:

> /plan
> Refactor all callback-style async code in src/ to async/await

Claude:
Plan:
1. Identify all files with callback patterns
2. Convert each to async/await
3. Run tests to verify
4. Handle edge cases

> /execute
[Claude ينفّذ خطوة 1… approval… خطوة 2… approval…]

Subagents — التفرّع

Claude Code يقدر يعمل subagents — instances منفصلة بتشتغل tasks parallel:

الأمر بيعمل إيه
/delegate "<task>" --name <name> Spawn subagent
/agents List active subagents
/agent <id> Switch لـ subagent
/kill <id> قفّل subagent
/merge <id> ادمج results في main

أنماط:

  • Parallel: Subagents على files مختلفة في نفس الوقت
  • Sequential: Subagent يخلّص → results ترجع للـ parent
  • Hierarchical: Parent → subagent → sub-subagent

Hooks — أتمتة

Git Hooks

claude --install-hook pre-commit
Hook بيعمل إيه
pre-commit Claude reviews staged changes قبل commit
post-commit Claude يولّد PR description
prepare-commit-msg Claude يكتب commit message

Custom Hooks

ضيف في ./.claude/hooks/:

#!/bin/bash
# .claude/hooks/before-edit
npm run lint -- --fix
Event بيتنفّذ إمتى
before-edit قبل ما Claude يعدّل أي ملف
after-edit بعد التعديل
before-command قبل shell command
after-command بعد shell command
before-commit قبل commit

MCP (Model Context Protocol)

Built-in MCP Servers

Server إمكانية
filesystem Read/write local files
shell Execute shell commands
git Git operations
github GitHub API
fetch HTTP requests
browser Web browsing

Custom MCP Servers

أنشئ ~/.claude/mcp.json:

{
  "mcpServers": {
    "postgres": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-postgres"],
      "env": { "DATABASE_URL": "postgresql://..." }
    },
    "slack": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-slack"],
      "env": { "SLACK_TOKEN": "xoxb-..." }
    }
  }
}

السيناريوهات العملية

سيناريو 1: Refactoring (Plan Mode)

> /plan
> Refactor all callback-style async code in src/ to async/await
[Claude يخطط… إنت توافق… /execute]

سيناريو 2: Debugging

> The tests in auth.test.js are failing. Find and fix the bug.
Claude: I'll run the tests, analyze the error, and trace through...
[يقرا → يشغّل → يلاقي الـ bug → يصلّح → يختبر]

سيناريو 3: Code Review

> Review the changes in this branch for security issues
> /diff
Claude: Analyzing 12 changed files... Found 2 potential SQL injection vectors...

سيناريو 4: Documentation

> Generate API documentation from the OpenAPI spec and update the README
[Claude يقرا الـ spec → يولّد docs → يعدّل README]

سيناريو 5: Learning a Codebase

> Explain the architecture of this project. Start with the entry points.
> @src/main.js what does this do?
> /tree

سيناريو 6: Test Generation

> Write comprehensive tests for src/services/payment.js
> Coverage should include edge cases and error handling
[Claude يكتب tests → يشغّلهم → يصلّح edge cases]

سيناريو 7: CI/CD Integration (Non-interactive)

# Non-interactive mode للـ CI
claude --execute "Review the PR diff and report issues" --no-approval < diff.patch

سيناريو 8: Multi-tasking (Subagents)

> /delegate "Audit all API routes for missing auth checks" --name security-audit
> Meanwhile, refactor the database layer to use connection pooling
[Subagent بيشتغل security + Claude بيشتغل refactor في نفس الوقت]

سيناريو 9: Cost Control

> /cost
Session cost: $0.18 · 42.3k tokens

> /compact
[يلخّص المحادثة → يفضّي context → يكمل]

سيناريو 10: Custom System Prompt

# في ~/.claude/prompts/custom.md:
You are a senior Rust engineer. Always suggest idiomatic solutions.

> /prompt custom
> Rewrite this Go function in Rust

Hidden / Lesser-Known Features

# الحركة إزاي
1 Silent mode claude --silent < script.txt — بدون TUI
2 Batch mode claude --batch commands.json — sequence من commands
3 Export conversation /export > session.json — save للتحليل
4 Import context claude --context previous-session.json
5 Custom prompts ~/.claude/prompts/custom.md + /prompt custom
6 Workspace presets claude --save-preset "react-app" + --load-preset
7 Token analytics /tokens — per-message breakdown
8 Diff side-by-side /diff --side-by-side
9 Auto-save يحفظ sessions في ~/.claude/sessions/--recover بعد crash
10 Network isolation claude --offline — limited functionality
11 Plugin system claude --plugin @anthropic-ai/plugin-eslint
12 @-mentions @src/utils/helpers.js أو @UserController — focus على code

Troubleshooting

المشكلة الحل
"Context full" /compact أو /clear
Slow responses /drop للـ files اللي مش محتاجها
Wrong file edits /undo + أكون أكتر specificity
Claude not finding files /add تضيفهم显式
Approval fatigue approval mode = partial
API errors تأكد من ANTHROPIC_API_KEY
"Permission denied" تأكد من الصلاحيات أو استخدم sudo

نصيحة الزتونة

أهم 3 حاجات بتفرق في الإنتاجية (بالترتيب):

  1. CLAUDE.md كويس — اكتب فيه conventions، commands، architecture بتاعة مشروعك
  2. /clear بين الـ tasks — context نضيف = قرارات أحسن
  3. Plan Mode للحاجات الكبيرة/plan → يخطط → إنت توافق → ينفّذ

Golden Rules:

  • استخدم /compact كل 20-30 turn في sessions الطويلة
  • استخدم /add تثبت الملفات المهمة في context
  • استخدم @mentions تركز Claude على code معين
  • استخدم Subagents للـ parallelizable research
  • استخدم Hooks لـ automated lint/test قبل commit

Claude Code vs GitHub Copilot CLI:

Claude Code Copilot CLI
الفكرة "صلّحلي الـ bug" "عايز أعمل إيه؟"
الـ workflow يقرا → يعدّل → يختبر → يصلّح يولّد command → إنت تنفّذ
Multi-file ✅ Deep ❌ One-shot
Plan mode
Subagents
Cost tracking
Git integration ✅ Deep ✅ Surface

جرّب الـ demo اللي تحت وشوف الـ workflow بنفسك. كل الزتونات عندنا والمقارنة الكاملة في صفحة الـ Models.

جرّب بنفسك — Terminal تفاعلي
# دوس Play وشوف الأوامر بتشتغل قدامك…

🔗 المصادر

🧭 مرتبط بالموضوع ده