LinkodIn - Demo & Usage Guide
Demonstrates a CLI tool for generating LinkedIn posts using a three-agent AI system and persona management.
What this file does
Demonstrates a CLI tool for generating LinkedIn posts using a three-agent AI system and persona management.
When to use it
- You want to automate LinkedIn content creation with AI
- You need a multi-persona post generation system
- You are evaluating clean architecture patterns for CLI tools
- You want to test or extend a repository-based AI service
Assumes this stack
LinkodIn - Demo & Usage Guide
๐ Quick Start
Installation
# Clone or extract the project
cd linkodin
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies (Python 3.9+ required)
pip install -e .
# Set up OpenAI API key (required for post generation)
export OPENAI_API_KEY='your-openai-api-key-here'
Run the Demo
python demo.py
๐ญ Persona Management
Create a Persona
linkodin persona create \
--id "tech-ceo" \
--name "Tech CEO" \
--niche "Technology Leadership" \
--target-audience "Tech professionals, entrepreneurs, investors" \
--industry "Technology" \
--content-themes "leadership,innovation,startup insights,tech trends" \
--brand-keywords "innovation,leadership,growth,technology" \
--tone "inspirational"
List All Personas
linkodin persona list
Show Persona Details
linkodin persona show tech-ceo
Delete a Persona
linkodin persona delete tech-ceo
๐ Post Generation
Generate a Post
linkodin post generate tech-ceo --topic "AI transformation in business"
Generate with Additional Context
linkodin post generate tech-ceo \
--topic "Remote work trends" \
--context "Focus on productivity and team collaboration"
List All Posts
linkodin post list
List Posts by Persona
linkodin post list --persona tech-ceo
Show Post Details
linkodin post show <post-id>
๐ค AI Agent System
The system uses three AI agents for optimal post generation:
- Market Analysis Agent: Analyzes current LinkedIn trends and crafts optimal prompts
- Content Generation Agent: Creates viral posts based on the analysis
- Image Prompt Agent: Generates compelling image descriptions
๐งช Testing
Run the complete test suite:
pytest tests/ -v
All 38 tests should pass โ
๐ Project Structure
src/
โโโ entities/ # Business entities
โ โโโ persona.py # Persona entity with validation
โ โโโ post.py # Post entities and requests
โโโ interactors/ # Business logic layer
โ โโโ interfaces.py # Repository and service interfaces
โ โโโ persona_interactor.py
โ โโโ post_generation_interactor.py
โโโ infrastructure/ # Concrete implementations
โ โโโ in_memory_persona_repository.py
โ โโโ in_memory_post_repository.py
โ โโโ openai_service.py # OpenAI GPT integration
โโโ cli/ # Command-line interface
โโโ main.py
๐๏ธ Architecture Highlights
- Clean Architecture: Separation of concerns with entities, interactors, and infrastructure
- Dependency Injection: Interfaces allow for easy testing and extension
- Repository Pattern: Abstract data storage from business logic
- Command Pattern: CLI commands are organized and testable
- Error Handling: Comprehensive validation and error messages
๐ง Extensibility
Adding New Repositories
Implement the PersonaRepository or PostRepository interfaces:
class DatabasePersonaRepository(PersonaRepository):
async def save_persona(self, persona: Persona) -> None:
# Your database implementation
pass
Adding New AI Services
Implement the AIService interface:
class CustomAIService(AIService):
async def generate_market_analysis_and_prompt(self, ...):
# Your AI implementation
pass
๐ก Example Personas
Tech CEO
- Niche: Technology Leadership
- Tone: Inspirational
- Themes: Leadership, Innovation, Startup Insights
Marketing Guru
- Niche: Digital Marketing
- Tone: Enthusiastic
- Themes: Growth Marketing, Social Media, ROI
AI Researcher
- Niche: Artificial Intelligence
- Tone: Professional
- Themes: Machine Learning, AI Ethics, Research
๐ฏ Key Features
โ
Three-Agent AI System: Market analysis โ Content generation โ Image prompts
โ
Viral Content Focus: Optimized for LinkedIn engagement and algorithm success
โ
Multi-Persona Support: Create unlimited personas with detailed configurations
โ
CLI Interface: Easy-to-use command-line tools
โ
Clean Architecture: Maintainable and testable codebase
โ
Comprehensive Testing: 38 tests covering all major functionality
โ
Extensible Design: Repository and service patterns for easy extension
๐ Next Steps
- Set up your OpenAI API key to enable post generation
- Create your first persona using the CLI
- Generate viral LinkedIn posts with AI-powered content
- Extend the system with additional repositories or services as needed
Happy posting! ๐
What's inside
14 sections, 8 CLI commands, 6 code blocks, 3 example personas, 1 project structure tree
Change this for your project
- Replace
'your-openai-api-key-here'with your actual OpenAI API key - Replace
linkodinwith your own package name if different - Replace
tech-ceopersona ID with your own persona identifiers
Where it goes
Use as the system prompt for your model call, or as the base instructions in your agent framework.
Worth borrowing
- Three-agent pipeline for market analysis, content generation, and image prompts
- Repository pattern with interfaces for swapping storage backends
- Persona as a configurable entity with niche, tone, and brand keywords
Related Documents
Character Persona
Defines a Fallout 2 roleplay persona for an LLM agent: charming rogue with social-first combat and moral code.
How to implement tool use
Explains how to define, configure, and control tool use with the Anthropic API, including model selection, tool definitions, output control, and parallel calls.
Gemini by Example
Collects 20+ Gemini API code examples covering text, images, audio, video, PDFs, agents, and token counting.
Claude Tool Use (Function Calling) Documentation
Teaches how to define and use Claude tool use (function calling) with Python, including schema rules, execution patterns, and best practices.