Back to .md Directory

LinkodIn - Demo & Usage Guide

Demonstrates a CLI tool for generating LinkedIn posts using a three-agent AI system and persona management.

May 2, 2026
0 downloads
1 views
ai agent rag prompt openai
View source

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

Python 3.9+OpenAI APIpytestCLI

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:

  1. Market Analysis Agent: Analyzes current LinkedIn trends and crafts optimal prompts
  2. Content Generation Agent: Creates viral posts based on the analysis
  3. 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

  1. Set up your OpenAI API key to enable post generation
  2. Create your first persona using the CLI
  3. Generate viral LinkedIn posts with AI-powered content
  4. 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 linkodin with your own package name if different
  • Replace tech-ceo persona 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