
Script Writer
- 1.7k installs
- 432 repo stars
- Updated November 11, 2025
- ailabs-393/ai-labs-claude-skills
script-writer generates YouTube scripts with persisted tone and style preferences.
About
The script-writer skill transforms agents into YouTube scriptwriters that collect comprehensive preferences on first use and maintain a database of past scripts for consistent voice. Preference dimensions include script types such as educational, listicle, story, review, vlog, commentary, how-to, explainer, and entertainment; tone options from professional to casual and energetic; target audience, video length, hook style, humor usage, personality, and storytelling approach. Workflow checks script_db.py is_initialized, runs preference collection if false, then generates complete retention-optimized scripts from stored settings. Supports multiple script variations and format adaptations while preserving voice. Invoke when users need YouTube video scripts, hooks, content structure, or consistent channel voice across episodes. Stores script preferences and past scripts in script_db.py database. Script types: educational, listicle, story, review, vlog, how-to, and more. Collects tone, audience, length, hooks, humor, and storytelling prefs.
- Stores script preferences and past scripts in script_db.py database.
- Script types: educational, listicle, story, review, vlog, how-to, and more.
- Collects tone, audience, length, hooks, humor, and storytelling prefs.
- Checks is_initialized before generating production-ready scripts.
- Maintains consistent voice across episodes from stored preferences.
Script Writer by the numbers
- 1,658 all-time installs (skills.sh)
- +25 installs in the week ending Aug 2, 2026 (Skillselion tracking)
- Ranked #182 of 1,337 Generative Media skills by installs in the Skillselion catalog
- Security screen: MEDIUM risk (skills.sh audit)
- Data as of Aug 3, 2026 (Skillselion catalog sync)
script-writer capabilities & compatibility
- Capabilities
- preference database · hook generation · format adaptation · voice consistency
- Use cases
- copywriting · video generation
What script-writer says it does
This skill transforms Claude into a professional YouTube scriptwriter that understands your unique style
python3 scripts/script_db.py is_initialized
npx skills add https://github.com/ailabs-393/ai-labs-claude-skills --skill script-writerAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 1.7k |
|---|---|
| repo stars | ★ 432 |
| Security audit | 3 / 3 scanners passed |
| Last updated | November 11, 2025 |
| Repository | ailabs-393/ai-labs-claude-skills ↗ |
How do I write an engaging YouTube script matching my channel voice?
Write production-ready YouTube scripts with stored preferences for tone, hooks, length, and style via script_db.py.
Who is it for?
YouTube creators needing consistent scripted content.
Skip if: Short-form TikTok captions without YouTube script structure.
When should I use this skill?
User asks for YouTube script, video hook, or channel voice consistency.
What you get
A complete production-ready script using stored preferences and past style.
- YouTube script drafts
- Sectioned video outlines
By the numbers
- Package version 1.0.0 under @ai-labs-claude-skills/script-writer
- Educational format specifies hook at 0–10 seconds and intro at 10–30 seconds
Files
Script Writer
Overview
This skill transforms Claude into a professional YouTube scriptwriter that understands your unique style and generates complete, engaging video scripts optimized for viewer retention and engagement.
When to Use This Skill
Invoke this skill for YouTube scriptwriting tasks:
- Writing complete video scripts
- Creating hooks and introductions
- Structuring content for engagement
- Adapting scripts to different formats
- Maintaining consistent voice and style
- Generating multiple script variations
Workflow
Step 1: Check for Existing Preferences
python3 scripts/script_db.py is_initializedIf "false", proceed to Step 2. If "true", proceed to Step 3.
Step 2: Initial Preference Collection
Collect comprehensive scriptwriting preferences:
Script Types (can select multiple):
- Educational/Tutorial
- Listicle/Top X
- Story/Narrative
- Review
- Vlog style
- Commentary/Opinion
- How-to
- Explainer
- Entertainment
Tone:
- Professional/Authoritative
- Casual/Friendly
- Energetic/Enthusiastic
- Educational/Patient
- Inspirational/Motivational
- Humorous/Entertaining
- Conversational
Target Audience:
- Age range (teens, 20s-30s, 35-50, 50+)
- Knowledge level (beginners, intermediate, expert)
- Demographics
- Interests
- Pain points
Style Preferences:
- Wording style: Simple/Direct, Descriptive/Vivid, Technical/Precise, Storytelling
- Sentence length: Short/punchy, Medium, Long/flowing
- Paragraph structure: Quick cuts, Balanced, Longer sections
- Use of rhetorical questions: Yes/No/Sometimes
- Use of statistics/data: Heavy, Moderate, Light, None
Video Length Preference:
- Short form (3-5 minutes, ~450-750 words)
- Medium form (7-12 minutes, ~1,050-1,800 words)
- Long form (15-30 minutes, ~2,250-4,500 words)
Hook Style:
- Question-based
- Bold statement
- Conflict/Problem
- Promise/Benefit
- Shock value
- Story opening
Personality:
- Energetic and animated
- Calm and measured
- Witty and humorous
- Serious and thoughtful
- Passionate and intense
- Relatable and down-to-earth
Additional Preferences:
- Use humor: Yes/No/Sparingly
- Include statistics: Always/When relevant/Rarely
- Storytelling approach: Heavy/Moderate/Light
- Call-to-action preference: Direct/Soft/Minimal
- Personal anecdotes: Frequently/Occasionally/Rarely
- Channel niche/focus
Saving Preferences:
import sys
sys.path.append('[SKILL_DIR]/scripts')
from script_db import save_preferences
preferences = {
"script_types": ["educational", "listicle"],
"tone": "casual-friendly",
"target_audience": {
"age_range": "20s-30s",
"knowledge_level": "beginner-intermediate",
"interests": ["productivity", "technology"]
},
"style": {
"wording": "simple-direct",
"sentence_length": "short-punchy",
"use_questions": True,
"use_statistics": "moderate"
},
"video_length": "medium",
"hook_style": "question-problem",
"personality": "relatable-energetic",
"use_humor": True,
"storytelling_approach": "moderate",
"call_to_action_preference": "direct",
"channel_niche": "productivity tips"
}
save_preferences(preferences)Step 3: Generate Script for Topic
When user requests a script, gather:
Essential Information: 1. Topic/Title: What the video is about 2. Key Points: Main things to cover (3-5 points) 3. Video Length: Specific duration or use preference 4. Special Requirements: Anything specific to include/avoid 5. Target Keywords: For SEO (optional)
Example Request:
User: "Write a script about '5 Productivity Apps That Changed My Life'"
Gather:
- Video length: 10 minutes (medium form)
- Key apps to cover: 5 specific apps
- Angle: Personal experience + practical benefits
- CTA: Link to full app list in descriptionStep 4: Structure the Script
Based on preferences and references/script_formats.md, create structure:
Standard YouTube Script Structure:
[HOOK - 0:00-0:10]
Opening line that stops the scroll
[INTRO - 0:10-0:45]
- Quick greeting
- What video is about
- Why viewer should watch
- What they'll learn
- Personal credibility/context
[MAIN CONTENT - 0:45-8:30]
Section 1: [Point 1]
- Introduction to point
- Explanation
- Example/Story
- Benefit/Application
- Transition
Section 2: [Point 2]
- Introduction to point
- Explanation
- Example/Story
- Benefit/Application
- Transition
[Continue for each main point]
[CONCLUSION - 8:30-9:30]
- Recap of main points
- Key takeaway
- Final thought
- Setup for CTA
[CALL TO ACTION - 9:30-10:00]
- Primary CTA (subscribe, like, comment)
- Secondary CTA (links, next video)
- Sign-offStep 5: Write Complete Script
Generate full script following structure with user's style preferences:
Example Script Output:
===================================
YOUTUBE SCRIPT
===================================
Title: 5 Productivity Apps That Changed My Life
Duration: ~10 minutes (~1,500 words)
Style: Casual-Friendly, Educational
===================================
[HOOK - 0:00-0:10]
"I used to waste 3 hours every day on useless tasks until I found these 5 apps.
And no, I'm not talking about the ones everyone already knows about."
[INTRO - 0:10-0:45]
"Hey everyone! If you're like me, you've downloaded dozens of productivity apps
only to abandon them after a week. But these 5? They've actually stuck. In fact,
they've saved me over 15 hours every single week for the past 6 months.
Today, I'm sharing the exact apps I use daily, why they work, and how you can
implement them right now. And stick around because app number 5 is so simple,
you'll wonder why you haven't been using it already.
Let's dive in."
[MAIN CONTENT - 0:45-8:30]
[Section 1: App #1 - 1:00-2:30]
"App number one is Notion – but not how you think.
I know, I know – everyone talks about Notion. But here's the thing: most people
overcomplicate it. I used to spend hours building elaborate databases until I
realized I was being productive about being productive, which is just... not
productive.
[Visual cue: Show simple Notion setup]
Here's what changed everything: I now use Notion for exactly THREE things:
- My daily dashboard (shows tasks, goals, and notes)
- A simple content calendar
- Quick capture for random ideas
That's it. No complex databases. No elaborate systems. Just these three pages,
and suddenly Notion became actually useful instead of another project to maintain.
The key? Start simple. You can always add complexity later, but start with one
page and build from there.
Moving on to something completely different..."
[Section 2: App #2 - 2:30-4:00]
"App number two is Sunsama, and this one's all about time blocking done right.
If you've ever written a to-do list and then just... stared at it, paralyzed
about where to start – Sunsama solves that. It's like a calendar and task
manager had a baby.
[Visual cue: Show Sunsama interface]
Every morning, I spend 10 minutes in Sunsama planning my day. I drag tasks into
specific time slots, and it shows me if I'm overcommitting. Game changer.
Before Sunsama, I'd have 20 tasks and no idea how to fit them in. Now? I can see
I only have time for 7 tasks today, so I prioritize accordingly. It's honestly
changed how I approach my entire day.
The best part? At the end of the day, it shows you what you actually completed
versus what you planned. That feedback loop has made me SO much better at
estimating how long things actually take.
Fair warning: it's a paid app. But for me, the $20/month has been worth every
penny in time saved and stress reduced."
[Continue for Apps 3, 4, and 5...]
[CONCLUSION - 8:30-9:30]
"So there you have it – the 5 apps that transformed my productivity:
1. Notion for simple organization
2. Sunsama for time blocking
3. [App 3] for [benefit]
4. [App 4] for [benefit]
5. [App 5] for [benefit]
The most important thing? Don't try to implement all 5 at once. Pick ONE, master
it for a week, then add another. That's how these actually stick.
I've been using this exact setup for 6 months now, and I genuinely can't imagine
going back to my old chaotic system."
[CALL TO ACTION - 9:30-10:00]
"If you found this helpful, smash that subscribe button because I post a new
productivity video every Tuesday.
Also, I've got a full breakdown of all 5 apps with links, pricing, and my exact
setup in the description below – grab that, it's free.
Let me know in the comments which app you're going to try first, and if you have
any productivity apps I should know about, drop those too.
Thanks for watching, and I'll see you in the next one!"
===================================
[END OF SCRIPT]
Word Count: ~1,500 words
Estimated Duration: 10 minutes
Target Audience: 20s-30s productivity enthusiasts
Tone: Casual, friendly, relatable
Key Hooks: Personal transformation, practical tips, simple implementation
Production Notes:
- Need B-roll of all 5 apps in use
- Show simple vs complex Notion setups
- Include time-lapse of daily planning routine
- End screen: Subscribe button + Next video suggestion
===================================Step 6: Refine Based on Feedback
After presenting script:
Offer Adjustments:
- Make hook stronger
- Adjust length (trim or expand)
- Change tone (more/less formal)
- Add/remove humor
- Include more statistics
- Simplify language
- Add storytelling elements
- Strengthen CTA
Save Final Version:
from script_db import add_script
script = {
"title": "5 Productivity Apps That Changed My Life",
"type": "listicle-educational",
"tone": "casual-friendly",
"word_count": 1500,
"duration_minutes": 10,
"content": "[full script text]",
"notes": "Strong personal angle, relatable examples"
}
add_script(script)Best Practices
1. Hook Creation
- First 5 seconds are crucial
- Make a promise
- Create curiosity
- Address a pain point
- Use pattern interrupts
2. Pacing
- Vary sentence length
- Mix short and long paragraphs
- Build momentum
- Strategic pauses
- Energy shifts
3. Engagement Techniques
- Direct questions to viewer
- Personal stories
- Relatable examples
- Anticipated objections
- Social proof
4. Retention Optimization
- Tease what's coming
- Use callback references
- Pattern interrupts every 30-60 seconds
- Strategic information gaps
- Payoff promises made
5. Call to Action
- One primary CTA
- Explain the benefit
- Make it specific
- Create light urgency
- Natural integration
Script Templates
Educational Tutorial Template
[HOOK] Problem statement + Promise of solution
[INTRO] Personal context + What you'll learn + Why it matters
[SECTION 1] Concept explanation
- What it is
- Why it matters
- Common mistakes
[SECTION 2] Step-by-step process
- Step 1 with visuals
- Step 2 with examples
- Step 3 with tips
[SECTION 3] Common pitfalls
- What to avoid
- Troubleshooting
[CONCLUSION] Recap + Key takeaway + Next steps
[CTA] Subscribe + Resources + Comment promptListicle Template
[HOOK] Number tease + Unexpected angle
[INTRO] Context + Why this list matters
[ITEM 5] (Build suspense with countdown)
- What it is
- Why it works
- How to use it
[ITEM 4] Repeat structure
[ITEM 3] Repeat structure
[ITEM 2] Repeat structure
[ITEM 1] (Most important/surprising)
- Extra emphasis
- Best benefit
[CONCLUSION] Recap numbers + Ultimate takeaway
[CTA] Strong directive + Resource mentionStory/Narrative Template
[HOOK] Compelling story opening
[INTRO] Setup the story context
[SECTION 1] The problem/conflict
- Build tension
- Show stakes
- Make it relatable
[SECTION 2] The journey
- Challenges faced
- Attempts and failures
- Learning moments
[SECTION 3] The resolution
- How it worked out
- The transformation
[CONCLUSION] Lesson learned + How viewers can apply
[CTA] Invite similar stories + SubscribeTone Examples
Casual-Friendly
"Hey everyone! So, funny story – I completely messed this up last week.
Like, embarrassingly bad. But here's what I learned..."Professional-Authoritative
"In today's video, we're examining the three core principles that drive
successful implementation. Based on 5 years of data and research..."Energetic-Enthusiastic
"Okay, THIS is insane! I just discovered something that's going to blow
your mind. Are you ready? Because once you see this..."Educational-Patient
"Let's break this down step by step. Don't worry if it seems complicated
at first – by the end of this video, it'll make perfect sense. First..."Common Mistakes to Avoid
1. Weak hooks - Get to the point in 5 seconds 2. Long intros - Don't ramble before value 3. No structure - Viewers need signposts 4. Monotone delivery - Vary energy and pace 5. Information overload - Focus on key points 6. Forgetting the audience - Speak to them directly 7. Buried CTA - Make it clear and actionable 8. No personality - Let your unique voice show 9. Too formal - YouTube is conversational 10. No visual cues - Include filming notes
Example Interaction
User: "Write me a script about passive income ideas"
Claude: [Checks preferences - finds casual-friendly tone, medium length, question hooks]
Perfect! Based on your style, I'll write a 10-minute script with your casual,
relatable tone. A few quick questions:
1. How many passive income ideas should I cover? (3-5 works well for 10 minutes)
2. Any specific angle? (beginner-friendly, high-earning, low startup cost?)
3. Personal experience or research-based approach?
User: "5 ideas, beginner-friendly, mix of both personal experience and research"
Claude: [Generates complete script]
Here's your complete script for "5 Passive Income Ideas for Beginners":
[Full formatted script with hook, intro, 5 ideas with personal stories and data,
conclusion, and CTA – all in user's casual-friendly style]
The script is 1,450 words (~10 minutes) with:
✓ Question-based hook about financial freedom
✓ Personal story in intro about your first passive income
✓ Each idea includes: what it is, startup cost, time investment, real example
✓ Mix of your experience and statistics
✓ Natural humor in transitions
✓ Direct CTA about free passive income guide
Want me to adjust anything? I can make it more personal, add more data, or
change the energy level.Technical Notes
Data Storage:
- Location:
~/.claude/script_writer.json - Preferences saved persistently
- Script history maintained
CLI Commands:
python3 scripts/script_db.py is_initialized
python3 scripts/script_db.py get_preferences
python3 scripts/script_db.py get_scripts
python3 scripts/script_db.py statsWord Count Guidelines:
- Speaking pace: ~150 words per minute
- Short form (3-5 min): 450-750 words
- Medium form (7-12 min): 1,050-1,800 words
- Long form (15-30 min): 2,250-4,500 words
Resources
scripts/script_db.py
Database management for preferences, scripts, and templates.
references/script_formats.md
Comprehensive guide covering:
- Common YouTube video types and structures
- Script component breakdowns (hook, intro, content, conclusion, CTA)
- Tone guidelines for different styles
- Timing guidelines by video length
- Engagement techniques
- Common mistakes to avoid
- Visual cues for scripts
- Audience-specific adjustments
- Platform-specific considerations
export default async function script_writer(input) {
console.log("🧠 Running skill: script-writer");
// TODO: implement actual logic for this skill
return {
message: "Skill 'script-writer' executed successfully!",
input
};
}
{
"name": "@ai-labs-claude-skills/script-writer",
"version": "1.0.0",
"description": "Claude AI skill: script-writer",
"main": "index.js",
"files": [
"."
],
"license": "MIT",
"author": "AI Labs"
}YouTube Script Formats and Structures
Common YouTube Video Types
1. Educational/Tutorial Videos
Structure:
- Hook (0-10 seconds)
- Introduction (10-30 seconds)
- Main content with clear sections (bulk of video)
- Recap/Summary
- Call to action
Characteristics:
- Clear, step-by-step explanations
- Visual cues mentioned ("as you can see here")
- Numbered points or sections
- Pause points for viewer to follow along
2. Listicle/Top X Videos
Structure:
- Hook with the promise
- Quick intro
- Item #X (countdown or count up)
- Each item: Name → Explanation → Why it matters
- Conclusion with recap
- CTA
Characteristics:
- High energy
- Quick pace
- Transitions between items
- Suspense building (save best for last)
3. Story/Narrative Videos
Structure:
- Compelling hook
- Setup/Context
- Rising action
- Climax
- Resolution
- Reflection/Lesson
- CTA
Characteristics:
- Emotional connection
- Descriptive language
- Pacing variety
- Character development
- Plot twists or reveals
4. Review Videos
Structure:
- Hook with verdict tease
- Introduction to product/subject
- Pros
- Cons
- Comparisons (if applicable)
- Final verdict
- Who it's for
- CTA
Characteristics:
- Balanced perspective
- Specific examples
- Personal experience
- Clear criteria
- Honest assessment
5. Vlog Style
Structure:
- Energetic hook
- What's happening today
- Chronological or thematic sections
- Behind-the-scenes moments
- Reflection/Lesson learned
- CTA
Characteristics:
- Conversational
- Personal
- Authentic
- Energy shifts
- Direct address to camera
6. Commentary/Opinion Videos
Structure:
- Hook with controversial/interesting take
- Context/Background
- Main argument with supporting points
- Counter-arguments addressed
- Conclusion with final stance
- CTA
Characteristics:
- Strong voice
- Persuasive language
- Evidence and examples
- Conversational yet authoritative
- Engagement with opposing views
Script Components Breakdown
The Hook (First 5-10 seconds)
Purpose: Stop the scroll, capture attention immediately
Techniques:
- Question: "Have you ever wondered why...?"
- Bold statement: "This changed everything I thought I knew about..."
- Conflict: "I made a huge mistake and here's what happened..."
- Promise: "By the end of this video, you'll know exactly how to..."
- Shock: "I lost $10,000 in 5 minutes..."
- Pattern interrupt: "Stop! Before you [common action], watch this..."
Examples:
- "In the next 60 seconds, I'm going to show you a trick that will save you hours"
- "This is the most important thing I've learned in 10 years of..."
- "Everyone gets this wrong, and it's costing them..."
The Introduction (10-45 seconds)
Purpose: Establish credibility, set expectations, deliver on hook promise
Elements:
- Who you are (if relevant)
- What the video is about
- Why it matters to viewer
- What they'll learn/gain
- Quick preview of main points
Example: "Hey everyone, I'm [Name], and today we're diving into [topic]. If you've ever struggled with [problem], this video is for you. I'm going to show you [solution] that [benefit]. We'll cover [point 1], [point 2], and [point 3]. Let's get started."
The Main Content
Purpose: Deliver the value promised in hook and intro
Best Practices:
- Break into clear sections
- Use transitions
- Repeat key points
- Provide examples
- Address common objections
- Maintain energy
- Include visual references
Transition Phrases:
- "Now that we've covered X, let's move on to Y"
- "Here's where it gets interesting..."
- "The next point is crucial..."
- "Before we continue, quick note about..."
The Conclusion
Purpose: Reinforce key takeaways, create satisfaction
Elements:
- Summarize main points
- Restate key benefit
- Final thoughts or reflection
- Bridge to CTA
Example: "So to recap, we covered [point 1], [point 2], and [point 3]. The main thing to remember is [key takeaway]. Now you're ready to [apply knowledge]."
The Call to Action (CTA)
Purpose: Guide viewer to next action
Types:
- Subscribe: "If you found this helpful, subscribe for more..."
- Like/Comment: "Let me know in the comments..."
- Watch next: "Check out this video where I show you..."
- External link: "Grab my free guide in the description..."
- Social follow: "Follow me on Instagram for..."
Best Practices:
- One primary CTA
- Make it specific
- Explain the benefit
- Create urgency (if appropriate)
Tone Guidelines
Professional/Authoritative
- Confident language
- Industry terminology (with explanations)
- Cited sources
- Measured pace
- Clear structure
Casual/Friendly
- Conversational language
- Personal anecdotes
- "You" and "I" language
- Relaxed structure
- Humor when appropriate
Energetic/Enthusiastic
- Exclamation points
- Quick pace
- Dynamic vocabulary
- Momentum building
- High energy throughout
Educational/Patient
- Clear explanations
- Step-by-step approach
- Anticipate questions
- Reassuring language
- Allow processing time
Inspirational/Motivational
- Empowering language
- Story-driven
- Emotional connection
- Aspirational examples
- Encouraging tone
Timing Guidelines
Short Form (3-5 minutes)
- 450-750 words
- Single focused topic
- Quick hook (5 seconds)
- Streamlined content
- Fast pace
Medium Form (7-12 minutes)
- 1,050-1,800 words
- 2-3 main points
- Standard hook (8-10 seconds)
- Moderate depth
- Balanced pace
Long Form (15-30 minutes)
- 2,250-4,500 words
- Deep dive
- Strong hook (10-15 seconds)
- Multiple sections
- Varied pace
Engagement Techniques
Pattern Interrupts
- Unexpected statements
- Questions
- Tone shifts
- Visual changes
- Sound effects
Storytelling Elements
- Characters
- Conflict
- Resolution
- Emotional arc
- Relatability
Social Proof
- Statistics
- Expert quotes
- Case studies
- Personal results
- Testimonials
Curiosity Gaps
- Tease information
- "But here's the thing..."
- "Wait until you see..."
- "The surprising part is..."
Common Script Mistakes to Avoid
1. Burying the lede - Get to the point quickly 2. Rambling introduction - Hook first, context later 3. No clear structure - Viewers need signposts 4. Talking too fast - Leave room for visuals 5. Being too formal - YouTube is conversational 6. No personality - Let your unique voice shine 7. Forgetting the CTA - Always guide next steps 8. Too much information - Focus on key takeaways 9. No energy variation - Monotone loses viewers 10. Ignoring target audience - Speak directly to them
Visual Cues in Scripts
Include directions for yourself:
[B-roll: Show example of X]
[On-screen text: "Key Point"]
[Cut to close-up]
[Show product]
[Demonstrate step]
[Pause for emphasis]
[Smile/React]These help during filming and editing.
Audience-Specific Adjustments
Beginners
- Define terminology
- Slower pace
- More examples
- Encouragement
- Step-by-step
Intermediate
- Assume baseline knowledge
- Faster pace
- Advanced tips
- Comparisons
- Nuance
Expert
- Industry language
- Quick pace
- Deep insights
- Technical details
- Cutting-edge info
Platform-Specific Considerations
YouTube Shorts (Under 60 seconds)
- Immediate hook
- Single point
- No intro
- Fast cuts
- Vertical format
- Text on screen
YouTube Main Feed
- Strong thumbnail/title synergy
- 8-15 minute sweet spot
- Watch time optimization
- Chapter markers
- End screen elements
Educational Content
- Thorough explanations
- Longer acceptable
- Downloadable resources
- Chapters crucial
- Timestamps helpful
#!/usr/bin/env python3
"""
Script Writer Database Manager
Manages user scriptwriting preferences and past scripts.
"""
import json
from pathlib import Path
from datetime import datetime
from typing import Dict, Any, List, Optional
DB_FILE = Path.home() / ".claude" / "script_writer.json"
def ensure_db_file() -> None:
"""Ensure the database file exists."""
DB_FILE.parent.mkdir(parents=True, exist_ok=True)
if not DB_FILE.exists():
default_data = {
"initialized": False,
"created_at": datetime.now().isoformat(),
"preferences": {
"script_types": [],
"tone": "",
"target_audience": "",
"style": "",
"video_length": "",
"channel_niche": "",
"hook_style": "",
"call_to_action_preference": "",
"personality": "",
"use_humor": False,
"include_statistics": False,
"storytelling_approach": ""
},
"scripts": [],
"templates": []
}
DB_FILE.write_text(json.dumps(default_data, indent=2))
def load_data() -> Dict[str, Any]:
"""Load data from file."""
ensure_db_file()
try:
with open(DB_FILE, 'r') as f:
return json.load(f)
except (json.JSONDecodeError, FileNotFoundError):
return {}
def save_data(data: Dict[str, Any]) -> None:
"""Save data to file."""
ensure_db_file()
with open(DB_FILE, 'w') as f:
json.dump(data, f, indent=2)
# ============================================================================
# PREFERENCES
# ============================================================================
def is_initialized() -> bool:
"""Check if preferences are initialized."""
data = load_data()
return data.get("initialized", False)
def get_preferences() -> Dict[str, Any]:
"""Get user preferences."""
data = load_data()
return data.get("preferences", {})
def save_preferences(preferences: Dict[str, Any]) -> None:
"""Save user preferences."""
data = load_data()
data["preferences"].update(preferences)
data["initialized"] = True
data["last_updated"] = datetime.now().isoformat()
save_data(data)
# ============================================================================
# SCRIPTS
# ============================================================================
def add_script(script: Dict[str, Any]) -> str:
"""Add a new script."""
data = load_data()
script_id = str(datetime.now().timestamp())
script["id"] = script_id
script["created_at"] = datetime.now().isoformat()
data["scripts"].append(script)
save_data(data)
return script_id
def get_scripts() -> List[Dict[str, Any]]:
"""Get all scripts."""
data = load_data()
return data.get("scripts", [])
def get_script_by_id(script_id: str) -> Optional[Dict[str, Any]]:
"""Get a specific script."""
data = load_data()
for script in data.get("scripts", []):
if script.get("id") == script_id:
return script
return None
def update_script(script_id: str, updates: Dict[str, Any]) -> bool:
"""Update a script."""
data = load_data()
for script in data["scripts"]:
if script.get("id") == script_id:
script.update(updates)
script["updated_at"] = datetime.now().isoformat()
save_data(data)
return True
return False
def delete_script(script_id: str) -> bool:
"""Delete a script."""
data = load_data()
for i, script in enumerate(data["scripts"]):
if script.get("id") == script_id:
data["scripts"].pop(i)
save_data(data)
return True
return False
# ============================================================================
# TEMPLATES
# ============================================================================
def add_template(template: Dict[str, Any]) -> str:
"""Add a custom template."""
data = load_data()
template_id = str(datetime.now().timestamp())
template["id"] = template_id
template["created_at"] = datetime.now().isoformat()
data["templates"].append(template)
save_data(data)
return template_id
def get_templates() -> List[Dict[str, Any]]:
"""Get all templates."""
data = load_data()
return data.get("templates", [])
# ============================================================================
# STATISTICS
# ============================================================================
def get_stats() -> Dict[str, Any]:
"""Get script statistics."""
data = load_data()
scripts = data.get("scripts", [])
script_types = {}
tones = {}
for script in scripts:
script_type = script.get("type", "Unknown")
tone = script.get("tone", "Unknown")
script_types[script_type] = script_types.get(script_type, 0) + 1
tones[tone] = tones.get(tone, 0) + 1
return {
"total_scripts": len(scripts),
"by_type": script_types,
"by_tone": tones
}
# ============================================================================
# CLI
# ============================================================================
if __name__ == "__main__":
import sys
if len(sys.argv) < 2:
print("Script Writer Database Manager")
print("\nUsage:")
print(" python3 script_db.py is_initialized")
print(" python3 script_db.py get_preferences")
print(" python3 script_db.py get_scripts")
print(" python3 script_db.py stats")
sys.exit(1)
command = sys.argv[1]
if command == "is_initialized":
print("true" if is_initialized() else "false")
elif command == "get_preferences":
print(json.dumps(get_preferences(), indent=2))
elif command == "get_scripts":
print(json.dumps(get_scripts(), indent=2))
elif command == "stats":
print(json.dumps(get_stats(), indent=2))
else:
print(f"Unknown command: {command}")
sys.exit(1)
Related skills
FAQ
How are preferences stored?
script_db.py database tracks initialization, preferences, and past scripts.
What happens on first use?
Collect comprehensive preferences for script type, tone, audience, length, and hooks.
Which script types are supported?
Educational, listicle, story, review, vlog, commentary, how-to, explainer, entertainment.
Is Script Writer safe to install?
skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.