Description:
Agentic Twitter Thread Creator is an agentic AI system built to generate high-quality, engaging Twitter/X threads by following proven writing frameworks instead of relying on generic LLM outputs. The system transforms a topic, notes, or rough draft into a publish-ready thread (≤15 tweets) complete with a strong hook, clear structure, TL;DR, and CTA.
This project was developed under the mentorship of Mr. Bargava (Alumnus) and as part of an internship at PinHead Analytics, with a strong focus on building production-grade agentic AI systems rather than demos.
1. Core Idea
Instead of a single prompt → response flow, the system mirrors how real writers think and iterate through a multi-step agentic pipeline:
source → filter → model → structure → draft → refineEach stage is handled by a specialized agent, enforcing clarity, scannability, and structure.
2. High-Level Flow (Agentic)
def generate_thread(input_data):
template = infer_template(input_data)
hooks = generate_hooks(template, input_data)
best_hook = rank_hooks(hooks)
outline = create_outline(template, input_data)
draft = draft_thread(outline)
tldr = generate_tldr(draft)
cta = generate_cta(draft)
return enforce_constraints({
"hook": best_hook,
"tweets": draft,
"tldr": tldr,
"cta": cta
})3. What the System Does
- Accepts topic / notes / rough draft as input
- Learns patterns from real, high-performing Twitter threads
- Selects the most suitable thread template
- Generates and ranks multiple hook candidates
- Produces a structured thread containing:
- Hook
- Body tweets (≤15)
- TL;DR
- CTA
- Outputs ready-to-publish text + structured JSON Example output:
{
"template": "checklist",
"hook": "Most people waste years writing threads no one reads.",
"tldr": "Structure beats inspiration every time.",
"tweets": ["1/ …", "2/ …", "…"],
"cta": "Follow for more writing systems."
}4. DSPy Prompt Programming (Key Differentiator)
Instead of static prompts, DSPy modules are used to program the LLM.
class GenerateHook(dspy.Module):
def forward(self, topic, audience, angle):
return dspy.Predict(
"Write a scroll-stopping hook using Ship30 principles"
)(topic=topic, audience=audience, angle=angle)DSPy’s compiler is used to optimize prompt behavior against a labeled dataset of real threads.
5. Agentic Architecture (Agno-style)
Each step is handled by a dedicated agent:
agents = [
RouterAgent(),
TemplateSelector(),
HookSmith(),
Outliner(),
Drafter(),
Editor(),
TLDRWriter(),
CTAWriter(),
Limiter(max_tweets=15),
Verifier()
]The workflow is deterministic, reviewable, and debuggable step by step.
6. Automation & Data Pipeline
n8n → scrape threads
→ filter by quality
→ store in Supabase
→ label templates & hooks
→ feed DSPy training/evalsSupabase stores:
- Raw threads
- Labels (template, hook type, CTA)
- Evaluation scores
- Run metadata for reproducibility
7. Evaluation & Guardrails
assert tweet_count <= 15
assert hook_present
assert tldr_present
assert cta_presentAdditional checks:
- Readability score
- Hook stop-scroll score
- Claim groundedness (source-backed or opinion-only)
- Side-by-side comparisons (Base vs DSPy vs Human-edited)
8. Why This Project Stands Out
- Uses real creator data, not synthetic examples
- Enforces Ship30for30 writing discipline
- Agent-based iteration instead of one-shot generation
- Designed as a production-grade agentic API
- Strong focus on evaluation, structure, and reproducibility
9. Tech Stack
- Language: Python
- LLMs: Gemini / GPT (pluggable adapters)
- Prompt Programming: DSPy
- Agent Orchestration: Agno
- Automation: n8n
- Data & Storage: Supabase
10. Project Status
- Core system fully implemented
- Dataset curated and labeled (500 threads)
- DSPy prompts compiled and evaluated
- Currently in deployment & packaging phase
- Planned launch as a SaaS product — coming soon 🚀
