quality-gates
npx machina-cli add skill mpuig/raw/quality-gates --openclawQuality Gates Skill
Use this skill to understand what each quality gate checks and how to ensure your workflow passes all gates.
Default Gates
1. validate - Structural Validation
What it checks:
- run.py exists and is valid Python
- PEP 723 metadata is present (
# /// script) - Required dependencies are declared (pydantic, rich)
- BaseWorkflow is subclassed
- run() method is implemented
- Imported tools exist in tools/ directory
Common failures:
✗ Missing PEP 723 metadata block
✗ run.py must subclass BaseWorkflow
✗ Workflow class must implement run() method
✗ Tool not found: yahoo_finance (imported from tools.yahoo_finance)
How to fix:
- Add PEP 723 block at top of run.py
- Ensure class inherits from
BaseWorkflow[ParamsType] - Implement
def run(self) -> int:method - Create missing tools in tools/ directory
2. dry - Dry Run
What it checks:
- Workflow executes with mock data (no real API calls)
- dry_run.py exists and provides mocks
- No crashes or unhandled exceptions
- Returns exit code 0
Common failures:
✗ dry_run.py not found
✗ KeyError: 'api_key' (accessing env var in dry run)
✗ ConnectionError: API not available (real network call in dry run)
How to fix:
- Create dry_run.py with mock functions
- Replace all external calls with mocks
- Use DryRunContext to log mock behavior
- Test locally:
raw run workflow --dry
Optional Gates
3. pytest - Unit Tests
What it checks:
- All tests in test.py pass
- No test failures or errors
Enable in .raw/config.yaml:
builder:
gates:
optional:
pytest:
command: "pytest test.py -v"
timeout_seconds: 60
Common failures:
✗ AssertionError: Expected 0 but got 1
✗ ModuleNotFoundError: No module named 'workflow_name'
How to fix:
- Write tests that match actual behavior
- Import workflow class correctly
- Run pytest locally to debug
4. ruff - Linting & Formatting
What it checks:
- Code follows Python style guide
- No unused imports
- Consistent formatting
Enable in .raw/config.yaml:
builder:
gates:
optional:
ruff:
command: "ruff check . && ruff format . --check"
timeout_seconds: 30
Common failures:
✗ F401 'sys' imported but unused
✗ E501 Line too long (92 > 88 characters)
How to fix:
- Remove unused imports
- Run
ruff format .to auto-format - Run
ruff check --fix .for auto-fixes
5. typecheck - Type Validation
What it checks:
- Type hints are correct
- No type mismatches
Enable in .raw/config.yaml:
builder:
gates:
optional:
typecheck:
command: "mypy run.py"
timeout_seconds: 60
Gate Failure Strategy
When gates fail:
-
Read the error message carefully
- Gate output is saved to
.raw/builds/<build_id>/logs/<gate>.log - Contains full error details
- Gate output is saved to
-
Fix one gate at a time
- Start with
validate(structural issues) - Then
dry(runtime issues) - Finally optional gates (quality issues)
- Start with
-
Test locally before rebuilding
raw validate workflow-id # Check validation raw run workflow-id --dry # Check dry run pytest test.py # Check tests -
Common patterns:
- validate fails → Fix run.py structure
- dry fails → Add/fix mocks in dry_run.py
- pytest fails → Fix tests or implementation
- ruff fails → Run auto-formatters
- typecheck fails → Add/fix type hints
Example: Fixing Validation Failure
✗ Validation failed
Errors:
• Missing PEP 723 metadata block (# /// script)
• Tool not found: yahoo_finance (imported from tools.yahoo_finance)
Steps to fix:
-
Add PEP 723 block to run.py:
#!/usr/bin/env python3 # /// script # requires-python = ">=3.10" # dependencies = ["pydantic>=2.0", "rich>=13.0", "yfinance>=0.2"] # /// -
Create tools/yahoo_finance/:
mkdir -p tools/yahoo_finance touch tools/yahoo_finance/__init__.py # Create tools/yahoo_finance/tool.py -
Validate again:
raw validate workflow-id
Source
git clone https://github.com/mpuig/raw/blob/main/builder/skills/quality-gates/SKILL.mdView on GitHub Overview
Quality gates define the checks your workflow must pass before deployment: structural validation (validate) and a dry run, plus optional checks like unit tests (pytest), linting (ruff), and type checking (typecheck). Understanding gate failures and how to fix them helps keep CI pipelines green and predictable.
How This Skill Works
Each gate has explicit criteria and common failures (e.g., missing PEP 723 metadata, missing run.py methods, or import issues). Gates are configured in .raw/config.yaml (optional gates for pytest, ruff, typecheck) and emit logs to .raw/builds/<build_id>/logs/<gate>.log. When a gate fails, the Gate Failure Strategy guides you to fix issues one gate at a time and re-test locally.
When to Use It
- Before merging a new workflow: run validate and dry to catch structural and runtime issues.
- When onboarding a new tool or dependency: ensure it's declared and importable via validate.
- When adding unit tests: enable pytest to verify test coverage and correctness.
- When tightening code quality: run ruff to catch style and unused imports.
- When validating types: run typecheck to catch type mismatches before runtimes.
Quick Start
- Step 1: Run validate <workflow-id> to catch structural issues in run.py (PEP 723 metadata, BaseWorkflow subclass, run method).
- Step 2: Run raw run <workflow-id> --dry to verify a dry run with mocks; fix any mock or import issues in dry_run.py.
- Step 3: If enabled, run the optional gates (pytest, ruff, typecheck) via .raw/config.yaml and review logs in .raw/builds/<build_id>/logs.
Best Practices
- Start with validate to fix structural issues in run.py and ensure proper BaseWorkflow subclassing and metadata.
- Create and maintain a dry_run.py with mocks to safely simulate workflow execution.
- Enable and tune optional gates in .raw/config.yaml to fit your project needs.
- Test locally in sequence: raw validate, raw run <workflow-id> --dry, then optional gates as needed.
- Inspect logs under .raw/builds/<build_id>/logs for detailed error messages and guidance.
Example Use Cases
- Missing PEP 723 metadata block causes a validate failure; fix by adding the metadata block to run.py.
- dry_run.py is missing; add mock implementations and replace external calls with mocks.
- pytest fails due to incorrect test imports; ensure tests import the correct workflow class and modules.
- F401 or E501 issues reported by ruff; remove unused imports and format code with ruff.
- Type mismatches detected by typecheck; add or adjust type hints in run.py.