typetype-coding-standards
TypeType coding standards, naming conventions, Python/QML style rules, and common pitfalls. Use when writing new code or refactoring.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
TypeType coding standards, naming conventions, Python/QML style rules, and common pitfalls. Use when writing new code or refactoring.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
Step-by-step workflow for adding new features to TypeType, following architecture/coding standards. Use when adding a feature, modifying, or fixing bugs.
TypeType development workflow, environment setup, testing, building, CI, and pre-commit checks. Use when setting up or preparing code for commit.
Understand TypeType project architecture, layering rules, dependency directions, and component responsibilities. Use when working on TypeType, adding features, or refactoring.
| name | typetype-coding-standards |
| description | TypeType coding standards, naming conventions, Python/QML style rules, and common pitfalls. Use when writing new code or refactoring. |
One blank line between groups:
# 1. Standard library
import os
import sys
# 2. Third-party
from PySide6.QtCore import QUrl
import darkdetect
# 3. Local
from src.backend.application.gateways.score_gateway import ScoreGateway
| Type | Convention | Example |
|---|---|---|
| Class | PascalCase | TextSourceGateway, LoadTextUseCase |
| Function/Variable | snake_case | load_text, source_key |
| File | snake_case / lowercase with underscores | text_source_gateway.py |
| Constant | UPPER_SNAKE_CASE | MAX_RETRIES, DEFAULT_TIMEOUT |
ALL function parameters and return values MUST have type hints.
# Good
def load_text(self, source_key: str) -> str | None: ...
# Bad - missing
def load_text(self, source_key): ...
infrastructure/network_errors.pyapplication/exception_handler.pySignal() + @Slot() for connectionsQRunnable via QThreadPool)BaseWorker patternProperty + notify signal for reactive updatesTheme.currentTheme.colors.*main.py; only dedicated reading/typing areas should set a custom fontFamily (current example: TypingPage.qml uses LXGW WenKai for正文区)import RinUI as Rin then Rin.TextAreaimport PySide6 in domain/services/Problem: QML onTextChanged is async → get negative position error:
QTextCursor::setPosition: Position 'X' out of range
Correct:
def clear(self) -> None:
self._state.session_stat.time = 0.0
self._state.session_stat.key_stroke_count = 0
# DON'T clear here → QML async issue
# self._state.session_stat.char_count = 0
# self._state.session_stat.wrong_char_count = 0
Correct clearing: set_total_chars() clears when safe.
Correct: process → clear deleted → update char_count last
else:
# process deletions
for i in range(len(s)): ...
# clear deleted AFTER processing
if grow_length < 0:
char_count = self._state.session_stat.char_count # use BEFORE value
for i in range(char_count + grow_length, char_count):
char_updates.append((i, "", False))
self._state.session_stat.char_count += grow_length # update LAST
Wrong: update char_count before processing → wrong indices
docs/ARCHITECTURE.md when changing layer boundaries, object responsibilities, or main data flowsuv run pytestuv run ruff check .uv run ruff format --check .