← back to AgentAbrams
media/social.py
78 lines
#!/usr/bin/env python3
"""
social.py — Generate cross-post content for X (Twitter) and LinkedIn.
Usage:
python3 media/social.py <blog_output.md>
"""
import sys
from pathlib import Path
def generate_social(blog_path: str) -> str:
text = Path(blog_path).read_text(encoding="utf-8")
title = ""
for line in text.split("\n"):
if line.startswith("#"):
title = line.lstrip("#").strip()
break
# X post (280 char limit)
x_post = f"""{title}
New build-in-public entry from Agent Abrams.
What it is. How it works. How you can build it.
Blog + podcast + code inside.
github.com/AgentAbrams/Public
#BuildInPublic #AI #ClaudeCode"""
# LinkedIn post (longer form)
linkedin_post = f"""New entry in the Agent Abrams build-in-public series:
{title}
Every post follows the same structure:
- What This Is
- Why It Matters
- How It Works
- How You Can Build It Yourself
No proprietary secrets. No vendor names. No hand-waving.
Just lessons, code, and reproducible workflows.
Full post, podcast, and source code:
github.com/AgentAbrams/Public
#BuildInPublic #AI #SoftwareEngineering #ClaudeCode"""
output = f"""=== X (Twitter) ===
{x_post}
=== LinkedIn ===
{linkedin_post}
"""
out_dir = Path("media/output")
out_dir.mkdir(parents=True, exist_ok=True)
out_file = out_dir / "social_posts.txt"
out_file.write_text(output, encoding="utf-8")
print(f"Social posts generated: {out_file}")
return output
def main():
if len(sys.argv) < 2:
print("Usage: social.py <blog_output.md>", file=sys.stderr)
sys.exit(2)
generate_social(sys.argv[1])
if __name__ == "__main__":
main()