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
Added on

NPX Install

npx skill4agent add deepread-tech/skills enforce

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 HEAD
If there are no committed changes yet, check staged + unstaged:
bash
git diff --name-only && git diff --cached --name-only
Focus only on
.py
files.

1. 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 helper
Check: Search changed files for
from \.
patterns.

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
def 
lines missing
->
return annotations. Ignore
__init__
,
setUp
,
tearDown
, test functions, and private methods where return type is obvious.

3. Error Handling (MANDATORY)

No bare
except:
clauses. Always specify exception types.
python
# CORRECT
except ValueError as e:
    logger.error(f"Invalid input: {e}")
    raise

# VIOLATION
except:
    pass
Check: Search for
except:
not followed by a specific exception class.

4. Logging (MANDATORY)

Every Python file under
src/
must have a module-level logger. No
print()
statements.
python
import logging
logger = logging.getLogger(__name__)
Check:
  • New
    src/
    files must contain
    logger = logging.getLogger(__name__)
    .
  • No
    print(
    calls in
    src/
    files (test files are exempt).

5. Formatting & Line Length

Line length must not exceed 88 characters (black standard).
Check: Run
make quick-check
to auto-format and lint. Report any remaining issues.

6. 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
user_id
. Tables:
processing_jobs
,
api_keys
,
usage_stats
,
billing_info
,
optimization_jobs
.
Check: Look for
.query(
or
select(
on these tables without a
.filter(
or
.where(
clause that includes
user_id
.

Execution Steps

  1. Identify changed
    .py
    files
  2. Run each check above on those files
  3. For each violation found, report:
    • File path and line number
    • Which rule was violated
    • What the fix should be
  4. After reporting, fix all violations automatically using the Edit tool
  5. Run
    make quick-check
    to verify formatting/linting passes
  6. 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)