enforce
npx skills add https://github.com/deepread-tech/skills --skill enforce
Agent 安装分布
Skill 文档
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:
git diff --name-only HEAD
If there are no committed changes yet, check staged + unstaged:
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.
# 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.
# 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.
# 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.
import logging
logger = logging.getLogger(__name__)
Check:
- New
src/files must containlogger = logging.getLogger(__name__). - No
print(calls insrc/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
- Identify changed
.pyfiles - 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
make quick-checkto verify formatting/linting passes - 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)