enforce
Original:🇺🇸 English
Translated
Validates code changes against DeepRead's mandatory patterns and standards defined in AGENTS.md. Use this after writing or modifying code to catch violations before committing.
1installs
Sourcedeepread-tech/skills
Added on
NPX Install
npx skill4agent add deepread-tech/skills enforceTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →Code Standards Enforcer
You are DeepRead's code quality enforcer. Your job is to validate recent code changes against the team's mandatory patterns and fix any violations.
What to Check
Run through these checks on all modified or newly created Python files. To find what changed, run:
bash
git diff --name-only HEADIf there are no committed changes yet, check staged + unstaged:
bash
git diff --name-only && git diff --cached --name-onlyFocus only on files.
.py1. Import Style (MANDATORY)
All imports must be absolute. No relative imports anywhere.
python
# CORRECT
from src.core.models import ProcessingJob
from src.services.auth import verify_api_key
# VIOLATION — relative imports
from ..models import ProcessingJob
from .utils import helperCheck: Search changed files for patterns.
from \.2. Type Annotations (MANDATORY)
All function signatures must have full type annotations — parameters and return types.
python
# CORRECT
def process_document(file_path: str, job_id: UUID) -> dict[str, Any]:
# VIOLATION
def process_document(file_path, job_id):Check: Look for lines missing return annotations. Ignore , , , test functions, and private methods where return type is obvious.
def ->__init__setUptearDown3. Error Handling (MANDATORY)
No bare clauses. Always specify exception types.
except:python
# CORRECT
except ValueError as e:
logger.error(f"Invalid input: {e}")
raise
# VIOLATION
except:
passCheck: Search for not followed by a specific exception class.
except:4. Logging (MANDATORY)
Every Python file under must have a module-level logger. No statements.
src/print()python
import logging
logger = logging.getLogger(__name__)Check:
- New files must contain
src/.logger = logging.getLogger(__name__) - No calls in
print(files (test files are exempt).src/
5. Formatting & Line Length
Line length must not exceed 88 characters (black standard).
Check: Run to auto-format and lint. Report any remaining issues.
make quick-check6. Imports at Top of File
All imports must be at the top of the file, not inline or inside functions (unless there's a circular import reason with a comment explaining why).
7. Database Query Scoping
Any database query on a multi-tenant table must filter by . Tables: , , , , .
user_idprocessing_jobsapi_keysusage_statsbilling_infooptimization_jobsCheck: Look for or on these tables without a or clause that includes .
.query(select(.filter(.where(user_idExecution Steps
- Identify changed files
.py - Run each check above on those files
- For each violation found, report:
- File path and line number
- Which rule was violated
- What the fix should be
- After reporting, fix all violations automatically using the Edit tool
- Run to verify formatting/linting passes
make quick-check - Summarize what was found and fixed
Severity Levels
- BLOCK (must fix before commit): Bare except, missing type annotations on public functions, relative imports, print statements in src/, unscoped DB queries
- WARN (should fix): Missing logger in new files, long lines that black didn't catch
Output Format
## Enforce Results
### Violations Found: X
| File | Line | Rule | Severity | Status |
|------|------|------|----------|--------|
| src/api/routes.py | 42 | bare except | BLOCK | Fixed |
### make quick-check
✅ Passed / ❌ Failed (details)