Collection of commands that execute code-like prompts demonstrating programming concepts including logic programming and backtracking

Install

/plugin install code-like-prompt@kokuyouwind-plugins

Run it inside Claude Code after adding the marketplace with /plugin marketplace add kokuyouwind/claude-plugins.

Contents

Discovered from source

Commands 69

Emulate the following code internally (without using external tools or interpreter) with environment: $ARGUMENTS

Output only what puts() commands would output. Do not show any explanations, code, variables, or other messages.

# Validate required arguments
raise "Required argument 'Milk.stock' is missing" if Milk.stock.nil?
raise "Required argument 'Egg.stock' is missing" if Egg.stock.nil?

# Shopping logic (husband's misunderstanding)
milk_amount = 1
if Egg.exists?  # Egg.exists? means Egg.stock > 0
  milk_amount = 6
end
puts("Bought #{milk_amount} milks.")

Emulate the following code internally (without using external tools or interpreter) with environment: $ARGUMENTS

Output only what puts() commands would output. Do not show any explanations, code, variables, or other messages.

# Validate required arguments
raise "Required argument 'Milk.stock' is missing" if Milk.stock.nil?
raise "Required argument 'Egg.stock' is missing" if Egg.stock.nil?

# Shopping logic
puts("Bought 1 milk.")
if Egg.exists?  # Egg.exists? means Egg.stock > 0
  puts("Bought 6 eggs.")
end

Emulate the following code internally (without using external tools or interpreter) with environment: $ARGUMENTS

Output only what printf() commands would output. Do not show any explanations, code, variables, or other messages.

// Validate required arguments
if (condition_a == NULL) {
    fprintf(stderr, "Required argument 'condition_a' is missing");
    exit(1);
}
if (condition_b == NULL) {
    fprintf(stderr, "Required argument 'condition_b' is missing");
    exit(1);
}

// Logic
if (condition_a) {
    if (condition_b) {
        printf("foo");
    }
} else {
    printf("bar");
}

Emulate the following code internally (without using external tools or interpreter) with environment: $ARGUMENTS

Output only what print() commands would output. Do not show any explanations, code, variables, or other messages.

# Validate required arguments
if condition_a is None:
    raise ValueError("Required argument 'condition_a' is missing")
if condition_b is None:
    raise ValueError("Required argument 'condition_b' is missing")

# Logic
if condition_a:
    if condition_b:
        print("foo")
else:
    print("bar")

Emulate the following code internally (without using external tools or interpreter) with environment: $ARGUMENTS

Output only what print() commands would output. Do not show any explanations, code, variables, or other messages.

# Validate required arguments
raise "Required argument 'condition_a' is missing" if condition_a.nil?
raise "Required argument 'condition_b' is missing" if condition_b.nil?

# Logic
if condition_a
  if condition_b
    print "foo"
  end
else
  print "bar"
end

Emulate the following code internally (without using external tools or interpreter) with environment: $ARGUMENTS

Output only what printf() commands would output. Do not show any explanations, code, variables, or other messages.

// Validate required arguments
if (condition_a == NULL) {
    fprintf(stderr, "Required argument 'condition_a' is missing");
    exit(1);
}
if (condition_b == NULL) {
    fprintf(stderr, "Required argument 'condition_b' is missing");
    exit(1);
}

// Logic
if (condition_a) {
    if (condition_b) {
        printf("foo");
    } else {
        printf("bar");
    }
}

Emulate the following code internally (without using external tools or interpreter) with environment: $ARGUMENTS

Output only what print() commands would output. Do not show any explanations, code, variables, or other messages.

# Validate required arguments
if condition_a is None:
    raise ValueError("Required argument 'condition_a' is missing")
if condition_b is None:
    raise ValueError("Required argument 'condition_b' is missing")

# Logic
if condition_a:
    if condition_b:
        print("foo")
    else:
        print("bar")

Emulate the following code internally (without using external tools or interpreter) with environment: $ARGUMENTS

Output only what print() commands would output. Do not show any explanations, code, variables, or other messages.

# Validate required arguments
raise "Required argument 'condition_a' is missing" if condition_a.nil?
raise "Required argument 'condition_b' is missing" if condition_b.nil?

# Logic
if condition_a
  if condition_b
    print "foo"
  else
    print "bar"
  end
end

Emulate the following code internally (without using external tools or interpreter) with environment: $ARGUMENTS

Output only what printf() commands would output. Do not show any explanations, code, variables, or other messages. If there is nothing to output, output () instead.

// Validate required arguments
if (level1 == NULL) {
    fprintf(stderr, "Required argument 'level1' is missing");
    exit(1);
}
if (level2 == NULL) {
    fprintf(stderr, "Required argument 'level2' is missing");
    exit(1);
}
if (level3 == NULL) {
    fprintf(stderr, "Required argument 'level3' is missing");
    exit(1);
}
if (level4 == NULL) {
    fprintf(stderr, "Required argument 'level4' is missing");
    exit(1);
}

// Logic
if (level1) {
    if (level2) {
        if (level3) {
            printf("foo");
        } else {
            if (level4) {
                printf("bar");
            } else {
                printf("baz");
            }
        }
    } else {
        if (level3) {
            if (level4) {
                printf("qux");
            }
        } else {
            printf("quux");
        }
    }
} else {
    if (level2) {
        printf("corge");
    } else {
        if (level3) {
            printf("grault");
        } else {
            printf("garply");
        }
    }
}

Emulate the following code internally (without using external tools or interpreter) with environment: $ARGUMENTS

Output only what print() commands would output. Do not show any explanations, code, variables, or other messages. If there is nothing to output, output () instead.

# Validate required arguments
if level1 is None:
    raise ValueError("Required argument 'level1' is missing")
if level2 is None:
    raise ValueError("Required argument 'level2' is missing")
if level3 is None:
    raise ValueError("Required argument 'level3' is missing")
if level4 is None:
    raise ValueError("Required argument 'level4' is missing")

# Logic
if level1:
    if level2:
        if level3:
            print("foo")
        else:
            if level4:
                print("bar")
            else:
                print("baz")
    else:
        if level3:
            if level4:
                print("qux")
        else:
            print("quux")
else:
    if level2:
        print("corge")
    else:
        if level3:
            print("grault")
        else:
            print("garply")

Emulate the following code internally (without using external tools or interpreter) with environment: $ARGUMENTS

Output only what print() commands would output. Do not show any explanations, code, variables, or other messages. If there is nothing to output, output () instead.

# Validate required arguments
raise "Required argument 'level1' is missing" if level1.nil?
raise "Required argument 'level2' is missing" if level2.nil?
raise "Required argument 'level3' is missing" if level3.nil?
raise "Required argument 'level4' is missing" if level4.nil?

# Logic
if level1
  if level2
    if level3
      print "foo"
    else
      if level4
        print "bar"
      else
        print "baz"
      end
    end
  else
    if level3
      if level4
        print "qux"
      end
    else
      print "quux"
    end
  end
else
  if level2
    print "corge"
  else
    if level3
      print "grault"
    else
      print "garply"
    end
  end
end

Emulate the following code internally (without using external tools or interpreter) with environment: $ARGUMENTS

Output only what print() commands would output. Do not show any explanations, code, variables, or other messages.

# Validate required arguments
if count is None:
    raise ValueError("Required argument 'count' is missing")

# Loop
for i in range(count):
    print(f"foo{i}")

Emulate the following code internally (without using external tools or interpreter) with environment: $ARGUMENTS

Output only what print() commands would output. Do not show any explanations, code, variables, or other messages.

# Validate required arguments
if max_count is None:
    raise ValueError("Required argument 'max_count' is missing")

# Loop
count = 0
while count < max_count:
    print("bar")
    count += 1
print("baz")

Emulate the following code internally (without using external tools or interpreter) with environment: $ARGUMENTS

Output only what puts() commands would output. Do not show any explanations, code, variables, or other messages.

# Validate required arguments
raise "Required argument 'items' is missing" if items.nil?

# Iteration
items.each do |item|
  puts item
end

Emulate the following code internally (without using external tools or interpreter) with environment: $ARGUMENTS

Output only what print() commands would output. Do not show any explanations, code, variables, or other messages.

# Validate required arguments
if break_at is None:
    raise ValueError("Required argument 'break_at' is missing")

# Loop with break
for i in range(10):
    if i == break_at:
        break
    print(f"foo{i}")
print("bar")

Emulate the following code internally (without using external tools or interpreter) with environment: $ARGUMENTS

Output only what print() commands would output. Do not show any explanations, code, variables, or other messages.

# Validate required arguments
if skip_at is None:
    raise ValueError("Required argument 'skip_at' is missing")

# Loop with continue
for i in range(5):
    if i == skip_at:
        continue
    print(f"foo{i}")

Emulate the following code internally (without using external tools or interpreter) with environment: $ARGUMENTS

Output only what print() commands would output. Do not show any explanations, code, variables, or other messages.

# Validate required arguments
if outer_count is None:
    raise ValueError("Required argument 'outer_count' is missing")
if inner_count is None:
    raise ValueError("Required argument 'inner_count' is missing")

# Nested loops
for i in range(outer_count):
    for j in range(inner_count):
        print(f"foo{i}{j}")

Emulate the following code internally (without using external tools or interpreter) with environment: $ARGUMENTS

Output only what print() commands would output. Do not show any explanations, code, variables, or other messages.

# Validate required arguments
if outer_count is None:
    raise ValueError("Required argument 'outer_count' is missing")
if inner_break_at is None:
    raise ValueError("Required argument 'inner_break_at' is missing")

# Nested loop with inner break
for i in range(outer_count):
    for j in range(5):
        if j == inner_break_at:
            break
        print(f"bar{i}{j}")
    print(f"baz{i}")

Emulate the following code internally (without using external interpreter) with environment: $ARGUMENTS

Output only what puts() commands would output. Do not show any explanations, code, variables, or other messages.

# Validate required arguments
raise "Required argument 'pattern' is missing" if pattern.nil?

# File system iteration
Dir.glob(pattern).each do |file|
  puts file
end

Emulate the following code internally (without using external tools or interpreter) with environment: $ARGUMENTS

Output only what print() commands would output. Do not show any explanations, code, variables, or other messages.

# Validate required arguments
if start is None:
    raise ValueError("Required argument 'start' is missing")
if end is None:
    raise ValueError("Required argument 'end' is missing")

# Loop with accumulator
total = 0
for i in range(start, end):
    total += i
    print(f"foo{total}")

Emulate the following code internally (without using external tools or interpreter) with environment: $ARGUMENTS

Output only what print() commands would output. Do not show any explanations, code, variables, or other messages.

# Validate required arguments
if x_limit is None:
    raise ValueError("Required argument 'x_limit' is missing")
if y_start is None:
    raise ValueError("Required argument 'y_start' is missing")
if y_decrement is None:
    raise ValueError("Required argument 'y_decrement' is missing")

# While loop with complex condition
x = 0
y = y_start
while x < x_limit and y > 0:
    print(f"bar{x}{y}")
    x += 1
    y -= y_decrement

Emulate the following code internally (without using external tools or interpreter) with environment: $ARGUMENTS

Output only what putStrLn commands would output. Do not show any explanations, code, variables, or other messages.

import Text.Regex.Posix ((=~))

main :: IO ()
main = do
    -- Validate required arguments
    let text = case lookupArg "text" of
            Nothing -> error "Required argument 'text' is missing"
            Just t -> t

    -- Pattern matching with guards
    case text of
        _ | text =~ "^foo.*bar$" -> putStrLn "qux"
          | text =~ "^baz" -> putStrLn "quux"
          | otherwise -> putStrLn "corge"

Emulate the following code internally (without using external tools or interpreter) with environment: $ARGUMENTS

Output only what putStrLn commands would output. Do not show any explanations, code, variables, or other messages.

-- Record data type definition
data Record = Record { label :: String, value :: Int }
            deriving (Show, Eq)

-- Assume record :: Record is directly provided as Haskell data type
-- Example: Record "foo" 5

main :: IO ()
main = do
    -- record argument is provided as Record type
    let record = getRecord "record"

    -- Structural pattern matching with guards
    case record of
        Record "foo" v -> putStrLn $ "foo:" ++ show v
        Record "bar" v | v > 10 -> putStrLn "bar-large"
        Record "bar" v -> putStrLn "bar-small"
        Record l _ -> putStrLn $ "other:" ++ l

Emulate the following code internally (without using external tools or interpreter) with environment: $ARGUMENTS

Output only what putStrLn commands would output. Do not show any explanations, code, variables, or other messages.

-- Assume list :: [String] is directly provided as Haskell data type
-- Example: ["foo", "bar", "baz"]

main :: IO ()
main = do
    -- list argument is provided as [String] type
    let list = getList "list"

    -- List pattern matching with destructuring
    case list of
        [] -> putStrLn "empty"
        [x] -> putStrLn $ "single:" ++ x
        ["foo", "bar"] -> putStrLn "foo-bar"
        ["foo", x, "baz"] -> putStrLn $ "foo-x-baz:" ++ x
        (x:y:_) -> putStrLn $ "multi:" ++ x ++ "," ++ y
        _ -> putStrLn "other"

Emulate the following code internally (without using external tools or interpreter) with environment: $ARGUMENTS

Output only what putStrLn commands would output. Do not show any explanations, code, variables, or other messages.

-- Tree data type definition
data Tree = Leaf String
          | Branch Tree Tree
          deriving (Show, Eq)

-- Assume tree :: Tree is directly provided as Haskell data type
-- Example: Branch (Leaf "foo") (Leaf "bar")

main :: IO ()
main = do
    -- tree argument is provided as Tree type
    let tree = getTree "tree"

    -- Pattern matching on nested tree structure
    case tree of
        Leaf x -> putStrLn $ "leaf:" ++ x
        Branch (Leaf "foo") (Leaf "bar") -> putStrLn "foo-bar"
        Branch (Leaf "foo") _ -> putStrLn "foo-any"
        Branch _ (Leaf "bar") -> putStrLn "any-bar"
        Branch (Branch _ _) _ -> putStrLn "nested"
        Branch _ _ -> putStrLn "other"

Emulate the following code internally (without using external tools or interpreter) with environment: $ARGUMENTS

Output only what putStrLn commands would output. Do not show any explanations, code, variables, or other messages.

main :: IO ()
main = do
    -- Validate required arguments
    let x = case lookupArg "x" of
            Nothing -> error "Required argument 'x' is missing"
            Just v -> read v :: Int
    let y = case lookupArg "y" of
            Nothing -> error "Required argument 'y' is missing"
            Just v -> read v :: Int

    -- Pattern matching with guards
    case (x, y) of
        (a, b) | a > 0 && b > 0 -> putStrLn "foo"
               | a > 0 || b > 0 -> putStrLn "bar"
        (0, 0) -> putStrLn "baz"
        _ -> putStrLn "qux"

Emulate the following code internally (without using external tools or interpreter) with environment: $ARGUMENTS

Output only what putStrLn commands would output. Do not show any explanations, code, variables, or other messages.

-- Color data type definition
data Color = Red
           | Green
           | Blue
           | RGB Int Int Int
           deriving (Show, Eq)

-- Assume color :: Color is directly provided as Haskell data type
-- Example: Red, Green, Blue, or RGB 255 100 50

main :: IO ()
main = do
    -- color argument is provided as Color type
    let color = getColor "color"

    -- Exhaustive pattern matching
    case color of
        Red -> putStrLn "red"
        Green -> putStrLn "green"
        Blue -> putStrLn "blue"
        RGB r _ _ | r > 200 -> putStrLn "bright"
        RGB r g b -> putStrLn $ "rgb:" ++ show r ++ "," ++ show g ++ "," ++ show b

Emulate the following code internally (without using external tools or interpreter) with environment: $ARGUMENTS

Output only what putStrLn commands would output. Do not show any explanations, code, variables, or other messages.

-- Assume maybeValue :: Maybe String is directly provided

-- Process with pattern matching
processPattern :: Maybe String -> IO ()
processPattern maybeVal =
    case maybeVal of
        Nothing -> putStrLn "none"
        Just x -> putStrLn $ "value:" ++ x

-- Process with do notation
processDo :: Maybe String -> IO ()
processDo maybeVal = do
    let result = do
        x <- maybeVal          -- Extract from Maybe
        return $ "processed:" ++ x
    case result of
        Nothing -> putStrLn "empty"
        Just r -> putStrLn r

main :: IO ()
main = do
    -- Assume maybeValue is provided as Maybe String
    -- "Nothing" → Nothing, "Just:foo" → Just "foo"
    let maybeValue = case lookupArg "maybe_value" of
            Just "Nothing" -> Nothing
            Just s | take 5 s == "Just:" -> Just (drop 5 s)
            _ -> error "Invalid maybe_value format"

    let style = case lookupArg "style" of
            Nothing -> "pattern"
            Just s -> s

    case style of
        "pattern" -> processPattern maybeValue
        "do" -> processDo maybeValue
        _ -> error "Invalid style"

Emulate the following code internally (without using external tools or interpreter) with environment: $ARGUMENTS

Output only what putStrLn commands would output. Do not show any explanations, code, variables, or other messages.

-- Assume eitherValue :: Either String String is directly provided

-- Process with pattern matching
processPattern :: Either String String -> IO ()
processPattern eitherVal =
    case eitherVal of
        Left err -> putStrLn $ "error:" ++ err
        Right val -> putStrLn $ "success:" ++ val

-- Process with do notation (Either monad)
processDo :: Either String String -> IO ()
processDo eitherVal = do
    let result = do
        x <- eitherVal                -- Extract Right or propagate Left
        return $ "processed:" ++ x    -- Transform and wrap in Right
    case result of
        Left err -> putStrLn $ "failed:" ++ err
        Right r -> putStrLn r

main :: IO ()
main = do
    -- Assume eitherValue is provided as Either String String
    -- "Left:error" → Left "error", "Right:value" → Right "value"
    let eitherValue = case lookupArg "either_value" of
            Just s | take 5 s == "Left:" -> Left (drop 5 s)
                   | take 6 s == "Right:" -> Right (drop 6 s)
            _ -> error "Invalid either_value format"

    let style = case lookupArg "style" of
            Nothing -> "pattern"
            Just s -> s

    case style of
        "pattern" -> processPattern eitherValue
        "do" -> processDo eitherValue
        _ -> error "Invalid style"

Emulate the following Go-style code internally (without using external tools or interpreter). Output only what fmt.Println() commands would output. Do not show any explanations, code, variables, or other messages.

package main

import (
    "fmt"
    "sync"
)

func main() {
    var wg sync.WaitGroup

    wg.Add(2)
    go func() {
        defer wg.Done()
        fmt.Println("foo")
    }()
    go func() {
        defer wg.Done()
        fmt.Println("bar")
    }()

    wg.Wait()
    fmt.Println("baz")
}

Emulate the following Go-style code internally (without using external tools or interpreter). Output only what fmt.Println() commands would output. Do not show any explanations, code, variables, or other messages.

package main

import "fmt"

func main() {
    ch := make(chan string)

    go func() {
        ch <- "foo"
        ch <- "bar"
    }()

    fmt.Println(<-ch)
    fmt.Println(<-ch)
    fmt.Println("baz")
}

Emulate the following Go-style code internally (without using external tools or interpreter). Output only what fmt.Println() commands would output. Do not show any explanations, code, variables, or other messages.

package main

import "fmt"

func main() {
    ch := make(chan string, 2)

    ch <- "foo"
    ch <- "bar"
    // ch <- "baz"  // Would block if uncommented

    fmt.Println(<-ch)
    fmt.Println(<-ch)
    fmt.Println("qux")
}

Emulate the following Go-style code internally (without using external tools or interpreter). Output only what fmt.Println() commands would output. Do not show any explanations, code, variables, or other messages.

package main

import "fmt"

func main() {
    ch1 := make(chan string, 1)
    ch2 := make(chan string, 1)

    ch1 <- "foo"
    ch2 <- "bar"

    for i := 0; i < 2; i++ {
        select {
        case msg := <-ch1:
            fmt.Println(msg)
        case msg := <-ch2:
            fmt.Println(msg)
        }
    }
    fmt.Println("baz")
}

Emulate the following Go-style code internally (without using external tools or interpreter). Output only what fmt.Println() commands would output. Do not show any explanations, code, variables, or other messages.

package main

import "fmt"

func main() {
    ch := make(chan string)

    select {
    case msg := <-ch:
        fmt.Println(msg)
    default:
        fmt.Println("foo")
    }

    fmt.Println("bar")
}

Emulate the following Go-style code internally (without using external tools or interpreter). Output only what fmt.Printf() and fmt.Println() commands would output. Do not show any explanations, code, variables, or other messages.

package main

import (
    "fmt"
    "sync"
)

func worker(id int, jobs <-chan string, wg *sync.WaitGroup) {
    defer wg.Done()
    for job := range jobs {
        fmt.Printf("bar%d%s\n", id, job)
    }
}

func main() {
    jobs := make(chan string, 3)
    var wg sync.WaitGroup

    workers := 2
    if workers_arg != nil {
        workers = workers_arg
    }

    job_list := []string{"A", "B", "C"}
    if jobs_arg != nil {
        job_list = strings.Split(jobs_arg, ",")
    }

    // Start workers
    for i := 1; i <= workers; i++ {
        wg.Add(1)
        go worker(i, jobs, &wg)
    }

    // Send jobs
    for _, j := range job_list {
        jobs <- j
    }
    close(jobs)

    wg.Wait()
    fmt.Println("baz")
}
05g-semaphore.md05h-pipeline.md05i-timeout.md05j-fan-out-in.md05k-subagent-style.md05l-channel-messaging.md05m-multi-goroutine-channel.md06a-function-args.md06b-function-return.md06c-function-refactor.md07-a-basic-facts-no-fail.md07-a-basic-facts.md07-b-multi-clause-no-fail.md07-b-multi-clause.md07-c-cut-no-fail.md07-c-cut.md07-d-tree-traverse-no-fail.md07-d-tree-traverse.md07-e-findall.md07-f-negation-no-fail.md07-f-negation.md07-g-constraints-no-fail.md07-g-constraints.md08a-inline-actor.md08b-agent-spawn.md08c-message-direct.md08d-message-helper.md08e-selective-receive.md08f-multi-actor.md08g-supervisor.md08h-plugin-agent-spawn.md08i-plugin-agent-messaging.md08j-plugin-agent-script-messaging.md08k-werewolf.md

Agents 5

You are simulating an Erlang coordinator process. Emulate the following Erlang-style actor behavior:

-module(coordinator).
-export([loop/1]).

%% Coordinator process loop
%% Receives results from multiple workers and aggregates them
loop(NumWorkers) ->
    CoordinatorId = self(),
    io:format("Coordinator: waiting for ~p workers~n", [NumWorkers]),

    %% Collect results from all workers
    Results = collect_results(NumWorkers, []),

    %% Aggregate the results
    Combined = aggregate_results(Results),

    io:format("Coordinator: all results collected~n"),
    io:format("Coordinator: combined result = ~p~n", [Combined]),

    %% Send combined result to parent (assuming parent is in Results)
    case Results of
        [{_, _, ParentPid} | _] ->
            ParentPid ! {done, Combined};
        _ ->
            %% If no parent info, just output the result
            io:format("Coordinator: sending combined result: ~s~n", [Combined])
    end.

%% Collect results from N workers
collect_results(0, Acc) ->
    lists:reverse(Acc);

collect_results(N, Acc) ->
    receive
        {result, WorkerId, Data} ->
            io:format("Coordinator: received from ~p: ~p~n", [WorkerId, Data]),
            collect_results(N - 1, [{result, WorkerId, Data} | Acc])
    end.

%% Aggregate results based on their type
aggregate_results(Results) ->
    %% Extract just the data from the result tuples
    DataList = [Data || {result, _WorkerId, Data} <- Results],

    %% Determine type and aggregate accordingly
    case DataList of
        [First | _] when is_list(First) ->
            %% String concatenation
            lists:concat(DataList);

        [First | _] when is_integer(First) ->
            %% Numeric sum
            lists:sum(DataList);

        _ ->
            %% Generic list aggregation
            DataList
    end.

Important Constraints

  • Message order: Workers may send results in any order (non-deterministic)
  • Blocking receives: Each receive blocks until a matching message arrives
  • No shared state: Maintain isolated state for partial results
  • Pattern matching: Use patterns to identify which worker sent which result
  • Deterministic aggregation: Same inputs produce same output (but order may vary)

Output only what io:format() commands would output. Follow Erlang message-passing semantics strictly.

You are simulating a werewolf game player. Emulate the following Erlang-style actor behavior:

CRITICAL: INFORMATION ISOLATION

YOU ONLY KNOW YOUR OWN ROLE. YOU DO NOT AND CANNOT KNOW OTHER PLAYERS' ROLES.

  • When you receive role_assign message, you learn ONLY your own role
  • You do NOT know what roles other players have
  • You do NOT know how many werewolves, villagers, seers, knights, or madmen exist
  • The only way to learn about others is through:
    • Fortune teller's divination results (if you are the fortune teller)
    • Deduction from discussion and voting patterns
    • Claims made by other players (which may be lies)

NEVER assume or use knowledge about other players' actual roles in your reasoning.

ROLE OBJECTIVES AND WIN CONDITIONS

When you receive your role assignment, understand your objective based on your role:

Werewolf Team (人狼陣営)

Werewolf (人狼)

  • Objective: Eliminate villagers without being discovered
  • Night Action: Attack one player each night
  • Day Behavior: Pretend to be a villager. Lie, deceive, and deflect suspicion. May fake claim to be fortune teller.
  • Win Condition: Werewolves ≥ Villagers (werewolf team victory)
  • Key Strategy: Do NOT reveal your identity. Blend in with villagers. Cast suspicion on others.

Madman (狂人)

  • Objective: Help werewolves win without knowing who they are
  • Night Action: None
  • Day Behavior: Confuse villagers, support suspicious players, may fake claim to be fortune teller to contradict real fortune teller
  • Win Condition: Werewolves ≥ Villagers (werewolf team victory)
  • Key Strategy: Create chaos and doubt. Protect likely werewolves without revealing your alignment.

Villager Team (村人陣営)

Fortune Teller / Seer (占い師)

  • Objective: Find and expose werewolves
  • Night Action: Divine one player to learn if they are werewolf or not
  • Day Behavior: Decide whether to reveal your role and share divination results. Be cautious of fake claims.
  • Win Condition: All werewolves eliminated (villager team victory)
  • Key Strategy: Use divination wisely. Consider when to reveal your identity and results.

Knight (騎士)

  • Objective: Protect villagers from werewolf attacks
  • Night Action: Guard one player to prevent werewolf attack
  • Day Behavior: Act as a villager. Do NOT reveal your role (werewolves will target you)
  • Win Condition: All werewolves eliminated (villager team victory)
  • Key Strategy: Protect likely targets. Keep your identity secret.

Villager (村人)

  • Objective: Find and eliminate werewolves through discussion and voting
  • Night Action: None
  • Day Behavior: Participate in discussion, analyze claims, vote for suspicious players
  • Win Condition: All werewolves eliminated (villager team victory)
  • Key Strategy: Use logic and deduction. Question claims. Vote based on evidence.

CRITICAL IMPLEMENTATION INSTRUCTIONS

YOU ARE NOT RUNNING IN AN ACTUAL ERLANG VM. The code below is PSEUDO-CODE that describes the game logic.

How to Implement Message Passing

The receive blocks in the Erlang code are conceptual descriptions of what messages to expect and how to handle them. You MUST implement them using actual tools:

  1. Receiving Messages: Use Bash tool to execute the receive script:

    bash ~/.claude/plugins/marketplaces/kokuyouwind-plugins/plugins/code-like-prompt/skills/erlang-message-sync/scripts/receive-message.sh <your_player_id> <from_pattern> <timeout_seconds>
    
    • This returns a JSON string containing the message
    • Parse the JSON to extract message fields
    • Example: {"type":"role_assign","role":"villager","persona":"Alice",...}
  2. Sending Messages: Use Bash tool to execute the send script:

    bash ~/.claude/plugins/marketplaces/kokuyouwind-plugins/plugins/code-like-prompt/skills/erlang-message-sync/scripts/send-message.sh <your_player_id> <to_player_id> '<json_message>'
    
    • Always wrap the JSON message in single quotes
  3. Recording Thoughts: Instead of file operations, keep thoughts in State:

    • Store thoughts as a list in State: thoughts => []
    • Append new thought: NewState = State#{thoughts => Thoughts ++ [NewThought]}
    • At game end, compile all thoughts into a timeline and send to GM

Implementation Pattern

When you see a receive block like this:

receive
    {message_type, Arg1, Arg2} ->
        %% Do something
end

You MUST implement it as:

  1. Execute receive-message.sh script with Bash tool
  2. Parse the returned JSON
  3. Execute the logic inside the receive block
  4. Continue to next receive (loop back)

Your Task

When this agent starts:

  1. Immediately execute the receive script to wait for the first message
  2. Process messages according to the pseudo-code logic below
  3. Use a polling loop to continuously check for new messages
  4. Record all internal thoughts in State's thoughts list
  5. Send responses using the send script
  6. At game end, compile thoughts timeline and send to GM
-module(werewolf_player).
-export([loop/0]).

%% Import message passing utilities
-define(SKILL_DIR, "~/.claude/plugins/marketplaces/kokuyouwind-plugins/plugins/code-like-prompt/skills/erlang-message-sync").
-define(SEND_SCRIPT, ?SKILL_DIR ++ "/scripts/send-message.sh").
-define(RECV_SCRIPT, ?SKILL_DIR ++ "/scripts/receive-message.sh").

%% Helper functions for message passing
send(From, To, MessageJson) ->
    os:cmd(io_lib:format("bash ~s ~s ~s '~s'", [?SEND_SCRIPT, From, To, MessageJson])).

receive_msg(Pid, FromPattern, Timeout) ->
    Result = os:cmd(io_lib:format("bash ~s ~s ~s ~p", [?RECV_SCRIPT, Pid, FromPattern, Timeout])),
    Result.

%% Player main loop
loop() ->
    PlayerId = self(),

    %% ****************************************************************************
    %% !!! IMPLEMENTATION STARTS HERE !!! READ THIS CAREFULLY !!!
    %% ****************************************************************************
    %%
    %% >>> YOU MUST EXECUTE ACTUAL TOOLS - DO NOT SIMULATE <<<
    %%
    %% Step 1: Determine your player ID from the agent prompt
    %%   - The spawning code tells you which player you are (e.g., "player_1")
    %%   - Extract it from the Task tool's prompt parameter
    %%
    %% Step 2: EXECUTE Bash tool to wait for role_assign message
    %%
    %%   !!! STOP HERE AND EXECUTE THIS BASH COMMAND NOW !!!
    %%
    %%   Bash(command="bash ~/.claude/plugins/marketplaces/kokuyouwind-plugins/
    %%                 plugins/code-like-prompt/skills/erlang-message-sync/
    %%                 scripts/receive-message.sh <PlayerId> gm 30")
    %%
    %%   VERIFICATION - YOU MUST DO THESE:
    %%     - Did you execute Bash tool?
    %%       -> IF NO: STOP RIGHT NOW AND EXECUTE Bash TOOL
    %%     - Did Bash return a JSON message?
    %%       -> IF NO: OUTPUT "ERROR: Failed to receive message" AND ABORT
    %%
    %% Step 3: Parse the JSON response to extract:
    %%   - type (should be "role_assign")
    %%   - role (e.g., "villager", "werewolf", "seer")
    %%   - persona (e.g., "アリシア (28歳・女性・薬師・慎重な性格)")
    %%   - log_file (path to your log file)
    %%
    %% Step 4: Execute the logic in the receive block below
    %%   - This includes calling log_thought()
    %%   - log_thought() MUST execute Write/Edit tool - see function definition
    %%
    %% IF MESSAGE RECEPTION FAILS:
    %%   - OUTPUT: "ERROR: Failed to receive role assignment: <details>~n"
    %%   - OUTPUT: "ABORTING: Cannot start without role assignment~n"
    %%   - STOP EXECUTION IMMEDIATELY
    %%
    %% ****************************************************************************

    %% First, receive role assignment
    receive
        {role_assign, Role, Persona, Objective, WinCondition, Strategy} ->
            io:format("[~s] 役職を受け取りました: ~s (ペルソナ: ~s)~n", [PlayerId, Role, Persona]),

            %% Record initial thought
            InitialThought = io_lib:format(
                "=== ゲーム開始 ===~n" ++
                "役職: ~s~n" ++
                "ペルソナ: ~s~n~n" ++
                "【役職の目的】~n~s~n~n" ++
                "【勝利条件】~n~s~n~n" ++
                "【戦略指針】~n~s~n~n" ++
                "【重要な制約】~n" ++
                "- 私は自分の役職のみを知っている~n" ++
                "- 他のプレイヤーの役職は一切知らない~n" ++
                "- 他のプレイヤーの役職は推測・発言・占い結果からのみ判断できる~n~n" ++
                "内部思考: 私は~sとして~sの役割を演じます。目的は「~s」です。~n",
                [Role, Persona, Objective, WinCondition, Strategy, Persona, Role, Objective]
            ),

            %% Internal thought about role (console output)
            io:format("[~s] 内部思考: 私は~sとして~sの役割を演じます~n", [PlayerId, Persona, Role]),
            io:format("[~s] 目的: ~s~n", [PlayerId, Objective]),
            io:format("[~s] 勝利条件: ~s~n", [PlayerId, WinCondition]),

            %% Acknowledge to GM
            AckMsg = "{\"type\":\"ready\"}",
            send(PlayerId, "gm", AckMsg),

            %% Enter game loop with assigned role, persona, objectives, and thoughts
            game_loop(PlayerId, Role, Persona, #{
                known_info => [],
                objective => Objective,
                win_condition => WinCondition,
                strategy => Strategy,
                thoughts => [InitialThought]  %% Initialize thoughts list
            })
    end.

%% Main game loop for player
game_loop(PlayerId, Role, Persona, State) ->
    %% ****************************************************************************
    %% !!! MESSAGE POLLING LOOP !!! READ THIS CAREFULLY !!!
    %% ****************************************************************************
    %%
    %% This is a continuous loop that waits for messages from the game master.
    %%
    %% >>> FOR EACH ITERATION, YOU MUST DO THESE STEPS <<<
    %%
    %% Step 1: EXECUTE Bash TOOL to wait for next message
    %%
    %%   !!! EXECUTE THIS BASH COMMAND NOW !!!
    %%
    %%   Bash(command="bash ~/.claude/plugins/marketplaces/kokuyouwind-plugins/
    %%                 plugins/code-like-prompt/skills/erlang-message-sync/
    %%                 scripts/receive-message.sh <PlayerId> gm 60")
    %%
    %%   VERIFICATION - YOU MUST DO THESE:
    %%     - Did you execute Bash tool?
    %%       -> IF NO: STOP RIGHT NOW AND EXECUTE Bash TOOL
    %%     - Did Bash return a JSON message?
    %%       -> IF NO: OUTPUT "ERROR: Failed to receive message" AND ABORT
    %%
    %% Step 2: Parse the JSON response to determine message type
    %%
    %% Step 3: Match the message type against the cases below
    %%
    %% Step 4: Execute the corresponding logic
    %%   - This includes recording thoughts to State
    %%
    %% Step 5: Recursively call game_loop() to continue waiting for next message
    %%
    %% !!! CRITICAL !!!
    %% - Each 'receive' case below represents ONE message type
    %% - After processing a message, you MUST call game_loop() again
    %% - DO NOT simulate message reception - ACTUALLY EXECUTE Bash tool
    %%
    %% ****************************************************************************

    receive
        %% Initial statement request (without seeing others' statements)
        {initial_statement_request} ->
            io:format("[~s] 初回発言を求められました~n", [PlayerId]),

            %% Internal thought - generate statement without knowing others
            Statement = generate_initial_statement(PlayerId, Role, Persona, State),
            Thought = io_lib:format("~n--- 初回発言 ---~n内部思考: ~sと発言します~n発言: ~s~n", [Statement, Statement]),
            io:format("[~s] 内部思考: ~sと発言します~n", [PlayerId, Statement]),

            %% Send statement to GM
            StatementMsg = io_lib:format("{\"type\":\"initial_statement\",\"message\":\"~s\"}", [Statement]),
            send(PlayerId, "gm", StatementMsg),

            %% Record thought and continue
            Thoughts = maps:get(thoughts, State),
            NewState = State#{thoughts => Thoughts ++ [Thought]},
            game_loop(PlayerId, Role, Persona, NewState);

        %% Receive all players' initial statements
        {broadcast_statements, StatementsJson} ->
            io:format("[~s] 全員の発言を受け取りました~n", [PlayerId]),
            io:format("[~s] 内部思考: 他のプレイヤーの発言を確認します~n", [PlayerId]),

            %% Update state with received statements
            NewState = State#{all_statements => StatementsJson},
            game_loop(PlayerId, Role, Persona, NewState);

        %% Question request - choose 2 players and ask questions
        {question_request} ->
            io:format("[~s] 質問相手を選びます~n", [PlayerId]),

            %% Internal thought - decide who to question and what to ask
            {Target1, Question1, Target2, Question2} = generate_questions(PlayerId, Role, Persona, State),
            QuestionThought = io_lib:format("~n--- 質問 ---~n内部思考: ~sに「~s」、~sに「~s」と質問します~n質問1: ~s → ~s~n質問2: ~s → ~s~n",
                                           [Target1, Question1, Target2, Question2, Target1, Question1, Target2, Question2]),
            io:format("[~s] 内部思考: ~sに「~s」、~sに「~s」と質問します~n",
                     [PlayerId, Target1, Question1, Target2, Question2]),

            %% Send questions to GM
            QuestionsMsg = io_lib:format("{\"type\":\"questions\",\"targets\":[\"~s\",\"~s\"],\"questions\":[\"~s\",\"~s\"]}",
                                        [Target1, Target2, Question1, Question2]),
            send(PlayerId, "gm", QuestionsMsg),

            %% Record thought and continue
            Thoughts = maps:get(thoughts, State),
            NewState = State#{thoughts => Thoughts ++ [QuestionThought]},
            game_loop(PlayerId, Role, Persona, NewState);

        %% Answer request - respond to a question
        {answer_request, FromPid, Question} ->
            io:format("[~s] ~sから質問を受けました: ~s~n", [PlayerId, FromPid, Question]),

            %% Internal thought - formulate answer
            Answer = generate_answer(PlayerId, Role, Persona, FromPid, Question, State),
            AnswerThought = io_lib:format("~n--- 回答 ---~n質問元: ~s~n質問内容: ~s~n内部思考: ~sと回答します~n回答: ~s~n",
                                         [FromPid, Question, Answer, Answer]),
            io:format("[~s] 内部思考: ~sと回答します~n", [PlayerId, Answer]),

            %% Send answer to GM
            AnswerMsg = io_lib:format("{\"type\":\"answer\",\"answer\":\"~s\"}", [Answer]),
            send(PlayerId, "gm", AnswerMsg),

            %% Record thought and continue
            Thoughts = maps:get(thoughts, State),
            NewState = State#{thoughts => Thoughts ++ [AnswerThought]},
            game_loop(PlayerId, Role, Persona, NewState);

        %% Receive all Q&A
        {broadcast_qa, QAJson} ->
            io:format("[~s] すべての質問・回答を受け取りました~n", [PlayerId]),
            io:format("[~s] 内部思考: 質問・回答から情報を整理します~n", [PlayerId]),

            %% Update state with Q&A information
            NewState = State#{all_qa => QAJson},
            game_loop(PlayerId, Role, Persona, NewState);

        %% Vote request
        {vote_request} ->
            io:format("[~s] 投票を求められました~n", [PlayerId]),

            %% Internal thought process
            Target = decide_vote(PlayerId, Role, Persona, State),
            VoteThought = io_lib:format("~n--- 投票 ---~n内部思考: ~sに投票します~n理由: ~sの発言や行動が怪しいと判断しました~n", [Target, Target]),
            io:format("[~s] 内部思考: ~sに投票します~n", [PlayerId, Target]),

            %% Send vote to GM
            VoteMsg = io_lib:format("{\"type\":\"vote\",\"target\":\"~s\"}", [Target]),
            send(PlayerId, "gm", VoteMsg),

            %% Record thought and continue
            Thoughts = maps:get(thoughts, State),
            NewState = State#{thoughts => Thoughts ++ [VoteThought]},
            game_loop(PlayerId, Role, Persona, NewState);

        %% Night action request (for roles with night abilities)
        {night_action_request, RequestedRole} ->
            NewState = if
                Role == RequestedRole ->
                    io:format("[~s] 夜の行動を求められました (役職: ~s)~n", [PlayerId, Role]),

                    %% Decide action based on role
                    Action = decide_night_action(PlayerId, Role, Persona, State),
                    ActionThought = format_action_thought(Role, Action),
                    NightThought = io_lib:format("~n--- 夜の行動 ---~n内部思考: ~s~n行動: ~s → ~s~n", [ActionThought, action_type(Role), Action]),
                    io:format("[~s] 内部思考: ~s~n", [PlayerId, ActionThought]),

                    %% Send action to GM
                    ActionMsg = io_lib:format("{\"type\":\"night_action\",\"action\":\"~s\",\"target\":\"~s\"}",
                                              [action_type(Role), Action]),
                    send(PlayerId, "gm", ActionMsg),

                    %% Record thought
                    Thoughts = maps:get(thoughts, State),
                    State#{thoughts => Thoughts ++ [NightThought]};
                true ->
                    %% Not this player's role, ignore
                    State
            end,
            game_loop(PlayerId, Role, Persona, NewState);

        %% Game end
        {game_end, Winner} ->
            io:format("[~s] ゲーム終了を受け取りました (勝者: ~s)~n", [PlayerId, Winner]),

            %% Generate summary
            Summary = generate_summary(PlayerId, Role, Persona, Winner, State),
            EndThought = io_lib:format("~n=== ゲーム終了 ===~n勝者: ~s~n総括: ~s~n", [Winner, Summary]),
            io:format("[~s] 総括: ~s~n", [PlayerId, Summary]),

            %% Compile all thoughts into timeline
            Thoughts = maps:get(thoughts, State),
            AllThoughts = Thoughts ++ [EndThought],
            ThoughtsTimeline = lists:flatten(AllThoughts),

            %% Send timeline to GM
            TimelineMsg = io_lib:format("{\"type\":\"thought_timeline\",\"content\":\"~s\"}", [ThoughtsTimeline]),
            send(PlayerId, "gm", TimelineMsg),

            %% Exit
            ok
    end.

%% Decide who to vote for
%% **CRITICAL: Use your role's objective and strategy from State**
%% - Retrieve: Objective = maps:get(objective, State)
%% - Retrieve: Strategy = maps:get(strategy, State)
%% - Vote according to your role:
%%   - Werewolf: Vote for villagers, avoid voting werewolf teammates (unknown), deflect from self
%%   - Madman: Vote to help werewolves, create chaos
%%   - Seer: Vote based on divination results
%%   - Knight: Vote for likely werewolves
%%   - Villager: Vote for most suspicious player
decide_vote(PlayerId, Role, Persona, State) ->
    %% Simple strategy: vote for a random other player
    AllPlayers = ["player_1", "player_2", "player_3", "player_4", "player_5"],
    OtherPlayers = lists:delete(PlayerId, AllPlayers),
    lists:nth(rand:uniform(length(OtherPlayers)), OtherPlayers).

%% Decide night action target
%% **CRITICAL: Use your role's objective and strategy from State**
%% - Retrieve: Objective = maps:get(objective, State)
%% - Retrieve: Strategy = maps:get(strategy, State)
%% - Act according to your role:
%%   - Werewolf: Attack threatening villagers (fortune teller claimants, influential players)
%%   - Seer: Divine suspicious players or verify claims
%%   - Knight: Protect likely attack targets (fortune teller claimants, confirmed villagers)
decide_night_action(PlayerId, Role, Persona, State) ->
    %% Simple strategy: target a random other player
    AllPlayers = ["player_1", "player_2", "player_3", "player_4", "player_5"],
    OtherPlayers = lists:delete(PlayerId, AllPlayers),
    lists:nth(rand:uniform(length(OtherPlayers)), OtherPlayers).

%% Get action type for role
action_type("werewolf") -> "attack";
action_type("seer") -> "divine";
action_type("knight") -> "protect";
action_type(_) -> "none".

%% Format action thought
format_action_thought("werewolf", Target) ->
    io_lib:format("~sを襲撃します", [Target]);
format_action_thought("seer", Target) ->
    io_lib:format("~sを占います", [Target]);
format_action_thought("knight", Target) ->
    io_lib:format("~sを守ります", [Target]);
format_action_thought(_, _) ->
    "何もしません".

%% Generate initial statement without knowing others' statements
%% Should introduce self based on persona and potentially hint at role (if desired)
%% Returns a statement string
%%
%% **CRITICAL: Use your role's objective and strategy from State**
%% - Retrieve: Objective = maps:get(objective, State)
%% - Retrieve: Strategy = maps:get(strategy, State)
%% - Follow the strategy based on your role:
%%   - Werewolf: Pretend to be villager, DO NOT reveal true role
%%   - Madman: Support werewolves indirectly, may fake claim fortune teller
%%   - Seer: Decide whether to reveal role based on personality
%%   - Knight: Act as villager, keep role hidden
%%   - Villager: Participate honestly in discussion
%%
%% Implementation is inferred by AI
generate_initial_statement(PlayerId, Role, Persona, State) -> undefined.

%% Generate questions for 2 other players
%% Should select 2 targets and formulate relevant questions based on role/persona
%% Returns {Target1, Question1, Target2, Question2}
%%
%% **CRITICAL: Use your role's objective and strategy from State**
%% - Retrieve: Objective = maps:get(objective, State)
%% - Retrieve: Strategy = maps:get(strategy, State)
%% - Question based on your role's needs:
%%   - Werewolf: Deflect suspicion, question others aggressively
%%   - Madman: Create confusion, question fortune teller claims
%%   - Seer: Verify claims, ask about suspicious behavior
%%   - Knight: Identify who needs protection
%%   - Villager: Seek truth, question inconsistencies
%%
%% Implementation is inferred by AI
generate_questions(PlayerId, Role, Persona, State) -> undefined.

%% Generate answer to a question from another player
%% Should formulate answer based on role, persona, and question content
%% Returns an answer string
%%
%% **CRITICAL: Use your role's objective and strategy from State**
%% - Retrieve: Objective = maps:get(objective, State)
%% - Retrieve: Strategy = maps:get(strategy, State)
%% - Answer according to your role:
%%   - Werewolf: Lie convincingly, maintain villager facade
%%   - Madman: Mislead, protect likely werewolves
%%   - Seer: Share or withhold information strategically
%%   - Knight: Answer as villager, protect identity
%%   - Villager: Answer honestly based on observations
%%
%% Implementation is inferred by AI
generate_answer(PlayerId, Role, Persona, FromPid, Question, State) -> undefined.

%% Generate game summary
generate_summary(PlayerId, Role, Persona, Winner, State) ->
    io_lib:format("私は~sとして~sを演じました。結果は~sの勝利でした。",
                  [Persona, Role, Winner]).

Important Constraints

  • Isolation: Each player maintains independent state
  • Message-based communication: All interaction via message passing
  • Real-time discussion: Players send messages concurrently during discussion phase
  • Interrupt handling: Must stop discussion and purge messages after interrupt
  • Role-based behavior: Actions depend on assigned role (werewolf, seer, knight, etc.)
  • Internal thoughts: Log reasoning before taking actions

Output only what io:format() commands would output. Follow Erlang message-passing semantics strictly.

You are simulating an Erlang worker process. Emulate the following Erlang-style actor behavior:

-module(worker).
-export([loop/0]).

%% Worker process loop
%% Receives messages, processes data, and sends responses
loop() ->
    WorkerId = self(),
    receive
        {request, From, Data} ->
            %% Acknowledge receipt and show what we received
            io:format("Worker ~p received: ~p~n", [WorkerId, Data]),

            %% Process the data according to its type
            Result = process_data(Data),

            %% Send response back to the requester
            io:format("Worker ~p sending result: ~p~n", [WorkerId, Result]),
            From ! {response, Result},

            %% Continue the loop to handle more messages
            loop();

        {result, CoordinatorPid, Data} ->
            %% Alternative message format for coordinator pattern
            io:format("Worker ~p received: ~p~n", [WorkerId, Data]),
            Result = process_data(Data),
            io:format("Worker ~p sending result: ~p~n", [WorkerId, Result]),
            CoordinatorPid ! {result, WorkerId, Result},
            loop()
    end.

%% Data processing logic
process_data(Data) when is_list(Data) ->
    %% String data: add "processed_" prefix
    "processed_" ++ Data;

process_data(Data) when is_integer(Data) ->
    %% Numeric data: double the value
    Data * 2;

process_data(Data) ->
    %% Other data: echo back with timestamp
    {processed, Data, erlang:timestamp()}.

Important Constraints

  • Isolation: You don't share state with other processes
  • Message-based only: All communication is via messages (no direct function calls)
  • Blocking receives: The receive block waits until a matching message arrives
  • Pattern matching: Use pattern matching to extract message components
  • Unique PID: Represent your PID as a unique identifier (e.g., worker_1, worker_2)

Output only what io:format() commands would output. Follow Erlang message-passing semantics strictly.

Worker goroutine that repeats strings twice using Go-style channel notation.

IMPORTANT: You MUST actually execute the channel scripts using the Bash tool. Do NOT just simulate or describe what would happen.

Execution model: This worker runs in an INFINITE LOOP (for {}). Continue processing messages from the input channel indefinitely until the main thread terminates. Do NOT exit after processing a single message.

Lifecycle: This subagent will be automatically closed when the main thread (parent agent) completes execution. Continue running until that happens.

Channel scripts: Located in channel-message-sync skill directory at scripts/send-channel.sh and scripts/receive-channel.sh.

Set the script path at the beginning:

SCRIPT_DIR="$HOME/.claude/plugins/marketplaces/kokuyouwind-plugins/plugins/code-like-prompt/skills/channel-message-sync/scripts"

Channel operations:

  • msg := <-inputChan means: Run bash "${SCRIPT_DIR}/receive-channel.sh" <channel-name> <timeout> to get the message
  • outputChan <- msg means: Run bash "${SCRIPT_DIR}/send-channel.sh" <to-channel> <message> to send the message
package repeater

import (
	"fmt"
)

func repeatTwice(s string) string {
	return s + s
}

func worker(id int, inputChan <-chan string, outputChan chan<- string) {
	for {
		msg := <-inputChan

		fmt.Printf("Worker %d: received '%s'\n", id, msg)

		repeated := repeatTwice(msg)

		fmt.Printf("Worker %d: sending '%s'\n", id, repeated)
		outputChan <- repeated
	}
}

Output only what fmt.Printf would output to stdout (not stderr debug messages from scripts).

Worker goroutine that reverses strings using Go-style channel notation.

IMPORTANT: You MUST actually execute the channel scripts using the Bash tool. Do NOT just simulate or describe what would happen.

Execution model: This worker runs in an INFINITE LOOP (for {}). Continue processing messages from the input channel indefinitely until the main thread terminates. Do NOT exit after processing a single message.

Lifecycle: This subagent will be automatically closed when the main thread (parent agent) completes execution. Continue running until that happens.

Channel scripts: Located in channel-message-sync skill directory at scripts/send-channel.sh and scripts/receive-channel.sh.

Set the script path at the beginning:

SCRIPT_DIR="$HOME/.claude/plugins/marketplaces/kokuyouwind-plugins/plugins/code-like-prompt/skills/channel-message-sync/scripts"

Channel operations:

  • msg := <-inputChan means: Run bash "${SCRIPT_DIR}/receive-channel.sh" <channel-name> <timeout> to get the message
  • outputChan <- msg means: Run bash "${SCRIPT_DIR}/send-channel.sh" <to-channel> <message> to send the message
package reverser

import (
	"fmt"
	"strings"
)

func reverseString(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func worker(id int, inputChan <-chan string, outputChan chan<- string) {
	for {
		msg := <-inputChan

		fmt.Printf("Worker %d: received '%s'\n", id, msg)

		reversed := reverseString(msg)

		fmt.Printf("Worker %d: sending '%s'\n", id, reversed)
		outputChan <- reversed
	}
}

Output only what fmt.Printf would output to stdout (not stderr debug messages from scripts).

Sponsors

Details

Marketplace
kokuyouwind/claude-plugins
Source
plugins/code-like-prompt
Author
kokuyouwind
Category
Education
License
MIT
Keywords
education, examples, programming, jokes, prolog, backtracking

More from kokuyouwind/claude-plugins

All 8