# Project Style Guide

> Enforces project-specific coding standards based on .pre-commit-config.yaml and .flake8. Invoke when generating code, formatting files, or checking style compliance. Use when this capability is needed.

- Skill: `tomevault-io/project-style-guide` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add tomevault-io/project-style-guide`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tomevault-io/project-style-guide/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: tomevault-io (https://skillmd.com/u/tomevault-io)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/tomevault-io/project-style-guide

---


# ScaleTorch Project Style Guide

此 Skill 包含了 ScaleTorch 项目的代码风格和 lint 规范，基于 `.pre-commit-config.yaml` 和 `.flake8` 配置。

## 核心规范

### 1. Python 代码风格 (Flake8 & Yapf)
*   **行长度限制**: **79 字符** (严格遵守，与 PEP 8 一致)。
*   **忽略规则**:
    *   `W503`: Line break before binary operator
    *   `W504`: Line break after binary operator
    *   `E251`: Unexpected spaces around keyword / parameter equals
    *   `E501`: Line too long (虽然设置了 max-line-length，但某些情况可能忽略)
    *   `E126`: Continuation line over-indented for hanging indent
*   **Import 排序**: 必须使用 `isort` 风格进行排序。
    *   Application import names: `scaletorch`
*   **格式化工具**: 使用 `yapf` 风格。

### 2. 文件格式与通用规则 (Pre-commit hooks)
*   **换行符**: 强制使用 **LF** (`mixed-line-ending --fix=lf`)。
*   **文件结尾**: 必须以且仅以一个换行符结尾 (`end-of-file-fixer`)。
*   **尾部空格**: 必须移除行尾多余空格 (`trailing-whitespace`)。
*   **编码声明**: **移除** 文件头的编码声明 (如 `# -*- coding: utf-8 -*-`) (`fix-encoding-pragma --remove`)。
*   **字符串引号**: 统一字符串引号风格 (`double-quote-string-fixer`)。

### 3. 特定文件检查
*   **YAML**: 必须符合 YAML 语法 (`check-yaml`)。
*   **Requirements.txt**: 必须排序 (`requirements-txt-fixer`)。
*   **合并冲突**: 检查并禁止提交包含合并冲突标记的代码 (`check-merge-conflict`).

## 使用建议
当生成或修改代码时，请务必：
1.  **检查行长**：确保生成的代码不超过 79 列。
2.  **排序 Imports**：将标准库、第三方库和本地库 (`scaletorch`) 分组并排序。
3.  **清理格式**：确保没有尾部空格，且文件以 LF 结尾。
4.  **遵循 Yapf 风格**：在复杂的表达式或参数列表中遵循 Yapf 的格式化习惯。

---
> Converted and distributed by [TomeVault](https://tomevault.io/claim/jianzhnie) — claim your Tome and manage your conversions.
<!-- tomevault:4.0:skill_md:2026-04-13 -->

