🎨 style(markdown): format all markdown files with prettier
- 使用 prettier 格式化所有 markdown 文件 - prose-wrap: always, print-width: 80 - 保持代码块和表格格式 - 提升可读性和一致性 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
---
|
||||
name: style-cleanup
|
||||
description: "Clean up formatting and code style with the repo’s existing toolchain (clang-format/black/isort/flake8/pre-commit/etc). Triggers: 整理代码风格, 格式化, format, fmt, lint fix, clang-format, black, isort."
|
||||
description:
|
||||
"Clean up formatting and code style with the repo’s existing toolchain
|
||||
(clang-format/black/isort/flake8/pre-commit/etc). Triggers: 整理代码风格,
|
||||
格式化, format, fmt, lint fix, clang-format, black, isort."
|
||||
---
|
||||
|
||||
# Style Cleanup Workflow(整理代码风格 / 格式化)
|
||||
@@ -20,7 +23,6 @@ description: "Clean up formatting and code style with the repo’s existing tool
|
||||
## Procedure(default)
|
||||
|
||||
1. **Baseline**
|
||||
|
||||
- 记录当前状态:`git status --porcelain`
|
||||
- 明确范围(默认只处理变更文件):
|
||||
- staged:`git diff --name-only --cached`
|
||||
@@ -28,26 +30,28 @@ description: "Clean up formatting and code style with the repo’s existing tool
|
||||
- untracked:`git ls-files -o --exclude-standard`
|
||||
|
||||
2. **Detect Toolchain(prefer repo truth)**
|
||||
|
||||
- 优先用仓库既有入口脚本 / 配置:
|
||||
- JS/TS:`package.json` scripts(`format`/`lint`/`lint:fix`)、prettier/biome/eslint 配置
|
||||
- Python:`pyproject.toml` / `.flake8` / `.pylintrc` / `.pre-commit-config.yaml`
|
||||
- JS/TS:`package.json`
|
||||
scripts(`format`/`lint`/`lint:fix`)、prettier/biome/eslint 配置
|
||||
- Python:`pyproject.toml` / `.flake8` / `.pylintrc` /
|
||||
`.pre-commit-config.yaml`
|
||||
- C/C++:`.clang-format`(唯一真相),可选 `.clang-tidy`
|
||||
- Shell:`shfmt`/`shellcheck`(若仓库已使用)
|
||||
- Markdown:prettier/markdownlint(仅在仓库已固定时使用)
|
||||
- 禁止默认“引入新 formatter/linter 配置”;缺配置时只做最小手工调整,并先确认是否允许落地配置文件。
|
||||
|
||||
3. **Apply(format first, then lint)**
|
||||
|
||||
- 先 formatter(会改文件),再 lint(检查),再 lint --fix(如有),最后再跑一次 check 确认干净。
|
||||
- 先 formatter(会改文件),再 lint(检查),再 lint
|
||||
--fix(如有),最后再跑一次 check 确认干净。
|
||||
- 默认只处理目标文件集合;避免全仓库 reformat(除非用户明确要求)。
|
||||
- 典型命令(按仓库实际替换):
|
||||
- C++:`clang-format -i <files...>`;CI 校验:`clang-format --dry-run --Werror <files...>`
|
||||
- Python:`black <files...>` + `isort <files...>`;或 `pre-commit run --files <files...>`
|
||||
- JS/TS:`npm run format -- <files...>` / `pnpm ...` / `npx prettier -w <files...>`(以项目脚本为准)
|
||||
- Python:`black <files...>` + `isort <files...>`;或
|
||||
`pre-commit run --files <files...>`
|
||||
- JS/TS:`npm run format -- <files...>` / `pnpm ...` /
|
||||
`npx prettier -w <files...>`(以项目脚本为准)
|
||||
|
||||
4. **Guardrails**
|
||||
|
||||
- 只做风格与格式:不改变行为、不改 public API、不做重构。
|
||||
- 如格式化导致 diff 暴涨(文件数/行数过大):先停下,给出原因与两种方案让用户选:
|
||||
1. 仅格式化本次改动文件(推荐默认)
|
||||
@@ -59,7 +63,8 @@ description: "Clean up formatting and code style with the repo’s existing tool
|
||||
|
||||
## Playbook as Authority(如果项目 vendoring 了本 Playbook)
|
||||
|
||||
当目标仓库包含 `docs/standards/playbook/docs/`(或直接包含 `docs/tsl|cpp|python/...`),风格决策参考:
|
||||
当目标仓库包含 `docs/standards/playbook/docs/`(或直接包含
|
||||
`docs/tsl|cpp|python/...`),风格决策参考:
|
||||
|
||||
- TSL:`docs/tsl/code_style.md`、`docs/tsl/naming.md`、`docs/tsl/toolchain.md`
|
||||
- C++:`docs/cpp/code_style.md`、`docs/cpp/naming.md`、`docs/cpp/toolchain.md`
|
||||
|
||||
Reference in New Issue
Block a user