Skip to content

📋 Full Skill Source — This is the complete, unedited SKILL.md file. Nothing is hidden or summarized.

← Back to Skills Library

CM Content Factory v2.0 — AI Content Machine Platform

Config-driven, self-improving content factory with real-time dashboard, multi-agent independence, and token management. Gets smarter with use through memory + reward system.

Architecture

┌─────────────────────────────────────────────┐
│         🌐 DASHBOARD (localhost:5050)        │
│  Pipeline │ Tasks │ Tokens │ Logs │ Landing  │
└───────────┬─────────────────────────────────┘
            │ SSE / Polling
┌───────────┴─────────────────────────────────┐
│            🏭 PIPELINE ENGINE               │
│  ┌──────────┐ ┌──────────┐ ┌────────────┐  │
│  │  State   │ │  Token   │ │   Agent    │  │
│  │ Manager  │ │ Manager  │ │ Dispatcher │  │
│  └──────────┘ └──────────┘ └────────────┘  │
│                    │                         │
│  EXTRACT → PLAN → WRITE → AUDIT → SEO → PUB│
│                    │         │              │
│              📊 SCOREBOARD (reward/penalty)  │
│                    │                         │
│              🧠 MEMORY (3-layer learning)   │
└─────────────────────────────────────────────┘

Config file: content-factory.config.json at project root. Schema: config.schema.json.


🚀 Quick Start

bash
# New project (interactive wizard)
python3 scripts/wizard.py

# Full pipeline WITH dashboard
python3 scripts/pipeline.py --dashboard

# Pipeline with budget limit
python3 scripts/pipeline.py --dashboard --budget 5.0

# Dashboard only (standalone)
python3 scripts/dashboard_server.py

Phase 0: Discovery (MANDATORY)

AI MUST ask 5 question groups in order:

#GroupKey Questions
Q1Niche InfoLĩnh vực, brand, địa chỉ, phone, USP
Q2Reference & AvoidWebsite tham khảo, phong cách tránh, tone
Q3Data SourcesFiles có sẵn, URLs extract, hình ảnh
Q4Content GoalsSố bài, keywords, ngôn ngữ, khu vực
Q5DeployCloudflare account, domain, milestone

Phase 0.5: Confirm

Display summary table → WAIT for user OK → then proceed.


Operating Modes (12)

ModeScriptPurpose
📦 EXTRACTextract.pySource docs → JSON knowledge-base
📋 PLANplan.pyKnowledge → topic queue
✍️ WRITEwrite.pyAI content generation (batch/single)
🔍 AUDITaudit.pyQuality check + auto-fix
🔎 SEOseo.pyMetadata optimization
🚀 PUBLISHpublish.pyBuild + deploy
🧠 LEARNscoreboard.py + memory.pyExtract patterns from feedback
🔬 RESEARCHresearch.pyAuto-research new topics
💰 REVIEWmonetize.pyMonetization scoring
🏭 PIPELINEpipeline.pyFull automated A→Z
📊 DASHBOARDdashboard_server.pyReal-time web dashboard
🎯 LANDINGlanding_generator.pyPersona-based landing pages

All scripts: python3 scripts/<script> --config content-factory.config.json


Dashboard (NEW in v2.0)

Real-time web dashboard at http://localhost:5050:

  • Pipeline Progress: Visual 6-phase timeline with progress bars
  • Task Queue: Active/queued/completed/failed task cards
  • Token Tracker: Cost by provider, budget progress bar
  • Event Log: Filterable real-time log viewer
  • Error Panel: Highlighted error details
bash
# Auto-start with pipeline
python3 scripts/pipeline.py --dashboard --dashboard-port 5050

# Standalone
python3 scripts/dashboard_server.py --port 5050

Multi-Agent Support (NEW in v2.0)

Multiple agents can work independently on the same pipeline via file-based task queue.

python
from agent_dispatcher import AgentDispatcher
d = AgentDispatcher()

# Enqueue tasks
d.enqueue("write-article-1", "write", {"topic": "SEO Tips"}, priority=3)
d.enqueue_batch([{"id": "w-2", "type": "write"}, {"id": "w-3", "type": "write"}])

# Agent claims next task
task = d.claim_next("gemini-agent-1")
d.heartbeat("gemini-agent-1", task["id"])  # Keep alive

# Complete or fail
d.complete(task["id"], "gemini-agent-1", {"result": "ok"})
d.fail(task["id"], "gemini-agent-1", "API timeout")  # Auto-retry up to 3x

Features: priority ordering, stale lock detection (10min), auto-retry (3x), heartbeat.


Token Management (NEW in v2.0)

Track token usage, costs, rate limits, and budget across all providers.

python
from token_manager import TokenManager
tm = TokenManager(budget_usd=5.0)

# Record usage
tm.record_usage("gemini", input_tokens=1000, output_tokens=500, task_id="w-1")

# Check budget
if not tm.check_budget():
    print("Budget exceeded!")

# Rate limiting
tm.wait_if_rate_limited("gemini")

# Circuit breaker (auto-stop after 5 consecutive failures)
if tm.is_circuit_open("gemini"):
    print("Provider down, switching...")
bash
python3 scripts/token_manager.py status

Landing Pages (NEW in v2.0)

Generate persona-based landing pages using Content Mastery SB7 framework.

Add personas array to config:

json
{
  "personas": [{
    "name": "Economic Buyer",
    "headline": "Tiết Kiệm 50% Chi Phí Marketing",
    "subheadline": "AI tạo nội dung chuyên nghiệp, nhanh gấp 10x",
    "pain_points": ["Chi phí marketing cao", "Thiếu nhân sự content"],
    "benefits": [{"title": "Tiết kiệm", "description": "Giảm 50% chi phí"}],
    "social_proof": [{"number": "2,347", "label": "Doanh nghiệp tin dùng"}],
    "steps": [{"title": "Cấu hình", "description": "Nhập thông tin doanh nghiệp"}],
    "cta_text": "Dùng Thử Miễn Phí"
  }]
}
bash
python3 scripts/landing_generator.py --config content-factory.config.json
python3 scripts/landing_generator.py --config content-factory.config.json --list

Pipeline Execution

1. INIT     → wizard.py + scaffold.py → Astro project + config
2. RESEARCH → pipeline:research → 30+ topics
3. EXPAND   → expand-topics.py → 30 → target (100/200/...)
4. WRITE    → pipeline:write → 3 workers, 8s sleep, ~3 articles/min
5. MILESTONE → audit → build → deploy (at 50%/100%)
6. SHIP     → Final audit → deploy → notify user

🛡️ Golden Rules (Score 95+)

  • Performance: Font preload, critical CSS inline, preconnect, img width/height, GTM defer
  • Accessibility: WCAG AA contrast (#555+ on white), semantic HTML, h1-h3 hierarchy
  • Security: CSP/HSTS/XFO headers via public/_headers, cache immutable for /_astro/*
  • SEO: robots.txt → sitemap, proper meta tags

Self-Learning System

Memory (3 layers)

LayerPathPurpose
Semanticmemory/semantic/Long-term patterns, style, SEO rules
Episodicmemory/episodic/Per-session experiences + outcomes
Workingmemory/working/Current session context

Scoreboard

EventPoints
User praise+10
Engagement (share/bookmark)+5
Article passes audit first try+3
User edits article-5
User deletes article-10
Audit fail-3

Scripts Reference

Core Pipeline

ScriptPurpose
pipeline.pyMaster orchestrator (6-phase) + dashboard integration
extract.pySource extraction
plan.pyTopic planning
write.pyAI content writer
audit.pyQuality audit + fixer
seo.pySEO optimization
validate.pyContent validation
publish.pyBuild + deploy
deploy.pyMulti-platform deploy

Platform Layer (NEW v2.0)

ScriptPurpose
state_manager.pyCentral state management (JSON + JSONL events)
token_manager.pyToken tracking, cost, rate limits, circuit breaker
dashboard_server.pyHTTP server + SSE for dashboard
agent_dispatcher.pyMulti-agent task queue with file locking
landing_generator.pyPersona → Landing page generator

Intelligence Layer

ScriptPurpose
memory.py3-layer memory engine
scoreboard.pyReward/penalty system
research.pyAuto-research engine
monetize.pyMonetization scoring

Setup

ScriptPurpose
wizard.pyInteractive project setup
scaffold.pyWebsite scaffolding (Astro)

⚠️ Rules

  1. LUÔN hỏi trước khi làm — Phase 0 Discovery bắt buộc
  2. LUÔN confirm — Hiển thị summary, chờ user OK
  3. LUÔN thông báo milestone — Tại 50%, deploy milestone, hoàn thành
  4. KHÔNG deploy khi chưa audit — Luôn audit trước deploy
  5. KHÔNG skip câu hỏi — Nếu user không cung cấp, dùng default + confirm
  6. LUÔN dùng dashboard — Khi chạy pipeline, thêm --dashboard

Content Mastery Framework — Bậc Thầy Viết Content Chuyển Đổi Cao

Hệ thống viết content thống nhất. Tổng hợp từ 8+ framework: StoryBrand (SB7), SUCCESs, Cialdini (7 Principles), STEPPS, Hook Model, JTBD, CRO, Grand Slam Offers.

Core Principle: Content xuất sắc không phải nghệ thuật — nó là khoa học có hệ thống. Mỗi câu chữ dẫn dắt người đọc: "không biết" → "quan tâm" → "muốn" → "hành động".

Phase 0: Persona & JTBD

User Persona Canvas (hoàn thành TRƯỚC khi viết):

DimensionCâu hỏi
DemographicsTuổi, giới, nghề, thu nhập
Pain Points3-5 vấn đề cấp bách nhất
Goals & DreamsDream Outcome — ngôn ngữ của họ
Fears & ObjectionsLo ngại gì khi mua?
Decision TriggersĐiều gì khiến MUA NGAY?
LanguageVoice of Customer — từ ngữ mô tả vấn đề

Buyer Persona: Economic (ROI) | User (UX) | Technical (specs) | Coach (case studies)

Job Statement (JTBD): Khi [hoàn cảnh], tôi muốn [kết quả], để [kết quả cuối]

  • 3 chiều: Functional + Emotional + Social
  • 4 lực: Push + Pull > Habit + Anxiety

Phase 1: Hook — 12 Công Thức

#Hook TypeCông thức
1Contrarian"[Điều mọi người tin] thực ra sai..."
2Curiosity Gap"Cách [người/đối thủ] [kết quả] mà không [bất ngờ]"
3Data Shock"[Số liệu sốc] — đây là điều bạn cần biết"
4Before/After"Trước: [pain]. Sau: [dream]. Trong [thời gian]"
5Question"[Câu hỏi chạm nỗi đau sâu nhất]?"
6Story Open"Vào lúc [thời điểm], [nhân vật] phát hiện..."
7Authority"[Credential] + [insight bất ngờ]"
8FOMO"[X người] đã [kết quả]. Bạn có đang bỏ lỡ?"
9Pain Agitation"Nếu bạn đang [nỗi đau cụ thể], hãy đọc tiếp..."
10Promise"Bạn sẽ [kết quả] trong [thời gian], ngay cả khi [rào cản]"
11Villain"[Kẻ thù] đang [hành động xấu] — đây là cách chống lại"
12Insider Secret"Điều [chuyên gia] không muốn bạn biết..."

Rule: 1 hook = 1 message. Test 3-5 hook cho mỗi content quan trọng.

Phase 2: SB7 Narrative

1. Hero (Khách hàng) → có MỘT khao khát
2. Problem → Villain + External + Internal + Philosophical
3. Guide (Bạn) → Empathy + Authority
4. Plan → 3 bước đơn giản
5. CTA → Direct + Transitional
6. Failure → hậu quả nếu không hành động
7. Success → bức tranh thành công

Nguyên tắc vàng: Khách hàng = HERO. Bạn = GUIDE. Không bao giờ biến brand thành nhân vật chính.

Phase 3: 7 Vũ Khí Cialdini

Nguyên tắcÁp dụngCopy Pattern
ReciprocityFree guide/trial/tool"Đây là quà tặng..."
CommitmentQuiz, micro-actions"Bạn đã hoàn thành bước 1!"
Social ProofTestimonials, logos"2,347 doanh nghiệp tin tưởng..."
AuthorityCredentials, data"Nghiên cứu từ Harvard..."
LikingBrand voice thân thiện"Chúng tôi cũng từng khổ sở..."
Scarcity/FOMOLimited spots, deadline"Chỉ còn 5 suất cuối cùng..."
UnityShared identity"Dành cho những ai đang xây dựng..."

FOMO 5 tầng: Time Scarcity → Quantity Scarcity → Exclusive Access → Social FOMO → Opportunity Cost

Ranh giới đạo đức: FOMO phải DỰA TRÊN SỰ THẬT. Countdown giả = phá hủy brand vĩnh viễn.

Phase 4: SUCCESs + STEPPS

SUCCESs (Made to Stick) — ≥4/6: Simple, Unexpected, Concrete, Credible, Emotional, Stories

STEPPS (Viral Check): Social Currency, Triggers, Emotion (high-arousal), Public, Practical Value, Stories

Phase 5: Offer & CTA

Grand Slam Offer: Perceived Value = (Dream Outcome × Likelihood) / (Time Delay × Effort)

CTA TypeKhi dùngVí dụ
DirectChuyển đổi chính"Đăng Ký Ngay — Miễn Phí"
TransitionalChưa sẵn sàng mua"Tải Checklist Miễn Phí"
UrgencyScarcity thật"Chỉ Còn 3 Suất — Trước 23:59"

O/CO (Objection/Counter-Objection): Trust → Testimonials. Price → ROI calc. Fit → Case study. Timing → Deadline. Effort → "Done-for-you".

Phase 6: SEO Checklist

  • Title Tag ≤ 60 chars + primary keyword
  • Meta Description ≤ 155 chars + CTA
  • H1 × 1 + keyword. H2-H3 hierarchy + secondary keywords
  • First 100 words chứa primary keyword
  • ≥ 3 internal links + 2-5 external authoritative links
  • Schema Markup: FAQ, How-to, Article phù hợp

Phase 7: Cross-Audit 7 Chiều (mỗi chiều /10)

  1. Hook Power — 3 giây đầu có giữ chân?
  2. Persona Fit — Đúng VoC + pain + dream?
  3. Persuasion Depth — ≥3 Cialdini + O/CO?
  4. Narrative Flow — SB7 chuẩn?
  5. Stickiness — ≥4/6 SUCCESs?
  6. SEO Compliance — Title/Meta/H1/links?
  7. CTA Clarity — 1 Direct CTA + repeat?

63-70: Exceptional | 49-62: Strong | 35-48: Average | <35: Fail — viết lại

Content Type Matrix

TypeHook FocusPersuasionCTA
Landing PageContrarian/Data ShockSocial Proof + ScarcityDirect
Blog PostCuriosity Gap/QuestionAuthority + ValueTransitional
EmailPain Agitation/StoryReciprocity + CommitmentDirect
Social MediaInsider Secret/FOMOSocial Currency + EmotionMixed
Ad CopyVillain/QuestionScarcity + EmotionDirect

Ethical Boundaries

  1. Không scarcity giả (timer giả, "hết hàng" giả)
  2. Không fabricate testimonials
  3. Không exploit vulnerable groups
  4. Không promise kết quả không thể deliver
  5. Không hide costs
  6. Không fear-mongering

Test cuối: "Bạn có sẵn lòng áp dụng kỹ thuật này cho gia đình mình không?"

Open Source AI Agent Skills Framework