π 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
π 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
- Subscribe to Claude: Visit claude.ai and sign up for Claude Pro or Team
- Install Claude Desktop (Optional): Download from the official Anthropic website for your operating system
- Install Claude Code: Follow the installation guide at docs.claude.com
- 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?
- Workflow starts and initializes the database
- Monitor agent begins streaming news from all sources
- Analyzer agent runs every 5 minutes to process new data
- Signals are generated with BUY/SELL recommendations
- Dashboard updates in real-time with latest signals
- 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
- Sub-agents are markdown files with YAML frontmatter and system prompts
- Each agent has a specific purpose and specialized instructions
- Orchestration workflows coordinate multiple agents to achieve complex goals
- Context isolation prevents confusion and improves agent performance
- Workflows can run agents in parallel, sequentially, or on schedules
- This pattern scales to handle increasingly complex automation tasks
π Additional Resources
Happy Building! π