skills/python/SKILL.md
Coding convention, style guide, and tooling for writing Python.
npx skillsauth add hayeah/dotfiles pythonInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Project setup
Code quality
CLI tools
uv tool install -e .Code structure
Error handling and cleanup
try ... except unless you have good reasons.try ... except just to wrap or re-report it.with statements to handle cleanup.try ... except if:
Loops and helper functions
Naming and file layout
Function naming:
get_ prefix for data-oriented functions.noun (preferred), or imperativeverb_noun.File naming conventions:
foo.py should have foo_test.py.foo.py, write it in foo.md.Testing (pytest)
Dataclasses and JSON serialization
class JsonMixin:
"""Mixin to add JSON serialization to dataclasses."""
def to_dict(self) -> dict[str, Any]:
"""
Return a JSON-serializable dict representation.
For dataclasses, this uses dataclasses.asdict, which also
recursively converts nested dataclasses.
"""
if is_dataclass(self):
return asdict(self)
# Fallback if you ever use this on a non-dataclass
return self.__dict__
def to_json(self, **json_kwargs: Any) -> str:
"""
Return a JSON string representation.
Extra keyword args are passed through to json.dumps
(e.g. indent=2, sort_keys=True).
"""
return json.dumps(self.to_dict(), **json_kwargs)
If an efficient HTTP client is called for (e.g. downloading many files), prefer httpx[http2] — async HTTP client with HTTP/2 multiplexing.
uv add "httpx[http2]"
Use rich if rich terminal output is called for:
https://github.com/Textualize/rich
See pymake for a detailed example of creating a Makefile.py for project build tasks. You MUST read this documentation when you first create Makefile.py.
"""Makefile.py for pymake project."""
from pymake import sh, task
@task()
def lint():
"""Run ruff linter."""
sh("ruff check src/pymake")
@task()
def typecheck():
"""Run mypy type checker."""
sh("mypy src/pymake")
If you are working on a Jupyter notebook, you MUST read ./notebook.md.
Use hayeah.core.logger for structured logging. See libs/hayeah-py/src/hayeah/core/logger/ for the full spec.
from hayeah.core.logger import new
log = new("my-tool")
log.info("message_sent", channel="telegram", duration_ms=120)
log.error("api_failed", status=429, retry_after=30)
new(name) returns a structlog BoundLogger. Same name returns the same logger (idempotent, safe to call from multiple modules).LOG_LEVEL env var overrides log level (default: INFO).lnav ~/.local/log/ or tail -f ~/.local/log/*.jsonl | jq .Add hayeah-core as an editable dependency in the tool's pyproject.toml:
[project]
dependencies = [
"hayeah-core",
# ... other deps
]
[tool.uv.sources]
hayeah-core = { path = "../../libs/hayeah-py", editable = true }
Adjust the relative path as needed for the tool's location relative to libs/hayeah-py/.
See libs/README.md for the full index of cross-language convention libraries:
hayeah.core.fzfmatch — fuzzy path matcherhayeah.core.config — single-envar config loadinghayeah.core.shortid — short ID generation and prefix resolutiontools
Web UI development — Vite+ toolchain setup and browser-based E2E testing workflow.
tools
Tooling and style guide for TypeScript projects.
development
Capture tmux pane content and export as text, HTML, SVG, PNG, or JPG. Use when you need a screenshot or text dump of a tmux pane for sharing, feeding to AI, or archiving terminal state.
testing
Copy-edit text. Fix grammar and/or tidy text into a concise listicle.