coding-like-redd
Redd's Python and Rust coding standards -- tooling (uv/ruff/ty; cargo/clippy/nextest), code style rules, error/logging/subprocess conventions, and required-project-file templates (including Makefiles). Load whenever writing, reviewing, editing, or scaffolding Python or Rust code, or asked about Redd's coding standards, in ANY project.
- License 许可
- MIT
- 所属仓库
- nredd/pi-harness
- 最近更新
- 2026-11-15
- Stars
- ★ 2
- Forks
- 1
01 前言 Front Matter
- name
- coding-like-redd
- description
- Redd's Python and Rust coding standards -- tooling (uv/ruff/ty; cargo/clippy/nextest), code style rules, error/logging/subprocess conventions, and required-project-file templates (including Makefiles). Load whenever writing, reviewing, editing, or scaffolding Python or Rust code, or asked about Redd's coding standards, in ANY project.
03 SKILL.md 正文
Python Development
Tooling (Astral Ecosystem)
- Package Manager:
uvfor all dependency management - Virtual Environments: Use them!
- Formatting & Linting:
ruff-- single tool for both - Type Checking:
ty. Not mypy, not pyright - Testing:
pytestwith comprehensive coverage - Matrix Testing:
tox, configured in[tool.tox]insidepyproject.toml
Code Standards
- PEP 604 unions only:
str | None,list[str],dict[str, Any]. NeverOptional[],Union[],typing.List-- including inside docstrings, which drift because nothing enforces agreement with the signature from __future__ import annotationsat the top of every new module- Annotate every return, including
-> None - Follow PEP 8 strictly
- Module order: docstring,
__future__, stdlib, third-party, first-party,LOGGER = logging.getLogger(__name__), compiled regex and SCREAMING constants, code - Module docstrings carry a
References:list of links to whatever upstream tool or spec the module models - Docstrings use my form, not Google or NumPy:
Parameters:/Returns:/Raises:, repeating types even though they are annotated. Private helpers get docstrings too. Pydantic models do not --description=on the field is the doc - Imports at module top. The only two acceptable local imports are breaking a cycle and deferring genuine import cost. Comment which one it is
- Compile regex once at module level,
SCREAMING_CASE. Neverre.compilein a loop pathlibonly.Path(str(x)).resolve(), then check.exists()/.is_file()- Pick the container deliberately: Pydantic
BaseModelfor validated or serialized data,TypedDictfor a function's return shape,@dataclass(frozen=True)for internal holders,StrEnumfor closed string sets dictmerge with|and|=, never.update()in an expression. Order-preserving dedup islist(dict.fromkeys(...))TODO(redd):andNOTE(redd):are the only marker forms. No FIXME, HACK, or XXX, no bareTODO. A bare issue URL as the body is fine, so is candid self-criticism- My abbreviations:
cfg(neverconfig),ti,ws,env,opts,cmd
Never Waive, Fix
- Never add
# noqaor# type: ignore. I configure both to be ignored outright (ruff check --fix --ignore-noqa, tyrespect-type-ignore-comments = false). Fix the source. If a rule is genuinely wrong, change the config and say so - Never widen an exclude or ignore list to make a check pass. Tighten the gate, then fix the code to clear it
- Every lint exception carries a written reason for why it exists
Errors, Logging, Validation
- Guard clauses open every function. Validate, coerce, then re-validate
- Backtick identifiers inside message strings. Single-quote interpolated VALUES so an
empty string is visible:
f"Path does not exist: '{source_path}'" - Exception choice is semantic, respect it.
ValueError/TypeError/FileNotFoundErrormean bad input and the caller is at fault. Domain-retryable and domain-fatal failures get distinct types. Neverraise Exceptionin new code - Wrap and re-raise with
from e. The new message names the operation and interpolates the original - Module-level
LOGGER, neverprint. f-strings in log calls are the house style -- do not "fix" them to%slazy formatting. Use levels with intent - Validate before expensive work starts, not after
Shell-out and Subprocess
- Logic goes in Python, never in the shell string. Evaluate every conditional, loop,
retry, and parse in Python and interpolate the result:
{"set -e" if self.exit_on_error else ""}. No branching inside embedded shell - Build args as
list[str]and join at the very end withshlex.join.shlex.quoteanything interpolated. Optional flags via*([flag] if cond else [])so the command stays one expression textwrap.dedentfor any embedded script block- Absolute binary paths always (
/usr/bin/find -O3).$PATHis not trusted subprocess.check_output(..., text=True, stderr=subprocess.STDOUT), list-form args.shell=Trueonly for a genuine pipeline
Required Project Files
- pyproject.toml -- comprehensive, including
[tool.ruff],[tool.ty],[tool.tox] - README.md -- kept current with installation, usage, examples
- Makefile -- developer convenience commands (template below)
- tests/ -- unit tests with real coverage
src/ layout is right for a distributable library. A flat package layout is fine for
applications and DAG or automation repos. Do not impose src/ where it buys nothing.
Makefile Template for Python
.PHONY: help install format lint type test tox clean all
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
install: ## Install dependencies with uv
uv sync --all-extras
format: ## Format code with ruff
uv run ruff format .
lint: ## Lint code with ruff
uv run ruff check . --fix --ignore-noqa
type: ## Type check with ty
uv run ty check
test: ## Run tests with pytest
uv run pytest -v --cov=src --cov-report=term-missing
tox: ## Run matrix tests
uv run tox
clean: ## Clean artifacts
rm -rf .pytest_cache .ruff_cache .tox dist build *.egg-info
find . -type d -name __pycache__ -exec rm -rf {} +
all: format lint type test ## Run full CI pipeline
Rust Development
Tooling
- Formatter:
rustfmtwith rustfmt.toml config - Linter:
clippyat pedantic level - Testing:
cargo testandcargo nextest(preferred) - Documentation:
cargo docmust build without warnings - Additional Tools: cargo-deny, cargo-outdated
Code Standards
- Follow Rust idioms and conventions religiously
- Leverage the type system fully
- Modern patterns (async/await, Result/Option)
- Zero-cost abstractions
- Comprehensive documentation comments (
///and//!) - Proper error handling, avoid unwrap/expect in production
Required Project Files
- Cargo.toml -- complete project configuration
- README.md -- kept current
- Makefile -- developer convenience commands (template below)
- rustfmt.toml -- formatting configuration
- tests/ -- integration tests
- examples/ -- usage examples
- benches/ -- benchmarks for performance-critical code
Makefile Template for Rust
.PHONY: help build test fmt lint doc check clean all
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
build: ## Build the project
cargo build
test: ## Run tests
cargo test --all-features
fmt: ## Format code
cargo fmt --all
lint: ## Run clippy
cargo clippy --all-targets --all-features -- -W clippy::pedantic
doc: ## Build documentation
cargo doc --no-deps --all-features
check: ## Fast compile check
cargo check --all-targets --all-features
clean: ## Clean artifacts
cargo clean
all: fmt lint check test doc ## Run full CI
04 同仓库更多 Skills
ship-issue
Address a GitHub issue in a dedicated git worktree -- implement, gate, obtain exact-HEAD reviews, open a PR, and hand protected merge ownership to the parent. Use when the user names an issue URL or number and wants it shipped.
get-it-merged
Land a requested set of open PRs as a dependency-aware merge train: the parent reviews, arms protected auto-merge, watches each terminal outcome with a native monitor, and advances until the list is merged or genuinely blocked. Use when multiple PRs are open in one repo and the user wants them merged.
code-review
Review the changes since a fixed point (commit, branch, tag, or merge-base) along two axes: Standards (does the code follow this repo's documented coding standards?) and Spec (does the code match what the originating issue/spec asked for?). Runs both reviews in parallel read-only `code-reviewer` sub-agents through the configured review route and reports them side by side. Use when the user wants to review a branch, a PR, work-in-progress changes, or asks to "review since X".