| name | coding-python |
| description | When python, flask, or jinja are being written or edited. Use this skill any time you are writing, editing, refactoring, or reviewing Python (.py), Django-related, Flask routes/blueprints, or Jinja2 templates (.jinja or .html with Jinja). Trigger even if the user only mentions a .py file, a Flask endpoint, a template, or asks about Python patterns, imports, error handling, or structure. Load with read_file on .kilocode/skills/coding-python/SKILL.md (ignore the absolute path in the location tag). |
Python Coding Standards
Mandatory Metadata
Every function or class you create or modify must include this header comment:
For modifications to existing functions/classes:
Use the current model name from context and today's date.
Syntax & Style
Quotes
- Use double quotes (
") in all cases.
- Good:
x += "."
- Bad:
x += '.'
String Formatting
- Use f-strings for interpolation (not
% or .format()).
- Good:
f"Hello, {name}!"
- Bad:
"Hello, {}!".format(name) or "Hello, %s" % name
SQL
- Always use multi-line triple-quoted strings for SQL queries.
Readability
- Prioritize readable code over clever/compact one-liners.
- Keep vertical spacing compact — no excessive blank lines.
Type Hints
Error Handling
Docstrings
Flask-Specific Patterns
Route Organization
- Keep route handlers thin — delegate logic to utility functions.
- Group related routes into blueprints (
blueprints/ folder).
- Route naming: use domain-first (e.g.,
/user/edit or /user_edit, not /edit_user).
Error Handlers
Response Pattern
- Use
jsonify() for API responses; set explicit status codes.
Jinja2-Specific Patterns
Template Inheritance
Variable Safety
Logic in Templates
- Keep logic minimal in templates — complex logic belongs in Python, not Jinja.
- Use
{% set %} for local variables rather than inline expressions when readability suffers.
Testing (pytest)
- Read skill-local guidance only when
.kilocode/skills/coding-python/AGENTS.md is confirmed to exist; otherwise use root AGENTS.md for project-specific Python, Flask, Jinja, and test paths.
- Test files generally follow
test_[module_name].py naming.
- Each test function name describes what it verifies:
test_user_sync_creates_backup.
- Use
tmp_path fixture for file system tests — never write to real project paths.
- Confirm a test doesn't already exist before writing a new one.