NAME

Wordsmith::Claude - AI-powered text rewriting with style

VERSION

Version 0.02

SYNOPSIS

use Wordsmith::Claude qw(rewrite question blog);
use IO::Async::Loop;

my $loop = IO::Async::Loop->new;

# Simple mode-based rewriting
my $result = rewrite(
    text => "The quantum entanglement phenomenon demonstrates non-local correlations",
    mode => 'eli5',
    loop => $loop,
)->get;

print $result->text;
# "It's like having two magic coins that always match, even far apart!"

# Different tones
my $formal = rewrite(text => $casual_message, mode => 'formal', loop => $loop)->get;
my $casual = rewrite(text => $business_email, mode => 'casual', loop => $loop)->get;

# Fun styles
my $pirate = rewrite(text => $boring, mode => 'pirate', loop => $loop)->get;
my $shakespeare = rewrite(text => $modern, mode => 'shakespeare', loop => $loop)->get;

# Custom instructions
my $custom = rewrite(
    text => $text,
    instruction => "Rewrite as a nature documentary narrator",
    loop => $loop,
)->get;

# Multiple variations
my $result = rewrite(
    text => $text,
    mode => 'casual',
    variations => 3,
    loop => $loop,
)->get;

print $_->text for $result->all_variations;

# Ask questions about text
my $answer = question(
    text     => $essay,
    question => "What is the main argument?",
    loop     => $loop,
)->get;

print $answer->text;

# Ask general questions (no context)
my $answer = question(
    question => "What is the capital of France?",
    loop     => $loop,
)->get;

# Parallel requests (non-blocking)
my $f1 = rewrite(text => $text1, mode => 'eli5', loop => $loop);
my $f2 = rewrite(text => $text2, mode => 'formal', loop => $loop);
my $f3 = question(question => "What is 2+2?", loop => $loop);

# Wait for all to complete
use Future;
my @results = Future->needs_all($f1, $f2, $f3)->get;

DESCRIPTION

Wordsmith::Claude is an AI-powered text rewriting tool built on the Claude Agent SDK. It can transform text into different styles, tones, and complexity levels.

BUILT-IN MODES

Complexity

  • eli5 - Explain Like I'm 5 (very simple)

  • eli10 - Explain Like I'm 10 (simple but more detail)

  • technical - Add technical precision and jargon

Tone

  • formal - Professional, business-appropriate

  • casual - Relaxed, conversational

  • friendly - Warm and approachable

  • professional - Polished and authoritative

Length/Format

  • concise - Trim to essentials

  • expand - Add detail and explanation

  • bullets - Convert to bullet points

  • summarize - Brief summary

Fun Styles

  • pirate - Arr, talk like a pirate!

  • shakespeare - Forsooth, in the Bard's tongue

  • yoda - Speak like Yoda, you will

  • corporate - Synergize the paradigm shift

  • valley - Like, totally rewrite it

Utility

  • proofread - Fix grammar and spelling

EXPORTED FUNCTIONS

rewrite

my $result = rewrite(
    text        => $input_text,       # Required
    mode        => 'eli5',            # Built-in mode (optional)
    instruction => 'custom prompt',   # Custom instruction (optional)
    variations  => 3,                 # Number of variations (default 1)
    options     => $options_obj,      # Wordsmith::Claude::Options (optional)
    loop        => $loop,             # IO::Async::Loop (optional)
)->get;

Rewrite text using a mode or custom instruction. Returns a Future that resolves to a Wordsmith::Claude::Result object.

Either mode or instruction must be provided.

question

my $result = question(
    question => "What is the capital of France?",  # Required
    text     => $context_text,                      # Optional context
    options  => $options_obj,                       # Optional
    loop     => $loop,                              # Optional
)->get;

# With context
my $result = question(
    text     => $essay,
    question => "What is the main argument?",
    loop     => $loop,
)->get;

print $result->text;  # The answer

Ask a question, optionally about provided text context. Returns a Future that resolves to a Wordsmith::Claude::Result object.

blog

my $result = blog(
    topic   => 'Building AI Tools with Perl',  # Required
    style   => 'technical',                     # Optional (default: technical)
    tone    => 'enthusiastic',                  # Optional (default: professional)
    length  => 'medium',                        # Optional (default: medium)
    sections => ['intro', 'main', 'conclusion'], # Optional custom sections
    options => $options_obj,                    # Optional
    loop    => $loop,                           # Optional
)->get;

print $result->title;
print $result->text;
print "Word count: ", $result->word_count, "\n";

Generate a blog post on a given topic. Returns a Future that resolves to a Wordsmith::Claude::Blog::Result object.

Interactive Mode

For an interactive blog building experience, use the prompt_cb callback to receive choices at each step:

my $result = blog(
    topic     => 'AI in Perl',
    prompt_cb => sub {
        my ($step, $options, $default) = @_;
        # $step is 'style', 'tone', 'length', or 'sections'
        # $options is arrayref of valid choices
        # $default is the default value
        # Return the chosen value
        print "Choose $step [$default]: ";
        my $choice = <STDIN>;
        chomp $choice;
        return $choice || $default;
    },
    loop => $loop,
)->get;

Available Styles

  • technical - Technical deep-dive with code examples

  • tutorial - Step-by-step guide with hands-on examples

  • announcement - Product or feature announcement

  • casual - Conversational, personal tone

  • listicle - Numbered list format

  • opinion - Thought leadership piece

  • comparison - Side-by-side comparison

  • howto - Practical how-to guide

Available Tones

  • professional - Polished and authoritative

  • friendly - Warm and approachable

  • enthusiastic - Excited and energetic

  • thoughtful - Reflective and considered

  • humorous - Light-hearted with wit

  • direct - Straight to the point

Available Lengths

  • short - Quick read (500-800 words)

  • medium - Standard post (1000-1500 words)

  • long - In-depth article (2000-3000 words)

SEE ALSO

AUTHOR

LNATION, <email at lnation.org>

LICENSE AND COPYRIGHT

This software is Copyright (c) 2026 by LNATION.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)