INNER CODE UNIT · Python

run_with_claude

wgpsec/AboutSecurity · scripts/bench-skill.py:86

def run_with_claude(prompt: str, timeout: int = 120, model: str = None) -> dict:
    """Run a prompt via `claude -p` and capture output + metrics."""
    cmd = ["claude", "-p", prompt, "--output-format", "json"]
    if model:
        cmd.extend(["--model", model])

    env = {k: v for k, v in os.environ.items() if k != "CLAUDECODE"}

    start = time.time()
    try:
        result = subprocess.run(
            cmd, capture_output=True, text=True, timeout=timeout,
            cwd=str(REPO_ROOT), env=env,
        )
        duration = time.time() - start

        try:
            output_data = json.loads(result.stdout)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…