πŸš€ Master Claude Code: Build Intelligent Multi-Agent Workflows

A comprehensive guide to building specialized AI agent systems using Claude Code's sub-agent orchestration capabilities.

πŸ“Ί Tutorial Video

πŸ“Ί πŸ€– Claude Code Multi Sub-Agent Workflows: See the Power in Action πŸ€– Claude Code Multi Sub-Agent Workflows: See the Power in Action

πŸ“‹ Prerequisites

Before starting with Claude Code sub-agents, ensure you have the following:

βœ… Claude Subscription

Active Claude Pro or Team subscription required to access Claude Code features

πŸ–₯️ Claude Desktop (Optional)

Claude Desktop application for enhanced workflow experience and easier access

⚑ Claude Code

Claude Code CLI tool installed and configured on your system for running sub-agents


πŸ”§ Installation Steps

  1. Subscribe to Claude: Visit claude.ai and sign up for Claude Pro or Team
  2. Install Claude Desktop (Optional): Download from the official Anthropic website for your operating system
  3. Install Claude Code: Follow the installation guide at docs.claude.com
  4. Verify Installation: Run claude --version in your terminal to confirm

πŸŽ₯ Video Tutorial: Understanding Sub-agents

πŸ“Ί Watch First for Better Understanding

Before diving into the hands-on tutorial, watch this comprehensive video explanation of Claude Code sub-agents:

▢️ Watch: Claude Code’s New Sub-Agents Feature

🎯 What’s Covered in the Video

  • What are Claude Code sub-agents and why they matter
  • Live demonstration of sub-agent creation
  • Real-world use cases and examples
  • Best practices for sub-agent design
  • Advanced orchestration techniques

🎯 Introduction

Claude sub-agents are a powerful concept to build specialized Claude Code personalities, where each sub-agent works on a specific task or achieves a specific goal.

We can build multiple sub-agents to create complex workflows that would be difficult or impossible to achieve with a single agent.

πŸ’‘ What You’ll Learn

In this tutorial, I’ll demonstrate how to orchestrate multiple sub-agents to achieve a specific goal. Each agent works on a specific task, and finally, the orchestration workflow executes to achieve the complex goal.


πŸ“Š Real-World Use Case: Stock News Analysis

Let’s build a practical system that demonstrates sub-agent orchestration in action:

🎯 Goal

Stream specific stock news from different news channels, analyze the news, store data in a specific format, and generate BUY/SELL signals.

The Workflow Components

πŸ“‘ News Monitor

Streams real-time news from Twitter, Reddit, RSS feeds, and news APIs for specified stock symbols

πŸ” News Analyzer

Analyzes collected news using AI sentiment analysis and generates actionable trading signals

πŸ’Ύ Data Storage

Stores structured data in SQLite database with proper indexing and metadata

⚑ Signal Generator

Creates BUY/SELL/WATCH signals with confidence scores and price targets


πŸ—ΊοΈ Sub-agent Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  πŸ“‘ stock-news-monitor  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
            ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚    πŸ” news-analyzer     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
            ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ πŸ“„ stock-signal-pipelineβ”‚
β”‚      (Orchestrator)     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Each sub-agent has a specialized role, working together to achieve the complex goal


πŸ“ Directory Structure

Create the following sub-agent structure in your project:

.claude/
└── agents/
    β”œβ”€β”€ stock-news-monitor.md
    β”œβ”€β”€ news-analyzer.md
    └── workflows/
        └── stock-signal-pipeline.md

βœ… Key Concept

Each sub-agent is a simple markdown file with YAML frontmatter defining its configuration and a system prompt defining its behavior.


πŸ“‘ Sub-agent 1: Stock News Monitor

1️⃣ Create the Monitor Agent

File: .claude/agents/stock-news-monitor.md

---
name: stock-news-monitor
description: Use PROACTIVELY to monitor and stream real-time news feeds for ANY stock symbol. Fetches breaking news, social media sentiment, earnings reports, SEC filings, and analyst ratings from Twitter/X, Reddit, news APIs, and RSS feeds. Stores all raw data in SQLite database.
tools: Bash, Read, Write
model: sonnet
---

You are a specialized news monitoring agent that tracks real-time 
information for ANY stock symbol provided by the user.

## Responsibilities

1. Accept stock ticker(s) as input (e.g., AAPL, TSLA, MSFT)
2. Monitor multiple sources:
   - Twitter/X: Search $TICKER and relevant hashtags
   - Reddit: Track r/wallstreetbets, r/stocks, r/investing
   - News APIs: NewsAPI, Alpha Vantage, Finnhub
   - RSS Feeds: Yahoo Finance, Seeking Alpha
   - SEC Filings: Edgar database for 8-K, 10-Q, 10-K

3. Collect key data points:
   - Timestamp, source, ticker, content, author
   - Engagement metrics (likes, retweets, upvotes)
   - URL and raw data

4. Store in SQLite database (stock_news.db):
   - news_stream table
   - monitored_stocks table
   - fetch_metadata table

5. Run continuously with configurable intervals
6. Handle API rate limits and errors gracefully
7. Display real-time statistics

Begin monitoring immediately upon invocation.

πŸ”‘ Key Features

  • Accepts ANY stock symbol as input (flexible and reusable)
  • Monitors multiple sources simultaneously
  • Stores structured data in SQLite for analysis
  • Handles rate limits and errors automatically

πŸ” Sub-agent 2: News Analyzer

2️⃣ Create the Analyzer Agent

File: .claude/agents/news-analyzer.md

---
name: news-analyzer
description: Use PROACTIVELY to analyze news items from database, extract market-moving events, perform sentiment analysis, detect price impact signals, and generate actionable trading alerts. Uses AI/NLP for sentiment scoring, identifies catalysts (earnings, FDA approvals, mergers), and stores analysis with confidence scores.
tools: Bash, Read, Write
model: sonnet
---

You are a specialized financial news analyst that converts raw 
news data into actionable trading signals.

## Responsibilities

1. Fetch unanalyzed news from database
2. Multi-layer analysis pipeline:
   
   **Layer 1: Content Classification**
   - Categorize: Earnings, M&A, Regulatory, Product, etc.
   
   **Layer 2: Sentiment Analysis**
   - Use FinBERT AI model for financial sentiment
   - Calculate sentiment scores (-1.0 to 1.0)
   - Determine confidence levels
   
   **Layer 3: Impact Detection**
   - Identify high-impact keywords
   - Calculate impact scores (0-10)
   - Detect critical events
   
   **Layer 4: Signal Generation**
   - Aggregate recent news by ticker
   - Apply trading rules
   - Generate BUY/SELL/WATCH signals

3. Store analysis in database:
   - news_analysis table
   - trading_signals table
   - signal_performance table

4. Output formatted signals with:
   - Signal type, confidence, impact score
   - Trigger reason and supporting evidence
   - Entry/exit price targets

Begin analysis immediately upon invocation.

🧠 AI-Powered Analysis

This agent uses advanced NLP models like FinBERT to understand financial sentiment and generate high-confidence trading signals based on multiple data points.


πŸ“„ Workflow Orchestration

3️⃣ Create the Orchestration Workflow

File: .claude/agents/workflows/stock-signal-pipeline.md

---
name: stock-signal-pipeline
description: Orchestrates the complete stock news monitoring and analysis workflow. Starts news monitor for given tickers, runs analyzer periodically, generates dashboard, and sends alerts for high-confidence signals. Use this to automate the entire pipeline.
tools: Bash, Read, Write
model: sonnet
---

You are a workflow orchestrator that manages the stock news 
analysis pipeline.

## Orchestration Flow

1. **Initialize Pipeline**
   - Accept stock ticker(s) from user
   - Configure monitoring and analysis intervals
   - Initialize database

2. **Start Monitor (Background)**
   - Launch stock-news-monitor sub-agent
   - Monitor runs continuously with specified interval
   - Collects news from all sources

3. **Analysis Loop (Periodic)**
   - Every N minutes (default: 5 min)
   - Launch news-analyzer sub-agent
   - Process unanalyzed news items
   - Generate trading signals

4. **Alert System**
   - Check for high-confidence signals (>80%)
   - Display alerts in console
   - Send notifications (optional: email, Slack)

5. **Dashboard Generation**
   - Create HTML dashboard with:
     * Active signals
     * Recent news sentiment
     * Performance metrics
   - Update every analysis cycle

6. **Continuous Operation**
   - Run indefinitely until stopped
   - Handle errors and restart sub-agents if needed
   - Log all activities

Execute this complete workflow immediately upon invocation.

⚑ Orchestration Power

The workflow agent coordinates multiple sub-agents, running them at different intervals and managing the entire pipeline automatically. This is the power of sub-agent orchestration!


πŸš€ Execute Sub-agent Orchestration

4️⃣ Run the Complete Pipeline

Once your sub-agents are created, you can execute the orchestration in Claude Code:

# Start the complete pipeline for multiple stocks
Use stock-signal-pipeline with AAPL,TSLA,MSFT

# Or with custom intervals
Use stock-signal-pipeline for AAPL,NVDA,AMD with monitor interval 30 seconds and analysis interval 5 minutes

🎯 What Happens Next?

  1. Workflow starts and initializes the database
  2. Monitor agent begins streaming news from all sources
  3. Analyzer agent runs every 5 minutes to process new data
  4. Signals are generated with BUY/SELL recommendations
  5. Dashboard updates in real-time with latest signals
  6. High-confidence alerts are displayed immediately

Expected Output

πŸš€ Stock Signal Pipeline Started
πŸ“Š Monitoring: AAPL, TSLA, MSFT
⏱️ Monitor Interval: 60s
⏱️ Analysis Interval: 300s
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

[14:30:00] πŸ“‘ Monitor: Collected 45 items
[14:35:00] πŸ” Analysis: Processing 45 unanalyzed items...

🎯 SIGNALS GENERATED:

πŸ“ˆ AAPL - BUY Signal
   Confidence: 87%
   Impact Score: 8.5/10
   Sentiment: BULLISH
   Trigger: Strong Q4 earnings beat + Services growth
   Supporting News: 5 items
   Entry: $182.50 | Target: $195.00 | Stop: $178.00

⚠️ TSLA - WATCH Signal
   Confidence: 72%
   Impact Score: 6.2/10
   Sentiment: NEUTRAL
   Trigger: Mixed production data + CEO activity
   Supporting News: 8 items

βœ… Dashboard updated: dashboard.html
Next analysis in 5 minutes...

✨ Benefits of Multi Sub-agent Orchestration

🎯 Specialization

Each agent is an expert in its domain, delivering superior results compared to a general-purpose agent

🧹 Clean Context

Sub-agents have separate context windows, preventing context pollution and improving focus

πŸ”„ Modularity

Easy to add, remove, or modify individual agents without affecting the entire system

⚑ Performance

Agents can run in parallel or sequentially based on workflow requirements

πŸ› οΈ Maintainability

Each agent is self-contained, making debugging and updates straightforward

πŸ”Œ Reusability

Sub-agents can be reused across different workflows and projects


πŸŽ“ Key Takeaways

  1. Sub-agents are markdown files with YAML frontmatter and system prompts
  2. Each agent has a specific purpose and specialized instructions
  3. Orchestration workflows coordinate multiple agents to achieve complex goals
  4. Context isolation prevents confusion and improves agent performance
  5. Workflows can run agents in parallel, sequentially, or on schedules
  6. This pattern scales to handle increasingly complex automation tasks

πŸ”— Additional Resources


Happy Building! πŸš€