Prompt file imported from traefikturkey/onramp (
.github/prompts/check.prompt.md). Copyright stays with the author.
Quality Check and Fix
Objective
Run comprehensive quality gates and systematically address any failures until all checks pass.
Context
This is the primary quality gate before committing code. All checks must pass.
Priority: Tests green > Lint clean > Types valid
Workflow
Step 1: Run Tests
Python (uv):
uv run pytest -q
Python (traditional):
pytest
Node.js:
npm test
Result:
- ✅ All tests pass → Proceed to Step 2
- ❌ Tests fail → Fix and re-run until green
Step 2: Run Linting (Optional)
Python (Ruff):
uv run ruff check .
Python (flake8):
uv run flake8 src/ tests/
JavaScript/TypeScript:
npm run lint
Result:
- ✅ No lint errors → Proceed to Step 3
- ❌ Lint errors → Fix and re-run
Step 3: Run Type Checking (Optional)
Python (mypy):
uv run mypy src/
TypeScript:
npm run type-check
Result:
- ✅ No type errors → All checks passed!
- ❌ Type errors → Fix and re-run
Step 4: Run Makefile Target (If Available)
If Makefile has a check target:
make check
This typically runs all quality checks in sequence.
Fixing Failures
Test Failures
Strategy:
- Read error messages carefully
- Identify the root cause
- Make minimal, targeted fixes
- Re-run tests to verify fix
- Repeat until all tests pass
Common issues:
- Import errors → Check
__init__.pyfiles, update imports - Missing dependencies →
uv add --dev <package> - Deleted files → Update tests or remove obsolete test files
- Changed APIs → Update test expectations
Example fix:
# Error: ModuleNotFoundError: No module named 'requests'
uv add requests
# Re-run tests
uv run pytest -q
Lint Failures
Strategy:
- Auto-fix what's safe:
uv run ruff check --fix . - Manually fix remaining issues
- Re-run linter to verify
Common issues:
- Unused imports → Remove them
- Line too long → Break into multiple lines
- Missing docstrings → Add brief docstrings
- Code style → Run formatter:
uv run ruff format .
Type Errors
Strategy:
- Add missing type hints
- Fix incorrect type annotations
- Use
# type: ignoresparingly for genuinely complex cases - Prefer fixing the code over ignoring errors
Common issues:
- Missing type hints → Add them
- Incorrect types → Fix annotations
- Incompatible types → Adjust code or types
Constraints
From Repository Instructions
- ✅ Use
uv run pytestfor uv projects (never callpytestdirectly in uv projects) - ✅ Make small, surgical fixes that preserve behavior
- ✅ Only add dependencies when explicitly required by failures
- ❌ Never add unnecessary flags:
uv run pytest(notuv run -m pytest) - ❌ Never prefix commands with
cd - ❌ Never add
|| trueto hide failures
Best Practices
- Prefer small changes that preserve existing behavior
- Fix root causes rather than symptoms
- Test frequently - run tests after each fix
- Keep commits clean - all checks should pass before committing
- Ask for clarification if the fix is unclear or risky
Example Sessions
Example 1: Tests pass, lint has minor issues
# Step 1: Run tests
uv run pytest -q
# ✅ All tests pass
# Step 2: Run linter
uv run ruff check .
# ❌ Found 3 errors:
# - Unused import 'sys' in src/main.py
# - Line too long in src/utils.py
# - Missing docstring in src/helpers.py
# Fix: Auto-fix safe issues
uv run ruff check --fix .
# ✅ Fixed 1 issue automatically
# Fix: Manually fix line length
# [Edit src/utils.py to break long line]
# Fix: Add docstring
# [Edit src/helpers.py to add docstring]
# Re-run linter
uv run ruff check .
# ✅ No errors found
# Report: All checks passed!
Example 2: Test failures due to missing dependency
# Step 1: Run tests
uv run pytest -q
# ❌ Tests failed:
# ModuleNotFoundError: No module named 'pydantic'
# Fix: Add missing dependency
uv add pydantic
# Re-run tests
uv run pytest -q
# ✅ All tests pass
# Step 2: Run linter
uv run ruff check .
# ✅ No errors found
# Report: All checks passed!
Example 3: Complex test failure requiring code fix
# Step 1: Run tests
uv run pytest -q
# ❌ Tests failed:
# test_user_service.py::test_create_user FAILED
# AssertionError: Expected status 201, got 400
# Analyze: Check test and implementation
# [Read test_user_service.py]
# [Read user_service.py]
# Fix: Update validation logic in user_service.py
# [Edit user_service.py to fix validation]
# Re-run tests
uv run pytest -q
# ✅ All tests pass
# Continue with linting...
Output Format
Success Report
✅ Quality checks passed!
Tests: All passing
Lint: No errors
Types: All valid
Ready to commit.
Failure Report
❌ Quality checks failed
Tests: 2 failing
- test_auth.py::test_login - AssertionError
- test_user.py::test_create - ValidationError
Fixes applied:
- Added missing pydantic dependency
- Updated test expectations
Re-running tests...
Makefile Integration
If make check exists:
Use it as the final comprehensive gate after individual checks pass:
# Run individual checks first
uv run pytest -q # ✅
uv run ruff check . # ✅
# Final comprehensive check
make check # ✅
# Report: All checks passed!
Makefile check target example:
.PHONY: check
check: test lint type-check
@echo "All checks passed!"
Troubleshooting
Tests hanging or taking too long
# Run with timeout
uv run pytest --timeout=60
# Run specific tests
uv run pytest tests/unit/ -k "fast"
# Skip slow tests
uv run pytest -m "not slow"
Linter too strict
# Check what can be auto-fixed
uv run ruff check --fix .
# For specific rules to ignore, update pyproject.toml
Type checker too strict
# Run with less strict checking
uv run mypy src/ --no-strict-optional
# Or add type: ignore comments strategically
Customization Notes
CUSTOMIZE THIS PROMPT for your project:
- Test command: Update for your test framework
- Linter: ruff, flake8, eslint, etc.
- Type checker: mypy, pyright, tsc
- Makefile: Adjust if using different targets
- Quality gates: Add/remove checks as needed
- CI alignment: Match your CI/CD pipeline checks
Source: Consolidated from agent-spike, onboard, attempt-one