affaan-m/ECC · error · RuntimeError

claude -p failed

Error message

claude -p failed: {result.stderr}

What it means

Subprocess guard in generate_spec's retry loop: claude -p exited non-zero while generating the compliance spec YAML. stderr is embedded; the loop distinguishes this hard failure from YAML parse errors, which get a retry with feedback instead.

Solutions

  1. Read the embedded stderr to find the claude CLI failure cause
  2. Fix auth/model issues and re-run spec generation
  3. If the failure is a YAML parse error rather than rc!=0, the script already retries with corrective feedback — check the last error text
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at skills/skill-comply/scripts/spec_generator.py:51 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16). Data as JSON: /api/errors/4952872472037442. Report an issue: GitHub.

Appendix: source

Thrown at skills/skill-comply/scripts/spec_generator.py:51

    for attempt in range(max_retries + 1):
        prompt = base_prompt
        if attempt > 0 and last_error is not None:
            prompt += (
                f"\n\nPREVIOUS ATTEMPT FAILED with YAML parse error:\n"
                f"{last_error}\n\n"
                f"Please fix the YAML. Remember to quote all string values "
                f"that contain colons, e.g.: description: \"Use type: description format\""
            )

        result = subprocess.run(
            ["claude", "-p", prompt, "--model", model, "--output-format", "text"],
            capture_output=True,
            text=True,
            timeout=120,
        )

        if result.returncode != 0:
            raise RuntimeError(f"claude -p failed: {result.stderr}")

        raw_yaml = extract_yaml(result.stdout)

        tmp_path = None
        with tempfile.NamedTemporaryFile(
            mode="w", suffix=".yaml", delete=False,
        ) as f:
            f.write(raw_yaml)
            tmp_path = Path(f.name)

        try:
            return parse_spec(tmp_path)
        except (yaml.YAMLError, KeyError, TypeError) as e:
            last_error = e
            if attempt == max_retries:
                raise
        finally:
            if tmp_path is not None:

View on GitHub (pinned to 8321021c54)