coreyhaines31/makerskills / skills/castmate
castmate
FlaggedWhen you want to pull in the right AI model for the right job: hand a task to another agent CLI (Codex, Claude, Gemini, Grok, Amp, OpenCode, Cursor, Kiro, Antigravity), or send one prompt to several at once for independent opinions, then synthesize. Delegate mode gives one castmate the job, optionally with write access ('have codex write the migration'). Fan-out mode runs read-only reviews in parallel. Rounds mode lets castmates build on and challenge each other's findings. Calls the official CLIs you already have installed and logged in (Gemini CLI needs an API key on personal accounts); no MCP. Triggers on '/castmate,' 'ask codex,' 'have gemini do this,' 'get a second opinion,' 'what would other models say,' 'fan this out,' 'cross-check this with another model,' 'delegate this to codex.' Advisor personas for founder questions go to maker-council. Personal models, casting rules, and run outputs live in ~/.config/makerskills/castmate/.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 12.7 KB |
| references/amp-readonly-settings.json | config | 229 B |
| references/casting.md | markdown | 2.6 KB |
| references/cli-setup.md | markdown | 11.3 KB |
| references/gemini-readonly-policy.toml | config | 857 B |
| references/presets/README.md | markdown | 757 B |
| references/presets/bughunt.md | markdown | 1.6 KB |
| references/presets/contracts.md | markdown | 1.1 KB |
| references/presets/hotspots.md | markdown | 1.7 KB |
| references/presets/invariants.md | markdown | 1.5 KB |
| references/presets/regression.md | markdown | 1.1 KB |
| references/presets/security.md | markdown | 1.5 KB |
| references/prompt-template.md | markdown | 3.1 KB |
| references/tools.json | config | 9.1 KB |
| scripts/castmate.pyexecutable | script | 21.1 KB |
| scripts/test_castmate.py | script | 11.7 KB |
scripts/test_castmate.py
View on GitHub#!/usr/bin/env python3
"""Process-handling tests for castmate.py, using fake CLIs. Run: python3 test_castmate.py"""
import json
import os
import shutil
import signal
import subprocess
import sys
import tempfile
import time
import unittest
from pathlib import Path
SCRIPT = Path(__file__).resolve().parent / "castmate.py"
sys.dont_write_bytecode = True
FAKE_CLI = r'''#!/usr/bin/env python3
import os, subprocess, sys, time
mode = sys.argv[1]
if mode == "echo":
sys.stdout.write("args=" + " ".join(sys.argv[2:]) + "\n" + sys.stdin.read())
elif mode == "hang":
print("partial line", flush=True)
child = subprocess.Popen([sys.executable, "-c", "import time; time.sleep(120)"])
open(os.environ["FAKE_PIDFILE"], "w").write(str(child.pid))
time.sleep(120)
elif mode == "authfail":
sys.stderr.write("banner line\nHTTP 401 Unauthorized\n")
sys.exit(1)
elif mode == "fail":
sys.stderr.write("boom\n")
sys.exit(3)
'''
class CastmateTest(unittest.TestCase):
def setUp(self):
self.tmp = Path(tempfile.mkdtemp(prefix="castmate-unit-"))
fake = self.tmp / "fakecli"
fake.write_text(FAKE_CLI)
fake.chmod(0o755)
self.pidfile = self.tmp / "grandchild.pid"
tool = {"name": "Fake", "binary": str(fake), "verified": True, "prompt": "stdin",
"model": ["--model", "{model}"], "readOnly": {"level": "enforced", "args": ["--ro"]},
"write": {"args": ["--rw"]}}
config = {
"tools": {
"echo": {**tool, "args": ["echo"]},
"hang": {**tool, "args": ["hang"]},
"fail": {**tool, "args": ["fail"]},
"authfail": {**tool, "args": ["authfail"], "setup": "codex"},
"nowrite": {**{k: v for k, v in tool.items() if k != "write"}, "args": ["echo"]},
"writeonly": {"binary": str(fake), "args": ["echo"], "write": {"args": ["--rw"]}},
},
"castmates": {"e": {"tool": "echo"}, "prompt": {"tool": "echo"}},
"groups": {},
"defaults": {"maxParallel": 1},
}
(self.tmp / "castmate").mkdir()
(self.tmp / "castmate" / "config.json").write_text(json.dumps(config))
self.prompt = self.tmp / "prompt.md"
self.prompt.write_text("hello castmate\n")
def tearDown(self):
shutil.rmtree(self.tmp, ignore_errors=True)
def run_cli(self, *args):
env = {**os.environ, "MAKERSKILLS_CONFIG": str(self.tmp), "FAKE_PIDFILE": str(self.pidfile)}
return subprocess.run([sys.executable, str(SCRIPT), *args], env=env, capture_output=True, text=True, timeout=120)
def run_json(self, *args):
proc = self.run_cli("run", "-f", str(self.prompt), "--out", str(self.tmp / "out"), "--json", *args)
return proc, json.loads(proc.stdout) if proc.stdout.strip().startswith("{") else None
def test_prompt_arrives_on_stdin_with_read_only_args(self):
proc, manifest = self.run_json("-c", "e")
self.assertEqual(proc.returncode, 0, proc.stderr)
report = manifest["castmates"][0]
self.assertEqual(report["status"], "success")
text = Path(report["outputFile"]).read_text()
self.assertIn("hello castmate", text)
self.assertIn("--ro", text)
def test_duplicates_get_distinct_outputs(self):
_, manifest = self.run_json("-c", "e,e")
labels = [r["label"] for r in manifest["castmates"]]
self.assertEqual(labels, ["e", "e-2"])
self.assertNotEqual(manifest["castmates"][0]["outputFile"], manifest["castmates"][1]["outputFile"])
def test_labels_stay_unique_when_a_name_looks_like_a_suffix(self):
sys.path.insert(0, str(SCRIPT.parent))
import castmate
labels = [c["label"] for c in castmate.label_castmates([{"castmate": "x"}, {"castmate": "x-2"}, {"castmate": "x"}])]
self.assertEqual(len(set(labels)), 3, labels)
def test_raw_tool_model_passthrough(self):
_, manifest = self.run_json("-c", "echo:brand-new-model")
text = Path(manifest["castmates"][0]["outputFile"]).read_text()
self.assertIn("--model brand-new-model", text)
def test_timeout_keeps_partial_output_and_kills_grandchild(self):
_, manifest = self.run_json("-c", "hang", "--timeout", "2")
report = manifest["castmates"][0]
self.assertEqual(report["status"], "timeout")
text = Path(report["outputFile"]).read_text()
self.assertIn("partial line", text)
self.assertIn("timed out", text)
grandchild = int(self.pidfile.read_text())
time.sleep(0.5)
with self.assertRaises(ProcessLookupError):
os.kill(grandchild, 0)
def test_failure_reports_error_and_stderr(self):
proc, manifest = self.run_json("-c", "fail")
self.assertEqual(proc.returncode, 1)
report = manifest["castmates"][0]
self.assertEqual(report["status"], "error")
self.assertIn("boom", Path(report["stderrFile"]).read_text())
def test_write_refuses_parallel_and_missing_write_mode(self):
proc = self.run_cli("run", "-c", "e,e", "-f", str(self.prompt), "--write")
self.assertEqual(proc.returncode, 2)
self.assertIn("one castmate at a time", proc.stderr)
proc = self.run_cli("run", "-c", "nowrite", "-f", str(self.prompt), "--write", "--out", str(self.tmp / "o2"))
self.assertEqual(proc.returncode, 2)
self.assertIn("no write mode", proc.stderr)
def test_reserved_label_does_not_overwrite_prompt(self):
_, manifest = self.run_json("-c", "prompt")
self.assertEqual(manifest["castmates"][0]["label"], "prompt_castmate")
self.assertEqual((self.tmp / "out" / "prompt.md").read_text(), "hello castmate\n")
def test_minimal_user_adapter_without_read_only(self):
proc = self.run_cli("run", "-c", "writeonly", "-f", str(self.prompt), "--out", str(self.tmp / "o3"))
self.assertEqual(proc.returncode, 2)
self.assertIn("no read-only mode", proc.stderr)
self.assertNotIn("Traceback", proc.stderr)
self.assertFalse((self.tmp / "o3").exists())
_, manifest = self.run_json("-c", "writeonly", "--write")
self.assertEqual(manifest["castmates"][0]["status"], "success")
def start_background(self, *args):
env = {**os.environ, "MAKERSKILLS_CONFIG": str(self.tmp), "FAKE_PIDFILE": str(self.pidfile)}
proc = subprocess.Popen([sys.executable, str(SCRIPT), "run", "-f", str(self.prompt), "--out", str(self.tmp / "out"), *args],
env=env, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
deadline = time.time() + 20
while not self.pidfile.exists() and time.time() < deadline:
time.sleep(0.1)
self.assertTrue(self.pidfile.exists(), "castmate never started")
time.sleep(0.3)
return proc
def assert_dead(self, pid):
for _ in range(50):
try:
os.kill(pid, 0)
except ProcessLookupError:
return
time.sleep(0.1)
self.fail(f"pid {pid} still alive")
def test_sigterm_reaps_castmates_and_exits_143(self):
proc = self.start_background("-c", "hang", "--timeout", "60")
grandchild = int(self.pidfile.read_text())
proc.send_signal(signal.SIGTERM)
proc.communicate(timeout=30)
self.assertEqual(proc.returncode, 143)
self.assert_dead(grandchild)
manifest = json.loads((self.tmp / "out" / "run.json").read_text())
self.assertTrue(manifest["aborted"])
self.assertEqual(manifest["castmates"][0]["status"], "aborted")
self.assertIn("partial line", Path(manifest["castmates"][0]["outputFile"]).read_text())
def test_signal_before_dispatch_exits_cleanly(self):
env = {**os.environ, "MAKERSKILLS_CONFIG": str(self.tmp)}
proc = subprocess.Popen([sys.executable, str(SCRIPT), "run", "-c", "e", "-f", "-"], env=env,
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
time.sleep(1)
proc.send_signal(signal.SIGTERM)
_, err = proc.communicate(timeout=10)
self.assertEqual(proc.returncode, 143)
self.assertNotIn("Traceback", err)
def test_interrupt_does_not_start_queued_castmates(self):
proc = self.start_background("-c", "hang,e", "--timeout", "60")
proc.send_signal(signal.SIGINT)
proc.communicate(timeout=30)
self.assertEqual(proc.returncode, 130)
reports = json.loads((self.tmp / "out" / "run.json").read_text())["castmates"]
self.assertEqual([r["status"] for r in reports], ["aborted", "aborted"])
self.assertNotIn("pid", reports[1])
self.assertFalse((self.tmp / "out" / "e.raw").exists())
def test_partial_read_only_override_keeps_shipped_args(self):
config = json.loads((self.tmp / "castmate" / "config.json").read_text())
config["tools"]["echo"]["readOnly"] = {"env": {"EXTRA": "1"}}
(self.tmp / "castmate" / "config.json").write_text(json.dumps(config))
sys.path.insert(0, str(SCRIPT.parent))
import importlib, castmate
os.environ["MAKERSKILLS_CONFIG"] = str(self.tmp)
try:
castmate = importlib.reload(castmate)
castmate.REFS = self.tmp / "refs"
(self.tmp / "refs").mkdir()
shipped = {"tools": {"echo": {"binary": "x", "readOnly": {"level": "enforced", "args": ["--ro"]}}},
"castmates": {}, "groups": {}, "defaults": {}}
(self.tmp / "refs" / "tools.json").write_text(json.dumps(shipped))
ro = castmate.load_registry()["tools"]["echo"]["readOnly"]
finally:
del os.environ["MAKERSKILLS_CONFIG"]
self.assertEqual(ro["args"], ["--ro"])
self.assertEqual(ro["level"], "enforced")
self.assertEqual(ro["env"], {"EXTRA": "1"})
def test_test_command_rejects_answers_that_only_contain_ok(self):
proc = self.run_cli("test", "e")
self.assertEqual(proc.returncode, 1)
self.assertIn("FAIL e", proc.stdout)
def test_run_paths_are_validated_before_dispatch(self):
cases = [
(["-f", str(self.tmp / "missing.md")], "can't read prompt file"),
(["-f", str(self.prompt), "--cwd", str(self.tmp / "nope")], "is not a directory"),
(["-f", str(self.prompt), "--out", str(self.tmp)], "new or empty directory"),
(["-f", str(self.prompt), "--cwd", str(self.tmp), "--out", str(self.tmp / "inside")], "inside --cwd"),
]
for extra, message in cases:
proc = self.run_cli("run", "-c", "e", *extra)
self.assertEqual(proc.returncode, 2, extra)
self.assertIn(message, proc.stderr)
self.assertNotIn("Traceback", proc.stderr)
def test_known_failures_carry_a_setup_hint(self):
_, manifest = self.run_json("-c", "authfail")
self.assertIn("cli-setup.md#codex", manifest["castmates"][0]["hint"])
proc = self.run_cli("test", "authfail")
self.assertIn("HTTP 401 Unauthorized", proc.stdout)
self.assertIn("hint: Not logged in", proc.stdout)
sys.path.insert(0, str(SCRIPT.parent))
import castmate
self.assertIn("API key", castmate.setup_hint({"setup": "gemini-cli"}, "HTTP 401 Unauthorized"))
proc = self.run_cli("run", "-c", "fail", "-f", str(self.prompt), "--out", str(self.tmp / "out-fail"), "--json")
self.assertNotIn("hint", json.loads(proc.stdout)["castmates"][0])
def test_write_mode_uses_write_args(self):
_, manifest = self.run_json("-c", "e", "--write")
text = Path(manifest["castmates"][0]["outputFile"]).read_text()
self.assertIn("--rw", text)
self.assertNotIn("--ro", text)
if __name__ == "__main__":
unittest.main()
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness. | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |