Skip to main content
MindStudio
Pricing
Blog About
My Workspace
ClaudeWorkflowsAutomation

How to Repurpose YouTube Videos Into Social Media Posts with Claude Code

Learn how to build a Claude Code skill that turns any YouTube video into LinkedIn, Instagram, and X posts with platform-optimized visuals automatically.

MindStudio Team
How to Repurpose YouTube Videos Into Social Media Posts with Claude Code

The Content Repurposing Problem No One Talks About

Most marketers and creators publish a YouTube video and move on. That one video often contains 20, 30, or 50 shareable moments — expert quotes, data points, step-by-step breakdowns — that never reach the people on LinkedIn, Instagram, or X who would find them useful.

The bottleneck isn’t ideas. It’s time. Manually transcribing a video, pulling out the best content, rewriting it for three different platforms, and creating visuals for each one takes hours per video.

This guide shows you how to repurpose YouTube videos automatically using Claude Code. By the end, you’ll have a working skill that takes any YouTube URL, extracts the transcript, generates platform-optimized posts for LinkedIn, Instagram, and X, and produces matching visuals — all from a single command.


Why This Is Worth Automating

Content repurposing isn’t a nice-to-have anymore. Research from the Content Marketing Institute consistently shows that top-performing B2B teams publish across multiple channels, and the highest-output teams rely on systematic repurposing rather than creating original content from scratch for every platform.

The math is straightforward. If a 15-minute video takes 12 hours of total production effort, and repurposing it reaches three more audiences with five minutes of work, the ROI is obvious. The problem is that five minutes of work is a fantasy without automation.

Claude Code — Anthropic’s agentic coding tool — is well-suited for this. It runs in your terminal, can execute shell commands, read and write files, and call external APIs. Pair it with a well-built skill, and it becomes a content production assistant that does the mechanical work while you direct the strategy.


What You’ll Need Before Starting

Before writing a single line, make sure you have:

  • Claude Code installed and configured (Anthropic’s official docs walk through setup)
  • Node.js 18+ — the scripts in this guide use JavaScript
  • A MindStudio account — you’ll use the Agent Skills Plugin for image generation (free to start at mindstudio.ai)
  • yt-dlp installed on your system — handles audio/subtitle extraction from YouTube
  • Basic comfort running commands in a terminal

You don’t need a YouTube API key for transcript extraction if you use the youtube-transcript npm package, which pulls auto-generated captions directly from YouTube without authentication.


How the Skill Works: A Quick Overview

The skill is a Claude Code custom slash command — a reusable instruction set stored in .claude/commands/ that you can invoke with /repurpose-video followed by a YouTube URL.

When triggered, the workflow runs in five stages:

  1. Extract — Pull the full transcript from the YouTube video
  2. Analyze — Identify the main topic, key quotes, and strongest moments
  3. Generate — Write platform-specific posts for LinkedIn, Instagram, and X
  4. Visualize — Create a matching image for each post using MindStudio
  5. Export — Write everything to a structured output file

Each stage builds on the last. The transcript gives Claude raw material. The analysis step shapes what gets used. The generation step adapts tone and format for each platform. The visual step adds images sized and styled correctly for each network.


Step 1: Set Up Your Project Structure

Create a dedicated folder for the skill and install dependencies:

mkdir youtube-repurpose
cd youtube-repurpose
npm init -y
npm install youtube-transcript @mindstudio-ai/agent dotenv

Then create a .env file at the root:

MINDSTUDIO_API_KEY=your_key_here

Your MindStudio API key is available in the account settings dashboard after you sign up.

Next, create the Claude Code command file. Inside your project (or your global Claude Code config), create:

.claude/
  commands/
    repurpose-video.md

This file will define what Claude Code does when you run /repurpose-video.


Step 2: Write the Transcript Extraction Script

Create a file called extract-transcript.js at the project root:

require('dotenv').config();
const { YoutubeTranscript } = require('youtube-transcript');

async function extractTranscript(url) {
  // Pull video ID from URL
  const videoId = url.match(
    /(?:youtube\.com\/watch\?v=|youtu\.be\/)([a-zA-Z0-9_-]{11})/
  )?.[1];

  if (!videoId) {
    throw new Error('Could not extract video ID from URL');
  }

  const transcript = await YoutubeTranscript.fetchTranscript(videoId);
  const fullText = transcript.map(entry => entry.text).join(' ');

  return {
    videoId,
    text: fullText,
    wordCount: fullText.split(' ').length
  };
}

// Run when called directly
const url = process.argv[2];
if (!url) {
  console.error('Usage: node extract-transcript.js <youtube-url>');
  process.exit(1);
}

extractTranscript(url)
  .then(result => console.log(JSON.stringify(result, null, 2)))
  .catch(err => {
    console.error(err.message);
    process.exit(1);
  });

Test it before moving on:

node extract-transcript.js https://www.youtube.com/watch?v=dQw4w9WgXcQ

If transcripts are disabled on a video, the script will throw. In that case, yt-dlp with the --write-auto-sub flag is a reliable fallback that pulls auto-generated subtitles and saves them as a text file.


Step 3: Generate Platform-Specific Posts

This is where Claude Code earns its place. Rather than hardcoding logic for every platform, you write a clear, structured prompt and let Claude reason about the best angle, tone, and format for each one.

Create generate-posts.js:

require('dotenv').config();
const Anthropic = require('@anthropic-ai/sdk');
const fs = require('fs');

const client = new Anthropic();

async function generatePosts(transcriptText, videoUrl) {
  const prompt = `
You are a social media strategist. Below is the transcript of a YouTube video.
Your job is to extract the best content from it and write platform-specific posts.

VIDEO URL: ${videoUrl}

TRANSCRIPT:
${transcriptText.slice(0, 8000)} // trim for context window safety

---

Write the following, clearly separated:

## LINKEDIN POST
- Professional tone, 150–300 words
- Lead with a specific insight or surprising fact from the video
- Use line breaks generously (people scan on LinkedIn)
- End with a question or clear takeaway
- Include 3–5 relevant hashtags at the bottom

## INSTAGRAM CAPTION
- Casual, conversational tone
- 80–150 words
- Hook in the first line (this appears before "more")
- Include a call to action (e.g., "Link in bio")
- Add 15–20 relevant hashtags on a new line at the end

## X THREAD
- Write a 5–7 tweet thread
- Tweet 1 is the hook — bold claim or counterintuitive insight
- Tweets 2–6 expand on key points (under 280 chars each)
- Final tweet: summary + engagement question
- Number each tweet (1/, 2/, etc.)

## SUGGESTED IMAGE PROMPT
- Write one image generation prompt for a visual that works across all three platforms
- Describe a clean, professional graphic (not photorealistic) that relates to the main topic
- Keep it under 100 words
`;

  const message = await client.messages.create({
    model: 'claude-opus-4-5',
    max_tokens: 2048,
    messages: [{ role: 'user', content: prompt }]
  });

  return message.content[0].text;
}

const transcript = JSON.parse(fs.readFileSync('transcript.json', 'utf8'));
const videoUrl = process.argv[2];

generatePosts(transcript.text, videoUrl).then(posts => {
  console.log(posts);
  fs.writeFileSync('posts-draft.md', posts);
  console.log('\n✓ Posts saved to posts-draft.md');
});

This script writes a markdown file with all three posts and an image prompt ready to use.


Step 4: Generate Visuals with MindStudio

This is where the workflow gets noticeably better than manually copy-pasting into design tools. The MindStudio Agent Skills Plugin lets Claude Code call generateImage() as a simple method — no API setup, no rate limiting headaches, no separate account.

Install the SDK if you haven’t already:

npm install @mindstudio-ai/agent

Create generate-visuals.js:

require('dotenv').config();
const { MindStudio } = require('@mindstudio-ai/agent');
const fs = require('fs');

const ms = new MindStudio(process.env.MINDSTUDIO_API_KEY);

async function generateVisuals(imagePrompt) {
  const sizes = [
    { label: 'linkedin', width: 1200, height: 627 },
    { label: 'instagram', width: 1080, height: 1080 },
    { label: 'x-twitter', width: 1200, height: 675 }
  ];

  const results = [];

  for (const size of sizes) {
    console.log(`Generating ${size.label} visual...`);

    const result = await ms.generateImage({
      prompt: `${imagePrompt} Clean, professional style. No text overlay.`,
      width: size.width,
      height: size.height
    });

    const filename = `visual-${size.label}.png`;
    fs.writeFileSync(filename, result.imageData, 'base64');
    results.push({ platform: size.label, file: filename });
    console.log(`✓ Saved ${filename}`);
  }

  return results;
}

// Pull the image prompt from the generated posts file
const postsContent = fs.readFileSync('posts-draft.md', 'utf8');
const promptMatch = postsContent.match(/## SUGGESTED IMAGE PROMPT\n([\s\S]+?)(?=\n##|$)/);
const imagePrompt = promptMatch?.[1]?.trim() || 'Professional business concept visual';

generateVisuals(imagePrompt).then(results => {
  console.log('\n✓ All visuals generated:', results);
});

The MindStudio Agent Skills Plugin handles retries and auth automatically, so you don’t need to add that logic yourself. This is one of the real advantages over calling image generation APIs directly — the plumbing is already done.

You can read more about the full range of capabilities available through the MindStudio Agent Skills Plugin, which includes methods for email, web search, workflow execution, and more.


Step 5: Wire It All Together as a Claude Code Skill

Now write the command definition in .claude/commands/repurpose-video.md:

# /repurpose-video

Given a YouTube URL, extract the transcript, generate platform-specific posts for
LinkedIn, Instagram, and X, and create matching visuals.

## Steps

1. Run: `node extract-transcript.js $ARGUMENTS` and save output to `transcript.json`
2. Run: `node generate-posts.js $ARGUMENTS` — this reads `transcript.json` and writes `posts-draft.md`
3. Review `posts-draft.md` briefly and note the SUGGESTED IMAGE PROMPT section
4. Run: `node generate-visuals.js` — this reads the image prompt and generates three sized visuals
5. Report back: summarize what was created, list the output files, and ask if any post needs revision

If the transcript step fails (e.g., captions disabled), suggest using yt-dlp as a fallback.

Now you can run the entire workflow with one command in Claude Code:

/repurpose-video https://www.youtube.com/watch?v=your-video-id

Claude Code reads the command definition, runs each step in sequence, handles errors, and reports back with a summary of what was created.


Platform-Specific Tips That Actually Matter

The scripts above produce solid first drafts, but a few platform-specific details are worth dialing in over time.

LinkedIn

LinkedIn’s algorithm rewards posts that hold attention in the feed. This means:

  • Your first line should work without any context — treat it like a subject line
  • Short paragraphs (1–2 lines) get more scrolls than blocks of text
  • Posts that end with a genuine question see significantly more comments than those that just state facts

Avoid the “[Number] things I learned from this video” format — it’s overused and rarely performs well anymore.

Instagram

Instagram captions have a 2,200-character limit, but only the first line or two shows before “more.” Your hook is everything. The caption after the break can be more informative — treat it like the body of an email.

For hashtags, using 15–20 relevant tags still works better than stuffing 30 generic ones. Mix specific niche tags with broader ones.

X / Twitter

Threads perform better than single tweets for educational or analytical content. The hook tweet is the highest-leverage element — if it doesn’t stop someone mid-scroll, the rest doesn’t matter.

Avoid clickbait hooks. Specific, concrete hooks (“We reduced customer churn by 34% — here’s the exact change we made”) outperform vague ones (“What I learned about growth this year”).


How MindStudio Fits Into Bigger Content Workflows

The Agent Skills Plugin is useful for one-off scripts like this one. But if you’re running a content team or producing this kind of output at volume, MindStudio’s visual workflow builder lets you turn this entire process into an automated pipeline — no script maintenance required.

You can build a workflow that triggers whenever a new YouTube video is published (via RSS or webhook), runs the full transcript-to-post pipeline, stores the drafts in Notion or Airtable, and routes them to Slack for a human review before publishing.

MindStudio’s AI Media Workbench also includes tools for adding subtitles, swapping backgrounds, and resizing video clips — useful if you want to extend this workflow to short-form video repurposing (Reels, Shorts, TikTok) in addition to static posts.

You can try MindStudio free at mindstudio.ai.


Common Mistakes and How to Fix Them

The transcript is too long and Claude loses the thread. Transcripts for longer videos can run 15,000+ words. Trim the input to the most information-dense portions, or chunk the transcript into segments and run the generation step on each chunk separately, then combine.

The posts sound too similar to each other. This usually means the prompt isn’t being specific enough about platform tone. Add explicit constraints: “LinkedIn post must use professional vocabulary. Instagram caption must use casual, first-person language. X thread must be punchy and opinionated.”

Image generation fails or produces irrelevant visuals. Generic prompts produce generic images. The more specific the image prompt — the topic, the visual style, the absence of text, the intended mood — the better the output. Iterate on the suggested image prompt before running the visual generation step.

Auto-generated captions are inaccurate. This is common for videos with technical jargon, accents, or fast speech. If accuracy matters, use a separate transcription service or correct obvious errors in the transcript before running the generation step.

The skill breaks when YouTube changes their embed format. The youtube-transcript package occasionally needs updating when YouTube updates its API. Keep dependencies current with npm update, and check the package’s GitHub issues page if extraction suddenly stops working.


Frequently Asked Questions

Does this work on videos without captions?

The youtube-transcript package relies on captions — either manually added or auto-generated by YouTube. Most videos published in English have auto-generated captions, but some creators disable them. If captions aren’t available, use yt-dlp with the --write-auto-sub --skip-download flags to pull whatever auto-subtitles exist. For videos with no subtitles at all, you’ll need to transcribe the audio separately using a tool like Whisper.

Can I use this with languages other than English?

Yes, with some adjustments. The youtube-transcript package can fetch transcripts in any language available on the video. Pass the lang option (e.g., { lang: 'es' } for Spanish). The platform post generation will work in any language that Claude supports, though you may need to adjust your prompt to specify the target language explicitly.

How do I handle videos that are long (60+ minutes)?

Claude’s context window has limits. For long videos, split the transcript into segments (by time or by topic), generate posts for each segment separately, and then run a final pass to select the best outputs. Alternatively, summarize the transcript first — ask Claude to reduce it to the most quotable, platform-ready content — before running the full generation step.

What’s the cost to run this per video?

Costs vary based on model and image generation. Claude Opus calls for a typical transcript run roughly $0.05–$0.15 depending on length. MindStudio’s image generation costs depend on your plan, but typical image calls are fractions of a cent. For most teams processing a handful of videos per week, monthly costs are well under $10 in API usage.

Can I schedule this to run automatically without manually triggering it?

Yes. Claude Code is well-suited for manual, on-demand workflows, but if you want this to run automatically when a new video is published, MindStudio’s automated workflow builder lets you set up a trigger (YouTube RSS feed, webhook from your CMS, etc.) and run the full pipeline without any manual step.

Is there a way to customize the post style per client or brand?

Absolutely. Add a style guide or brand voice document to the prompt context. Store brand-specific instructions as a text file and prepend it to the generation prompt. You can also create separate command files in .claude/commands/ for different clients — /repurpose-video-client-a vs. /repurpose-video-client-b — each with different tone and format instructions baked in.


Key Takeaways

Building a YouTube-to-social repurposing skill with Claude Code is a practical, low-maintenance way to get more reach from content you’ve already invested in.

Here’s what to remember:

  • The skill runs in five stages: extract transcript → analyze content → generate posts → create visuals → export output
  • Claude Code’s slash commands make the workflow reusable and consistent without requiring you to remember long prompts
  • Platform differences matter: LinkedIn, Instagram, and X each have distinct formats and audience behaviors that your prompts need to account for explicitly
  • The MindStudio Agent Skills Plugin handles image generation from inside Claude Code without requiring you to set up separate API integrations
  • Most failures are transcript-related — always verify your extraction step works before debugging the generation or visual steps

If you process more than a few videos per week, moving this workflow into MindStudio’s visual builder gives you scheduling, team collaboration, and integration with tools like Notion, Slack, and Airtable — without maintaining scripts. Start free at mindstudio.ai and see how much of the workflow you can hand off entirely.

Presented by MindStudio

No spam. Unsubscribe anytime.