[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M71G0HXY8X9XHG4PRYWFVWGC":3,"skill-same:01M71G0HXY8X9XHG4PRYWFVWGC":62},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":28,"linkOnly":29,"markdownContent":30,"markdownBody":31,"frontMatter":32,"refName":34,"commitSha":35,"skillDirectory":36,"forksCount":14,"repositoryHtmlUrl":37,"repositoryHomepageUrl":6,"ownerHtmlUrl":38,"ownerBlogUrl":39,"ownerDescription":40,"updatedAt":41,"install":42,"resources":55},"01M71G0HXY8X9XHG4PRYWFVWGC","python-code-standards",null,"Python code standards enforced across all skills. Loaded by other skills, not invoked directly.","outcomeeng\u002Fplugins","outcomeeng","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F257335685?v=4","01M71FRVRF36XYR3HRSCGFHK2R","Outcome Engineering","01M71FRVS4BZG17DWANFJ7EPNY",1,"MIT","https:\u002F\u002Fgithub.com\u002Foutcomeeng\u002Fplugins\u002Fblob\u002Fmain\u002Fsrc\u002Fplugins\u002Fpython\u002Fskills\u002Fpython-code-standards\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27],"standards","python code","python code standards","code standards","code","python","false","read","across","2026-11-10 10:12:30",false,"---\nname: python-code-standards\nuser-invocable: false\ndescription: >-\n  Python code standards enforced across all skills. Loaded by other skills, not invoked directly.\nallowed-tools: Read\n---\n\n\u003Cobjective>\nThe Python code standards every Python skill enforces.\n\u003C\u002Fobjective>\n\n\u003Csuccess_criteria>\nCode follows these standards when ruff and mypy pass, every manual rejection criterion in `${CLAUDE_SKILL_DIR}\u002Freferences\u002Frejection-criteria.md` has been evaluated, and no source-ownership, import-hygiene, security, resource-management, or code-hygiene rule in this reference remains violated.\n\u003C\u002Fsuccess_criteria>\n\n\u003Creference_note>\nThis is a reference skill. Composing Python skills load these standards explicitly before writing, testing, or auditing. It is not a standalone workflow.\n\nThese standards apply to ALL Python code: production and test code alike.\n\u003C\u002Freference_note>\n\n\u003Crepo_local_overlay>\nWhen another skill loads this reference inside a repository, it must also check for `spx\u002Flocal\u002Fpython.md` at the repository root. Read that file after this reference if it exists and apply it as repo-local routing to the product's governing specs and decisions. A local overlay supplements skill behavior; it does not declare product truth.\n\u003C\u002Frepo_local_overlay>\n\n\u003Ctype_annotations>\n\nALL functions require complete type annotations. No exceptions.\n\n```python\n# ✅ REQUIRED: Return types on ALL functions\ndef process_items(\n    items: list[str],\n    config: Config,\n    logger: logging.Logger,\n) -> ProcessResult:\n    \"\"\"Process items according to config.\"\"\"\n\n\n# ✅ REQUIRED: -> None on functions that return nothing\ndef test_validates_input(self) -> None:\n    result = validate(\"test\")\n    assert result.valid\n\n\n# ✅ REQUIRED: -> None on __init__\ndef __init__(self, config: Config) -> None:\n    self.config = config\n\n\n# ✅ REQUIRED: Type annotations on ALL parameters\ndef test_creates_file(self, tmp_path: Path) -> None:\n    file = tmp_path \u002F \"test.txt\"\n    assert not file.exists()\n\n\n# ✅ REQUIRED: Return types on fixtures\n@pytest.fixture\ndef config(tmp_path: Path) -> Config:\n    return Config(path=tmp_path)\n\n\n# ❌ REJECTED: Missing return type (ANN201)\ndef test_something(self):\n    pass\n\n\n# ❌ REJECTED: Missing parameter type (ANN001)\ndef test_with_fixture(self, tmp_path) -> None:\n    pass\n\n\n# ❌ REJECTED: Missing __init__ return type (ANN204)\ndef __init__(self, config: Config):\n    self.config = config\n```\n\n**Ruff rules enforced:**\n\n| Rule   | What it catches                        |\n| ------ | -------------------------------------- |\n| ANN001 | Missing type annotation on parameter   |\n| ANN201 | Missing return type on public function |\n| ANN204 | Missing return type on `__init__`      |\n\n\u003C\u002Ftype_annotations>\n\n\u003Csource_owned_values>\n\nProduction modules must own semantic literals through enums, schemas, registries, constructors, typed factories, or public constants that production consumers can import. Tests import those source-owned values instead of defining test-local constants.\n\n```python\n# ✅ REQUIRED: production source owns the domain contract\nMIN_SCORE = 0\nMAX_SCORE = 100\n\n\ndef validate_score(score: int) -> bool:\n    return MIN_SCORE \u003C= score \u003C= MAX_SCORE\n\n\n# ✅ REQUIRED IN TESTS: import the source-owned contract\nfrom product.scoring import MAX_SCORE, validate_score\n\n\ndef test_rejects_above_maximum() -> None:\n    assert validate_score(MAX_SCORE + 1) is False\n```\n\n```python\n# ❌ REJECTED IN TESTS: local copy of source-owned domain values\nMAX_SCORE = 100\n\n\ndef test_rejects_above_maximum() -> None:\n    assert validate_score(MAX_SCORE + 1) is False\n```\n\nRuff's PLR2004 rule catches many obscure magic values, but it does not decide ownership. A local test constant that duplicates production vocabulary is still wrong when lint passes.\n\n```python\n# ✅ OK: Idiomatic values are exempt\nassert len(results) == 0\nassert count == 1\nif __name__ == \"__main__\":\n    main()\n```\n\n**Artifacts are downstream of Python.** A YAML, HCL, bash, JSON schema, IaC template, or any other rendered artifact file is not a legitimate source-of-truth for Python code. A Python module either renders the artifact (producing it from a typed schema or template) or consumes it (parsing it into a typed structure), and that module owns the artifact's vocabulary. Consumers that need to reason about the artifact's labels, paths, step names, or tokens import from the owning module. When no such module exists yet, the missing module is the architectural defect — the artifact is not an exemption from source ownership.\n\n**Container keys are vocabulary.** In dict literals, JSON-encoded strings, set or tuple members, and f-string templates, the *keys* and *members* are vocabulary and follow source ownership; only *values* may be synthetic at the call site. Construct containers via `{LABEL: synthetic_value, ...}` with `LABEL` imported from the owning production module, then serialize with `json.dumps` if a string is needed. A hand-written key is a hand-picked case for the parser or consumer that reads the container.\n\n\u003C\u002Fsource_owned_values>\n\n\u003Cconstant_objects>\n\nWhen a module defines a set of related named values, choose the right container for the shape:\n\n| Pattern                          | When to use                                                                                             |\n| -------------------------------- | ------------------------------------------------------------------------------------------------------- |\n| `Final`-annotated dict           | String-to-string maps where keys and values are loosely related                                         |\n| `StrEnum` (Python 3.11+)         | Closed set of string values with enumerable identity — prefer when call sites use `status is Status.OK` |\n| Frozen `@dataclass(frozen=True)` | Richer shapes: structured config, typed records                                                         |\n\n```python\n# ✅ Final dict: loosely related string map\nfrom typing import Final\n\nHEADERS: Final = {\n    \"Content-Type\": \"application\u002Fjson\",\n    \"Accept\": \"application\u002Fjson\",\n}\n\n# ✅ StrEnum: closed set with identity semantics (Python 3.11+)\nfrom enum import StrEnum\n\n\nclass GateStatus(StrEnum):\n    PASS = \"pass\"\n    FAIL = \"fail\"\n    SKIPPED = \"skipped\"\n\n\n# ✅ Frozen dataclass: structured config record\nfrom dataclasses import dataclass\n\n\n@dataclass(frozen=True)\nclass RetryConfig:\n    max_attempts: int\n    backoff_seconds: float\n    timeout_seconds: float\n\n\n# ❌ REJECTED: plain class with uppercase fields — not immutable, no type narrowing\nclass Status:\n    PASS = \"pass\"\n    FAIL = \"fail\"\n```\n\n**No re-export of library constants.** When production code and tests both need an HTTP status code, both import from the same canonical source (`http.HTTPStatus`, `fastapi.status`, etc.). Never create a product-local re-export.\n\n```python\n# ❌ REJECTED: re-export in product code\nfrom http import HTTPStatus\n\nHTTP_OK = HTTPStatus.OK  # product-local alias\n\n# ✅ REQUIRED: both production and test code import from the canonical source\nfrom http import HTTPStatus\n\nresponse_code = HTTPStatus.OK\n```\n\n\u003C\u002Fconstant_objects>\n\n\u003Cnaming_conventions>\n\n**Lowercase Argument Names (N803)**\n\n```python\n# ❌ REJECTED: Uppercase argument names\ndef __init__(self, domain: ClockDomain, WIDTH: int = 8) -> None:\n    pass\n\n\n# ✅ REQUIRED: Lowercase argument names\ndef __init__(self, domain: ClockDomain, width: int = 8) -> None:\n    pass\n```\n\n**Avoid Shadowing Builtins**\n\n```python\n# ❌ BAD: Shadows builtin `input`\n@pytest.mark.parametrize(\"input,expected\", TEST_CASES)\ndef test_processing(self, input: str, expected: int) -> None:\n    pass\n\n\n# ✅ GOOD: Descriptive name, no shadowing\n@pytest.mark.parametrize((\"input_val\", \"expected\"), TEST_CASES)\ndef test_processing(self, input_val: str, expected: int) -> None:\n    pass\n```\n\n**Why avoid `input` as a parameter name:**\n\n- Shadows Python's builtin `input()` function\n- Causes A002 (argument shadows builtin) lint errors\n- Makes code confusing when the actual `input()` function is needed\n- The tuple form `(\"input_val\", \"expected\")` is also preferred by pytest for clarity\n\n\u003C\u002Fnaming_conventions>\n\n\u003Cs101_policy>\n\nRuff's S101 rule flags `assert` statements because they can be disabled with Python's `-O` flag.\n\n**Policy:** `assert` is ACCEPTED in test files because:\n\n1. pytest rewrites assertions for better error messages\n2. Tests are never run with `-O` optimization\n3. The alternative (`if not x: raise AssertionError`) adds noise\n\n**Required product configuration** in `pyproject.toml`:\n\n```toml\n[tool.ruff.lint.per-file-ignores]\n\"**\u002Ftest_*.py\" = [\"S101\"]\n\"**\u002Ftests\u002F**\u002F*.py\" = [\"S101\"]\n```\n\nIf the product hasn't configured this, tests will fail linting. Fix by adding the config, not by avoiding `assert`.\n\n\u003C\u002Fs101_policy>\n\n\u003Ctype_strictness>\n\n```python\n# ❌ REJECTED: Unqualified Any — hides real types\ndef process(data: Any) -> Any: ...\n\n\n# ✅ REQUIRED: Use concrete types or justify Any\ndef process(data: dict[str, str]) -> ProcessResult: ...\n\n\n# ❌ REJECTED: type: ignore without explanation\nresult = cast(str, value)  # type: ignore\n\n# ✅ REQUIRED: Explain what's being suppressed and why\nresult = cast(str, value)  # type: ignore[no-untyped-call]  # third-party lib missing stubs\n```\n\n**Rules:**\n\n| Rule            | What it catches                        |\n| --------------- | -------------------------------------- |\n| mypy strict     | Unqualified `Any` usage                |\n| (manual review) | `# type: ignore` without justification |\n\n\u003C\u002Ftype_strictness>\n\n\u003Cmodern_syntax>\n\nUse modern syntax: `X | None` (not `Optional[X]`), `X | Y` (not `Union[X, Y]`), and lowercase generics `list[str]` \u002F `dict[str, V]` (not `List` \u002F `Dict`).\n\n**Ruff rules enforced:**\n\n| Rule  | What it catches                                               |\n| ----- | ------------------------------------------------------------- |\n| UP006 | `List`, `Dict`, `Tuple` instead of `list`, `dict`, `tuple`    |\n| UP007 | `Optional[X]`, `Union[X, Y]` instead of `X \\| None`, `X \\| Y` |\n\n\u003C\u002Fmodern_syntax>\n\n\u003Cerror_handling>\n\nCatch specific exceptions and handle or re-raise them; never a bare `except:` or a broad `except Exception: pass` that swallows errors.\n\n```python\n# ✅ REQUIRED: catch specific exceptions, then handle or re-raise\ntry:\n    process()\nexcept ValueError as e:\n    log.error(\"Invalid input: %s\", e)\n    raise\n```\n\n**Ruff rules enforced:**\n\n| Rule | What it catches                          |\n| ---- | ---------------------------------------- |\n| E722 | Bare `except:` clause                    |\n| S110 | `try`-`except`-`pass` on broad exception |\n\n\u003C\u002Ferror_handling>\n\n\u003Csecurity>\n\n```python\n# ❌ REJECTED: Hardcoded secrets (S105\u002FS106)\nAPI_KEY = \"sk-1234567890\"\npassword = \"hunter2\"\n\n# ❌ REJECTED: eval\u002Fexec (S307\u002FS102)\nresult = eval(user_input)\nexec(code_string)\n\n# ❌ REJECTED: shell=True with untrusted input (S602)\nsubprocess.run(f\"grep {user_input} file.txt\", shell=True)\n\n# ❌ REJECTED: Pickle with untrusted data (S301)\ndata = pickle.loads(untrusted_bytes)\n\n# ❌ REJECTED: SSL verification disabled (S501)\nrequests.get(url, verify=False)\n```\n\nContext matters for security rules — a CLI tool invoked by the user has different trust boundaries than a web service. See `\u002Faudit-python-code` for false positive handling.\n\n**Ruff rules enforced:**\n\n| Rule | What it catches                           |\n| ---- | ----------------------------------------- |\n| S105 | Hardcoded password in variable assignment |\n| S106 | Hardcoded password in function argument   |\n| S307 | Use of `eval()`                           |\n| S102 | Use of `exec()`                           |\n| S602 | `subprocess` call with `shell=True`       |\n| S301 | Use of `pickle.loads`                     |\n| S501 | SSL verification disabled                 |\n\n\u003C\u002Fsecurity>\n\n\u003Cresource_management>\n\nAcquire files and other resources with a context manager (`with open(...) as f:`), never a manual `open()` \u002F `.close()` pair.\n\n**Ruff rules enforced:**\n\n| Rule   | What it catches                   |\n| ------ | --------------------------------- |\n| SIM115 | Open file without context manager |\n\n\u003C\u002Fresource_management>\n\n\u003Ccode_hygiene>\n\nRemove commented-out code and unused imports; never manipulate `sys.path` to reach modules — depend on an installed package instead (see `\u003Cimport_hygiene>`).\n\n**Ruff rules enforced:**\n\n| Rule   | What it catches    |\n| ------ | ------------------ |\n| ERA001 | Commented-out code |\n| F401   | Unused imports     |\n\n\u003C\u002Fcode_hygiene>\n\n\u003Cimport_hygiene>\n\n**Depth Rules**\n\n| Depth     | Syntax              | Verdict | Rationale                                      |\n| --------- | ------------------- | ------- | ---------------------------------------------- |\n| Same dir  | `from . import x`   | OK      | Module-internal, same package                  |\n| 1 level   | `from .. import x`  | REVIEW  | Is this truly module-internal?                 |\n| 2+ levels | `from ... import x` | REJECT  | Use absolute import — crosses package boundary |\n\n**Module-Internal vs. Infrastructure**\n\n**Module-internal files** live in the same package and move together. Relative imports are acceptable:\n\n```python\n# ✅ ACCEPTABLE: Same package, files move together\nfrom . import tokens\nfrom .position import Position\n```\n\n**Infrastructure** is stable code that doesn't move when the feature moves. Absolute imports are required:\n\n```python\n# ❌ REJECTED: Deep relative to infrastructure\nfrom .......tests.helpers import with_temp_product\n\n# ✅ REQUIRED: Absolute import\nfrom myproject_testing.harnesses import with_temp_product\n```\n\n**Anti-Patterns**\n\n```python\n# ❌ REJECTED: sys.path manipulation\nimport sys\n\nsys.path.insert(0, str(Path(__file__).parent.parent))\n\n# ❌ REJECTED: Deep relative imports\nfrom .....lib.utils import helper\n\n# ❌ REJECTED: Assuming working directory\nfrom lib.utils import helper  # Only works if CWD is product root\n```\n\n**Required Product Setup**\n\n**1. Use explicit product package layout:**\n\n```text\nproduct\u002F\n├── product\u002F\n│   ├── __init__.py\n│   └── ...\n├── product_testing\u002F\n│   ├── __init__.py\n│   ├── generators\u002F\n│   ├── harnesses\u002F\n│   └── fixtures\u002F\n└── pyproject.toml\n```\n\n**2. Configure `pyproject.toml`:**\n\n```toml\n[project]\nname = \"product\"\n\n[tool.setuptools.packages.find]\nwhere = [\"src\"]\n```\n\n**3. Install in editable mode** (portable fallback; prefer the product's own wrapper):\n\n```bash\npython3 -m pip install -e .\n```\n\n\u003C\u002Fimport_hygiene>\n\n\u003Crejection_criteria_summary>\nThe complete rejection-criteria lookup — every issue the sections above state, indexed by its ruff rule code (or `manual` \u002F `review` \u002F `mypy`) — lives in `${CLAUDE_SKILL_DIR}\u002Freferences\u002Frejection-criteria.md`.\n\u003C\u002Frejection_criteria_summary>\n","\u003Cobjective>\nThe Python code standards every Python skill enforces.\n\u003C\u002Fobjective>\n\n\u003Csuccess_criteria>\nCode follows these standards when ruff and mypy pass, every manual rejection criterion in `${CLAUDE_SKILL_DIR}\u002Freferences\u002Frejection-criteria.md` has been evaluated, and no source-ownership, import-hygiene, security, resource-management, or code-hygiene rule in this reference remains violated.\n\u003C\u002Fsuccess_criteria>\n\n\u003Creference_note>\nThis is a reference skill. Composing Python skills load these standards explicitly before writing, testing, or auditing. It is not a standalone workflow.\n\nThese standards apply to ALL Python code: production and test code alike.\n\u003C\u002Freference_note>\n\n\u003Crepo_local_overlay>\nWhen another skill loads this reference inside a repository, it must also check for `spx\u002Flocal\u002Fpython.md` at the repository root. Read that file after this reference if it exists and apply it as repo-local routing to the product's governing specs and decisions. A local overlay supplements skill behavior; it does not declare product truth.\n\u003C\u002Frepo_local_overlay>\n\n\u003Ctype_annotations>\n\nALL functions require complete type annotations. No exceptions.\n\n```python\n# ✅ REQUIRED: Return types on ALL functions\ndef process_items(\n    items: list[str],\n    config: Config,\n    logger: logging.Logger,\n) -> ProcessResult:\n    \"\"\"Process items according to config.\"\"\"\n\n\n# ✅ REQUIRED: -> None on functions that return nothing\ndef test_validates_input(self) -> None:\n    result = validate(\"test\")\n    assert result.valid\n\n\n# ✅ REQUIRED: -> None on __init__\ndef __init__(self, config: Config) -> None:\n    self.config = config\n\n\n# ✅ REQUIRED: Type annotations on ALL parameters\ndef test_creates_file(self, tmp_path: Path) -> None:\n    file = tmp_path \u002F \"test.txt\"\n    assert not file.exists()\n\n\n# ✅ REQUIRED: Return types on fixtures\n@pytest.fixture\ndef config(tmp_path: Path) -> Config:\n    return Config(path=tmp_path)\n\n\n# ❌ REJECTED: Missing return type (ANN201)\ndef test_something(self):\n    pass\n\n\n# ❌ REJECTED: Missing parameter type (ANN001)\ndef test_with_fixture(self, tmp_path) -> None:\n    pass\n\n\n# ❌ REJECTED: Missing __init__ return type (ANN204)\ndef __init__(self, config: Config):\n    self.config = config\n```\n\n**Ruff rules enforced:**\n\n| Rule   | What it catches                        |\n| ------ | -------------------------------------- |\n| ANN001 | Missing type annotation on parameter   |\n| ANN201 | Missing return type on public function |\n| ANN204 | Missing return type on `__init__`      |\n\n\u003C\u002Ftype_annotations>\n\n\u003Csource_owned_values>\n\nProduction modules must own semantic literals through enums, schemas, registries, constructors, typed factories, or public constants that production consumers can import. Tests import those source-owned values instead of defining test-local constants.\n\n```python\n# ✅ REQUIRED: production source owns the domain contract\nMIN_SCORE = 0\nMAX_SCORE = 100\n\n\ndef validate_score(score: int) -> bool:\n    return MIN_SCORE \u003C= score \u003C= MAX_SCORE\n\n\n# ✅ REQUIRED IN TESTS: import the source-owned contract\nfrom product.scoring import MAX_SCORE, validate_score\n\n\ndef test_rejects_above_maximum() -> None:\n    assert validate_score(MAX_SCORE + 1) is False\n```\n\n```python\n# ❌ REJECTED IN TESTS: local copy of source-owned domain values\nMAX_SCORE = 100\n\n\ndef test_rejects_above_maximum() -> None:\n    assert validate_score(MAX_SCORE + 1) is False\n```\n\nRuff's PLR2004 rule catches many obscure magic values, but it does not decide ownership. A local test constant that duplicates production vocabulary is still wrong when lint passes.\n\n```python\n# ✅ OK: Idiomatic values are exempt\nassert len(results) == 0\nassert count == 1\nif __name__ == \"__main__\":\n    main()\n```\n\n**Artifacts are downstream of Python.** A YAML, HCL, bash, JSON schema, IaC template, or any other rendered artifact file is not a legitimate source-of-truth for Python code. A Python module either renders the artifact (producing it from a typed schema or template) or consumes it (parsing it into a typed structure), and that module owns the artifact's vocabulary. Consumers that need to reason about the artifact's labels, paths, step names, or tokens import from the owning module. When no such module exists yet, the missing module is the architectural defect — the artifact is not an exemption from source ownership.\n\n**Container keys are vocabulary.** In dict literals, JSON-encoded strings, set or tuple members, and f-string templates, the *keys* and *members* are vocabulary and follow source ownership; only *values* may be synthetic at the call site. Construct containers via `{LABEL: synthetic_value, ...}` with `LABEL` imported from the owning production module, then serialize with `json.dumps` if a string is needed. A hand-written key is a hand-picked case for the parser or consumer that reads the container.\n\n\u003C\u002Fsource_owned_values>\n\n\u003Cconstant_objects>\n\nWhen a module defines a set of related named values, choose the right container for the shape:\n\n| Pattern                          | When to use                                                                                             |\n| -------------------------------- | ------------------------------------------------------------------------------------------------------- |\n| `Final`-annotated dict           | String-to-string maps where keys and values are loosely related                                         |\n| `StrEnum` (Python 3.11+)         | Closed set of string values with enumerable identity — prefer when call sites use `status is Status.OK` |\n| Frozen `@dataclass(frozen=True)` | Richer shapes: structured config, typed records                                                         |\n\n```python\n# ✅ Final dict: loosely related string map\nfrom typing import Final\n\nHEADERS: Final = {\n    \"Content-Type\": \"application\u002Fjson\",\n    \"Accept\": \"application\u002Fjson\",\n}\n\n# ✅ StrEnum: closed set with identity semantics (Python 3.11+)\nfrom enum import StrEnum\n\n\nclass GateStatus(StrEnum):\n    PASS = \"pass\"\n    FAIL = \"fail\"\n    SKIPPED = \"skipped\"\n\n\n# ✅ Frozen dataclass: structured config record\nfrom dataclasses import dataclass\n\n\n@dataclass(frozen=True)\nclass RetryConfig:\n    max_attempts: int\n    backoff_seconds: float\n    timeout_seconds: float\n\n\n# ❌ REJECTED: plain class with uppercase fields — not immutable, no type narrowing\nclass Status:\n    PASS = \"pass\"\n    FAIL = \"fail\"\n```\n\n**No re-export of library constants.** When production code and tests both need an HTTP status code, both import from the same canonical source (`http.HTTPStatus`, `fastapi.status`, etc.). Never create a product-local re-export.\n\n```python\n# ❌ REJECTED: re-export in product code\nfrom http import HTTPStatus\n\nHTTP_OK = HTTPStatus.OK  # product-local alias\n\n# ✅ REQUIRED: both production and test code import from the canonical source\nfrom http import HTTPStatus\n\nresponse_code = HTTPStatus.OK\n```\n\n\u003C\u002Fconstant_objects>\n\n\u003Cnaming_conventions>\n\n**Lowercase Argument Names (N803)**\n\n```python\n# ❌ REJECTED: Uppercase argument names\ndef __init__(self, domain: ClockDomain, WIDTH: int = 8) -> None:\n    pass\n\n\n# ✅ REQUIRED: Lowercase argument names\ndef __init__(self, domain: ClockDomain, width: int = 8) -> None:\n    pass\n```\n\n**Avoid Shadowing Builtins**\n\n```python\n# ❌ BAD: Shadows builtin `input`\n@pytest.mark.parametrize(\"input,expected\", TEST_CASES)\ndef test_processing(self, input: str, expected: int) -> None:\n    pass\n\n\n# ✅ GOOD: Descriptive name, no shadowing\n@pytest.mark.parametrize((\"input_val\", \"expected\"), TEST_CASES)\ndef test_processing(self, input_val: str, expected: int) -> None:\n    pass\n```\n\n**Why avoid `input` as a parameter name:**\n\n- Shadows Python's builtin `input()` function\n- Causes A002 (argument shadows builtin) lint errors\n- Makes code confusing when the actual `input()` function is needed\n- The tuple form `(\"input_val\", \"expected\")` is also preferred by pytest for clarity\n\n\u003C\u002Fnaming_conventions>\n\n\u003Cs101_policy>\n\nRuff's S101 rule flags `assert` statements because they can be disabled with Python's `-O` flag.\n\n**Policy:** `assert` is ACCEPTED in test files because:\n\n1. pytest rewrites assertions for better error messages\n2. Tests are never run with `-O` optimization\n3. The alternative (`if not x: raise AssertionError`) adds noise\n\n**Required product configuration** in `pyproject.toml`:\n\n```toml\n[tool.ruff.lint.per-file-ignores]\n\"**\u002Ftest_*.py\" = [\"S101\"]\n\"**\u002Ftests\u002F**\u002F*.py\" = [\"S101\"]\n```\n\nIf the product hasn't configured this, tests will fail linting. Fix by adding the config, not by avoiding `assert`.\n\n\u003C\u002Fs101_policy>\n\n\u003Ctype_strictness>\n\n```python\n# ❌ REJECTED: Unqualified Any — hides real types\ndef process(data: Any) -> Any: ...\n\n\n# ✅ REQUIRED: Use concrete types or justify Any\ndef process(data: dict[str, str]) -> ProcessResult: ...\n\n\n# ❌ REJECTED: type: ignore without explanation\nresult = cast(str, value)  # type: ignore\n\n# ✅ REQUIRED: Explain what's being suppressed and why\nresult = cast(str, value)  # type: ignore[no-untyped-call]  # third-party lib missing stubs\n```\n\n**Rules:**\n\n| Rule            | What it catches                        |\n| --------------- | -------------------------------------- |\n| mypy strict     | Unqualified `Any` usage                |\n| (manual review) | `# type: ignore` without justification |\n\n\u003C\u002Ftype_strictness>\n\n\u003Cmodern_syntax>\n\nUse modern syntax: `X | None` (not `Optional[X]`), `X | Y` (not `Union[X, Y]`), and lowercase generics `list[str]` \u002F `dict[str, V]` (not `List` \u002F `Dict`).\n\n**Ruff rules enforced:**\n\n| Rule  | What it catches                                               |\n| ----- | ------------------------------------------------------------- |\n| UP006 | `List`, `Dict`, `Tuple` instead of `list`, `dict`, `tuple`    |\n| UP007 | `Optional[X]`, `Union[X, Y]` instead of `X \\| None`, `X \\| Y` |\n\n\u003C\u002Fmodern_syntax>\n\n\u003Cerror_handling>\n\nCatch specific exceptions and handle or re-raise them; never a bare `except:` or a broad `except Exception: pass` that swallows errors.\n\n```python\n# ✅ REQUIRED: catch specific exceptions, then handle or re-raise\ntry:\n    process()\nexcept ValueError as e:\n    log.error(\"Invalid input: %s\", e)\n    raise\n```\n\n**Ruff rules enforced:**\n\n| Rule | What it catches                          |\n| ---- | ---------------------------------------- |\n| E722 | Bare `except:` clause                    |\n| S110 | `try`-`except`-`pass` on broad exception |\n\n\u003C\u002Ferror_handling>\n\n\u003Csecurity>\n\n```python\n# ❌ REJECTED: Hardcoded secrets (S105\u002FS106)\nAPI_KEY = \"sk-1234567890\"\npassword = \"hunter2\"\n\n# ❌ REJECTED: eval\u002Fexec (S307\u002FS102)\nresult = eval(user_input)\nexec(code_string)\n\n# ❌ REJECTED: shell=True with untrusted input (S602)\nsubprocess.run(f\"grep {user_input} file.txt\", shell=True)\n\n# ❌ REJECTED: Pickle with untrusted data (S301)\ndata = pickle.loads(untrusted_bytes)\n\n# ❌ REJECTED: SSL verification disabled (S501)\nrequests.get(url, verify=False)\n```\n\nContext matters for security rules — a CLI tool invoked by the user has different trust boundaries than a web service. See `\u002Faudit-python-code` for false positive handling.\n\n**Ruff rules enforced:**\n\n| Rule | What it catches                           |\n| ---- | ----------------------------------------- |\n| S105 | Hardcoded password in variable assignment |\n| S106 | Hardcoded password in function argument   |\n| S307 | Use of `eval()`                           |\n| S102 | Use of `exec()`                           |\n| S602 | `subprocess` call with `shell=True`       |\n| S301 | Use of `pickle.loads`                     |\n| S501 | SSL verification disabled                 |\n\n\u003C\u002Fsecurity>\n\n\u003Cresource_management>\n\nAcquire files and other resources with a context manager (`with open(...) as f:`), never a manual `open()` \u002F `.close()` pair.\n\n**Ruff rules enforced:**\n\n| Rule   | What it catches                   |\n| ------ | --------------------------------- |\n| SIM115 | Open file without context manager |\n\n\u003C\u002Fresource_management>\n\n\u003Ccode_hygiene>\n\nRemove commented-out code and unused imports; never manipulate `sys.path` to reach modules — depend on an installed package instead (see `\u003Cimport_hygiene>`).\n\n**Ruff rules enforced:**\n\n| Rule   | What it catches    |\n| ------ | ------------------ |\n| ERA001 | Commented-out code |\n| F401   | Unused imports     |\n\n\u003C\u002Fcode_hygiene>\n\n\u003Cimport_hygiene>\n\n**Depth Rules**\n\n| Depth     | Syntax              | Verdict | Rationale                                      |\n| --------- | ------------------- | ------- | ---------------------------------------------- |\n| Same dir  | `from . import x`   | OK      | Module-internal, same package                  |\n| 1 level   | `from .. import x`  | REVIEW  | Is this truly module-internal?                 |\n| 2+ levels | `from ... import x` | REJECT  | Use absolute import — crosses package boundary |\n\n**Module-Internal vs. Infrastructure**\n\n**Module-internal files** live in the same package and move together. Relative imports are acceptable:\n\n```python\n# ✅ ACCEPTABLE: Same package, files move together\nfrom . import tokens\nfrom .position import Position\n```\n\n**Infrastructure** is stable code that doesn't move when the feature moves. Absolute imports are required:\n\n```python\n# ❌ REJECTED: Deep relative to infrastructure\nfrom .......tests.helpers import with_temp_product\n\n# ✅ REQUIRED: Absolute import\nfrom myproject_testing.harnesses import with_temp_product\n```\n\n**Anti-Patterns**\n\n```python\n# ❌ REJECTED: sys.path manipulation\nimport sys\n\nsys.path.insert(0, str(Path(__file__).parent.parent))\n\n# ❌ REJECTED: Deep relative imports\nfrom .....lib.utils import helper\n\n# ❌ REJECTED: Assuming working directory\nfrom lib.utils import helper  # Only works if CWD is product root\n```\n\n**Required Product Setup**\n\n**1. Use explicit product package layout:**\n\n```text\nproduct\u002F\n├── product\u002F\n│   ├── __init__.py\n│   └── ...\n├── product_testing\u002F\n│   ├── __init__.py\n│   ├── generators\u002F\n│   ├── harnesses\u002F\n│   └── fixtures\u002F\n└── pyproject.toml\n```\n\n**2. Configure `pyproject.toml`:**\n\n```toml\n[project]\nname = \"product\"\n\n[tool.setuptools.packages.find]\nwhere = [\"src\"]\n```\n\n**3. Install in editable mode** (portable fallback; prefer the product's own wrapper):\n\n```bash\npython3 -m pip install -e .\n```\n\n\u003C\u002Fimport_hygiene>\n\n\u003Crejection_criteria_summary>\nThe complete rejection-criteria lookup — every issue the sections above state, indexed by its ruff rule code (or `manual` \u002F `review` \u002F `mypy`) — lives in `${CLAUDE_SKILL_DIR}\u002Freferences\u002Frejection-criteria.md`.\n\u003C\u002Frejection_criteria_summary>\n",{"name":5,"description":7,"allowed-tools":33,"user-invocable":29},"Read","main","978d51c51d68c99cffb2ba48f7cad9d2f07e5738","src\u002Fplugins\u002Fpython\u002Fskills\u002Fpython-code-standards","https:\u002F\u002Fgithub.com\u002Foutcomeeng\u002Fplugins","https:\u002F\u002Fgithub.com\u002Foutcomeeng","https:\u002F\u002Foutcome.engineering","Spec-driven development for AI-assisted engineering","2026-11-14 20:33:56",{"source":8,"skillName":5,"commands":43,"prompt":53,"zipAvailable":54},[44,47,50],{"tool":45,"command":46},"npx","npx skills add outcomeeng\u002Fplugins --skill python-code-standards",{"tool":48,"command":49},"bunx","bunx skills add outcomeeng\u002Fplugins --skill python-code-standards",{"tool":51,"command":52},"pnpm","pnpm dlx skills add outcomeeng\u002Fplugins --skill python-code-standards","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Foutcomeeng\u002Fplugins\u002Fblob\u002Fmain\u002Fsrc\u002Fplugins\u002Fpython\u002Fskills\u002Fpython-code-standards\u002FSKILL.md",true,[56],{"path":57,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":60,"sourceHtmlUrl":61},"references\u002Frejection-criteria.md","REFERENCE","参考文档",2445,"https:\u002F\u002Fgithub.com\u002Foutcomeeng\u002Fplugins\u002Fblob\u002Fmain\u002Fsrc\u002Fplugins\u002Fpython\u002Fskills\u002Fpython-code-standards\u002Freferences\u002Frejection-criteria.md",[63,69,96,112,122,130],{"skillNo":64,"name":65,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":66,"categories":67,"keywords":68,"publishedAt":28},"01M71G25RZTPQG9KJ00JCHC1F7","plugin","https:\u002F\u002Fgithub.com\u002Foutcomeeng\u002Fplugins\u002Fblob\u002Fmain\u002Fsrc\u002Ftemplates\u002Fplugin\u002FSKILL.md",[],[65],{"skillNo":70,"name":71,"nameZh":6,"description":72,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":73,"categories":74,"keywords":75,"publishedAt":28},"01M71G23DCX3SV60H63HBBKQ6J","sanitize-powerpoint","ALWAYS invoke this skill when sanitizing, cleaning up, auditing, or aligning a PowerPoint (.pptx) deck — slide-master and layout structure, layout type attributes, stray fonts, non-theme colors, or layout naming. NEVER hand-edit pptx XML without this skill.","https:\u002F\u002Fgithub.com\u002Foutcomeeng\u002Fplugins\u002Fblob\u002Fmain\u002Fsrc\u002Fplugins\u002Fwork\u002Fskills\u002Fsanitize-powerpoint\u002FSKILL.md",[],[76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95],"sanitize powerpoint","powerpoint","sanitize","fonts","type","cleaning","structure","never","attributes","theme","pptx","naming","layout","deck","up","edit","xml","master","invoke","when",{"skillNo":97,"name":98,"nameZh":6,"description":99,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":100,"categories":101,"keywords":102,"publishedAt":28},"01M71G21PQKBCDECHGVYSKPJW5","draw-excalidraw","ALWAYS invoke this skill when creating Excalidraw diagrams, visualizing workflows, architectures, or concepts. NEVER generate Excalidraw JSON without this skill.","https:\u002F\u002Fgithub.com\u002Foutcomeeng\u002Fplugins\u002Fblob\u002Fmain\u002Fsrc\u002Fplugins\u002Fwork\u002Fskills\u002Fdraw-excalidraw\u002FSKILL.md",[],[103,104,105,106,107,83,94,108,109,95,110,111],"draw excalidraw","excalidraw","draw","diagrams","architectures","generate","workflows","concepts","json",{"skillNo":113,"name":114,"nameZh":6,"description":115,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":116,"categories":117,"keywords":118,"publishedAt":28},"01M71G1ZMNGFD37RZYM620XM2C","typescript-test-standards","TypeScript test standards enforced across all skills. Loaded by other skills, not invoked directly.","https:\u002F\u002Fgithub.com\u002Foutcomeeng\u002Fplugins\u002Fblob\u002Fmain\u002Fsrc\u002Fplugins\u002Ftypescript\u002Fskills\u002Ftypescript-test-standards\u002FSKILL.md",[],[119,120,121,19,25,26,27],"typescript","typescript test standards","test",{"skillNo":123,"name":124,"nameZh":6,"description":125,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":126,"categories":127,"keywords":128,"publishedAt":28},"01M71G1XBH0X1VCTR7269MDGSY","typescript-code-standards","TypeScript code standards enforced across all skills. Loaded by other skills, not invoked directly.","https:\u002F\u002Fgithub.com\u002Foutcomeeng\u002Fplugins\u002Fblob\u002Fmain\u002Fsrc\u002Fplugins\u002Ftypescript\u002Fskills\u002Ftypescript-code-standards\u002FSKILL.md",[],[119,23,129,22,19,25,26,27],"typescript code standards",{"skillNo":131,"name":132,"nameZh":6,"description":133,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":134,"categories":135,"keywords":136,"publishedAt":28},"01M71G1TQ3VN45SJ75DFMJDB9W","typescript-architecture-standards","TypeScript ADR conventions enforced across architect and auditor skills. Loaded by other skills, not invoked directly.","https:\u002F\u002Fgithub.com\u002Foutcomeeng\u002Fplugins\u002Fblob\u002Fmain\u002Fsrc\u002Fplugins\u002Ftypescript\u002Fskills\u002Ftypescript-architecture-standards\u002FSKILL.md",[],[137,19,138,139,119,140,141,27,26,142,25,143],"architecture standards","typescript architecture standards","architecture","adr","architect","auditor","conventions"]